mvn2 2.1.0 → 2.2.0

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: bbe17e1824645491f53d325e16cbc27fd78fb92e
4
- data.tar.gz: b80978a9c66ff6b807a0d0cfbc352a9b49cc1057
3
+ metadata.gz: b39f2e1b31e73e8e0e46b2933b0a99a61a894f15
4
+ data.tar.gz: 8910e23d49347ba7beb82506f0e3fa34ebbecee9
5
5
  SHA512:
6
- metadata.gz: ac64c92c0b0fdde3ef7f241594065286d9f7e0949e94cf3f442407541d91cad908ee83e484612defaa91abf1220f33f8e763f6a8e301c0e1774390510b9511cc
7
- data.tar.gz: d2aefc76312bb99b7346327d6f189914ab3dba2a6271574d1dc0aa935e50d6c4aef330904877d549fc9b6201795682f61d97c96c3d6fd506c6419537859e4369
6
+ metadata.gz: 9f6c81c323f67a021138a7fcd5a655d6c660331942cedb07981aebc85b4c2a96f33325c21912e1f530a8d5f27374e94bab229c0a48acdfe378a3f77769b2477f
7
+ data.tar.gz: bd83204629ee2518a77280f9e01567e1235ad3fb4f6cad43ada9aebc3b6e22e3508d8f81fdb5d8e0591ae9d8f963ce89c0e63d38a7ae615526542089adaf1ba0
data/README.md CHANGED
@@ -12,7 +12,7 @@ Install it yourself as:
12
12
 
13
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
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`
15
+ Please see the plugin folder in this gem for examples of how to use the plugin system. My `colorconfig` and `mvn2-say` gems also have plugins for `mvn2`
16
16
 
17
17
  ###optional parameters:
18
18
  * `-t` or `--timer` to display a timer while the build is in progress (default is display nothing)
@@ -41,4 +41,85 @@ Please see the plugin folder in this gem for examples of how to use the plugin s
41
41
  * `-1` or `--set-defaults` to set the defaults so you can just run `mvn2` without any parameters
42
42
 
43
43
  ###displays:
44
- a Growl notification indicating success or failure
44
+ a Growl notification indicating success or failure
45
+
46
+ ##Plugin System
47
+
48
+ The following is my initial documentation of the plugin system. It may be improved as I have time.
49
+
50
+ -----
51
+
52
+ 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.
53
+
54
+ Two examples of this are my gems `colorconfig` and `mvn2-say`.
55
+
56
+ The `Mvn2::Plugin` module is used for registering a plugin of a defined type. It defines the `register` method. You should use `extend` so that you can define things statically. There is no need for a `build` method because it automatically adds the plugins at the time you call the method.
57
+
58
+ Here is an example:
59
+
60
+ ```ruby
61
+ register :option, sym: :timer, names: %w(-t --timer), desc: 'display a timer while the build is in progress'
62
+ ```
63
+
64
+ And another:
65
+
66
+ ```ruby
67
+ register(:before_run, order: 2) { |options|
68
+ Mvn2::Plugins.set_var :time1, Time.now
69
+ Mvn2::Plugins.set_var :thread, options[:timer] ? Thread.new {
70
+ start_time = Mvn2::Plugins.get_var :time1
71
+ while true
72
+ print "\r#{get_timer_message(start_time, Time.now)}"
73
+ sleep(0.05)
74
+ end
75
+ } : nil
76
+ }
77
+ ```
78
+
79
+ The `register` method takes a first parameter of the plugin type identifier, followed by an optional (but probably necessary) hash of options, and an optional block (usable with most built-in plugin types, required by some).
80
+
81
+ -----
82
+
83
+ If you want to define a new plugin type, you can extend the `Mvn2::PluginType`. This defines the `register_type` and `register_variable` methods. Technically, you don't really need to register a variable, but if you want to give it a certain starting value, you will need to register it and pass over the value. `register_type` takes a first parameter of the plugin type identifier, followed by a block. The block will always take a first parameter of the list of instances, followed by any additional parameters passed to the plugin when it is called. The block has the task of taking the list of plugin instances and turning it into whatever result the plugin is supposed to have.
84
+
85
+ Here is an example:
86
+
87
+ ```ruby
88
+ register_type(:command_flag) { |list|
89
+ options = Mvn2::Plugins.get_var :options
90
+ flags = []
91
+ list.each { |flag|
92
+ if flag[:block].nil?
93
+ flags << " #{flag[:options][:flag]}" if flag[:options].has_key?(:option) && options[flag[:options][:option]] == (flag[:options].has_key?(:value) ? flag[:options][:value] : true)
94
+ else
95
+ flag[:block].call(options, flags)
96
+ end
97
+ }
98
+ flags.join
99
+ }
100
+ ```
101
+
102
+ -----
103
+
104
+ You might notice in the second plugin example, as well as the plugin type example, methods are called on `Mvn2::Plugins`. This is the class that stores all of the plugins and types. It has various methods, but the ones involved in making a plugin are:
105
+
106
+ * `Mvn2::Plugins.get(type, *args)`
107
+ * Gets the result of a plugin type. The first parameter is the plugin type identifier, followed by any additional arguments the plugin type takes.
108
+ * `Mvn2::Plugins.get_var(name)`
109
+ * Gets a single variable by name
110
+ * `Mvn2::Plugins.get_vars(*names)`
111
+ * Gets a list of variables by name. Useful for getting a lot of variables in one line.
112
+ * `Mvn2::Plugins.set_var(name, value)`
113
+ * Sets a single variable of the given name to the given value.
114
+ * `Mvn2::Plugins.set_vars(vars = {})`
115
+ * Sets a list of variables to the values specified. It use a hash format, so you can do something like `Mvn2::Plugins.set_vars found: true, info_line_last: false`
116
+
117
+ If you come up with a plugin, feel free to publish it on your own (that's what the plugin system is designed to support). If you think it should be part of the built-in plugin set, you can always file a pull request.
118
+
119
+ ## Contributing
120
+
121
+ 1. Fork it ( http://github.com/henderea/mvn2/fork )
122
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
123
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
124
+ 4. Push to the branch (`git push origin my-new-feature`)
125
+ 5. Create new Pull Request
data/bin/mvn2 CHANGED
@@ -8,23 +8,14 @@ require 'everyday-cli-utils'
8
8
  include EverydayCliUtils
9
9
  import :maputil, :format, :kmeans, :option
10
10
  require 'mvn2/plugin'
11
- begin
12
- Gem.find_latest_files('/mvn2/plugin/*.plugin.rb').each { |plugin|
13
- #noinspection RubyResolve
14
- begin
15
- require plugin
16
- rescue LoadError => e
17
- puts "Error in loading plugin '#{plugin}'"
18
- puts e.inspect
19
- end
20
- }
21
- rescue Exception => e
22
- puts 'Error in loading plugins'
23
- puts e.inspect
24
- end
11
+ require 'everyday-plugins'
12
+
13
+ include EverydayPlugins
14
+
15
+ Plugins.load_plugins 'mvn2'
25
16
 
26
- #abcd h jkl n p stuvw 012
27
- # efg i m o qr xyz 3456789
17
+ #abcd h jkl n p stuvw y 012
18
+ # efg i m o qr x z 3456789
28
19
 
29
20
  class MyOptions
30
21
  extend OptionUtil
@@ -36,14 +27,14 @@ class MyOptions
36
27
  help_option ['--help'], desc: 'print out this help'
37
28
  end
38
29
 
39
- Mvn2::Plugins.get :option, MyOptions
40
- Mvn2::Plugins.get :option_with_param, MyOptions
30
+ Plugins.get :option, MyOptions
31
+ Plugins.get :option_with_param, MyOptions
41
32
 
42
33
  MyOptions.parse!
43
34
 
44
35
  options = MyOptions.options
45
36
 
46
- Mvn2::Plugins.set_var(:options, options)
37
+ Plugins.set_var(:options, options)
47
38
 
48
39
  Signal.trap('SIGINT') {
49
40
  puts "\nBuild Canceled\n\n"
@@ -56,7 +47,7 @@ class String
56
47
  end
57
48
  end
58
49
 
59
- Mvn2::Plugins.get :color_override
50
+ Plugins.get :color_override
60
51
 
61
52
  class Mvn2Runner
62
53
  HEADLESS = ' -Djava.awt.headless=true'
@@ -66,32 +57,32 @@ class Mvn2Runner
66
57
  def initialize(options)
67
58
  @options = options
68
59
  setup_cmd
69
- Mvn2::Plugins.set_var :cmd, @cmd
70
- Mvn2::Plugins.set_var :cmd_clean, @cmd_clean
60
+ Plugins.set_var :cmd, @cmd
61
+ Plugins.set_var :cmd_clean, @cmd_clean
71
62
  end
72
63
 
73
64
  def setup_cmd
74
- flags = Mvn2::Plugins.get :command_flag
75
- goals = Mvn2::Plugins.get :goal_override
65
+ flags = Plugins.get :command_flag
66
+ goals = Plugins.get :goal_override
76
67
  @cmd = "mvn #{goals}#{flags}#{HEADLESS} 2>&1"
77
68
  @cmd_clean = @cmd[0...(-5-HEADLESS.length)]
78
69
  end
79
70
 
80
71
  def run_and_filter_output
81
- Mvn2::Plugins.get :before_run
82
- @result = Mvn2::Plugins.get :runner
83
- Mvn2::Plugins.get :after_run
72
+ Plugins.get :before_run
73
+ @result = Plugins.get :runner
74
+ Plugins.get :after_run
84
75
  end
85
76
 
86
77
  def run
87
- Mvn2::Plugins.get :before_start
78
+ Plugins.get :before_start
88
79
  run_and_filter_output
89
- Mvn2::Plugins.get :after_end
80
+ Plugins.get :after_end
90
81
 
91
- operation_name = Mvn2::Plugins.get :operation_name
92
- Mvn2::Plugins.set_var :message_text, "#{operation_name} #{(@result ? 'Successful' : 'Failed')}"
82
+ operation_name = Plugins.get :operation_name
83
+ Plugins.set_var :message_text, "#{operation_name} #{(@result ? 'Successful' : 'Failed')}"
93
84
 
94
- Mvn2::Plugins.get :notification
85
+ Plugins.get :notification
95
86
  end
96
87
  end
97
88
 
@@ -1,70 +1,85 @@
1
1
  require 'mvn2/plugin'
2
+ require 'everyday-plugins'
3
+ include EverydayPlugins
2
4
  class AvgPlugin
3
- extend Mvn2::Plugin
4
- extend Mvn2::PluginType
5
+ extend Plugin
6
+ extend PluginType
5
7
  extend Mvn2::TypeHelper
6
8
 
7
- register_variable :average
8
- register_variable :averages2
9
- register_variable :counts
10
-
11
- register_type(:full_avg_name) { |list|
12
- options = Mvn2::Plugins.get_var :options
13
- pieces = []
14
- list.sort_by { |v| v[:options][:order] }.each { |name| pieces << name[:block].call(options) }
15
- pieces.join
16
- }
17
-
18
- register_type(:block_average) { |list| basic_type(list) }
19
-
20
- register_type(:block_update) { |list|
21
- result, average, diff = Mvn2::Plugins.get_vars :result, :average, :diff
22
- basic_type(list, result, average, diff)
23
- }
24
-
25
- register_type(:block_full_average) { |list| Mvn2::Plugins.get(:block_average) || basic_type(list) }
26
-
27
- 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'
9
+ def self.def_vars
10
+ register_variable :average
11
+ register_variable :averages2
12
+ register_variable :counts
13
+ end
28
14
 
29
- register :option, sym: :track_full_average, names: %w(-u --track-full-average), desc: 'update the average list and also display a progress bar while the build is in progress'
15
+ def_vars
30
16
 
31
- register :option, sym: :advanced_average, names: %w(-d --advanced-average), desc: 'use k-means (with minimum optimal k) to find a list of averages and use the closest one for the progress bar and displayed average'
17
+ def self.def_types
18
+ register_type(:full_avg_name) { |list|
19
+ options = Plugins.get_var :options
20
+ pieces = []
21
+ list.sort_by { |v| v[:options][:order] }.each { |name| pieces << name[:block].call(options) }
22
+ pieces.join
23
+ }
32
24
 
33
- register :option, sym: :show_average, names: %w(-w --show-average), desc: 'show the average(s) before and after the build (average tracking must be enabled)'
25
+ register_type(:block_average) { |list| basic_type(list) }
34
26
 
35
- register :option, sym: :block_update, names: %w(-b --block-update), desc: 'block the average feature from updating the file(s)'
27
+ register_type(:block_update) { |list|
28
+ result, average, diff = Plugins.get_vars :result, :average, :diff
29
+ basic_type(list, result, average, diff)
30
+ }
36
31
 
37
- register :block_update, option: :block_update
32
+ register_type(:block_full_average) { |list| Plugins.get(:block_average) || basic_type(list) }
33
+ end
38
34
 
39
- register(:block_update) { |options, result, average, diff| !(result || (!options[:skip_tests] && diff >= average / 2.0)) }
35
+ def_types
40
36
 
41
- register :block_full_average, option: :track_full_average, value: false
37
+ def self.def_options
38
+ 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'
39
+ register :option, sym: :track_full_average, names: %w(-u --track-full-average), desc: 'update the average list and also display a progress bar while the build is in progress'
40
+ register :option, sym: :advanced_average, names: %w(-d --advanced-average), desc: 'use k-means (with minimum optimal k) to find a list of averages and use the closest one for the progress bar and displayed average'
41
+ register :option, sym: :show_average, names: %w(-w --show-average), desc: 'show the average(s) before and after the build (average tracking must be enabled)'
42
+ register :option, sym: :block_update, names: %w(-b --block-update), desc: 'block the average feature from updating the file(s)'
43
+ end
42
44
 
43
- register :block_average, option: :track_average, value: false
45
+ def_options
44
46
 
45
- register(:before_run, order: 1) { |options|
46
- read_avg
47
- read_full_avg
48
- read_advanced_avg
49
- show_averages if options[:show_average]
50
- }
47
+ def self.def_blockers
48
+ register :block_update, option: :block_update
49
+ register(:block_update) { |options, result, average, diff| !(result || (!options[:skip_tests] && diff >= average / 2.0)) }
50
+ register :block_full_average, option: :track_full_average, value: false
51
+ register :block_average, option: :track_average, value: false
52
+ end
51
53
 
52
- register(:after_run, order: 2) { |_, _|
53
- update_avg
54
- update_full_avg
55
- }
54
+ def_blockers
56
55
 
57
- register(:after_run, order: 4) { |options, _|
58
- if options[:show_average]
56
+ def self.def_actions
57
+ register(:before_run, order: 1) { |options|
59
58
  read_avg
60
59
  read_full_avg
61
60
  read_advanced_avg
62
- show_averages
63
- end
64
- }
61
+ show_averages if options[:show_average]
62
+ }
63
+
64
+ register(:after_run, order: 2) { |_, _|
65
+ update_avg
66
+ update_full_avg
67
+ }
68
+
69
+ register(:after_run, order: 4) { |options, _|
70
+ if options[:show_average]
71
+ read_avg
72
+ read_full_avg
73
+ read_advanced_avg
74
+ show_averages
75
+ end
76
+ }
77
+ end
78
+
79
+ def_actions
65
80
 
66
81
  def self.full_avg_file
67
- pieces = Mvn2::Plugins.get :full_avg_name
82
+ pieces = Plugins.get :full_avg_name
68
83
  "avg#{pieces}.txt"
69
84
  end
70
85
 
@@ -78,31 +93,31 @@ class AvgPlugin
78
93
  end
79
94
 
80
95
  def self.read_full_avg
81
- average = Mvn2::Plugins.get_var :average
96
+ average = Plugins.get_var :average
82
97
  file_name = full_avg_file
83
- if !Mvn2::Plugins.get(:block_full_average) && File.exist?(file_name)
98
+ if !Plugins.get(:block_full_average) && File.exist?(file_name)
84
99
  lines = IO.readlines(file_name)
85
100
  data = lines.filtermap { |line| float_filter(line) }
86
101
  average = data.average
87
102
  end
88
- Mvn2::Plugins.set_var :average, average
103
+ Plugins.set_var :average, average
89
104
  end
90
105
 
91
106
  def self.read_advanced_avg
92
- options, average = Mvn2::Plugins.get_vars :options, :average
107
+ options, average = Plugins.get_vars :options, :average
93
108
  averages = [average]
94
109
  file_name = full_avg_file
95
- if !Mvn2::Plugins.get(:block_full_average) && options[:advanced_average] && File.exist?(file_name)
110
+ if !Plugins.get(:block_full_average) && options[:advanced_average] && File.exist?(file_name)
96
111
  lines = IO.readlines(file_name)
97
112
  data = lines.filtermap { |line| float_filter(line) }
98
113
  averages = data.nmeans
99
114
  end
100
- Mvn2::Plugins.set_var :averages, averages
115
+ Plugins.set_var :averages, averages
101
116
  end
102
117
 
103
118
  def self.update_full_avg
104
- diff = Mvn2::Plugins.get_var :diff
105
- if !Mvn2::Plugins.get(:block_full_average) && !Mvn2::Plugins.get(:block_update)
119
+ diff = Plugins.get_var :diff
120
+ if !Plugins.get(:block_full_average) && !Plugins.get(:block_update)
106
121
  file = File.new(full_avg_file, 'a+')
107
122
  file.puts(diff)
108
123
  file.close
@@ -119,11 +134,11 @@ class AvgPlugin
119
134
  end
120
135
 
121
136
  def self.read_avg
122
- options = Mvn2::Plugins.get_var :options
137
+ options = Plugins.get_var :options
123
138
  average = 0
124
139
  averages = [0, 0, 0, 0]
125
140
  counts = [0, 0, 0, 0]
126
- if !Mvn2::Plugins.get(:block_average) && File.exist?('avg.txt')
141
+ if !Plugins.get(:block_average) && File.exist?('avg.txt')
127
142
  lines = IO.readlines('avg.txt')
128
143
  get_data(averages, counts, lines, 0)
129
144
  get_data(averages, counts, lines, 1)
@@ -132,26 +147,26 @@ class AvgPlugin
132
147
  pkg = options[:package] ? 2 : 0
133
148
  average = averages[(options[:skip_tests] ? 0 : 1) + pkg]
134
149
  end
135
- Mvn2::Plugins.set_vars average: average, averages2: averages, counts: counts
150
+ Plugins.set_vars average: average, averages2: averages, counts: counts
136
151
  end
137
152
 
138
153
  def self.calc_new_avg(ind)
139
- averages2, counts, diff = Mvn2::Plugins.get_vars :averages2, :counts, :diff
154
+ averages2, counts, diff = Plugins.get_vars :averages2, :counts, :diff
140
155
  sum = averages2[ind] * counts[ind] + diff
141
156
  counts[ind] += 1
142
157
  averages2[ind] = sum / counts[ind]
143
158
  end
144
159
 
145
160
  def self.update_avg
146
- options, averages2, counts = Mvn2::Plugins.get_vars :options, :averages2, :counts
147
- if !Mvn2::Plugins.get(:block_average) && !Mvn2::Plugins.get(:block_update)
161
+ options, averages2, counts = Plugins.get_vars :options, :averages2, :counts
162
+ if !Plugins.get(:block_average) && !Plugins.get(:block_update)
148
163
  options[:skip_tests] ? calc_new_avg(0) : calc_new_avg(1)
149
164
  IO.write('avg.txt', "#{averages2[0]};#{counts[0]}\n#{averages2[1]};#{counts[1]}\n#{averages2[2]};#{counts[2]}\n#{averages2[3]};#{counts[3]}")
150
165
  end
151
166
  end
152
167
 
153
168
  def self.show_averages
154
- averages = Mvn2::Plugins.get_var :averages
169
+ averages = Plugins.get_var :averages
155
170
  unless averages.empty? || (averages.length == 1 && averages[0] == 0)
156
171
  strs = averages.map { |a|
157
172
  m, s = get_time_parts(a)
@@ -1,33 +1,44 @@
1
- require 'mvn2/plugin'
1
+ require 'everyday-plugins'
2
+ include EverydayPlugins
2
3
  class CommandPlugin
3
- extend Mvn2::Plugin
4
- extend Mvn2::PluginType
4
+ extend Plugin
5
+ extend PluginType
6
+
7
+ def self.def_options
8
+ register :option_with_param, sym: :command_override, names: ['--command-override'], desc: 'override the maven command (disables average tracking options and skip test option)'
9
+ register :option, sym: :package, names: %w(-p --package), desc: 'run "mvn clean package" (with optional "-D skipTests")'
10
+ register :option_with_param, sym: :run_before, names: ['--run-before'], desc: 'run a command before calling the maven build'
11
+ register :option_with_param, sym: :run_after, names: ['--run-after'], desc: 'run a command after finishing the maven build'
12
+ register :option_with_param, sym: :run_success, names: ['--run-success'], desc: 'run a command after finishing a successful maven build'
13
+ register :option_with_param, sym: :run_failure, names: ['--run-failure'], desc: 'run a command after finishing an unsuccessful maven build'
14
+ end
5
15
 
6
- register :option_with_param, sym: :command_override, names: ['--command-override'], desc: 'override the maven command (disables average tracking options and skip test option)'
16
+ def_options
7
17
 
8
- register :option, sym: :package, names: %w(-p --package), desc: 'run "mvn clean package" (with optional "-D skipTests")'
18
+ def self.def_others
19
+ register :goal_override, order: 10, option: :package, goal: 'package'
9
20
 
10
- register :option_with_param, sym: :run_before, names: ['--run-before'], desc: 'run a command before calling the maven build'
11
- register :option_with_param, sym: :run_after, names: ['--run-after'], desc: 'run a command after finishing the maven build'
12
- register :option_with_param, sym: :run_success, names: ['--run-success'], desc: 'run a command after finishing a successful maven build'
13
- register :option_with_param, sym: :run_failure, names: ['--run-failure'], desc: 'run a command after finishing an unsuccessful maven build'
21
+ register :goal_override, override_all: true, priority: 100, option: :command_override
14
22
 
15
- register :goal_override, order: 10, option: :package, goal: 'package'
23
+ register(:full_avg_name, order: 20) { |options| options[:package] ? '-package' : '' }
16
24
 
17
- register :goal_override, override_all: true, priority: 100, option: :command_override
25
+ register(:operation_name, priority: 100) { |options| options[:command_override].nil? ? nil : 'Operation' }
18
26
 
19
- register(:full_avg_name, order: 20) { |options| options[:package] ? '-package' : '' }
27
+ register(:block_average) { |options| !options[:command_override].nil? }
28
+ end
20
29
 
21
- register(:operation_name, priority: 100) { |options| options[:command_override].nil? ? nil : 'Operation' }
30
+ def_others
22
31
 
23
- register(:block_average) { |options| !options[:command_override].nil? }
32
+ def self.def_actions
33
+ register(:before_start, order: 10) { |options| run_cmd(options[:run_before]) }
24
34
 
25
- register(:before_start, order: 10) { |options| run_cmd(options[:run_before]) }
35
+ register(:after_end, order: 10) { |options, result|
36
+ run_cmd(options[:run_after])
37
+ result ? run_cmd(options[:run_success]) : run_cmd(options[:run_failure])
38
+ }
39
+ end
26
40
 
27
- register(:after_end, order: 10) { |options, result|
28
- run_cmd(options[:run_after])
29
- result ? run_cmd(options[:run_success]) : run_cmd(options[:run_failure])
30
- }
41
+ def_actions
31
42
 
32
43
  def self.run_cmd(cmd)
33
44
  unless cmd.nil?
@@ -1,30 +1,39 @@
1
- require 'mvn2/plugin'
1
+ require 'everyday-plugins'
2
+ include EverydayPlugins
2
3
  class DefaultRunnerPlugin
3
- extend Mvn2::Plugin
4
- extend Mvn2::PluginType
4
+ extend Plugin
5
+ extend PluginType
5
6
 
6
7
  register_variable :output
7
8
 
8
- register(:runner_enable, key: :default) { |_| true }
9
+ def self.def_runners
10
+ register(:runner_enable, key: :default) { |_| true }
9
11
 
10
- register(:runner, key: :default, priority: 0) { |_, cmd|
11
- output = `#{cmd}`
12
- result = $?.success?
13
- Mvn2::Plugins.set_var :output, output
14
- result
15
- }
12
+ register(:runner, key: :default, priority: 0) { |_, cmd|
13
+ output = `#{cmd}`
14
+ result = $?.success?
15
+ Plugins.set_var :output, output
16
+ result
17
+ }
18
+ end
16
19
 
17
- register(:after_run, order: 1000) { |_, _|
18
- runner = Mvn2::Plugins.get_var :runner
19
- if runner == :default
20
- output = Mvn2::Plugins.get_var :output
21
- IO.write(Mvn2::Plugins.get(:log_file_name), output) if Mvn2::Plugins.get(:log_file_enable)
22
- output.each_line { |l|
23
- tmp = Mvn2::Plugins.get :line_filter, l
24
- puts tmp unless tmp.nil?
25
- }
26
- found = Mvn2::Plugins.get_var :found
27
- output.each_line { |line| puts line } unless found
28
- end
29
- }
20
+ def_runners
21
+
22
+ def self.def_actions
23
+ register(:after_run, order: 1000) { |_, _|
24
+ runner = Plugins.get_var :runner
25
+ if runner == :default
26
+ output = Plugins.get_var :output
27
+ IO.write(Plugins.get(:log_file_name), output) if Plugins.get(:log_file_enable)
28
+ output.each_line { |l|
29
+ tmp = Plugins.get :line_filter, l
30
+ puts tmp unless tmp.nil?
31
+ }
32
+ found = Plugins.get_var :found
33
+ output.each_line { |line| puts line } unless found
34
+ end
35
+ }
36
+ end
37
+
38
+ def_actions
30
39
  end
@@ -1,6 +1,7 @@
1
- require 'mvn2/plugin'
1
+ require 'everyday-plugins'
2
+ include EverydayPlugins
2
3
  class ExceptionPlugin
3
- extend Mvn2::Plugin
4
+ extend Plugin
4
5
 
5
6
  register :option, sym: :exception, names: %w(-e --exception), desc: 'add the "-e -X" options to the mvn call'
6
7
 
@@ -1,4 +1,5 @@
1
- require 'mvn2/plugin'
1
+ require 'everyday-plugins'
2
+ include EverydayPlugins
2
3
 
3
4
  class String
4
5
  def start_with_any?(*strs)
@@ -7,75 +8,102 @@ class String
7
8
  end
8
9
 
9
10
  class FilterPlugin
10
- extend Mvn2::Plugin
11
- extend Mvn2::PluginType
11
+ extend Plugin
12
+ extend PluginType
12
13
 
13
14
  INFO_LINE = '[INFO] ------------------------------------------------------------------------'
14
15
  BUILD_REGEX = /\[INFO\] Building (?!(jar|war|zip))/
15
16
 
16
- register_variable :info_line_last, false
17
- register_variable :found, false
17
+ def self.def_vars
18
+ register_variable :info_line_last, false
19
+ register_variable :found, false
20
+ end
21
+
22
+ def_vars
18
23
 
19
- register :option, sym: :hide_between, names: %w(-h --hide-between), desc: 'hide the output between the end of test results (the line starting with "Tests run:") and the next trigger line'
24
+ def self.def_options
25
+ register :option, sym: :hide_between, names: %w(-h --hide-between), desc: 'hide the output between the end of test results (the line starting with "Tests run:") and the next trigger line'
26
+ register :option, sym: :show_projects, names: %w(-j --show-projects), desc: 'show the "Building <project>" lines when outputting'
27
+ end
20
28
 
21
- register :option, sym: :show_projects, names: %w(-j --show-projects), desc: 'show the "Building <project>" lines when outputting'
29
+ def_options
22
30
 
23
- register(:line_filter, priority: 10) { |_, line|
24
- info_line_last = Mvn2::Plugins.get_var :info_line_last
25
- if line.start_with_any?('[INFO] BUILD SUCCESS', '[INFO] Reactor Summary:', '[INFO] BUILD FAILURE')
26
- str = ''
27
- str << INFO_LINE << "\n" unless info_line_last
28
- str << line << "\n"
29
- Mvn2::Plugins.set_vars found: true, info_line_last: false
30
- str
31
- else
32
- nil
33
- end
34
- }
31
+ def self.def_filters
32
+ def_filter1
33
+ def_filter2
34
+ def_filter3
35
+ def_filter4
36
+ def_filter5
37
+ end
35
38
 
36
- register(:line_filter, priority: 20) { |_, line|
37
- if line.start_with_any?('[ERROR] COMPILATION ERROR :', 'Results :')
38
- str = line << "\n"
39
- Mvn2::Plugins.set_vars found: true, info_line_last: false
40
- str
41
- else
42
- nil
43
- end
44
- }
39
+ def self.def_filter1
40
+ register(:line_filter, priority: 10) { |_, line|
41
+ info_line_last = Plugins.get_var :info_line_last
42
+ if line.start_with_any?('[INFO] BUILD SUCCESS', '[INFO] Reactor Summary:', '[INFO] BUILD FAILURE')
43
+ str = ''
44
+ str << INFO_LINE << "\n" unless info_line_last
45
+ str << line << "\n"
46
+ Plugins.set_vars found: true, info_line_last: false
47
+ str
48
+ else
49
+ nil
50
+ end
51
+ }
52
+ end
45
53
 
46
- register(:line_filter, priority: 30) { |_, line|
47
- found = Mvn2::Plugins.get_var :found
48
- if found
49
- str = line << "\n"
50
- Mvn2::Plugins.set_vars found: true, info_line_last: line.start_with?(INFO_LINE)
51
- str
52
- else
53
- nil
54
- end
55
- }
54
+ def self.def_filter2
55
+ register(:line_filter, priority: 20) { |_, line|
56
+ if line.start_with_any?('[ERROR] COMPILATION ERROR :', 'Results :')
57
+ str = line << "\n"
58
+ Plugins.set_vars found: true, info_line_last: false
59
+ str
60
+ else
61
+ nil
62
+ end
63
+ }
64
+ end
56
65
 
57
- register(:line_filter, priority: 40) { |options, line|
58
- found = Mvn2::Plugins.get_var :found
59
- if options[:hide_between] && found && line.start_with?('Tests run:')
60
- str = line << "\n\n"
61
- Mvn2::Plugins.set_vars found: false, info_line_last: false
62
- str
63
- else
64
- nil
65
- end
66
- }
66
+ def self.def_filter3
67
+ register(:line_filter, priority: 30) { |_, line|
68
+ found = Plugins.get_var :found
69
+ if found
70
+ str = line << "\n"
71
+ Plugins.set_vars found: true, info_line_last: line.start_with?(INFO_LINE)
72
+ str
73
+ else
74
+ nil
75
+ end
76
+ }
77
+ end
78
+
79
+ def self.def_filter4
80
+ register(:line_filter, priority: 40) { |options, line|
81
+ found = Plugins.get_var :found
82
+ if options[:hide_between] && found && line.start_with?('Tests run:')
83
+ str = line << "\n\n"
84
+ Plugins.set_vars found: false, info_line_last: false
85
+ str
86
+ else
87
+ nil
88
+ end
89
+ }
90
+ end
91
+
92
+ def self.def_filter5
93
+ register(:line_filter, priority: 50) { |options, line|
94
+ info_line_last = Plugins.get_var :info_line_last
95
+ if options[:show_projects] && line =~ BUILD_REGEX
96
+ str = ''
97
+ str << INFO_LINE << "\n" unless info_line_last
98
+ str << line << "\n"
99
+ str << INFO_LINE << "\n"
100
+ Plugins.set_var :info_line_last, true
101
+ str
102
+ else
103
+ nil
104
+ end
105
+ }
106
+ end
67
107
 
68
- register(:line_filter, priority: 50) { |options, line|
69
- info_line_last = Mvn2::Plugins.get_var :info_line_last
70
- if options[:show_projects] && line =~ BUILD_REGEX
71
- str = ''
72
- str << INFO_LINE << "\n" unless info_line_last
73
- str << line << "\n"
74
- str << INFO_LINE << "\n"
75
- Mvn2::Plugins.set_var :info_line_last, true
76
- str
77
- else
78
- nil
79
- end
80
- }
108
+ def_filters
81
109
  end
@@ -1,7 +1,8 @@
1
- require 'mvn2/plugin'
1
+ require 'everyday-plugins'
2
+ include EverydayPlugins
2
3
  class GrowlPlugin
3
- extend Mvn2::Plugin
4
- extend Mvn2::PluginType
4
+ extend Plugin
5
+ extend PluginType
5
6
 
6
7
  register :option, sym: :no_sticky, names: %w(-n --no-sticky), desc: 'make the growl notification non-sticky'
7
8
 
@@ -1,6 +1,7 @@
1
- require 'mvn2/plugin'
1
+ require 'everyday-plugins'
2
+ include EverydayPlugins
2
3
  class LivePrintPlugin
3
- extend Mvn2::Plugin
4
+ extend Plugin
4
5
 
5
6
  register :option, sym: :display_all, names: %w(-a --display-all), desc: 'display all output'
6
7
 
@@ -14,10 +15,10 @@ class LivePrintPlugin
14
15
  register(:runner, key: :live_print, priority: 1000) { |_, cmd|
15
16
  result = false
16
17
  begin
17
- log_file = Mvn2::Plugins.get(:log_file_enable) ? File.open(Mvn2::Plugins.get(:log_file_name), 'w+') : nil
18
+ log_file = Plugins.get(:log_file_enable) ? File.open(Plugins.get(:log_file_name), 'w+') : nil
18
19
  IO.popen(cmd).each do |l|
19
20
  log_file << l unless log_file.nil?
20
- output = Mvn2::Plugins.get :line_filter, l
21
+ output = Plugins.get :line_filter, l
21
22
  puts "\r\e[2K#{output}" unless output.nil?
22
23
  result = true if l.chomp.start_with?('[INFO] BUILD SUCCESS')
23
24
  end
@@ -1,7 +1,8 @@
1
- require 'mvn2/plugin'
1
+ require 'everyday-plugins'
2
+ include EverydayPlugins
2
3
  class LoggingPlugin
3
- extend Mvn2::Plugin
4
- extend Mvn2::PluginType
4
+ extend Plugin
5
+ extend PluginType
5
6
 
6
7
  register :option, sym: :write_log, names: %w(-l --write-log), desc: 'write all of the output to a log file'
7
8
  register :option_with_param, sym: :log_file, names: ['--log-file'], desc: 'set the log file name', default: 'build.log'
@@ -1,6 +1,7 @@
1
- require 'mvn2/plugin'
1
+ require 'everyday-plugins'
2
+ include EverydayPlugins
2
3
  class SkipTestsPlugin
3
- extend Mvn2::Plugin
4
+ extend Plugin
4
5
 
5
6
  register :option, sym: :skip_tests, names: %w(-s --skip-tests), desc: 'skip tests'
6
7
 
@@ -1,7 +1,8 @@
1
- require 'mvn2/plugin'
1
+ require 'everyday-plugins'
2
+ include EverydayPlugins
2
3
  class TimerPlugin
3
- extend Mvn2::Plugin
4
- extend Mvn2::PluginType
4
+ extend Plugin
5
+ extend PluginType
5
6
 
6
7
  register_variable :time1
7
8
  register_variable :diff
@@ -12,9 +13,9 @@ class TimerPlugin
12
13
  register :option, sym: :colored, names: %w(-c --colored), desc: 'display some colors in the timer/progress message'
13
14
 
14
15
  register(:before_run, order: 2) { |options|
15
- Mvn2::Plugins.set_var :time1, Time.now
16
- Mvn2::Plugins.set_var :thread, options[:timer] ? Thread.new {
17
- start_time = Mvn2::Plugins.get_var :time1
16
+ Plugins.set_var :time1, Time.now
17
+ Plugins.set_var :thread, options[:timer] ? Thread.new {
18
+ start_time = Plugins.get_var :time1
18
19
  while true
19
20
  print "\r#{get_timer_message(start_time, Time.now)}"
20
21
  sleep(0.05)
@@ -24,12 +25,12 @@ class TimerPlugin
24
25
 
25
26
  register(:after_run, order: 1) { |_, _|
26
27
  time2 = Time.now
27
- time1 = Mvn2::Plugins.get_var :time1
28
- Mvn2::Plugins.set_var :diff, time2 - time1
28
+ time1 = Plugins.get_var :time1
29
+ Plugins.set_var :diff, time2 - time1
29
30
  }
30
31
 
31
32
  register(:after_run, order: 3) { |_, _|
32
- thread = Mvn2::Plugins.get_var :thread
33
+ thread = Plugins.get_var :thread
33
34
  unless thread.nil?
34
35
  thread.kill
35
36
  print "\n"
@@ -37,7 +38,7 @@ class TimerPlugin
37
38
  }
38
39
 
39
40
  def self.colorize_if_should(text)
40
- options = Mvn2::Plugins.get_var :options
41
+ options = Plugins.get_var :options
41
42
  options[:colored] ? text.format_all : text.remove_format
42
43
  end
43
44
 
@@ -48,7 +49,7 @@ class TimerPlugin
48
49
  end
49
50
 
50
51
  def self.get_closest(time)
51
- averages = Mvn2::Plugins.get_var :averages
52
+ averages = Plugins.get_var :averages
52
53
  averages.min { |a, b| (a - time).abs <=> (b - time).abs }
53
54
  end
54
55
 
data/lib/mvn2/plugin.rb CHANGED
@@ -1,93 +1,14 @@
1
1
  require 'everyday-cli-utils'
2
2
  include EverydayCliUtils
3
3
  import :maputil
4
+ require 'everyday-plugins'
5
+ include EverydayPlugins
4
6
 
5
7
  module Mvn2
6
- class Plugins
7
- def self.instance
8
- @instance ||= Plugins.new
9
- end
10
-
11
- def initialize
12
- @ext = {}
13
- @types = {}
14
- @vars = {}
15
- end
16
-
17
- def register(type, options = {}, &block)
18
- @ext[type] ||= []
19
- @ext[type] << { options: options, block: block }
20
- end
21
-
22
- def register_type(type, &block)
23
- @types[type] = block
24
- end
25
-
26
- def register_variable(name, value = nil)
27
- @vars[name] = value
28
- end
29
-
30
- def [](type)
31
- @ext[type] || []
32
- end
33
-
34
- def get(type, *args)
35
- @types[type].call(self[type], *args)
36
- end
37
-
38
- def self.get(type, *args)
39
- instance.get(type, *args)
40
- end
41
-
42
- def get_var(name)
43
- @vars[name] || nil
44
- end
45
-
46
- def get_vars(*names)
47
- names.map { |name| get_var(name) }
48
- end
49
-
50
- def set_var(name, value)
51
- @vars[name] = value
52
- end
53
-
54
- def set_vars(vars = {})
55
- vars.each { |v| set_var(*v) }
56
- end
57
8
 
58
- def self.get_var(name)
59
- instance.get_var(name)
60
- end
61
-
62
- def self.get_vars(*names)
63
- instance.get_vars(*names)
64
- end
65
-
66
- def self.set_var(name, value)
67
- instance.set_var(name, value)
68
- end
69
-
70
- def self.set_vars(vars = {})
71
- instance.set_vars(vars)
72
- end
73
- end
74
- module Plugin
75
- def register(type, options = {}, &block)
76
- Mvn2::Plugins.instance.register(type, options, &block)
77
- end
78
- end
79
- module PluginType
80
- def register_type(type, &block)
81
- Mvn2::Plugins.instance.register_type(type, &block)
82
- end
83
-
84
- def register_variable(name, value = nil)
85
- Mvn2::Plugins.instance.register_variable(name, value)
86
- end
87
- end
88
9
  module TypeHelper
89
10
  def basic_type(list, *args)
90
- options = Mvn2::Plugins.get_var :options
11
+ options = Plugins.get_var :options
91
12
  list.any? { |item|
92
13
  if item[:block].nil?
93
14
  flag_boolean(item, options)
@@ -117,25 +38,24 @@ module Mvn2
117
38
  end
118
39
 
119
40
  def simple_type(list, *args)
120
- options = Mvn2::Plugins.get_var :options
41
+ options = Plugins.get_var :options
121
42
  list.sort_by { |v| v[:options][:order] }.each { |item| item[:block].call(options, *args) }
122
43
  end
123
44
 
124
45
  def simple_type_with_result(list)
125
- result = Mvn2::Plugins.get_var :result
46
+ result = Plugins.get_var :result
126
47
  simple_type(list, result)
127
48
  end
128
- end
129
- class DefaultTypes
130
- extend Mvn2::PluginType
131
- extend Mvn2::TypeHelper
132
49
 
133
- register_variable :options
134
- register_variable :result
135
- register_variable :runner
136
- register_variable :cmd
137
- register_variable :cmd_clean
138
- register_variable :message_text
50
+ def get_name(list)
51
+ options = Plugins.get_var :options
52
+ rval = complex_filter(list.sort_by { |v| -v[:options][:priority] }, options, :name)
53
+ (rval.nil? || rval.empty?) ? false : rval.first
54
+ end
55
+ end
56
+ class OptionTypes
57
+ extend PluginType
58
+ extend TypeHelper
139
59
 
140
60
  def self.register_option(list, options)
141
61
  list.sort_by { |v| v[:options][:sym].to_s }.each { |option|
@@ -153,19 +73,10 @@ module Mvn2
153
73
  end
154
74
 
155
75
  def_options
156
-
157
- register_type(:command_flag) { |list|
158
- options = Mvn2::Plugins.get_var :options
159
- flags = []
160
- list.each { |flag|
161
- if flag[:block].nil?
162
- flags << " #{flag[:options][:flag]}" if flag_boolean(flag, options)
163
- else
164
- flag[:block].call(options, flags)
165
- end
166
- }
167
- flags.join
168
- }
76
+ end
77
+ class ActionTypes
78
+ extend PluginType
79
+ extend TypeHelper
169
80
 
170
81
  def self.def_actions
171
82
  register_type(:before_run) { |list| simple_type(list) }
@@ -173,74 +84,119 @@ module Mvn2
173
84
  register_type(:before_start) { |list| simple_type(list) }
174
85
  register_type(:after_end) { |list| simple_type_with_result(list) }
175
86
  register_type(:notification) { |list|
176
- options, result, cmd_clean, message_text = Mvn2::Plugins.get_vars :options, :result, :cmd_clean, :message_text
87
+ options, result, cmd_clean, message_text = Plugins.get_vars :options, :result, :cmd_clean, :message_text
177
88
  list.sort_by { |v| v[:options][:order] }.each { |item| item[:block].call(options, result, cmd_clean, message_text) }
178
89
  }
179
90
  end
180
91
 
181
92
  def_actions
182
-
183
- def self.get_name(list)
184
- options = Mvn2::Plugins.get_var :options
185
- rval = complex_filter(list.sort_by { |v| -v[:options][:priority] }, options, :name)
186
- (rval.nil? || rval.empty?) ? false : rval.first
187
- end
93
+ end
94
+ class LogTypes
95
+ extend PluginType
96
+ extend TypeHelper
188
97
 
189
98
  def self.def_logs
190
99
  register_type(:log_file_name) { |list| get_name(list) }
191
100
  register_type(:log_file_disable) { |list| basic_type(list) }
192
- register_type(:log_file_enable) { |list| (Mvn2::Plugins.get(:log_file_name).nil? || Mvn2::Plugins.get(:log_file_disable)) ? false : basic_type(list) }
101
+ register_type(:log_file_enable) { |list| (Plugins.get(:log_file_name).nil? || Plugins.get(:log_file_disable)) ? false : basic_type(list) }
193
102
  end
194
103
 
195
104
  def_logs
105
+ end
106
+ class FilterTypes
107
+ extend PluginType
108
+ extend TypeHelper
109
+
110
+ def self.def_filter
111
+ register_type(:line_filter) { |list, line|
112
+ options = Plugins.get_var :options
113
+ line = line.chomp
114
+ result = nil
115
+ begin
116
+ list.sort_by { |v| -v[:options][:priority] }.each { |item|
117
+ tmp = item[:block].call(options, line)
118
+ unless tmp.nil?
119
+ result = tmp || nil
120
+ break
121
+ end
122
+ }
123
+ rescue
124
+ result = line
125
+ end
126
+ result
127
+ }
128
+ end
129
+
130
+ def_filter
131
+ end
132
+ class RunnerTypes
133
+ extend PluginType
134
+ extend TypeHelper
196
135
 
197
- register_type(:line_filter) { |list, line|
198
- options = Mvn2::Plugins.get_var :options
199
- line = line.chomp
200
- result = nil
201
- begin
136
+ def self.def_runner
137
+ register_type(:runner_enable) { |list, key| basic_type(list.select { |v| v[:options][:key] == key }) }
138
+
139
+ register_type(:runner) { |list|
140
+ options, cmd = Plugins.get_vars :options, :cmd
141
+ Plugins.set_var :result, false
202
142
  list.sort_by { |v| -v[:options][:priority] }.each { |item|
203
- tmp = item[:block].call(options, line)
204
- unless tmp.nil?
205
- result = tmp || nil
143
+ if Plugins.get(:runner_enable, item[:options][:key])
144
+ Plugins.set_var :runner, item[:options][:key]
145
+ Plugins.set_var :result, item[:block].call(options, cmd)
206
146
  break
207
147
  end
208
148
  }
209
- rescue
210
- result = line
211
- end
212
- result
213
- }
149
+ Plugins.get_var :result
150
+ }
151
+ end
214
152
 
215
- register_type(:runner_enable) { |list, key| basic_type(list.select { |v| v[:options][:key] == key }) }
153
+ def_runner
154
+ end
155
+ class CommandTypes
156
+ extend PluginType
157
+ extend TypeHelper
158
+
159
+ def self.def_command
160
+ def_command_flag
161
+ def_command_goal
162
+ register_type(:operation_name) { |list| get_name(list) || 'Operation' }
163
+ end
164
+
165
+ def self.def_command_flag
166
+ register_type(:command_flag) { |list|
167
+ options = Plugins.get_var :options
168
+ flags = []
169
+ list.each { |flag|
170
+ if flag[:block].nil?
171
+ flags << " #{flag[:options][:flag]}" if flag_boolean(flag, options)
172
+ else
173
+ flag[:block].call(options, flags)
174
+ end
175
+ }
176
+ flags.join
177
+ }
178
+ end
216
179
 
217
- register_type(:runner) { |list|
218
- options, cmd = Mvn2::Plugins.get_vars :options, :cmd
219
- Mvn2::Plugins.set_var :result, false
220
- list.sort_by { |v| -v[:options][:priority] }.each { |item|
221
- if Mvn2::Plugins.get(:runner_enable, item[:options][:key])
222
- Mvn2::Plugins.set_var :runner, item[:options][:key]
223
- Mvn2::Plugins.set_var :result, item[:block].call(options, cmd)
224
- break
180
+ def self.def_command_goal
181
+ register_type(:goal_override) { |list|
182
+ options = Plugins.get_var :options
183
+ full_overrides = complex_filter(list.select { |v| v[:options][:override_all] }.sort_by { |v| -v[:options][:priority] }, options, :goal)
184
+ if full_overrides.nil? || full_overrides.empty?
185
+ goals = complex_filter(list.select { |v| !v[:options][:override_all] }.sort_by { |v| v[:options][:order] }, options, :goal)
186
+ goals = ['install'] if (goals - ['clean']).empty?
187
+ goals = ['clean'] + goals unless goals.include?('clean')
188
+ goals.join(' ')
189
+ else
190
+ full_overrides.first
225
191
  end
226
192
  }
227
- Mvn2::Plugins.get_var :result
228
- }
229
-
230
- register_type(:goal_override) { |list|
231
- options = Mvn2::Plugins.get_var :options
232
- full_overrides = complex_filter(list.select { |v| v[:options][:override_all] }.sort_by { |v| -v[:options][:priority] }, options, :goal)
233
- if full_overrides.nil? || full_overrides.empty?
234
- goals = complex_filter(list.select { |v| !v[:options][:override_all] }.sort_by { |v| v[:options][:order] }, options, :goal)
235
- goals = ['install'] if (goals - ['clean']).empty?
236
- goals = ['clean'] + goals unless goals.include?('clean')
237
- goals.join(' ')
238
- else
239
- full_overrides.first
240
- end
241
- }
193
+ end
242
194
 
243
- register_type(:operation_name) { |list| get_name(list) || 'Operation' }
195
+ def_command
196
+ end
197
+ class ColorTypes
198
+ extend PluginType
199
+ extend TypeHelper
244
200
 
245
201
  DEFAULT_COLOR_OPTS = {
246
202
  time: {
@@ -257,17 +213,36 @@ module Mvn2
257
213
  },
258
214
  }
259
215
 
260
- register_type(:color_override) { |list|
261
- options = Mvn2::Plugins.get_var :options
262
- opts = DEFAULT_COLOR_OPTS
263
- list.sort_by { |v| -v[:options][:priority] }.each { |item|
264
- rval = item[:block].call(options)
265
- unless rval.nil? || !rval
266
- opts = rval
267
- break
268
- end
216
+ def self.def_color
217
+ register_type(:color_override) { |list|
218
+ options = Plugins.get_var :options
219
+ opts = DEFAULT_COLOR_OPTS
220
+ list.sort_by { |v| -v[:options][:priority] }.each { |item|
221
+ rval = item[:block].call(options)
222
+ unless rval.nil? || !rval
223
+ opts = rval
224
+ break
225
+ end
226
+ }
227
+ opts.each { |opt| Format.color_profile opt[0], fgcolor: opt[1][:fg], bgcolor: opt[1][:bg] }
269
228
  }
270
- opts.each { |opt| Format.color_profile opt[0], fgcolor: opt[1][:fg], bgcolor: opt[1][:bg] }
271
- }
229
+ end
230
+
231
+ def_color
232
+ end
233
+ class DefaultTypes
234
+ extend PluginType
235
+ extend TypeHelper
236
+
237
+ def self.def_vars
238
+ register_variable :options
239
+ register_variable :result
240
+ register_variable :runner
241
+ register_variable :cmd
242
+ register_variable :cmd_clean
243
+ register_variable :message_text
244
+ end
245
+
246
+ def_vars
272
247
  end
273
248
  end
data/lib/mvn2/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Mvn2
2
- VERSION = '2.1.0'
2
+ VERSION = '2.2.0'
3
3
  end
data/mvn2.gemspec CHANGED
@@ -23,4 +23,5 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency 'rake', '~> 10.0'
24
24
 
25
25
  spec.add_dependency 'everyday-cli-utils', '>= 1.3.0'
26
+ spec.add_dependency 'everyday-plugins', '>= 1.0.0'
26
27
  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.1.0
4
+ version: 2.2.0
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-02 00:00:00.000000000 Z
11
+ date: 2014-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: 1.3.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: everyday-plugins
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 1.0.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 1.0.0
55
69
  description: a Ruby script that runs a maven build, including (or not including) tests,
56
70
  and only outputs the lines that come after a compile failure, build success, test
57
71
  result, or reactor summary start line