Class: Gitloggl::Toggle::Cli

Inherits:
Object
  • Object
show all
Includes:
Hooks, Hooks::InstanceHooks
Defined in:
lib/gitloggl/toggle/cli.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) {|_self| ... } ⇒ Cli

Returns a new instance of Cli.

Yields:

  • (_self)

Yield Parameters:



11
12
13
14
# File 'lib/gitloggl/toggle/cli.rb', line 11

def initialize(params = {})
  params.each { |k, v| public_send("#{k}=", v) }
  yield(self) if block_given?
end

Instance Attribute Details

#date_fromObject

Returns the value of attribute date_from.



9
10
11
# File 'lib/gitloggl/toggle/cli.rb', line 9

def date_from
  @date_from
end

#date_toObject

Returns the value of attribute date_to.



9
10
11
# File 'lib/gitloggl/toggle/cli.rb', line 9

def date_to
  @date_to
end

#project_idObject

Returns the value of attribute project_id.



9
10
11
# File 'lib/gitloggl/toggle/cli.rb', line 9

def project_id
  @project_id
end

#tokenObject

Returns the value of attribute token.



9
10
11
# File 'lib/gitloggl/toggle/cli.rb', line 9

def token
  @token
end

#verboseObject

Returns the value of attribute verbose.



9
10
11
# File 'lib/gitloggl/toggle/cli.rb', line 9

def verbose
  @verbose
end

#workspace_idObject

Returns the value of attribute workspace_id.



9
10
11
# File 'lib/gitloggl/toggle/cli.rb', line 9

def workspace_id
  @workspace_id
end

Instance Method Details

#runObject



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

def run
  data = request.fetch('data').flat_map { |row| row.fetch('items') }

  data.map! do |row|
    OpenStruct.new(
      title: row.fetch('title').fetch('time_entry'),
      spent_ms: row.fetch('time')
    )
  end

  run_hook(:on_done, data)
end