the_hulk 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. data/Gemfile +1 -1
  2. data/README.md +10 -3
  3. data/lib/hulk/version.rb +1 -1
  4. data/lib/hulk.rb +26 -21
  5. metadata +2 -2
data/Gemfile CHANGED
@@ -3,4 +3,4 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in hulk.gemspec
4
4
  gemspec
5
5
 
6
- gem 'colorize', '~> 0.7.3'
6
+ gem 'colorize', '~> 0.7.3'
data/README.md CHANGED
@@ -20,7 +20,7 @@ deploy:
20
20
 
21
21
  The above example will give you the following:
22
22
  1. Calling `hulk push` will run the 3 commands you see under `push:`, in the order they appear, in a synchronous manner.
23
- 2. Calling `hulk deploy` will run the `push` build, and then run the push to the heroku server.
23
+ 2. Calling `hulk deploy` will run the `push` build, and then run the deploy to the heroku server.
24
24
 
25
25
  ### Nesting builds
26
26
 
@@ -30,7 +30,7 @@ You can mix and match builds with commands, and nest builds as frequent, or infr
30
30
 
31
31
  ### Using variables
32
32
 
33
- Hulk can support one variable per command, with the use of `$$` as a placeholder.
33
+ Hulk can support variables in commands, with the use of `$$` as a placeholder.
34
34
 
35
35
  ```YML
36
36
  build:
@@ -40,4 +40,11 @@ build:
40
40
  - "git push -f heroku:$$"
41
41
  ```
42
42
 
43
- Hulk runs two passes on your .yml file and will discover all variables before the commands begin running. Hulk will prompt you for each variable in your build before the build runs, and then you may step away as Hulk smashes through your build with your assigned variables.
43
+ Feel free to use multiple variables.
44
+
45
+ ```YML
46
+ perform:
47
+ - "$$ and then $$ followed by $$"
48
+ ```
49
+
50
+ Hulk will prompt you for each variable in your build before it runs, and then you may step away as Hulk smashes through your build with your assigned variables.
data/lib/hulk/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Hulk
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
data/lib/hulk.rb CHANGED
@@ -33,17 +33,17 @@ module Hulk
33
33
 
34
34
  def list_builds
35
35
  builds = parse_yaml
36
- puts "Hulk show you builds!".colorize(:green) if builds.length > 0
36
+ puts "Hulk show builds!".colorize(:green) if builds.length > 0
37
37
  count = 1
38
38
  builds.each do |key, value|
39
- puts " [#{count}] >> #{key}"
39
+ puts " #{count}: #{key}"
40
40
  count += 1
41
41
  end
42
42
  end
43
43
 
44
44
 
45
45
  def collect_build_commands build, commands
46
- puts "Hulk run build: #{build.colorize(:green)}"
46
+ puts "#{'Hulk run build:'.colorize(:green)} #{build.colorize(:light_blue)}"
47
47
  commands.each do |command|
48
48
  if command =~ /^--/
49
49
  cmds = []
@@ -57,12 +57,15 @@ module Hulk
57
57
 
58
58
 
59
59
  def prep_command command
60
- if command.include? '$$'
61
- input = [(print "Enter var for: #{command.colorize(:light_blue)}: "), $stdin.gets.rstrip][1] # Prompt and gets on same line
62
- $stdin.flush
63
- command .sub! '$$', input
64
- end
65
- @complete_command_list << command
60
+ while command.include? '$$'
61
+ tokens = command.split('$$', 2)
62
+ before = tokens[0]
63
+ after = tokens[1]
64
+ puts "Enter replacement for: #{before}#{'$$'.colorize(:light_blue)}#{after}"
65
+ input = $stdin.gets.chomp
66
+ command.sub! '$$', input
67
+ end
68
+ @complete_command_list << command
66
69
  end
67
70
 
68
71
 
@@ -72,7 +75,7 @@ module Hulk
72
75
  if builds.has_key? arg
73
76
  collect_build_commands arg, builds[arg]
74
77
  else
75
- puts "Hulk no find build: #{arg}".colorize(:green)
78
+ puts "#{'Hulk no find build:'.colorize(:green)} #{arg.colorize(:light_blue)}"
76
79
  end
77
80
  end
78
81
  end
@@ -81,8 +84,8 @@ module Hulk
81
84
  def run_builds
82
85
  @complete_command_list.each do |command|
83
86
  begin
84
- puts "Hulk run command: #{command.colorize(:green)}"
85
- system command
87
+ puts "#{'Hulk run command:'.colorize(:green)} #{command.colorize(:light_blue)}"
88
+ system(command + '2>&1')
86
89
  puts
87
90
  rescue
88
91
  $stderr.puts "There was an error when attempting to run: #{command}".colorize(:red)
@@ -93,11 +96,9 @@ module Hulk
93
96
 
94
97
 
95
98
  def parse args
96
- options = OpenStruct.new
97
-
98
- options.list = false
99
+ options = {}
99
100
 
100
- opt_parser = OptionParser.new do |opts|
101
+ opt = OptionParser.new do |opts|
101
102
  opts.banner = "Usage: hulk [options]"
102
103
 
103
104
  opts.on('-l', '--list', 'List Builds') do |l|
@@ -107,12 +108,12 @@ module Hulk
107
108
  end
108
109
 
109
110
  begin
110
- opt_parser.parse!(args)
111
+ opt.parse!
111
112
  rescue OptionParser::InvalidOption => e
112
- $stderr.puts "Invalid Hulk option: #{e}".colorize(:red)
113
- exit 1
113
+ puts "#{'Hulk no find option:'.colorize(:green)} #{e}"
114
114
  end
115
- options
115
+
116
+ return options
116
117
  end
117
118
 
118
119
 
@@ -124,7 +125,7 @@ module Hulk
124
125
 
125
126
  options = parse ARGV
126
127
  if ARGV.empty?
127
- list_builds if options.list == true
128
+ list_builds if options[:list] == true
128
129
  else
129
130
  collect_builds ARGV
130
131
  run_builds
@@ -134,3 +135,7 @@ module Hulk
134
135
  end
135
136
 
136
137
  end
138
+
139
+ # TODO remove this
140
+ runner = Hulk::Runner.new
141
+ runner.bootstrap
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: the_hulk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-01-29 00:00:00.000000000 Z
12
+ date: 2015-02-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler