the_hulk 0.0.3 → 0.0.5

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. checksums.yaml +4 -4
  2. data/README.md +4 -4
  3. data/lib/hulk/version.rb +1 -1
  4. data/lib/hulk.rb +39 -11
  5. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 333464c50b20cdf9636ed76aee77d7b76c4b6a1c
4
- data.tar.gz: ec56d94da606309bd8c3f514184cd0f327d2015c
3
+ metadata.gz: 0a8acae90df239dadd0816fa7b0c059bece0a8a9
4
+ data.tar.gz: 5875140383e9c7b65a2f35bc6c0f232f4c9b6f9b
5
5
  SHA512:
6
- metadata.gz: 78157ffb6cf2b70ea677d57f6e3cf7fe6fee980e7ae9ef2cd9cd659b2e6eb40d81797d0ccaab7bdf3cf55605af6048f261afd7e4228a33830cb9e15c616f7ca4
7
- data.tar.gz: 8cd32d8c8e43fe9600d21c914b8c7c2de4026048cfa1921290e64e738c9c74207798ea641bc2192ad5a5eae7b2cd37a32cb1ebf8e93e8991ba95d9c174c47b65
6
+ metadata.gz: fd23ef8b5a8afd8dc7087f90a48c7c557af1f1ebfa64e5228ec33faa3e50efe8342ea3d31be0ef93ee421636c8d4abafe74e7e4453b9fbab9c173e4b14eca17e
7
+ data.tar.gz: ed8c95111ee7f2e1e90622a291c67b6a74e1b43159908a8f4b8c3359e5fbd87b9ec4f07e8e833493d47e190e4e2dcf8e47c5285be417b3577f456daaf04e61dd
data/README.md CHANGED
@@ -10,12 +10,12 @@ After adding a `hulk.yml` file to your project root, simply reference the follow
10
10
 
11
11
  ```YML
12
12
  push:
13
- - git add .
14
- - git commit -m 'Made some changes.'
15
- - git push origin master
13
+ - "git add ."
14
+ - "git commit -m 'Made some changes.'"
15
+ - "git push origin master"
16
16
  deploy:
17
17
  - --push
18
- - git push -f heroku dev:master
18
+ - "git push -f heroku dev:master"
19
19
  ```
20
20
 
21
21
  The above example will give you the following:
data/lib/hulk/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Hulk
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.5"
3
3
  end
data/lib/hulk.rb CHANGED
@@ -3,17 +3,22 @@ require 'colorize'
3
3
  require 'yaml'
4
4
  require 'optparse'
5
5
  require 'ostruct'
6
+ require 'shellwords'
6
7
 
7
8
  module Hulk
8
9
  class Runner
9
10
 
11
+ def initialize
12
+ @complete_command_list = Array.new
13
+ end
14
+
10
15
  def parse_yaml
11
16
  builds = nil
12
17
 
13
18
  begin
14
19
  builds = YAML::load( File.open( './hulk.yml' ) )
15
20
  rescue Exception
16
- STDERR.puts "#{$!}".colorize(:red)
21
+ $stderr.puts "#{$!}".colorize(:red)
17
22
  exit 1
18
23
  end
19
24
 
@@ -37,27 +42,35 @@ module Hulk
37
42
  end
38
43
 
39
44
 
40
- def run_build build, commands
41
- puts "Hulk run build: #{build}".colorize(:green)
45
+ def collect_build_commands build, commands
46
+ puts "Hulk run build: #{build.colorize(:green)}"
42
47
  commands.each do |command|
43
48
  if command =~ /^--/
44
49
  cmds = []
45
50
  cmds << command[2..-1]
46
- spawn_builds cmds
51
+ collect_builds cmds
47
52
  else
48
- puts "Hulk run command: #{command}".colorize(:green)
49
- system( command )
50
- puts
53
+ prep_command command
51
54
  end
52
55
  end
53
56
  end
54
57
 
55
58
 
56
- def spawn_builds args
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
66
+ end
67
+
68
+
69
+ def collect_builds args
57
70
  builds = parse_yaml
58
71
  args.each do |arg|
59
72
  if builds.has_key? arg
60
- run_build arg, builds[arg]
73
+ collect_build_commands arg, builds[arg]
61
74
  else
62
75
  puts "Hulk no find build: #{arg}".colorize(:green)
63
76
  end
@@ -65,6 +78,20 @@ module Hulk
65
78
  end
66
79
 
67
80
 
81
+ def run_builds
82
+ @complete_command_list.each do |command|
83
+ begin
84
+ puts "Hulk run command: #{command.colorize(:green)}"
85
+ system command
86
+ puts
87
+ rescue
88
+ $stderr.puts "There was an error when attempting to run: #{command}".colorize(:red)
89
+ exit
90
+ end
91
+ end
92
+ end
93
+
94
+
68
95
  def parse args
69
96
  options = OpenStruct.new
70
97
 
@@ -82,7 +109,7 @@ module Hulk
82
109
  begin
83
110
  opt_parser.parse!(args)
84
111
  rescue OptionParser::InvalidOption => e
85
- STDERR.puts "Invalid Hulk option: #{e}".colorize(:red)
112
+ $stderr.puts "Invalid Hulk option: #{e}".colorize(:red)
86
113
  exit 1
87
114
  end
88
115
  options
@@ -99,7 +126,8 @@ module Hulk
99
126
  if ARGV.empty?
100
127
  list_builds if options.list == true
101
128
  else
102
- spawn_builds ARGV
129
+ collect_builds ARGV
130
+ run_builds
103
131
  end
104
132
  end
105
133
 
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.3
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ethan Welborn