Class: Hotspots::Main

Inherits:
Object
  • Object
show all
Defined in:
lib/hotspots.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = nil) ⇒ Main

TODO : change this signature - this method should get resolved options as parameters initialize is not responsible for invoking option parsing



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/hotspots.rb', line 15

def initialize(opts = nil)
  options          = opts.nil? ? Hotspots::OptionsParser.new.parse(*ARGV) : Hotspots::OptionsParser.default_options.merge(opts)

  @logger          = Hotspots::Logger.new
  @repository      = options[:repository]
  @verbose         = options[:verbose]
  @exit_strategy   = options[:exit_strategy]

  @time            = options[:time]
  @message_filters = options[:message_filters]
  @file_filter     = options[:file_filter]
  @cutoff          = options[:cutoff]
end

Instance Attribute Details

#cutoffObject (readonly)

Returns the value of attribute cutoff.



9
10
11
# File 'lib/hotspots.rb', line 9

def cutoff
  @cutoff
end

#driverObject (readonly)

Returns the value of attribute driver.



9
10
11
# File 'lib/hotspots.rb', line 9

def driver
  @driver
end

#exit_strategyObject (readonly)

Returns the value of attribute exit_strategy.



9
10
11
# File 'lib/hotspots.rb', line 9

def exit_strategy
  @exit_strategy
end

#file_filterObject (readonly)

Returns the value of attribute file_filter.



9
10
11
# File 'lib/hotspots.rb', line 9

def file_filter
  @file_filter
end

#loggerObject (readonly)

Returns the value of attribute logger.



9
10
11
# File 'lib/hotspots.rb', line 9

def logger
  @logger
end

#message_filtersObject (readonly)

Returns the value of attribute message_filters.



9
10
11
# File 'lib/hotspots.rb', line 9

def message_filters
  @message_filters
end

#parserObject (readonly)

Returns the value of attribute parser.



9
10
11
# File 'lib/hotspots.rb', line 9

def parser
  @parser
end

#repositoryObject (readonly)

Returns the value of attribute repository.



9
10
11
# File 'lib/hotspots.rb', line 9

def repository
  @repository
end

#storeObject (readonly)

Returns the value of attribute store.



9
10
11
# File 'lib/hotspots.rb', line 9

def store
  @store
end

#timeObject (readonly)

Returns the value of attribute time.



9
10
11
# File 'lib/hotspots.rb', line 9

def time
  @time
end

#verboseObject (readonly)

Returns the value of attribute verbose.



9
10
11
# File 'lib/hotspots.rb', line 9

def verbose
  @verbose
end

Instance Method Details

#outputObject Also known as: execute!



29
30
31
32
33
# File 'lib/hotspots.rb', line 29

def output
  validate
  set
  run
end

#runObject

TODO : this method should be private



49
50
51
# File 'lib/hotspots.rb', line 49

def run #:nodoc:
  puts store.to_s
end

#setObject

TODO : this method should be private



42
43
44
45
46
# File 'lib/hotspots.rb', line 42

def set #:nodoc:
  set_logger_if_verbose
  set_path
  assign
end

#validateObject Also known as: validate!

TODO : this method should be private



36
37
38
39
# File 'lib/hotspots.rb', line 36

def validate #:nodoc:
  exit_if_options_are_for_help
  exit_if_not_git_repository
end