abt-cli 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 48f55dc71fb2babaa1b1b6ce4aa99dfdc3eea8a31f0cdc8bd43eecd94cd220f0
4
- data.tar.gz: 94ece036845a7375e434bde005f388bf7e8e9a7f0f1b89c6b19ecfa7bbb8bb7a
3
+ metadata.gz: cd99c9123cfbd4222176495fd039015ad56ddaf0841350347169fa6809f8d6b2
4
+ data.tar.gz: 33d0adf3e73be8f5b2a6f52d61cea46285e0e2ab036b2d1b0e1b4fe1f2c0a27a
5
5
  SHA512:
6
- metadata.gz: 56ab38ab3607b95f420cb8178250d6bb83f338a92695011d753b9218a462292f2a0c95cb06d32a7b316142ace8def6a20be441df0e01f1dbb214384af239cf99
7
- data.tar.gz: 96927e87f95be0cb844dbabbceb855ee26f5d77ef0f44e3728166f3e9e84123a71d4a71f5eb38f9c8ebb099be7ba3eda46dd7ed8fd1e5e41ddf5bcc0f71c2061
6
+ metadata.gz: 2ea6b3ea3f1f2056b9e7911144542f0d2f3b568544fcd68901299fb64c84414290d7cecfc884405bde0125b096bc7033b99d3c2eb87e0598f434de79cfa76ae3
7
+ data.tar.gz: 3c8ffb1c3ba6553d16611c0f55a1c1bae3cf97d156fc79242f66b2d0b2ac622b08ab4ef049b98299553c708dc36365fc4e6158e31b556d830d863019134f34eb
@@ -39,14 +39,14 @@ module Abt
39
39
 
40
40
  cli.warn 'Showing the 10 first matches' if matches.size > 10
41
41
  choice = cli.prompt_choice 'Select a project', matches[0...10], true
42
- break choice unless choice.nil?
42
+ break choice['project'] unless choice.nil?
43
43
  end
44
44
  end
45
45
 
46
46
  def matches_for_string(string)
47
47
  search_string = sanitize_string(string)
48
48
 
49
- projects.select do |project|
49
+ searchable_projects.select do |project|
50
50
  sanitize_string(project['name']).include?(search_string)
51
51
  end
52
52
  end
@@ -55,6 +55,15 @@ module Abt
55
55
  string.downcase.gsub(/[^\w]/, '')
56
56
  end
57
57
 
58
+ def searchable_projects
59
+ @searchable_projects ||= projects.map do |project|
60
+ {
61
+ 'name' => "#{project['client']['name']} > #{project['name']}",
62
+ 'project' => project
63
+ }
64
+ end
65
+ end
66
+
58
67
  def projects
59
68
  @projects ||= begin
60
69
  cli.warn 'Fetching projects...'
@@ -42,13 +42,21 @@ module Abt
42
42
  end
43
43
 
44
44
  def create_time_entry
45
- body = Oj.dump({
45
+ body = {
46
46
  project_id: project_id,
47
47
  task_id: task_id,
48
48
  user_id: config.user_id,
49
49
  spent_date: Date.today.iso8601
50
- }.merge(external_link_data), mode: :json)
51
- api.post('time_entries', body)
50
+ }
51
+
52
+ if external_link_data
53
+ body.merge! external_link_data
54
+ else
55
+ cli.warn 'No external link provided'
56
+ body[:notes] ||= cli.prompt('Fill in comment (optional)')
57
+ end
58
+
59
+ api.post('time_entries', Oj.dump(body, mode: :json))
52
60
  end
53
61
 
54
62
  def project
@@ -76,7 +84,7 @@ module Abt
76
84
  arg_strs = cli.args.join(' ')
77
85
  lines = `#{$PROGRAM_NAME} harvest-time-entry-data #{arg_strs}`.split("\n")
78
86
 
79
- return {} if lines.empty?
87
+ return if lines.empty?
80
88
 
81
89
  # TODO: Make user choose which reference to use by printing the urls
82
90
  if lines.length > 1
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Abt
4
- VERSION = '0.0.6'
4
+ VERSION = '0.0.7'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: abt-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jesper Sørensen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-18 00:00:00.000000000 Z
11
+ date: 2021-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-inflector