Module: Metrical::Options
- Defined in:
- lib/metrical/options.rb
Class Method Summary collapse
- .defaults ⇒ Object
- .metrics ⇒ Object
- .parse(argv) ⇒ Object
- .ruby ⇒ Object
- .version(version) ⇒ Object
Class Method Details
.defaults ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/metrical/options.rb', line 6 def self.defaults defaults = { :open => true, :metrics => Hash.new(true) } defaults[:metrics][:saikuro] = version(ruby) < version("1.9") defaults[:metrics][:rcov] = version(ruby) < version("1.9") defaults end |
.metrics ⇒ Object
25 26 27 |
# File 'lib/metrical/options.rb', line 25 def self.metrics MetricFu.configuration.metrics.sort_by(&:to_s) end |
.parse(argv) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/metrical/options.rb', line 29 def self.parse(argv) = defaults.dup opts = OptionParser.new do |opts| opts.version = Metrical::VERSION metrics.each do |metric| opts.on "--[no-]#{metric}", "Enables or disables #{metric.to_s.titleize} (default: #{[:metrics][metric]})" do |option| [:metrics][metric] = option end end opts.on "--[no-]open", "Open report in browser" do |open| [:open] = open end end begin opts.parse!(argv) rescue OptionParser::InvalidOption => error puts error. puts opts exit 1 end end |
.ruby ⇒ Object
21 22 23 |
# File 'lib/metrical/options.rb', line 21 def self.ruby RUBY_VERSION.dup end |
.version(version) ⇒ Object
17 18 19 |
# File 'lib/metrical/options.rb', line 17 def self.version(version) Gem::Version.new(version) end |