Class: Deka::Cli

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Cli

Returns a new instance of Cli.



12
13
14
15
16
17
# File 'lib/deka/cli.rb', line 12

def initialize(options = {})
  @config = options[:config] || './deka.yml'
  @save_file = options[:save] || './.tracked_hash'
  @base_hash = File.read(save_file).chomp
  @dry_run = options[:'dry-run']
end

Instance Attribute Details

#base_hashObject

Returns the value of attribute base_hash.



6
7
8
# File 'lib/deka/cli.rb', line 6

def base_hash
  @base_hash
end

#configObject

Returns the value of attribute config.



6
7
8
# File 'lib/deka/cli.rb', line 6

def config
  @config
end

#save_fileObject

Returns the value of attribute save_file.



6
7
8
# File 'lib/deka/cli.rb', line 6

def save_file
  @save_file
end

#yaml=(value) ⇒ Object

Sets the attribute yaml

Parameters:

  • value

    the value to set the attribute yaml to.



6
7
8
# File 'lib/deka/cli.rb', line 6

def yaml=(value)
  @yaml = value
end

Class Method Details

.run(options = {}) ⇒ Object



8
9
10
# File 'lib/deka/cli.rb', line 8

def self.run(options = {})
  new(options).run
end

Instance Method Details

#clientObject



34
35
36
# File 'lib/deka/cli.rb', line 34

def client
  @client ||= Octokit::Client.new(access_token: access_token)
end

#runObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/deka/cli.rb', line 19

def run
  log = fetch_log

  all_hashes = log.each_line.map { |line| line.strip[0..39] }
  issue_hashes = all_hashes.take_while { |hash| hash != base_hash }.reverse

  issue_hashes.each do |issue_hash|
    create_issue(issuing_repo, issue_hash)
  end

  update_lastest_hash(issue_hashes.last)
ensure
  delete_temp_repo
end