Module: Autoshell::Environment
- Included in:
- Base
- Defined in:
- lib/autoshell/environment.rb
Overview
Stuff for working with a development environment
Instance Method Summary collapse
-
#environment? ⇒ Boolean
Do we have an environment setup?.
-
#node? ⇒ Boolean
Is this a node project?.
-
#python? ⇒ Boolean
Is this a python project?.
-
#ruby? ⇒ Boolean
Is this a ruby project?.
-
#setup_environment ⇒ String
Setup the environment.
-
#setup_node_environment ⇒ String
Setup a node environment.
-
#setup_python_environment ⇒ String
Setup a python environment.
-
#setup_ruby_environment ⇒ String
Setup a ruby environment.
Instance Method Details
#environment? ⇒ Boolean
Do we have an environment setup?
33 34 35 |
# File 'lib/autoshell/environment.rb', line 33 def environment? dir?('.bundle') || dir?('.virtualenv') || dir?('node_modules') end |
#node? ⇒ Boolean
Is this a node project?
18 19 20 |
# File 'lib/autoshell/environment.rb', line 18 def node? exist? 'package.json' end |
#python? ⇒ Boolean
Is this a python project?
12 13 14 |
# File 'lib/autoshell/environment.rb', line 12 def python? exist? 'requirements.txt' end |
#ruby? ⇒ Boolean
Is this a ruby project?
6 7 8 |
# File 'lib/autoshell/environment.rb', line 6 def ruby? exist? 'Gemfile' end |
#setup_environment ⇒ String
Setup the environment
24 25 26 27 28 |
# File 'lib/autoshell/environment.rb', line 24 def setup_environment setup_ruby_environment || setup_python_environment || setup_node_environment end |
#setup_node_environment ⇒ String
Setup a node environment
58 59 60 61 |
# File 'lib/autoshell/environment.rb', line 58 def setup_node_environment return unless node? cd { run 'npm', 'install' } end |
#setup_python_environment ⇒ String
Setup a python environment
46 47 48 49 50 51 52 53 54 |
# 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 ⇒ String
Setup a ruby environment
39 40 41 42 |
# File 'lib/autoshell/environment.rb', line 39 def setup_ruby_environment return unless ruby? cd { run 'bundle', 'install', '--path', '.bundle', '--deployment' } end |