togglv8 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,140 @@
1
+ # require "codeclimate-test-reporter"
2
+ # CodeClimate::TestReporter.start
3
+
4
+ require 'coveralls'
5
+ Coveralls.wear!
6
+
7
+ # require 'simplecov'
8
+ # SimpleCov.start do
9
+ # require 'simplecov-badge'
10
+ # add_group 'lib', 'lib/'
11
+ # add_filter '/doc/'
12
+ # add_filter '/spec/'
13
+ # add_filter '/pkg/'
14
+ # # configure any options you want for SimpleCov::Formatter::BadgeFormatter
15
+ # SimpleCov::Formatter::BadgeFormatter.generate_groups = true
16
+ # SimpleCov::Formatter::BadgeFormatter.timestamp = true
17
+ # SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
18
+ # SimpleCov::Formatter::HTMLFormatter,
19
+ # SimpleCov::Formatter::BadgeFormatter,
20
+ # ]
21
+ # end
22
+ # NOTE: SimpleCov.start must be issued before any application code is required!
23
+ # -----------------------------------------------------------------------------
24
+
25
+ require_relative 'togglv8_spec_helper'
26
+ require_relative '../lib/togglv8'
27
+
28
+ # This file was generated by the `rspec --init` command. Conventionally, all
29
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
30
+ # The generated `.rspec` file contains `--require spec_helper` which will cause this
31
+ # file to always be loaded, without a need to explicitly require it in any files.
32
+ #
33
+ # Given that it is always loaded, you are encouraged to keep this file as
34
+ # light-weight as possible. Requiring heavyweight dependencies from this file
35
+ # will add to the boot time of your test suite on EVERY test run, even for an
36
+ # individual file that may not need all of that loaded. Instead, consider making
37
+ # a separate helper file that requires the additional dependencies and performs
38
+ # the additional setup, and require it from the spec files that actually need it.
39
+ #
40
+ # The `.rspec` file also contains a few flags that are not defaults but that
41
+ # users commonly want.
42
+ #
43
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
44
+ RSpec.configure do |config|
45
+ config.filter_run :focus
46
+ config.filter_run_excluding :pro_account unless ENV['TOGGL_PRO_ACCOUNT']
47
+ config.run_all_when_everything_filtered = true
48
+
49
+ config.order = :random
50
+ Kernel.srand config.seed
51
+
52
+ # rspec-expectations config goes here. You can use an alternate
53
+ # assertion/expectation library such as wrong or the stdlib/minitest
54
+ # assertions if you prefer.
55
+ config.expect_with :rspec do |expectations|
56
+ # This option will default to `true` in RSpec 4. It makes the `description`
57
+ # and `failure_message` of custom matchers include text for helper methods
58
+ # defined using `chain`, e.g.:
59
+ # be_bigger_than(2).and_smaller_than(4).description
60
+ # # => "be bigger than 2 and smaller than 4"
61
+ # ...rather than:
62
+ # # => "be bigger than 2"
63
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
64
+ expectations.syntax = :expect
65
+ end
66
+
67
+ # rspec-mocks config goes here. You can use an alternate test double
68
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
69
+ config.mock_with :rspec do |mocks|
70
+ # Prevents you from mocking or stubbing a method that does not exist on
71
+ # a real object. This is generally recommended, and will default to
72
+ # `true` in RSpec 4.
73
+ mocks.verify_partial_doubles = true
74
+ end
75
+
76
+ config.before(:suite) do
77
+ TogglV8SpecHelper.setUp()
78
+ puts "NOTE: Delaying #{Testing::DELAY_SEC} second(s) between specs to avoid failure due to '429 Too Many Requests'"
79
+ end
80
+
81
+ config.before(:each) do
82
+ sleep(Testing::DELAY_SEC)
83
+ end
84
+
85
+ # The settings below are suggested to provide a good initial experience
86
+ # with RSpec, but feel free to customize to your heart's content.
87
+ =begin
88
+ # These two settings work together to allow you to limit a spec run
89
+ # to individual examples or groups you care about by tagging them with
90
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
91
+ # get run.
92
+ config.filter_run :focus
93
+ config.run_all_when_everything_filtered = true
94
+
95
+ # Limits the available syntax to the non-monkey patched syntax that is recommended.
96
+ # For more details, see:
97
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
98
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
99
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
100
+ config.disable_monkey_patching!
101
+
102
+ # This setting enables warnings. It's recommended, but in some cases may
103
+ # be too noisy due to issues in dependencies.
104
+ config.warnings = true
105
+
106
+ # Many RSpec users commonly either run the entire suite or an individual
107
+ # file, and it's useful to allow more verbose output when running an
108
+ # individual spec file.
109
+ if config.files_to_run.one?
110
+ # Use the documentation formatter for detailed output,
111
+ # unless a formatter has already been configured
112
+ # (e.g. via a command-line flag).
113
+ config.default_formatter = 'doc'
114
+ end
115
+
116
+ # Print the 10 slowest examples and example groups at the
117
+ # end of the spec run, to help surface which specs are running
118
+ # particularly slow.
119
+ config.profile_examples = 10
120
+
121
+ # Run specs in random order to surface order dependencies. If you find an
122
+ # order dependency and want to debug it, you can fix the order by providing
123
+ # the seed, which is printed after each run.
124
+ # --seed 1234
125
+ config.order = :random
126
+
127
+ # Seed global randomization in this process using the `--seed` CLI option.
128
+ # Setting this allows you to use `--seed` to deterministically reproduce
129
+ # test failures related to randomization by passing the same `--seed` value
130
+ # as the one that triggered the failure.
131
+ Kernel.srand config.seed
132
+ =end
133
+ end
134
+
135
+ class Testing
136
+ API_TOKEN = '4880adbe1bee9a241fa08070d33bd49f'
137
+ USERNAME = 'togglv8@mailinator.com'
138
+ PASSWORD = 'togglv8'
139
+ DELAY_SEC = 1
140
+ end
@@ -0,0 +1,71 @@
1
+ require_relative '../lib/togglv8'
2
+ require 'logger'
3
+
4
+ class TogglV8SpecHelper
5
+ @logger = Logger.new(STDOUT)
6
+
7
+ def self.setUp()
8
+ toggl = TogglV8::API.new(Testing::API_TOKEN)
9
+ user = toggl.me(all=true)
10
+ default_workspace_id = user['default_wid']
11
+
12
+ delete_all_clients(toggl)
13
+ delete_all_projects(toggl)
14
+ delete_all_tags(toggl)
15
+ delete_all_time_entries(toggl)
16
+ delete_all_workspaces(toggl)
17
+ end
18
+
19
+ def self.delete_all_clients(toggl)
20
+ clients = toggl.my_clients
21
+ unless clients.nil?
22
+ client_ids ||= clients.map { |c| c['id'] }
23
+ client_ids.each do |c_id|
24
+ toggl.delete_client(c_id)
25
+ end
26
+ end
27
+ end
28
+
29
+ def self.delete_all_projects(toggl)
30
+ projects = toggl.my_projects
31
+ unless projects.nil?
32
+ project_ids ||= projects.map { |p| p['id'] }
33
+ project_ids.each do |p_id|
34
+ toggl.delete_project(p_id)
35
+ end
36
+ end
37
+ end
38
+
39
+ def self.delete_all_tags(toggl)
40
+ tags = toggl.my_tags
41
+ unless tags.nil?
42
+ tag_ids ||= tags.map { |t| t['id'] }
43
+ tag_ids.each do |t_id|
44
+ toggl.delete_tag(t_id)
45
+ end
46
+ end
47
+ end
48
+
49
+ def self.delete_all_time_entries(toggl)
50
+ time_entries = toggl.my_time_entries
51
+ unless time_entries.nil?
52
+ time_entry_ids ||= time_entries.map { |t| t['id'] }
53
+ time_entry_ids.each do |t_id|
54
+ toggl.delete_time_entry(t_id)
55
+ end
56
+ end
57
+ end
58
+
59
+ def self.delete_all_workspaces(toggl)
60
+ user = toggl.me(all=true)
61
+ workspaces = toggl.my_workspaces(user)
62
+ unless workspaces.nil?
63
+ workspace_ids ||= workspaces.map { |w| w['id'] }
64
+ workspace_ids.delete(user['default_wid'])
65
+ workspace_ids.each do |w_id|
66
+ @logger.debug(w_id)
67
+ toggl.leave_workspace(w_id)
68
+ end
69
+ end
70
+ end
71
+ end
data/togglv8.gemspec ADDED
@@ -0,0 +1,35 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'togglv8/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "togglv8"
8
+ spec.version = TogglV8::VERSION
9
+ spec.authors = ["Tom Kane"]
10
+ spec.email = ["kexf7pqsdu@snkmail.com"]
11
+ spec.summary = %q{Toggl v8 API wrapper (See https://github.com/toggl/toggl_api_docs)}
12
+ spec.homepage = "https://github.com/kanet77/togglv8"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.requirements << 'A Toggl account (https://toggl.com/)'
21
+
22
+ spec.add_development_dependency "bundler"
23
+ spec.add_development_dependency "rake"
24
+ spec.add_development_dependency "rspec"
25
+ spec.add_development_dependency "awesome_print"
26
+ spec.add_development_dependency "fivemat"
27
+ spec.add_development_dependency "simplecov"
28
+ # spec.add_development_dependency "simplecov-badge"
29
+ # spec.add_development_dependency "codeclimate-test-reporter"
30
+ spec.add_development_dependency "coveralls"
31
+
32
+ spec.add_dependency "logger"
33
+ spec.add_dependency "faraday"
34
+ spec.add_dependency "oj"
35
+ end
metadata ADDED
@@ -0,0 +1,227 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: togglv8
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Tom Kane
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-08-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: awesome_print
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: fivemat
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: coveralls
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: logger
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: faraday
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: oj
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ description:
154
+ email:
155
+ - kexf7pqsdu@snkmail.com
156
+ executables: []
157
+ extensions: []
158
+ extra_rdoc_files: []
159
+ files:
160
+ - ".coveralls.yml"
161
+ - ".gitignore"
162
+ - ".rdoc_options"
163
+ - ".rspec"
164
+ - ".travis.yml"
165
+ - API calls.md
166
+ - Gemfile
167
+ - LICENSE.txt
168
+ - README.md
169
+ - Rakefile
170
+ - lib/togglv8.rb
171
+ - lib/togglv8/clients.rb
172
+ - lib/togglv8/dashboard.rb
173
+ - lib/togglv8/project_users.rb
174
+ - lib/togglv8/projects.rb
175
+ - lib/togglv8/tags.rb
176
+ - lib/togglv8/tasks.rb
177
+ - lib/togglv8/time_entries.rb
178
+ - lib/togglv8/users.rb
179
+ - lib/togglv8/version.rb
180
+ - lib/togglv8/workspaces.rb
181
+ - spec/lib/togglv8/clients_spec.rb
182
+ - spec/lib/togglv8/dashboard_spec.rb
183
+ - spec/lib/togglv8/projects_spec.rb
184
+ - spec/lib/togglv8/tags_spec.rb
185
+ - spec/lib/togglv8/tasks_spec.rb
186
+ - spec/lib/togglv8/time_entries_spec.rb
187
+ - spec/lib/togglv8/users_spec.rb
188
+ - spec/lib/togglv8_spec.rb
189
+ - spec/spec_helper.rb
190
+ - spec/togglv8_spec_helper.rb
191
+ - togglv8.gemspec
192
+ homepage: https://github.com/kanet77/togglv8
193
+ licenses:
194
+ - MIT
195
+ metadata: {}
196
+ post_install_message:
197
+ rdoc_options: []
198
+ require_paths:
199
+ - lib
200
+ required_ruby_version: !ruby/object:Gem::Requirement
201
+ requirements:
202
+ - - ">="
203
+ - !ruby/object:Gem::Version
204
+ version: '0'
205
+ required_rubygems_version: !ruby/object:Gem::Requirement
206
+ requirements:
207
+ - - ">="
208
+ - !ruby/object:Gem::Version
209
+ version: '0'
210
+ requirements:
211
+ - A Toggl account (https://toggl.com/)
212
+ rubyforge_project:
213
+ rubygems_version: 2.4.5.1
214
+ signing_key:
215
+ specification_version: 4
216
+ summary: Toggl v8 API wrapper (See https://github.com/toggl/toggl_api_docs)
217
+ test_files:
218
+ - spec/lib/togglv8/clients_spec.rb
219
+ - spec/lib/togglv8/dashboard_spec.rb
220
+ - spec/lib/togglv8/projects_spec.rb
221
+ - spec/lib/togglv8/tags_spec.rb
222
+ - spec/lib/togglv8/tasks_spec.rb
223
+ - spec/lib/togglv8/time_entries_spec.rb
224
+ - spec/lib/togglv8/users_spec.rb
225
+ - spec/lib/togglv8_spec.rb
226
+ - spec/spec_helper.rb
227
+ - spec/togglv8_spec_helper.rb