Class: Git::Gems::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/git/gems/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object (private)



78
79
80
# File 'lib/git/gems/cli.rb', line 78

def method_missing(name, *args)
  self.__send__(:exec, name, *args)
end

Class Method Details

.default_binstubs_pathObject



21
22
23
# File 'lib/git/gems/cli.rb', line 21

def default_binstubs_path()
  return "./.bundle/bin"
end

.default_install_pathObject



14
15
16
17
18
19
# File 'lib/git/gems/cli.rb', line 14

def default_install_path()
  install_path = options[:path]
  install_path = is_rackapp? ?
    "./vendor/bundle" : "./.bundle" if install_path.nil?
  return install_path
end

.is_rackapp?Boolean



10
11
12
# File 'lib/git/gems/cli.rb', line 10

def is_rackapp?
  return File.exist?(File.expand_path("./config.ru"))
end

Instance Method Details

#bundler(*args) ⇒ Object



34
35
36
37
38
39
40
41
# File 'lib/git/gems/cli.rb', line 34

def bundler(*args)
  options[:"no-path"], options[:"no-binstubs"] = true if options[:global]
  group_opt    = options[:production] ? "--without development test" : %{}
  path_opt     = options[:"no-path"] ? %{} : "--path=#{options[:path]}"
  binstubs_opt = options[:"no-binstubs"] ? %{} : "--binstubs=#{options[:binstubs]}"

  exec_cmd "bundle install #{path_opt} #{binstubs_opt} #{group_opt} #{args.join(%{ })}"
end

#exec(cmd, *args) ⇒ Object



45
46
47
# File 'lib/git/gems/cli.rb', line 45

def exec(cmd, *args)
  exec_cmd "bundle exec #{cmd} #{args.join(%{ })}"
end

#initObject



50
51
52
53
54
55
56
57
# File 'lib/git/gems/cli.rb', line 50

def init()
  %w(Rakefile Gemfile README.md).each do |f|
    exec_cmd "cp -a #{File.expand_path("../../../fixtures/#{f}.template", File.dirname(__FILE__))} ./#{f}"
  end
  exec_cmd "mkdir -p lib spec"
  exec_cmd "touch lib/.keep spec/.keep"
  exec_cmd "git init"
end

#releaseObject



62
63
64
65
# File 'lib/git/gems/cli.rb', line 62

def release
  exec_cmd "git tag -a 'release-#{options[:version]}'"
  exec_cmd "git push origin --tags" if options[:push]
end

#update(*args) ⇒ Object



68
69
70
# File 'lib/git/gems/cli.rb', line 68

def update(*args)
  exec_cmd "bundle update #{args.join(%{ })}"
end