mvn2 2.0.1 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 96d64cc9e54b052462726c7f70924c7389856c52
4
- data.tar.gz: 0ddc356eb79c6e731e4c4d39533b255a601bb0c0
3
+ metadata.gz: c72be85209bb1530015bcd6b2eb25e2d426e25c0
4
+ data.tar.gz: 7c07e923c4bdb1ad8bf1e45bd5335045e47189e7
5
5
  SHA512:
6
- metadata.gz: 059cf6860c233b75df01bda3550ed84a86a3741823c71199b157db00c5f09dc3fc06c1df3d4333ff1f7e7f74ef5b7781fafa4f86735a6670a1097b8a79902764
7
- data.tar.gz: 5e42b3f66b81374682650711bd2a1080579069f76b8ead84cd493a03f09b81fc928e7999001fdc29839bf394fced7a04ec75966b865638f5fc69c0c691c2aa2c
6
+ metadata.gz: 4ef22f5679a9697663580798ca40473aa527a44380c57d497646fbd767c229d3640aecf124c75fa6c6836dc3c8fd8a931e83eb55101eb281af0efe9a2fee7747
7
+ data.tar.gz: f360db16d6a98677ca1822642c358339859d5373d34aac49d6c3b0b4d0dc94a70bd0ecfb783c56ab5c7fdaadb070bff3ba4344d7faee4a665ac0f5d2b7aa7c26
data/README.md CHANGED
@@ -10,6 +10,10 @@ Install it yourself as:
10
10
 
11
11
  ## Usage
12
12
 
13
+ Version 2.0.0 introduces a plugin system. Other gems can add plugins to mvn2. The files have to match the pattern `mvn2/plugin/*.plugin.rb` in your gem's `lib/` folder. If you do that, when the gem is installed, `mvn2` will automatically pick up on it and load it.
14
+
15
+ Please see the plugin folder in this gem for examples of how to use the plugin system. I might add an explanation here later, but for now, you'll just have to figure it out. My `colorconfig` gem also has a plugin for `mvn2`
16
+
13
17
  ###optional parameters:
14
18
  * `-t` or `--timer` to display a timer while the build is in progress (default is display nothing)
15
19
  * `-s` or `--skip-tests` to skip tests (default is running tests)
@@ -35,8 +39,6 @@ Install it yourself as:
35
39
  * `-e` or `--exception` to add the `-e -X` options to the `mvn` call
36
40
  * `-0` or `--live-print` to print filtered lines as they are outputted by maven
37
41
  * `-1` or `--set-defaults` to set the defaults so you can just run `mvn2` without any parameters
38
- * `--mobile-number NUM` to use the mobile number `NUM` (with country code and nothing other than digits) (country code for US is 1 so an example phone number would be `--mobile-number "13175649047"`) as the recipient of a text message (from **13179120742**) indicating the success or failure of a build and the name of the immediate folder of the build (requires gem `nexmo`)
39
- * `-2` or `--advanced-text` to upload the folder name, build time so far, and estimated percent complete (based on stored averages) to a server so that you can text **13179120742** (the number you get the build completion texts from) to get the status(es) of your ongoing build(s). If you send the exact name of the folder (case-**sensitive**, only 1 at a time), it will only reply with entries matching that build. If you text anything that does not exactly match a folder name, it will simply reply with all of the ongoing build statuses. It identifies your builds by your mobile number, so make sure you're texting from the number you used as the parameter to the `--mobile-number NUM` option.
40
42
 
41
43
  ###displays:
42
44
  a Growl notification indicating success or failure
@@ -14,45 +14,16 @@ class AvgPlugin
14
14
  pieces.join
15
15
  }
16
16
 
17
- register_type(:block_average) { |list|
18
- options = Mvn2::Plugins.get_var :options
19
- list.any? { |item|
20
- if item[:block].nil?
21
- item[:options].has_key?(:option) && options[item[:options][:option]] == (item[:options].has_key?(:value) ? item[:options][:value] : true)
22
- else
23
- item[:block].call(options)
24
- end
25
- }
26
- }
17
+ register_type(:block_average) { |list| basic_type(list) }
27
18
 
28
19
  register_type(:block_update) { |list|
29
- options = Mvn2::Plugins.get_var :options
30
20
  result = Mvn2::Plugins.get_var :result
31
21
  average = Mvn2::Plugins.get_var :average
32
22
  diff = Mvn2::Plugins.get_var :diff
33
- list.any? { |item|
34
- if item[:block].nil?
35
- item[:options].has_key?(:option) && options[item[:options][:option]] == (item[:options].has_key?(:value) ? item[:options][:value] : true)
36
- else
37
- item[:block].call(options, result, average, diff)
38
- end
39
- }
23
+ basic_type(list, result, average, diff)
40
24
  }
41
25
 
42
- register_type(:block_full_average) { |list|
43
- if Mvn2::Plugins.get(:block_average)
44
- true
45
- else
46
- options = Mvn2::Plugins.get_var :options
47
- list.any? { |item|
48
- if item[:block].nil?
49
- item[:options].has_key?(:option) && options[item[:options][:option]] == (item[:options].has_key?(:value) ? item[:options][:value] : true)
50
- else
51
- item[:block].call(options)
52
- end
53
- }
54
- end
55
- }
26
+ register_type(:block_full_average) { |list| Mvn2::Plugins.get(:block_average) || basic_type(list) }
56
27
 
57
28
  register :option, sym: :track_average, names: %w(-k --track-average), desc: 'update the average and also display a progress bar while the build is in progress'
58
29
 
data/lib/mvn2/plugin.rb CHANGED
@@ -68,6 +68,17 @@ module Mvn2
68
68
  def register_variable(name, value = nil)
69
69
  Mvn2::Plugins.instance.register_variable(name, value)
70
70
  end
71
+
72
+ def basic_type(list, *args)
73
+ options = Mvn2::Plugins.get_var :options
74
+ list.any? { |item|
75
+ if item[:block].nil?
76
+ item[:options].has_key?(:option) && options[item[:options][:option]] == (item[:options].has_key?(:value) ? item[:options][:value] : true)
77
+ else
78
+ item[:block].call(options, *args)
79
+ end
80
+ }
81
+ end
71
82
  end
72
83
  class DefaultTypes
73
84
  extend Mvn2::PluginType
@@ -79,25 +90,19 @@ module Mvn2
79
90
  register_variable :cmd_clean
80
91
  register_variable :message_text
81
92
 
82
- register_type(:option) { |list, options|
93
+ def self.register_option(list, options)
83
94
  list.sort_by { |v| v[:options][:sym].to_s }.each { |option|
84
95
  id = option[:options].delete(:sym)
85
96
  names = option[:options].delete(:names)
86
97
  default = option[:options].delete(:default) || nil
87
- options.option id, names, option[:options]
98
+ yield(id, names, option)
88
99
  options.default_options id => default unless default.nil?
89
100
  }
90
- }
101
+ end
91
102
 
92
- register_type(:option_with_param) { |list, options|
93
- list.sort_by { |v| v[:options][:sym].to_s }.each { |option|
94
- id = option[:options].delete(:sym)
95
- names = option[:options].delete(:names)
96
- default = option[:options].delete(:default) || nil
97
- options.option_with_param id, names, option[:options]
98
- options.default_options id => default unless default.nil?
99
- }
100
- }
103
+ register_type(:option) { |list, options| register_option(list, options) { |id, names, option| options.option id, names, option[:options] } }
104
+
105
+ register_type(:option_with_param) { |list, options| register_option(list, options) { |id, names, option| options.option_with_param id, names, option[:options] } }
101
106
 
102
107
  register_type(:command_flag) { |list|
103
108
  options = Mvn2::Plugins.get_var :options
@@ -165,30 +170,10 @@ module Mvn2
165
170
  name
166
171
  }
167
172
 
168
- register_type(:log_file_disable) { |list|
169
- options = Mvn2::Plugins.get_var :options
170
- list.any? { |item|
171
- if item[:block].nil?
172
- item[:options].has_key?(:option) && options[item[:options][:option]] == (item[:options].has_key?(:value) ? item[:options][:value] : true)
173
- else
174
- item[:block].call(options)
175
- end
176
- }
177
- }
173
+ register_type(:log_file_disable) { |list| basic_type(list) }
178
174
 
179
175
  register_type(:log_file_enable) { |list|
180
- if Mvn2::Plugins.get(:log_file_name).nil? || Mvn2::Plugins.get(:log_file_disable)
181
- false
182
- else
183
- options = Mvn2::Plugins.get_var :options
184
- list.any? { |item|
185
- if item[:block].nil?
186
- item[:options].has_key?(:option) && options[item[:options][:option]] == (item[:options].has_key?(:value) ? item[:options][:value] : true)
187
- else
188
- item[:block].call(options)
189
- end
190
- }
191
- end
176
+ (Mvn2::Plugins.get(:log_file_name).nil? || Mvn2::Plugins.get(:log_file_disable)) ? false : basic_type(list)
192
177
  }
193
178
 
194
179
  register_type(:line_filter) { |list, line|
@@ -209,16 +194,7 @@ module Mvn2
209
194
  result
210
195
  }
211
196
 
212
- register_type(:runner_enable) { |list, key|
213
- options = Mvn2::Plugins.get_var :options
214
- list.select { |v| v[:options][:key] == key }.any? { |item|
215
- if item[:block].nil?
216
- item[:options].has_key?(:option) && options[item[:options][:option]] == (item[:options].has_key?(:value) ? item[:options][:value] : true)
217
- else
218
- item[:block].call(options)
219
- end
220
- }
221
- }
197
+ register_type(:runner_enable) { |list, key| basic_type(list.select { |v| v[:options][:key] == key }) }
222
198
 
223
199
  register_type(:runner) { |list|
224
200
  options = Mvn2::Plugins.get_var :options
@@ -234,33 +210,24 @@ module Mvn2
234
210
  Mvn2::Plugins.get_var :result
235
211
  }
236
212
 
237
- register_type(:goal_override) { |list|
238
- options = Mvn2::Plugins.get_var :options
239
- full_overrides = list.select { |v| v[:options][:override_all] }.sort_by { |v| -v[:options][:priority] }.filtermap { |item|
240
- if item[:block].nil?
241
- if item[:options].has_key?(:goal) && item[:options].has_key?(:option) && options[item[:options][:option]] == (item[:options].has_key?(:value) ? item[:options][:value] : true)
242
- item[:options][:goal]
243
- else
244
- item[:options].has_key?(:option) && !options[item[:options][:option]].nil? ? options[item[:options][:option]] : false
245
- end
213
+ def self.goal_filter(item, options)
214
+ if item[:block].nil?
215
+ if item[:options].has_key?(:goal) && item[:options].has_key?(:option) && options[item[:options][:option]] == (item[:options].has_key?(:value) ? item[:options][:value] : true)
216
+ item[:options][:goal]
246
217
  else
247
- rval = item[:block].call(options)
248
- (rval.nil? || !rval) ? false : rval
218
+ item[:options].has_key?(:option) && !options[item[:options][:option]].nil? ? options[item[:options][:option]] : false
249
219
  end
250
- }
220
+ else
221
+ rval = item[:block].call(options)
222
+ (rval.nil? || !rval) ? false : rval
223
+ end
224
+ end
225
+
226
+ register_type(:goal_override) { |list|
227
+ options = Mvn2::Plugins.get_var :options
228
+ full_overrides = list.select { |v| v[:options][:override_all] }.sort_by { |v| -v[:options][:priority] }.filtermap { |item| goal_filter(item, options) }
251
229
  if full_overrides.nil? || full_overrides.empty?
252
- goals = list.select { |v| !v[:options][:override_all] }.sort_by { |v| v[:options][:order] }.filtermap { |item|
253
- if item[:block].nil?
254
- if item[:options].has_key?(:goal) && item[:options].has_key?(:option) && options[item[:options][:option]] == (item[:options].has_key?(:value) ? item[:options][:value] : true)
255
- item[:options][:goal]
256
- else
257
- item[:options].has_key?(:option) && !options[item[:options][:option]].nil? ? options[item[:options][:option]] : false
258
- end
259
- else
260
- rval = item[:block].call(options)
261
- (rval.nil? || !rval) ? false : rval
262
- end
263
- }
230
+ goals = list.select { |v| !v[:options][:override_all] }.sort_by { |v| v[:options][:order] }.filtermap { |item| goal_filter(item, options) }
264
231
  goals = ['install'] if (goals - ['clean']).empty?
265
232
  goals = ['clean'] + goals unless goals.include?('clean')
266
233
  goals.join(' ')
data/lib/mvn2/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Mvn2
2
- VERSION = '2.0.1'
2
+ VERSION = '2.0.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mvn2
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Henderson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-01 00:00:00.000000000 Z
11
+ date: 2014-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler