dude-cli 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f02315720e15482265874ba01bfc392dd99629d1
4
- data.tar.gz: a95af1edff51e7d4b463768200503df64e9dbc17
3
+ metadata.gz: a3aa88a007d7a042aeb2c3da6c8e28f129c65da9
4
+ data.tar.gz: b19823bddc4e323dad4ad0a2eeac462bd1cbb7fe
5
5
  SHA512:
6
- metadata.gz: 843a5ae8a1329cf13dae40fb8fe8db799ed8d70f4e30a215f9c0490fdb9c9e52054b170b49946baeb1961df7d174156735d4c0a083cb21df8591f53414842d84
7
- data.tar.gz: 61f0ef2295c0f751576edf8ff9a3eb4e4a9f430ff6577203c3326f165f779ec596a1814ea29b71bb11e99be1ada5002b41ba3bda4eb3cf16dde91b13d14fe80c
6
+ metadata.gz: cdc5afd6f5cf7bbd23fe53891344d66a693c48c930a9317bc32b06ce2882e74648cdddd20b26caeadead5309b046b0b78b255e3d1c386e90c77fd0d2a7ce9316
7
+ data.tar.gz: 458f666059881e8974a7b41ce7e93a9f18f2940e91dea0fdbe265757f5432ea87406ac9759dd09f65bbb5867b400782e70e50d7d949c95447567808d95a703a6
data/.gitignore CHANGED
@@ -6,6 +6,7 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ .byebug_history
9
10
 
10
11
  # rspec failure tracking
11
12
  .rspec_status
data/Gemfile.lock CHANGED
@@ -1,11 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dude (0.1.0)
4
+ dude-cli (0.2.1)
5
5
  colorize
6
6
  git
7
7
  gitlab
8
- motivator
9
8
  rest-client
10
9
  thor
11
10
 
@@ -28,7 +27,6 @@ GEM
28
27
  mime-types (3.1)
29
28
  mime-types-data (~> 3.2015)
30
29
  mime-types-data (3.2016.0521)
31
- motivator (1.0.4)
32
30
  multi_xml (0.6.0)
33
31
  netrc (0.11.0)
34
32
  rake (10.0.4)
@@ -63,7 +61,7 @@ PLATFORMS
63
61
  DEPENDENCIES
64
62
  bundler (~> 1.16)
65
63
  byebug
66
- dude!
64
+ dude-cli!
67
65
  rake (~> 10.0)
68
66
  rspec (~> 3.0)
69
67
 
data/README.md CHANGED
@@ -9,7 +9,7 @@ TODO: Delete this and the text above, and describe your gem
9
9
  Add this line to your application's Gemfile:
10
10
 
11
11
  ```ruby
12
- gem 'dude'
12
+ gem 'dude-cli'
13
13
  ```
14
14
 
15
15
  And then execute:
@@ -18,7 +18,7 @@ And then execute:
18
18
 
19
19
  Or install it yourself as:
20
20
 
21
- $ gem install dude
21
+ $ gem install dude-cli
22
22
 
23
23
  ## Usage
24
24
 
data/lib/dude/cli.rb CHANGED
@@ -34,7 +34,7 @@ module Dude
34
34
  issue_title = Gitlab.new(
35
35
  issue_id: issue_id, project_title: project_title
36
36
  ).call
37
- Toggl.new(title: "##{issue_id} #{issue_title}").start_time_entry
37
+ Toggl.new(title: "##{issue_id} #{issue_title}", project_title: project_title).start_time_entry
38
38
  puts "Starting Toggl task"
39
39
  end
40
40
 
data/lib/dude/toggl.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'rest-client'
2
+ require 'date'
2
3
  require_relative 'settings'
3
4
 
4
5
  module Dude
@@ -30,7 +31,8 @@ module Dude
30
31
  def report_params
31
32
  {
32
33
  workspace_id: settings['TOGGL_WORKSPACE_ID'],
33
- user_agent: settings['TOGGL_EMAIL']
34
+ user_agent: settings['TOGGL_EMAIL'],
35
+ since: Date.parse('monday').strftime('%Y-%m-%d')
34
36
  }
35
37
  end
36
38
 
@@ -38,15 +40,29 @@ module Dude
38
40
  {
39
41
  time_entry: {
40
42
  description: title,
43
+ pid: project_id,
41
44
  created_with: "dude"
42
45
  }
43
46
  }
44
47
  end
45
48
 
49
+ def project_id
50
+ projects_array.each do |arr|
51
+ return arr.last if arr.first.eql?(options[:project_title])
52
+ end
53
+ nil
54
+ end
55
+
46
56
  def current_time_entry
47
57
  JSON.parse(toggl_api['time_entries/current'].get)['data']
48
58
  end
49
59
 
60
+ def projects_array
61
+ JSON.parse(
62
+ toggl_api["workspaces/#{settings['TOGGL_WORKSPACE_ID']}/projects"].get
63
+ ).map { |a| [a['name'].downcase.gsub(/\s/, '-'), a['id']] }
64
+ end
65
+
50
66
  def toggl_api
51
67
  @toggl_api ||= RestClient::Resource.new(
52
68
  'https://www.toggl.com/api/v8',
@@ -56,7 +72,6 @@ module Dude
56
72
  end
57
73
 
58
74
  def toggl_report
59
- # site['posts/1/comments'].post 'Good article.', :content_type => 'text/plain'
60
75
  @toggl_report ||= RestClient::Resource.new(
61
76
  'https://www.toggl.com/reports/api/v2/weekly',
62
77
  settings['TOGGL_TOKEN'],
data/lib/dude/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Dude
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dude-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nikita Pupko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-25 00:00:00.000000000 Z
11
+ date: 2017-12-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -184,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
184
184
  version: '0'
185
185
  requirements: []
186
186
  rubyforge_project:
187
- rubygems_version: 2.6.13
187
+ rubygems_version: 2.6.14
188
188
  signing_key:
189
189
  specification_version: 4
190
190
  summary: Daily assistant