Class: Release::Gem::Cli::GemAction
- Inherits:
-
Object
- Object
- Release::Gem::Cli::GemAction
- Defined in:
- lib/release/gem/gem_cli_action.rb
Instance Method Summary collapse
- #build(*pargs, &block) ⇒ Object
- #exec(&block) ⇒ Object
-
#initialize(root, opts = {}) ⇒ GemAction
constructor
A new instance of GemAction.
-
#install(*args, &block) ⇒ Object
push.
-
#method_missing(mtd, *args, &block) ⇒ Object
install.
-
#push(*pargs, &block) ⇒ Object
build.
- #release_dependencies ⇒ Object
Constructor Details
#initialize(root, opts = {}) ⇒ GemAction
Returns a new instance of GemAction.
10 11 12 13 14 15 |
# File 'lib/release/gem/gem_cli_action.rb', line 10 def initialize(root, opts = {}) opts = { } if opts.nil? opts[:ui] = TTY::Prompt.new @inst = Action::GemAction.new(root, opts) @pmt = opts[:tty] || opts[:ui] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(mtd, *args, &block) ⇒ Object
install
194 195 196 |
# File 'lib/release/gem/gem_cli_action.rb', line 194 def method_missing(mtd, *args, &block) @inst.send(mtd,*args, &block) end |
Instance Method Details
#build(*pargs, &block) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 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 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/release/gem/gem_cli_action.rb', line 71 def build(*pargs, &block) @inst.build do |ops, *args| case ops when :action_start @pmt.say " Gem building starting...\n".yellow when :select_version preset = false if block res = block.call(ops, *args) if res.nil? preset = true else res end else preset = true end if preset opts = args.first res = @pmt.select("\n Please select new gem version : \n".yellow) do |m| opts[:proposed_next].reverse.each do |v| m.choice v,v end m.choice "#{opts[:current_version]} -> Current version ", opts[:current_version] m.choice "Custom version", :custom m.choice "Abort", :abort end raise Release::Gem::Abort, "Abort by user" if res == :abort if res == :custom loop do res = @pmt.ask("\n Please provide custom version number for the release : ".yellow,required: true) confirmed = @pmt.yes?("\n Use version '#{res}'? No to try again") break if confirmed end end end # if preset res when :multiple_version_files_found preset = false if block res = block.call(ops, *args) if res.nil? preset = true else res end else preset = true end if preset res = @pmt.select("\n There are multiple version file found. Please select which one to update : ".yellow) do |m| opts = args.first opts.each do |f| m.choice f,f end m.choice "Abort", :abort end raise Release::Gem::Abort, "Abort by user" if res == :abort end res when :new_version_number @selVersion = args.first when :gem_build_successfully @pmt.puts "\n Gem version '#{args.first}' built successfully".green @inst.register(:selected_version, args.first) [true, args.first] end end end |
#exec(&block) ⇒ Object
17 18 19 |
# File 'lib/release/gem/gem_cli_action.rb', line 17 def exec(&block) instance_eval(&block) if block end |
#install(*args, &block) ⇒ Object
push
185 186 187 188 189 190 191 192 |
# File 'lib/release/gem/gem_cli_action.rb', line 185 def install(*args, &block) sysInst = @pmt.yes?("\n Install release into system? ".yellow) if sysInst @inst.install(*args) end end |
#push(*pargs, &block) ⇒ Object
build
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
# File 'lib/release/gem/gem_cli_action.rb', line 156 def push(*pargs, &block) @inst.push(*pargs) do |ops, *args| case ops when :multiple_rubygems_account creds = args.first res = @pmt.select("\n Multiple rubygems account detected. Please select one : ".yellow) do |m| creds.each do |k,v| m.choice k,k end m.choice "Skip gem push", :skip m.choice "Abort", :abort end raise Release::Gem::Abort, "Abort by user" if res == :abort res when :gem_push_output st = pargs.first res = pargs[1] if st @pmt.puts "\n Gem push successful.".green else @pmt.puts "\n Gem push failed. Error was :\n #{res}".red end end end end |
#release_dependencies ⇒ Object
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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/release/gem/gem_cli_action.rb', line 21 def release_dependencies @inst.release_dependencies do |ops, *args| case ops when :action_start @pmt.say "\n Release dependencies starting...\n".yellow when :define_gem_prod_config config = {} selections = args.first[:gems] loop do sel = @pmt.select("\n The following development gems requires configuration. Please select one to configure ".yellow) do |m| selections.each do |g| m.choice g, g end end config[sel] = {} if config[sel].nil? type = @pmt.select("\n The gem in production will be runtime or development ? ".yellow) do |m| m.choice "Runtime", :runtime m.choice "Development only", :dev end config[sel][:type] = type ver = @pmt.ask("\n Is there specific version pattern (including the ~>/>/>=/= of gemspec) for the gem in production? (Not mandatory) : ".yellow) config[sel][:version] = ver if not_empty?(ver) @pmt.puts " ** Done configure for gem #{sel}".yellow selections.delete_if { |v| v == sel } break if selections.length == 0 end config when :development_gem_temporary_promoted @pmt.puts "\n Development gem(s) temporary promoted to production status".yellow when :no_development_gems_found @pmt.puts "\n No development gem(s) in used found".yellow end end end |