module Autoshell::Environment
Stuff for working with a development environment
Public Instance Methods
environment?()
click to toggle source
Do we have an environment setup? @return [Boolean] true if this dir has a bundle, virtualenv
or node modules
# File lib/autoshell/environment.rb, line 33 def environment? dir?('.bundle') || dir?('.virtualenv') || dir?('node_modules') end
node?()
click to toggle source
Is this a node project? @return [Boolean] true if this dir has a package.json
# File lib/autoshell/environment.rb, line 18 def node? exist? 'package.json' end
python?()
click to toggle source
Is this a python project? @return [Boolean] true if this dir has a requirements.txt
# File lib/autoshell/environment.rb, line 12 def python? exist? 'requirements.txt' end
ruby?()
click to toggle source
Is this a ruby project? @return [Boolean] true if this dir has a Gemfile
# File lib/autoshell/environment.rb, line 6 def ruby? exist? 'Gemfile' end
setup_environment()
click to toggle source
Setup the environment @return [String] output of the environment setup commands
# File lib/autoshell/environment.rb, line 24 def setup_environment setup_ruby_environment || setup_python_environment || setup_node_environment end
setup_node_environment()
click to toggle source
Setup a node environment @return [String] output of the environment setup commands
# File lib/autoshell/environment.rb, line 58 def setup_node_environment return unless node? cd { run 'npm', 'install' } end
setup_python_environment()
click to toggle source
Setup a python environment @return [String] output of the environment setup commands
# File lib/autoshell/environment.rb, line 46 def setup_python_environment return unless python? cd do [ run('virtualenv', '.virtualenv'), run('./.virtualenv/bin/pip', '-r', 'requirements.txt') ].join("\n") end end
setup_ruby_environment()
click to toggle source
Setup a ruby environment @return [String] output of the environment setup commands
# File lib/autoshell/environment.rb, line 39 def setup_ruby_environment return unless ruby? cd { run 'bundle', 'install', '--path', '.bundle', '--deployment' } end