Class: Bookwatch::Commands::Components::CommandOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/bookwatch/commands/components/command_options.rb

Instance Method Summary collapse

Constructor Details

#initialize(opts, base_streams, verbose = false) ⇒ CommandOptions

Returns a new instance of CommandOptions.



10
11
12
13
14
# File 'lib/bookwatch/commands/components/command_options.rb', line 10

def initialize(opts, base_streams, verbose = false)
  @opts = opts
  @base_streams = base_streams
  @verbosity = verbose
end

Instance Method Details

#bind_sourceObject



16
17
18
# File 'lib/bookwatch/commands/components/command_options.rb', line 16

def bind_source
  opts.first
end

#local_repo_dirObject



20
21
22
# File 'lib/bookwatch/commands/components/command_options.rb', line 20

def local_repo_dir
  File.expand_path('..') if bind_source == 'local'
end

#optionsObject



24
25
26
# File 'lib/bookwatch/commands/components/command_options.rb', line 24

def options
  opts[1..-1]
end

#ref_overrideObject



28
29
30
# File 'lib/bookwatch/commands/components/command_options.rb', line 28

def ref_override
  'master' if options.include?('--ignore-section-refs')
end

#streamsObject



32
33
34
35
36
37
# File 'lib/bookwatch/commands/components/command_options.rb', line 32

def streams
  base_streams.merge(
    out: verbosity ? base_streams[:out] :
      Streams::FilterStream.new(/^(?:\s*error|Invalid CSS|Undefined mixin|\/)/i, Streams::ColorizedStream.new(Colorizer::Colors.red, base_streams[:out])),
  )
end