Module: TodoAnalyser

Defined in:
lib/todo_analyser.rb,
lib/todo_analyser/version.rb

Overview

Versioning

Defined Under Namespace

Classes: Error

Constant Summary collapse

VERSION =
'1.0.1'

Class Method Summary collapse

Class Method Details

.analyse(todos_path, number) ⇒ Object



30
31
32
33
34
35
# File 'lib/todo_analyser.rb', line 30

def self.analyse(todos_path, number)
  # Calls
  reader = TodoReaderJSON.new(todos_path)
  consumer = TodoConsumer.new(reader, number, ConsoleOutput.new)
  consumer.consume
end

.configureObject



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

def self.configure
  # Command-line argument parsing
  options = {}
  OptionParser.new do |opts|
    opts.banner = 'Usage: todo_analyser.rb URL [OPTIONS]'

    opts.on('-n', '--number N', 'Number of TODOs to consume (default: 20)') do |n|
      options[:number] = n.to_i
    end
  end.parse!

  [ARGV[0], options[:number] || 20]
end

.runObject



37
38
39
40
41
42
43
# File 'lib/todo_analyser.rb', line 37

def self.run
  todos_path, number = configure

  raise 'Please specify a file to consume TODOs from.' unless todos_path

  analyse(todos_path, number)
end