TaxonWorks Docs
Guide
Develop
About
Start a project
Cite
API
Bug report
Contact
  • Docs
  • Code
  • API
  • English
  • Español
Guide
Develop
About
Start a project
Cite
API
Bug report
Contact
  • Docs
  • Code
  • API
  • English
  • Español
  • Develop
    • Overview
    • Contributing
    • Install
      • Development
        • Overview
        • Native
          • Operating Systems
          • Arch Linux
          • macOS
          • Ubuntu 22.04
          • Ubuntu 24.04
          • Windows 10 with WSL2
        • Docker
          • Build and push the development container to Docker
          • Docker
          • Windows 10 with WSL2
      • Production
        • Overview
        • Kubernetes
          • Overview
        • Capistrano
          • Overview
      • Overview
    • Code
      • Overview
      • Development Environment
      • Features
        • Scenarios
        • Scaffolding
        • Help bubbles
        • Rake task
        • Radial
        • TaxonWorks task
        • Tests
      • Conventions
      • Contributing
      • Troubleshoot
      • Roadmap
    • Data
      • Overview
      • Models
      • Tables
This site uses VuePress, a static site generator

Rake task

Access and/or update via scripts that utilize TaxonWork's envirnoment.

Warning

TODO: Integrate taxonworks_api_scripts

Code here makes use of Ruby's Rake (like make in other languages). It loads the TaxonWorks environment so you have access to all the underlying logic and code used inside TaxonWorks.

Environment

Assumes:

  • Ruby is installed

Create a Gemfile:

ruby '3.3.0'

# Coming from TW
# gem 'rake'
# gem 'byebug'
# gem 'rainbow'

gem 'require_all'

if ENV['TW_PATH'] && (ENV['TW_PATH'].length != 0)
  if !Dir.exist?(ENV['TW_PATH']) 
    puts "Can not find" + ENV['TW_PATH']
  else
    eval_gemfile(ENV['TW_PATH'] + '/Gemfile')
  end
else
  puts "ENV variable 'TW_PATH' not set, do `TW_PATH=/path/to/taxonworks && export TW_PATH`."
  exit
end

Create a Rakefile:

require 'rake'
require 'byebug'
require 'rainbow'
require 'require_all'

Rake.add_rakelib './tasks' # Doesn't detect subdirectories?
Dir.glob('tasks/**/*.rake').each { |r| load r }

if p = ENV['TW_PATH']
  a = File.join(p, '/config/environment')
  if true # Dir.exists?(a)
    puts Rainbow("TaxonWorks found at #{a}").green
    require_relative a
    true
  else
    puts Rainbow("TaxonWorks NOT found at #{a}").red
    exit
  end 
else
  puts Rainbow("ENV variable 'TW_PATH' not set, do `TW_PATH=/path/to/taxonworks && export TW_PATH`.").red
  exit 
end

desc 'default'
task :default do
  puts Rainbow("Configuration successful.").purple
end

Setup

bundle install 

Set a TW_PATH.

Temporarily (or see your OS for adding it to your PATH):

export TW_PATH=/path/to/taxonworks

Test the configuration

rake 

If you see Configuration successful

At this point you are able to create Rake tasks that access TaxonWork's environment.

Edit this page
Last Updated:
Contributors: mjy
Prev
Help bubbles
Next
Radial