Class: Scrutinize::Config
- Inherits:
-
Object
- Object
- Scrutinize::Config
- Defined in:
- lib/scrutinize/config.rb
Constant Summary collapse
- KNOWN_VERSIONS =
%w(ruby18 ruby19 ruby20 ruby21 ruby22, ruby23, ruby24)
Instance Method Summary collapse
- #[](key) ⇒ Object
- #files ⇒ Object
-
#initialize(opts = {}) ⇒ Config
constructor
A new instance of Config.
-
#ruby_parser ⇒ Object
Public: A Parser instance for the configured Ruby version.
-
#ruby_version ⇒ Object
Public: The normalized Ruby version, inferred from RUBY_VERSION and the configured version.
-
#ruby_version=(value) ⇒ Object
Public: Set a new Ruby version.
-
#trigger ⇒ Object
Public: A Trigger object based on the configured options.
Constructor Details
#initialize(opts = {}) ⇒ Config
Returns a new instance of Config.
7 8 9 |
# File 'lib/scrutinize/config.rb', line 7 def initialize(opts = {}) @options = opts end |
Instance Method Details
#[](key) ⇒ Object
11 12 13 |
# File 'lib/scrutinize/config.rb', line 11 def [](key) @options[key] end |
#files ⇒ Object
15 16 17 |
# File 'lib/scrutinize/config.rb', line 15 def files Dir.glob(File.join(@options['dir'], "**/*.rb")) end |
#ruby_parser ⇒ Object
Public: A Parser instance for the configured Ruby version.
Returns a Parser.
70 71 72 |
# File 'lib/scrutinize/config.rb', line 70 def ruby_parser @ruby_parser ||= parser_for_version ruby_version end |
#ruby_version ⇒ Object
Public: The normalized Ruby version, inferred from RUBY_VERSION and the configured version.
Returns a String.
48 49 50 51 52 53 |
# File 'lib/scrutinize/config.rb', line 48 def ruby_version @ruby_version ||= begin version = @options['ruby_version'] || RUBY_VERSION normalize_version version end end |
#ruby_version=(value) ⇒ Object
Public: Set a new Ruby version.
value - A String Ruby version.
Returns the normalized value provided.
60 61 62 63 64 65 |
# File 'lib/scrutinize/config.rb', line 60 def ruby_version=(value) normalize_version(value).tap do |version| @ruby_version = @options['ruby_version'] = version @ruby_parser = parser_for_version version end end |
#trigger ⇒ Object
Public: A Trigger object based on the configured options.
Returns a Trigger.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/scrutinize/config.rb', line 22 def trigger @trigger ||= begin trigger = Scrutinize::Trigger.new # Trigger configured at top level keys = %w(methods method targets target) unless (@options.keys & keys).empty? trigger.add @options.select { |k,v| keys.include?(k) } end # Trigger configured under trigger key trigger.add @options['trigger'] if @options['trigger'].is_a?(Hash) # Triggers configured under triggers key if @options['triggers'].is_a? Array @options['triggers'].each { |t| trigger.add t } end trigger end end |