Class: Codelation::Cli
- Inherits:
-
Thor
- Object
- Thor
- Codelation::Cli
- Includes:
- Thor::Actions
- Defined in:
- lib/codelation/base.rb,
lib/codelation/version.rb,
lib/codelation/development.rb,
lib/codelation/development/atom.rb,
lib/codelation/development/ruby.rb,
lib/codelation/development/postgres.rb,
lib/codelation/development/dot_files.rb,
lib/codelation/development/sequel_pro.rb,
lib/codelation/development/dependencies.rb,
lib/codelation/development/atom_packages.rb,
lib/codelation/development/install_methods.rb
Constant Summary collapse
- ATOM_APP_DOWNLOAD_URL =
"https://atom.io/download/mac"- RUBY_INSTALL_VERSION =
"0.5.0"- RUBY_INSTALL_URL =
"https://github.com/postmodern/ruby-install/archive/v#{RUBY_INSTALL_VERSION}.tar.gz"- RUBY_VERSION =
"2.2.2"- POSTGRES_APP_DOWNLOAD_URL =
"https://github.com/PostgresApp/PostgresApp/releases/download/9.4.1.0/Postgres-9.4.1.0.zip"- SEQUEL_PRO_APP_DOWNLOAD_URL =
"http://codelation-cli.s3.amazonaws.com/sequel-pro-1.0.2.zip"
Class Method Summary collapse
-
.source_root ⇒ Object
This is the directory where your templates should be placed.
Instance Method Summary collapse
- #development_install ⇒ Object
-
#help(method = nil) ⇒ Object
Add the ablitity to print help for commands like: ‘codelation help development:install` This would print help for the method: `development_install`.
-
#method_missing(method, *args, &block) ⇒ Object
Add the ablitity to run commands like: ‘codelation development:install` This would run the defined method: `development_install`.
- #update ⇒ Object
- #version ⇒ Object
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
Add the ablitity to run commands like:
`codelation development:install`
This would run the defined method:
`development_install`
26 27 28 29 30 31 32 33 34 |
# File 'lib/codelation/base.rb', line 26 def method_missing(method, *args, &block) if method.to_s.split(":").length >= 2 self.send(method.to_s.gsub(":", "_"), *args) elsif method.to_s == "run" self.walk(*args) else super end end |
Class Method Details
.source_root ⇒ Object
This is the directory where your templates should be placed.
37 38 39 |
# File 'lib/codelation/base.rb', line 37 def self.source_root File.("../../../resources", __FILE__) end |
Instance Method Details
#development_install ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/codelation/development.rb', line 16 def development_install print_heading("Installing Dependencies") install_dependencies unless Dir.exist?("/Applications/Atom.app") print_heading("Installing Atom.app") install_atom print_heading("Installing Atom Packages") install_atom_packages end print_heading("Installing Dot Files") install_dot_files unless Dir.exist?("/Applications/Postgres.app") print_heading("Installing Postgres.app") install_postgres end print_heading("Installing Ruby") install_ruby unless Dir.exist?("/Applications/Sequel Pro.app") print_heading("Installing Sequel Pro.app") install_sequel_pro end `source ~/.bash_profile` end |
#help(method = nil) ⇒ Object
Add the ablitity to print help for commands like:
`codelation help development:install`
This would print help for the method:
`development_install`
13 14 15 16 17 18 19 20 |
# File 'lib/codelation/base.rb', line 13 def help(method = nil) if method.to_s.split(":").length >= 2 method = method.to_s.gsub(":", "_") elsif method.to_s == "run" method = "walk" end super end |
#update ⇒ Object
10 11 12 13 14 |
# File 'lib/codelation/version.rb', line 10 def update command = "gem install codelation-cli" puts "Running #{command}..." exec(command) end |
#version ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/codelation/version.rb', line 17 def version gem_version = "v#{Codelation::VERSION}" # Grab the latest version of the RubyGem rubygems_json = open("https://rubygems.org/api/v1/gems/codelation-cli.json").read rubygems_version = "v#{JSON.parse(rubygems_json)['version'].strip}" = "" if gem_version != rubygems_version = " Run `codelation update` to install" end puts puts "Codelation CLI" puts " Installed: #{gem_version}" puts " Latest: #{rubygems_version}#{}" puts end |