time_log_robot 0.3.0 → 0.4.0

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: 8d5097db263a7073c5b5c858536dabfe61ced24e
4
- data.tar.gz: 381891c32f3499ecbcb611395db2294f1018b923
3
+ metadata.gz: 988c8965a9c707284a9309e134f39ba5c03de1bd
4
+ data.tar.gz: 21dac20a7c85acd1465c4bf709555960d4945c2b
5
5
  SHA512:
6
- metadata.gz: 03c8d6335b209654b4b4f37c18b894cce613639d40e4167e5a8aefb79f02f6f40f64a0a6ba8eaf1c468a8cf1087ffdd1f162fd597b6a4e04af09f2693bfd2fbd
7
- data.tar.gz: 791e6755bfd9a6a6768eba806a709c94713f1d273d8215dbb4d37f6d7d19c15eac1e3420e9280e10661de07d9013a103f6d9fae7e53ac5b8f5f0e9fca1e2f907
6
+ metadata.gz: 21ece193667a30cdb9cd147465b3a670c11015abca96f10ef637bfe7ad520f6b3c4f431dae25a4dbe8306020493aa8f7f9db9e1ff424f83591c52ca0ba8c8df9
7
+ data.tar.gz: 3c9b4f00aae5677a921b2d5e9651e7c7f5ee015ebde65853b1f30c1652ed7bc427c33f7d54786faae790fcca88926c1d989e38fa740a0dc69bb46c47f0fe379d
@@ -0,0 +1,58 @@
1
+ Contributing
2
+ ============
3
+
4
+ We love pull requests from everyone. By participating in this project, you agree
5
+ to abide by the [contributor covenant].
6
+
7
+ [contributor covenant v1.4]: http://contributor-covenant.org/version/1/4/
8
+
9
+ Here's a quick guide for contributing:
10
+
11
+ 1. Fork the repo.
12
+
13
+ 1. Run the tests. We only take pull requests with passing tests, and it's great
14
+ to know that you have a clean slate: `bundle && bundle exec rake`
15
+
16
+ 1. Add a test for your change. Only refactoring and documentation changes
17
+ require no new tests. If you are adding functionality or fixing a bug, we need
18
+ a test!
19
+
20
+ 1. Make the test pass.
21
+
22
+ 1. Push to your fork and submit a pull request.
23
+
24
+ At this point you're waiting on us. We like to at least comment on, if not
25
+ accept, pull requests within seven business days. We may suggest some changes or improvements or
26
+ alternatives.
27
+
28
+ Some things that will increase the chance that your pull request is accepted,
29
+ taken straight from the Ruby on Rails guide:
30
+
31
+ * Use Rails idioms and helpers
32
+ * Include tests that fail without your code, and pass with it
33
+ * Update the documentation, the surrounding one, examples elsewhere, guides,
34
+ whatever is affected by your contribution
35
+
36
+ Running Tests
37
+ -------------
38
+
39
+ time_log_robot uses [minitest](https://github.com/seattlerb/minitest) for its unit tests. If you submit
40
+ tests that are not written for minitest without a very good reason, you
41
+ will be asked to rewrite them before we'll accept.
42
+
43
+ ### To run a full test suite:
44
+
45
+ bundle exec rake
46
+
47
+ This will run RSpec and Cucumber against all version of Rails
48
+
49
+ ### To run single test file
50
+
51
+ bundle exec rake test TEST=test/test_foobar.rb
52
+
53
+ Syntax
54
+ ------
55
+
56
+ Please follow the [Ruby style guide](https://github.com/bbatsov/ruby-style-guide).
57
+ Rubocop will be used on Pull Requests. If you submit code that deviates from this style,
58
+ you will be asked to justify it, and may be asked to change it.
@@ -1,19 +1,12 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- time_log_robot (0.3.0)
5
- activesupport (~> 4.2, >= 4.2.6)
4
+ time_log_robot (0.4.0)
6
5
  httparty (~> 0.13, >= 0.13.0)
7
6
 
8
7
  GEM
9
8
  remote: https://rubygems.org/
10
9
  specs:
11
- activesupport (4.2.7.1)
12
- i18n (~> 0.7)
13
- json (~> 1.7, >= 1.7.7)
14
- minitest (~> 5.1)
15
- thread_safe (~> 0.3, >= 0.3.4)
16
- tzinfo (~> 1.1)
17
10
  ansi (1.5.0)
18
11
  builder (3.2.2)
19
12
  codeclimate-test-reporter (0.6.0)
@@ -22,7 +15,6 @@ GEM
22
15
  docile (1.1.5)
23
16
  httparty (0.14.0)
24
17
  multi_xml (>= 0.5.2)
25
- i18n (0.7.0)
26
18
  json (1.8.1)
27
19
  method_source (0.8.2)
28
20
  minitest (5.9.0)
@@ -44,9 +36,6 @@ GEM
44
36
  simplecov-html (~> 0.10.0)
45
37
  simplecov-html (0.10.0)
46
38
  slop (3.6.0)
47
- thread_safe (0.3.5)
48
- tzinfo (1.2.2)
49
- thread_safe (~> 0.1)
50
39
 
51
40
  PLATFORMS
52
41
  ruby
data/Rakefile CHANGED
@@ -7,7 +7,6 @@ task :console do
7
7
  require 'irb/completion'
8
8
  require 'pp'
9
9
  require 'yaml'
10
- require 'active_support'
11
10
  require 'httparty'
12
11
  Dir[File.expand_path "lib/**/*.rb"].each{|file| require_relative file }
13
12
  ARGV.clear
@@ -19,4 +18,4 @@ Rake::TestTask.new do |t|
19
18
  t.test_files = FileList['test/**/*_test.rb']
20
19
  end
21
20
 
22
- task default: :test
21
+ task default: :test
@@ -13,7 +13,7 @@ module TimeLogRobot
13
13
 
14
14
  def comment
15
15
  matches = raw_entry['description'].match(/(\{(?<comment>[^\}]*)\})/)
16
- return matches['comment'] if matches.present?
16
+ return matches['comment'] unless matches.nil? || !matches.strip.empty?
17
17
  description
18
18
  end
19
19
 
@@ -1,5 +1,3 @@
1
- require 'active_support/core_ext/date/calculations'
2
-
3
1
  module TimeLogRobot
4
2
  module Toggl
5
3
  class Report
@@ -10,7 +8,7 @@ module TimeLogRobot
10
8
  # TODO Refactor to avoid having to pass around `since` so much
11
9
  class << self
12
10
  def fetch(since: nil)
13
- since ||= Date.today.beginning_of_week(:saturday).to_time
11
+ since = since_or_default(since)
14
12
  response = get('/details', basic_auth: auth, query: query(since))
15
13
  if response.success?
16
14
  pages = number_of_pages(response['total_count'])
@@ -21,8 +19,28 @@ module TimeLogRobot
21
19
  end
22
20
  class FetchError < Exception; end
23
21
 
22
+ def since_or_default(since)
23
+ since || default_since
24
+ end
25
+
24
26
  private
25
27
 
28
+ def default_since
29
+ # DAYNAMES structure:
30
+ # ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
31
+ # Therefore saturday index is 6, calculate it anyways incase it changes
32
+ saturday_index = Date::DAYNAMES.index("Saturday")
33
+ today_index = Date.today.wday
34
+
35
+ # Return today if it is Saturday (this is what the previous
36
+ # implementation would do)
37
+ return Date.today.to_time if today_index == saturday_index
38
+
39
+ # Otherwise, subtract the index + 1 (to account
40
+ # for indecies starting at 0)
41
+ (Date.today - (today_index + 1)).to_time
42
+ end
43
+
26
44
  def aggregate_entries(entries, pages, since)
27
45
  2.upto(pages) do |page|
28
46
  entries += get_entries_from_next_page(since, page)
@@ -1,3 +1,3 @@
1
1
  module TimeLogRobot
2
- VERSION = '0.3.0'
2
+ VERSION = '0.4.0'
3
3
  end
@@ -5,7 +5,6 @@ require 'minitest/autorun'
5
5
  require 'minitest/pride'
6
6
  require 'minitest/reporters'
7
7
  require 'yaml'
8
- require 'active_support'
9
8
  require 'httparty'
10
9
 
11
10
  Dir[File.expand_path "lib/**/*.rb"].each{|file| require_relative file }
@@ -0,0 +1,23 @@
1
+ require_relative '../../test_helper'
2
+
3
+ module TimeLogRobot
4
+ module Toggl
5
+ class ReportTest < Minitest::Test
6
+ def setup
7
+ @described_class = TimeLogRobot::Toggl::Report
8
+ end
9
+
10
+ def test_since_or_default_with_since
11
+ since = DateTime.now - 10
12
+ assert_equal(@described_class.since_or_default(since), since)
13
+ end
14
+
15
+ def test_since_or_default_without_since
16
+ Date.stub(:today, Date.new(2016,10,18)) do
17
+ expected_since = Date.new(2016,10,15).to_time
18
+ assert_equal(@described_class.since_or_default(nil), expected_since)
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -26,6 +26,5 @@ Gem::Specification.new do |spec|
26
26
  spec.add_development_dependency 'minitest-reporters', '~> 1.1'
27
27
  spec.add_development_dependency 'codeclimate-test-reporter', '~> 0.5'
28
28
 
29
- spec.add_runtime_dependency 'activesupport', '~> 4.2', '>= 4.2.6'
30
- spec.add_runtime_dependency 'httparty', '~> 0.13', '>= 0.13.0'
29
+ spec.add_runtime_dependency 'httparty', '~> 0.13', '>= 0.13.0'
31
30
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: time_log_robot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark J. Lehman
@@ -94,26 +94,6 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0.5'
97
- - !ruby/object:Gem::Dependency
98
- name: activesupport
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: '4.2'
104
- - - ">="
105
- - !ruby/object:Gem::Version
106
- version: 4.2.6
107
- type: :runtime
108
- prerelease: false
109
- version_requirements: !ruby/object:Gem::Requirement
110
- requirements:
111
- - - "~>"
112
- - !ruby/object:Gem::Version
113
- version: '4.2'
114
- - - ">="
115
- - !ruby/object:Gem::Version
116
- version: 4.2.6
117
97
  - !ruby/object:Gem::Dependency
118
98
  name: httparty
119
99
  requirement: !ruby/object:Gem::Requirement
@@ -146,6 +126,7 @@ files:
146
126
  - ".codeclimate.yml"
147
127
  - ".gitignore"
148
128
  - ".rubocop.yml"
129
+ - CONTRIBUTING.md
149
130
  - Gemfile
150
131
  - Gemfile.lock
151
132
  - LICENSE.txt
@@ -165,6 +146,7 @@ files:
165
146
  - lib/time_log_robot/version.rb
166
147
  - test/test_helper.rb
167
148
  - test/time_log_robot/jira/issue_key_parser_test.rb
149
+ - test/time_log_robot/toggl/report_test.rb
168
150
  - time_log_robot.gemspec
169
151
  homepage: https://github.com/supremebeing7/time_log_robot
170
152
  licenses:
@@ -193,3 +175,4 @@ summary: Automate work time logging
193
175
  test_files:
194
176
  - test/test_helper.rb
195
177
  - test/time_log_robot/jira/issue_key_parser_test.rb
178
+ - test/time_log_robot/toggl/report_test.rb