Class: Vendorificator::CLI
- Inherits:
-
Thor
- Object
- Thor
- Vendorificator::CLI
- Defined in:
- lib/vendorificator/cli.rb
Constant Summary collapse
- VERBOSITY_LEVELS =
{1 => :quiet, 2 => :default, 3 => :chatty, 9 => :debug}
Instance Attribute Summary collapse
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
-
#verbosity ⇒ Object
readonly
Returns the value of attribute verbosity.
Class Method Summary collapse
Instance Method Summary collapse
- #diff(*args) ⇒ Object
- #git(command, *args) ⇒ Object
- #info(mod_name) ⇒ Object
-
#initialize(args = [], options = {}, config = {}) ⇒ CLI
constructor
A new instance of CLI.
- #install(*modules) ⇒ Object
- #list ⇒ Object
- #log(*args) ⇒ Object
- #outdated ⇒ Object
- #pry ⇒ Object
- #pull ⇒ Object
- #push ⇒ Object
- #status ⇒ Object
- #sync ⇒ Object
- #update(*modules) ⇒ Object
Constructor Details
#initialize(args = [], options = {}, config = {}) ⇒ CLI
Returns a new instance of CLI.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/vendorificator/cli.rb', line 32 def initialize(args = [], = {}, config = {}) super if verbosity >= 9 MiniGit.debug = true end if self.[:version] say "Vendorificator #{Vendorificator::VERSION}" exit end @environment = Vendorificator::Environment.new( shell, VERBOSITY_LEVELS[verbosity] || :default, self.[:file] ) class << shell # Make say_status always say it. def quiet? false end end end |
Instance Attribute Details
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
18 19 20 |
# File 'lib/vendorificator/cli.rb', line 18 def environment @environment end |
#verbosity ⇒ Object (readonly)
Returns the value of attribute verbosity.
18 19 20 |
# File 'lib/vendorificator/cli.rb', line 18 def verbosity @verbosity end |
Class Method Details
.start(*args) ⇒ Object
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
# File 'lib/vendorificator/cli.rb', line 203 def self.start(*args) # Make --git-options always quoted if i = ARGV.index('--git-options') ARGV[i+1,0] = '--' end if ENV['FIXTURES_DIR'] require 'vcr' VCR.configure do |c| c.cassette_library_dir = File.join(ENV['FIXTURES_DIR'], 'vcr') c. = { :record => :new_episodes } c.hook_into :webmock end VCR.use_cassette(ENV['VCR_CASSETTE'] || 'vendorificator') do super(*args) end else super(*args) end end |
Instance Method Details
#diff(*args) ⇒ Object
185 186 187 188 |
# File 'lib/vendorificator/cli.rb', line 185 def diff(*args) modules, = (args) invoke :git, %w'diff' + modules + %w'--' + + %w'@MERGED@ -- @PATH@' end |
#git(command, *args) ⇒ Object
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/vendorificator/cli.rb', line 164 def git(command, *args) modules, = (args) environment.each_segment(*modules) do |mod| unless mod.merged say_status 'unmerged', mod.to_s, :red next end actual_args = .dup.map do |arg| arg. gsub('@MERGED@', mod.merged). gsub('@PATH@', mod.work_dir) end say_status command, mod.to_s output = environment.git.git(command, *actual_args) end end |
#info(mod_name) ⇒ Object
113 114 115 116 117 |
# File 'lib/vendorificator/cli.rb', line 113 def info(mod_name) environment.info mod_name, rescue MissingVendorfileError fail! "Vendorfile not found. Vendorificator needs to run in the directory containing Vendorfile or config/vendor.rb." end |
#install(*modules) ⇒ Object
71 72 73 74 75 |
# File 'lib/vendorificator/cli.rb', line 71 def install(*modules) environment.sync .merge(:segments => modules) rescue DirtyRepoError fail! 'Repository is not clean.' end |
#list ⇒ Object
120 121 122 |
# File 'lib/vendorificator/cli.rb', line 120 def list environment.list end |
#log(*args) ⇒ Object
192 193 194 195 |
# File 'lib/vendorificator/cli.rb', line 192 def log(*args) modules, = (args) invoke :git, %w'log' + modules + %w'--' + + %w'@[email protected] -- @PATH@' end |
#outdated ⇒ Object
125 126 127 |
# File 'lib/vendorificator/cli.rb', line 125 def outdated environment.outdated end |
#pry ⇒ Object
198 199 200 201 |
# File 'lib/vendorificator/cli.rb', line 198 def pry require 'pry' binding.pry end |
#pull ⇒ Object
132 133 134 135 136 137 138 |
# File 'lib/vendorificator/cli.rb', line 132 def pull environment.pull_all rescue DirtyRepoError fail! 'Repository is not clean.' rescue MissingVendorfileError fail! "Vendorfile not found. Vendorificator needs to run in the directory containing Vendorfile or config/vendor.rb." end |
#push ⇒ Object
142 143 144 145 146 147 148 |
# File 'lib/vendorificator/cli.rb', line 142 def push environment.push rescue DirtyRepoError fail! 'Repository is not clean.' rescue MissingVendorfileError fail! "Vendorfile not found. Vendorificator needs to run in the directory containing Vendorfile or config/vendor.rb." end |
#status ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/vendorificator/cli.rb', line 86 def status environment.config[:use_upstream_version] = [:update] environment.load_vendorfile say_status 'DEPRECATED', 'Using vendor status is deprecated and will be removed in future versions', :yellow say_status 'WARNING', 'Git repository is not clean', :red unless environment.clean? environment.each_segment(*modules) do |mod| status_line = mod.to_s updatable = mod.updatable? if updatable if updatable == true status_line << ' (updatable)' else status_line << " (updatable to #{updatable.name})" end end say_status( mod.status.to_s.gsub('_', ' '), status_line, ( mod.status == :up_to_date ? :green : :yellow ) ) end rescue MissingVendorfileError fail! "Vendorfile not found. Vendorificator needs to run in the directory containing Vendorfile or config/vendor.rb." end |
#sync ⇒ Object
61 62 63 64 65 66 67 68 |
# File 'lib/vendorificator/cli.rb', line 61 def sync say_status 'DEPRECATED', 'Using vendor sync is deprecated and will be removed in future versions. Use vendor install or vendor update instead.', :yellow environment.sync .merge(:segments => modules) rescue DirtyRepoError fail! 'Repository is not clean.' rescue MissingVendorfileError fail! "Vendorfile not found. Vendorificator needs to run in the directory containing Vendorfile or config/vendor.rb." end |
#update(*modules) ⇒ Object
78 79 80 81 82 |
# File 'lib/vendorificator/cli.rb', line 78 def update(*modules) environment.sync .merge(:segments => modules, :update => true) rescue DirtyRepoError fail! 'Repository is not clean.' end |