rototiller 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- OTczNzRmOTAwNjkwMmFkNGNkYzE2NjFhY2I2YjIwZDcxNDQ3OTgwMQ==
5
- data.tar.gz: !binary |-
6
- ZDc0MDhjM2E3NWU2NjMwZjYwODAxMjAxNzkyYzRlZjQ1YzU1NjE4MQ==
2
+ SHA1:
3
+ metadata.gz: 5bac726b080a90b1a417f2dbbe519753651e0a09
4
+ data.tar.gz: 226f14f9d9527f807928b9f642a8dfe2190890ca
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- ZTZiZDIzOTgxMmIwM2JiMDVhZTc0ODM4ZjU4YmZjMTU4ZjRjZmZhNTY3NTUw
10
- N2I5ZTg3MDg1NzU4MzM4YmUyNTEwZTUyZmZhZDM2ZDJkYmU2ZDgyYjM0NWZj
11
- OWQyNTNiN2JmMDMyZTY1MTg0NDU1NGQ4MjUxZmI0NGU0Y2U2MGQ=
12
- data.tar.gz: !binary |-
13
- NDdjMGM3ZGY0NWZiNTgxODMyZDc0ZWM0YjIyZTlhMWFjNDAxMDllMzVhYWQx
14
- ZmQzMWViZDM0MTM4MDcyYjI3MmYxNGM4MTE0ZDMyNTA2MDM1YWI4OWFjNTAx
15
- MGQ1ZTdmMzdhMjJmZTcwYTRhMWEyMjUxMDBjYTYyNDIxMDI0NDU=
6
+ metadata.gz: 47025a7eba9c59e1681fbdb270173478d42a9afa46d75053f1521c23231ef5b6813528300fc8a8d4353870120bc59e210a3983f1100750cd2e09518950e8aca9
7
+ data.tar.gz: 8afc54e03f69185564f16256da20ccba2e67910b01df2b57ebc3b7937eb4ca1c308af1245e7e065c16d742765a6f5279b4c0c5c7b054ece96941bca5493289e4
@@ -37,8 +37,25 @@
37
37
  * Yard docs are great for other developers, but often are difficult to read for users. If your change impacts user-facing functionality, please include changes to the human-readable markdown docs starting at README.md
38
38
  * During the time that you are working on your patch the master Rototiller branch may have changed - you'll want to [rebase](http://git-scm.com/book/en/Git-Branching-Rebasing) before you submit your PR with `git rebase master`. A successful rebase ensures that your patch will cleanly merge into Rototiller.
39
39
  * Submitted patches will be smoke tested through a series of acceptance level tests that ensures basic Rototiller functionality - the results of these tests will be evaluated by a Rototiller team member. Failures associated with the submitted patch will result in the patch being rejected.
40
- * Rototiller's Architecture:
41
- ![Rototiller's Architecture](doc/rototiller_class_graph.png)
40
+
41
+ ## Submitting Changes
42
+
43
+ * Sign the [Contributor License Agreement](http://links.puppet.com/cla).
44
+ * Push your changes to a topic branch in _your_ fork of the repository.
45
+ * Submit a pull request to [Rototiller](https://github.com/puppetlabs/rototiller)
46
+ * PRs are reviewed as time permits.
47
+
48
+ # Additional Resources
49
+
50
+ * [Rototiller's Yard Docs](http://www.rubydoc.info/github/puppetlabs/rototiller) (API/internal Architecture docs)
51
+ * [Rototiller's Architecture](docs/rototiller_class_graph.png)
52
+ * [More information on contributing](http://links.puppet.com/contribute-to-puppet)
53
+ * [Contributor License Agreement](http://links.puppet.com/cla)
54
+ * [General GitHub documentation](http://help.github.com/)
55
+ * [GitHub pull request documentation](http://help.github.com/send-pull-requests/)
56
+ * Questions? Comments? Contact the Rototiller team at qa-team@puppet.com
57
+ * The keyword `rototiller` is monitored and we'll get back to you as quick as we can.
58
+ * Rototiller's Architecture: [Rototiller's Architecture](docs/rototiller_class_graph.png)
42
59
 
43
60
  ## Submitting Changes
44
61
 
data/README.md CHANGED
@@ -74,150 +74,16 @@ this does, _mostly_ the same as below. but what do the various environment vari
74
74
  * [rototiller\_task reference](docs/rototiller_task_reference.md)
75
75
  * contains usage information on all rototiller_task API methods
76
76
 
77
- ## Issues
78
-
79
- * none. it's perfect, but just in case (sorry, this is Puppet-internal for now)
80
- * [Jira: Rototiller](https://tickets.puppetlabs.com/issues/?jql=project%20%3D%20QA)
81
- * [Puppet QA-team](mailto:qa-team@puppet.com)
82
-
83
77
  ## More Documentation
84
78
 
85
79
  Rototiller is documented using yard
86
- to view yard docs, including internal Classes and Modules:
87
-
88
- First build a local copy of the gem
89
-
90
- $) bundle exec rake build
91
-
92
- Next start the yard server
93
-
94
- $) bundle exec yard server
95
-
96
- Finally navigate to http://0.0.0.0:8808/ to view the documentation
80
+ * [Rototiller's Yard Docs](http://www.rubydoc.info/github/puppetlabs/rototiller) (API/internal Architecture docs)
97
81
 
98
82
  ## Contributing
99
83
  * [Contributing](CONTRIBUTING.md)
100
84
 
101
- ## abandon hope, all ye who enter here
102
- ### All permutations of v2 API (remove and refactor into useful doc sections below upon testing, merge-up to stable)
103
-
104
- * all things that can take multiples should use add\_ as precursor to method name
105
- * all things that only take one should use set\_ as precursor to method name?
106
- require 'rototiller'
107
-
108
- ## all task methods
109
- rototiller_task :name do |t|
110
- t.add_command # t.add_cmd? me no likey
111
- t.add_env
112
- end
113
- rototiller_task do |t|
114
- t.set_name = 'string_name' # should this be validated?? e.g.: spaces, etc
115
- t.add_command
116
- t.add_env
117
- end
118
-
119
-
120
- ## all task's add_env invocations with just name
121
- t.add_env('env_name') #required, default messaging
122
- t.add_env :env_name
123
- t.add_env 'env_name' # implicitly allowed by ruby
124
- t.add_env do |e|
125
- e.name
126
- end
127
-
128
- ## all task's add_env invocations with name, message
129
- #t.add_env('env_name') # impossible
130
- t.add_env :env_name do |e|
131
- t.add_env 'env_name' do |e| # should we do this too?
132
- e.set_message
133
- end
134
- t.add_env do |e|
135
- e.name
136
- e.message
137
- end
138
-
139
- ## all task's add_env invocations with name, value
140
- #t.add_env('env_name') # impossible
141
- t.add_env :env_name do |e|
142
- t.add_env 'env_name' do |e| # should we do this too?
143
- e.default/value # does value imply the env will be set by rototiller? does default NOT?
144
- end
145
- t.add_env do |e|
146
- e.name
147
- e.default/value
148
- end
149
-
150
- ## all task's add_env invocations with name, value, message
151
- #t.add_env('env_name') # impossible
152
- t.add_env :env_name do |e|
153
- e.default/value # does value imply the env will be set by rototiller? does default NOT?
154
- e.message
155
- end
156
- t.add_env do |e|
157
- e.name
158
- e.default/value
159
- e.message
160
- end
161
-
162
-
163
- ## all task's add_command invocations with only name
164
- # default messaging, no env override?
165
- t.add_command('echo --blah my name is ray')
166
- t.add_command :echo
167
- t.add_command 'echo'
168
- t.add_command do |c|
169
- c.name = 'echo'
170
- end
171
-
172
- ## all task's add_command invocations with name (string), message
173
- #t.add_command('echo --blah my name is ray', 'message') # ArgumentError
174
- t.add_command :echo
175
- t.add_command 'echo' do |c|
176
- c.name = 'echo' # # nomethod error?
177
- c.message = 'why we echo'
178
- end
179
- t.add_command do |c|
180
- c.name = 'echo'
181
- c.message = 'blah'
182
- end
183
-
184
- ## all task's add_command invocations with name (block) (could be same for message?)
185
- #t.add_command('echo --blah my name is ray', 'message') # ArgumentError
186
- #t.add_command :echo
187
- #t.add_command 'echo' do |c|
188
- # c.message = 'blah'
189
- #end
190
- t.add_command do |c|
191
- c.name 'echo' do |n|
192
- n.add_env
193
- end
194
- c.add_arg 'some_arg' do |a|
195
- a.add_env
196
- a.message
197
- end
198
- c.add_option '--option_name' do |o|
199
- o.add_arg 'switch_arg' do |a|
200
- a.add_env 'opion-arg_env' do |e|
201
- e.set_name
202
- e.set_message
203
- e.set_value
204
- end
205
- end
206
- o.add_env 'option-name_env' do |e|
207
- e.set_name
208
- e.set_message
209
- e.set_value
210
- end
211
- o.message
212
- end
213
- c.add_switch '--some_switch' do |s|
214
- s.add_env 'env_name' do |e|
215
- e.set_name
216
- e.set_message
217
- e.set_value
218
- end
219
- s.message
220
- end
221
- end
85
+ ## Issues
222
86
 
223
- #should we be able to add an env for any given message? i don't see a use case, we should probably just save users from themselves here.
87
+ * none. it's perfect, but just in case:
88
+ * [Jira: Rototiller](https://tickets.puppetlabs.com/issues/?jql=project%20%3D%20QA) (sorry, this is Puppet-internal for now)
89
+ * [Puppet QA-team](mailto:qa-team@puppet.com)
@@ -1,33 +1,25 @@
1
1
  # Rototiller Task Reference
2
2
  * herein lies the reference to the rototiller_task API
3
3
 
4
- * [#rototiller_task](#rototiller_task)
5
- * [#add_command](#rototiller_task:add_command)
6
- * [#add_env](#rototiller_task:add_env)
7
- * [Command](#Command)
8
- * [#add\_env](#Command:add_env)
9
- * [#add\_switch](#Command:add_switch)
10
- * [#add\_env](#Command:add_switch:add_env)
11
- * [#add\_option](#Command:add_option)
12
- * [#add\_env](#Command:add_option:add_env)
13
- * [#add\_argument](#Command:add_option:add_argument)
14
- * [#add\_env](#Command:add_option:add_argument:add_env)
15
- * [#add\_argument](#Command:add_argument)
16
- * [#add\_env](#Command:add_argument:add_env)
4
+ * [rototiller_task](rototiller_task)
5
+ * [#add_env](rototiller_task-add_env)
6
+ * [#add_command](rototiller_task-add_command)
7
+ * [Command](Command)
8
+ * [#add\_env](Command-add_env)
9
+ * [#add\_switch](Command-add_switch)
10
+ * [#add\_env](Command-add_switch-add_env)
11
+ * [#add\_option](Command-add_option)
12
+ * [#add\_env](Command-add_option-add_env)
13
+ * [#add\_argument](Command-add_option-add_argument)
14
+ * [#add\_env](Command-add_option-add_argument-add_env)
15
+ * [#add\_argument](Command-add_argument)
16
+ * [#add\_env](Command-add_argument-add_env)
17
17
 
18
18
  <a name="rototiller_task"></a>
19
- ## #rototiller_task
19
+ ## rototiller_task
20
20
  * behaves just like any other rake task name (see below)
21
21
 
22
- <a name="rototiller_task:add_command"></a>
23
- ### #add_command
24
- * adds a command to a rototiller_task. This command can in turn contain environment variables, switches, options and arguments
25
- * this command (and any others) will be run with the task is executed
26
- * (!) currently a task will fail if its command fails _only_ if `#fail_on_error` is set
27
- * the error message from the command will only be shown when rake is run with `--verbose`
28
- * this will be fixed post-1.0
29
-
30
- <a name="rototiller_task:add_env"></a>
22
+ <a name="rototiller_task-add_env"></a>
31
23
  ### #add_env
32
24
  * parent methods such as `add_command`, `add_argument`, `add_switch`, and `add_option` can utilize the method `add_env` to add an env to a param
33
25
  * adds an arbitrary environment variable for use in the task
@@ -35,20 +27,25 @@
35
27
  * If the parent does not call the `name=` method and the method `default=` is called under `add_env` the value passed to `default=` is the default
36
28
  * If the parent does not call the `name=` method and the method `name=` is called under `add_env` the task will only continue if a value is found in the environment
37
29
  * if specified with a default value, and the system environment does not have this variable set, rototiller will set it, for later use in a task or otherwise
38
- * the same method can be used for any portion of a [command](#Command:add_env) as well, including command name, options, option arguments, switches, and command arguments. In these cases the environment variable's value will override that portion of the command string.
30
+ * the same method can be used for any portion of a [command](#Command-add_env) as well, including command name, options, option arguments, switches, and command arguments. In these cases the environment variable's value will override that portion of the command string.
39
31
  * more add_env use cases can be seen in the [env\_var\_example\_reference](env_var_example_reference.md)
40
32
 
41
- | Environment Variable and Task/Command Interactions |
33
+ #### Environment Variable and Task/Command Interactions
34
+
42
35
  | has default? | exists in ENV? | rototiller creates | rototiller stops |
43
36
  | ------------ | -------------- | ------------------ | ---------------- |
44
37
  | n | n | n | y |
45
- | ------------ | -------------- | ------------------ | ---------------- |
46
38
  | n | y | n | n |
47
- | ------------ | -------------- | ------------------ | ---------------- |
48
39
  | y | n | y | n |
49
- | ------------ | -------------- | ------------------ | ---------------- |
50
40
  | y | y | n | n |
51
41
 
42
+ <a name="rototiller_task-add_command"></a>
43
+ ### #add_command
44
+ * adds a command to a rototiller_task. This command can in turn contain environment variables, switches, options and arguments
45
+ * this command (and any others) will be run with the task is executed
46
+ * (!) currently a task will fail if its command fails _only_ if `#fail_on_error` is set
47
+ * the error message from the command will only be shown when rake is run with `--verbose`
48
+ * this will be fixed post-1.0
52
49
 
53
50
  &nbsp;
54
51
 
@@ -83,7 +80,7 @@ produces:
83
80
 
84
81
  <a name="Command"></a>
85
82
  ## Command
86
- <a name="Command:add_env"></a>
83
+ <a name="Command-add_env"></a>
87
84
  ### #add_env
88
85
  * adds an arbitrary environment variable which overrides the name of the command
89
86
  * if specified with a default value, and the system environment does not have this variable set, rototiller will set it, for later use in a task or otherwise
@@ -130,36 +127,36 @@ produces:
130
127
  partial success
131
128
  awwww yeah!
132
129
 
133
- <a name="Command:add_switch"></a>
130
+ <a name="Command-add_switch"></a>
134
131
  ### #add_switch
135
- <a name="Command:add_argument"></a>
132
+ <a name="Command-add_argument"></a>
136
133
  ### #add_argument
137
134
  * adds an arbitrary string to a command
138
135
  * intended to add `--switch` type binary switches that do not take arguments (see [add_option](#Command:add_option))
139
136
  * add\_argument is intended to add strings to the end of the command string (options and switches are added prior to arguments
140
137
 
141
- <a name="Command:add_switch:add_env"></a>
142
- <a name="Command:add_argument:add_env"></a>
138
+ <a name="Command-add_switch-add_env"></a>
139
+ <a name="Command-add_argument-add_env"></a>
143
140
  #### #add_env
144
141
  * just like the other `#add_env` methods for other portions of a Command
145
142
  * adds an arbitrary environment variable which overrides the name of the switch or argument
146
143
  * if specified with a default value, and the system environment does not have this variable set, rototiller will set it, for later use in a task or otherwise
147
144
  * more add_env use cases can be seen in the [env\_var\_example\_reference](env_var_example_reference.md)
148
145
 
149
- <a name="Command:add_option"></a>
146
+ <a name="Command-add_option"></a>
150
147
  ### #add_option
151
148
 
152
- <a name="Command:add_option:add_env"></a>
149
+ <a name="Command-add_option-add_env"></a>
153
150
  #### #add_env
154
151
  * adds an arbitrary environment variable which overrides the name of the option (usually the thing with the --)
155
152
  * just like the other `#add_env` methods for other portions of a Command
156
153
  * more add_env use cases can be seen in the [env\_var\_example\_reference](env_var_example_reference.md)
157
154
 
158
- <a name="Command:add_option:add_argument"></a>
155
+ <a name="Command-add_option-add_argument"></a>
159
156
  #### #add_argument
160
157
  * adds an arbitrary string to trail an option (aka: an option argument)
161
158
 
162
- <a name="Command:add_option:add_argument:add_env"></a>
159
+ <a name="Command-add_option-add_argument-add_env"></a>
163
160
  ##### #add_env
164
161
  * adds an arbitrary environment variable which overrides the name of _argument_ of this option
165
162
  * just like the other `#add_env` methods for other portions of a Command
@@ -1,4 +1,3 @@
1
- require 'open3'
2
1
  require 'rototiller/task/collections/env_collection'
3
2
  require 'rototiller/task/collections/switch_collection'
4
3
  require 'rototiller/task/collections/option_collection'
@@ -12,7 +11,7 @@ module Rototiller
12
11
  # @since v0.1.0
13
12
  # @attr [String] name The name of the command to run
14
13
  # @attr_reader [Struct] result A structured command result
15
- # contains members: output, exit_code and pid (from Open3.popen2e)
14
+ # contains members: output, exit_code and pid
16
15
  class Command < RototillerParam
17
16
 
18
17
  # @return [String] the command to be used, could be considered a default
@@ -161,15 +160,41 @@ module Rototiller
161
160
  # we may have to convert this to a class if it gets complex
162
161
  @result = Result.new
163
162
  @result.output = ''
164
- # add ';' to command string as it is a metacharacter that forces open3
165
- # to send the command to the shell. This returns the correct
166
- # exit_code and stderr, etc when the command is not found
167
- Open3.popen2e(self.to_str + ";"){|stdin, stdout_err, wait_thr|
168
- stdout_err.each { |line| puts line
169
- @result.output << line }
170
- @result.pid = wait_thr.pid # pid of the started process.
171
- @result.exit_code = wait_thr.value.exitstatus # Process::Status object returned.
172
- }
163
+
164
+ read_pipe, write_pipe = IO.pipe
165
+ begin
166
+ @result.pid = Process.spawn(self.to_str, :out => write_pipe, :err => write_pipe)
167
+ rescue Errno::ENOENT => e
168
+ $stderr.puts e
169
+ @result.output << e.to_s
170
+ @result.exit_code = 127
171
+ raise
172
+ end
173
+ #create a thread that monitors the process and tells us when it is done
174
+ @exitstatus = :not_done
175
+ Thread.new do
176
+ Process.wait(@result.pid);
177
+ @exitstatus = $?.exitstatus
178
+ @result.exit_code = @exitstatus
179
+ write_pipe.close
180
+ end
181
+
182
+ #FIXME: monitor for deadlock?
183
+ while @exitstatus == :not_done
184
+ begin
185
+ # readpartial will read UP to amount given
186
+ # we should never really need 64k, but it makes the responsiveness
187
+ # of our output much better when something is really quickly spewing output
188
+ sixty_four_k = 65536
189
+ this_read = read_pipe.readpartial(sixty_four_k)
190
+ rescue EOFError
191
+ next
192
+ end
193
+ @result.output << this_read
194
+ $stdout.sync = true # print stuff right away
195
+ print this_read
196
+ sleep 0.001
197
+ end
173
198
 
174
199
  if block_given? # if block, send result to the block
175
200
  yield @result
@@ -107,7 +107,10 @@ module Rototiller
107
107
  @commands.each do |command|
108
108
  puts command if @verbose
109
109
 
110
- command.run
110
+ begin
111
+ command.run
112
+ rescue Errno::ENOENT => e
113
+ end
111
114
  command_failed = command.result.exit_code > 0
112
115
 
113
116
  if command_failed
@@ -1,5 +1,5 @@
1
1
  module Rototiller
2
2
  module Version
3
- STRING = '1.0.0'
3
+ STRING = '1.0.1'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rototiller
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet, Inc.
@@ -10,22 +10,22 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-11-29 00:00:00.000000000 Z
13
+ date: 2017-05-04 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
- - - ~>
19
+ - - ">="
20
20
  - !ruby/object:Gem::Version
21
- version: '11.0'
21
+ version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
- - - ~>
26
+ - - ">="
27
27
  - !ruby/object:Gem::Version
28
- version: '11.0'
28
+ version: '0'
29
29
  description: Puppet Labs tool for building rake tasks
30
30
  email:
31
31
  - qa@puppet.com
@@ -69,17 +69,17 @@ require_paths:
69
69
  - lib
70
70
  required_ruby_version: !ruby/object:Gem::Requirement
71
71
  requirements:
72
- - - ! '>='
72
+ - - ">="
73
73
  - !ruby/object:Gem::Version
74
74
  version: 1.9.3
75
75
  required_rubygems_version: !ruby/object:Gem::Requirement
76
76
  requirements:
77
- - - ! '>='
77
+ - - ">="
78
78
  - !ruby/object:Gem::Version
79
79
  version: '0'
80
80
  requirements: []
81
81
  rubyforge_project:
82
- rubygems_version: 2.6.8
82
+ rubygems_version: 2.6.11
83
83
  signing_key:
84
84
  specification_version: 4
85
85
  summary: Puppet Labs rake tool