harvested 0.3.3 → 0.4.0

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.
Files changed (109) hide show
  1. data/Gemfile +15 -0
  2. data/HISTORY +11 -0
  3. data/README.md +14 -6
  4. data/Rakefile +13 -31
  5. data/TODO +2 -0
  6. data/VERSION +1 -1
  7. data/examples/user_assignments.rb +1 -1
  8. data/harvested.gemspec +114 -126
  9. data/lib/ext/array.rb +52 -0
  10. data/lib/ext/date.rb +9 -0
  11. data/lib/ext/hash.rb +17 -0
  12. data/lib/ext/time.rb +5 -0
  13. data/lib/harvest/api/account.rb +8 -1
  14. data/lib/harvest/api/base.rb +32 -10
  15. data/lib/harvest/api/contacts.rb +1 -1
  16. data/lib/harvest/api/expenses.rb +3 -4
  17. data/lib/harvest/api/invoice_categories.rb +26 -0
  18. data/lib/harvest/api/invoices.rb +16 -0
  19. data/lib/harvest/api/projects.rb +2 -10
  20. data/lib/harvest/api/reports.rb +13 -16
  21. data/lib/harvest/api/task_assignments.rb +8 -6
  22. data/lib/harvest/api/tasks.rb +1 -1
  23. data/lib/harvest/api/time.rb +13 -13
  24. data/lib/harvest/api/user_assignments.rb +7 -5
  25. data/lib/harvest/base.rb +9 -1
  26. data/lib/harvest/behavior/activatable.rb +2 -2
  27. data/lib/harvest/behavior/crud.rb +15 -13
  28. data/lib/harvest/client.rb +18 -13
  29. data/lib/harvest/contact.rb +13 -11
  30. data/lib/harvest/errors.rb +6 -4
  31. data/lib/harvest/expense.rb +40 -14
  32. data/lib/harvest/expense_category.rb +10 -9
  33. data/lib/harvest/hardy_client.rb +1 -1
  34. data/lib/harvest/invoice.rb +103 -0
  35. data/lib/harvest/invoice_category.rb +18 -0
  36. data/lib/harvest/line_item.rb +12 -0
  37. data/lib/harvest/model.rb +120 -0
  38. data/lib/harvest/project.rb +55 -26
  39. data/lib/harvest/rate_limit_status.rb +9 -8
  40. data/lib/harvest/task.rb +17 -14
  41. data/lib/harvest/task_assignment.rb +27 -22
  42. data/lib/harvest/time_entry.rb +32 -30
  43. data/lib/harvest/user.rb +46 -22
  44. data/lib/harvest/user_assignment.rb +24 -17
  45. data/lib/harvested.rb +12 -5
  46. data/spec/functional/account_spec.rb +17 -0
  47. data/spec/functional/clients_spec.rb +58 -0
  48. data/spec/functional/errors_spec.rb +22 -0
  49. data/spec/functional/expenses_spec.rb +84 -0
  50. data/spec/functional/hardy_client_spec.rb +33 -0
  51. data/spec/functional/invoice_spec.rb +67 -0
  52. data/spec/functional/project_spec.rb +50 -0
  53. data/spec/functional/reporting_spec.rb +80 -0
  54. data/spec/functional/tasks_spec.rb +88 -0
  55. data/spec/functional/time_tracking_spec.rb +53 -0
  56. data/spec/functional/users_spec.rb +102 -0
  57. data/spec/harvest/base_spec.rb +1 -1
  58. data/spec/harvest/credentials_spec.rb +1 -1
  59. data/spec/harvest/expense_category_spec.rb +5 -0
  60. data/spec/harvest/expense_spec.rb +8 -5
  61. data/spec/harvest/invoice_spec.rb +47 -0
  62. data/spec/harvest/project_spec.rb +11 -0
  63. data/spec/harvest/task_assignment_spec.rb +4 -4
  64. data/spec/harvest/task_spec.rb +7 -0
  65. data/spec/harvest/time_entry_spec.rb +11 -10
  66. data/spec/harvest/user_assignment_spec.rb +3 -3
  67. data/spec/harvest/user_spec.rb +3 -1
  68. data/spec/spec_helper.rb +37 -6
  69. data/{features → spec}/support/harvest_credentials.example.yml +0 -1
  70. data/spec/support/harvested_helpers.rb +44 -0
  71. data/spec/support/json_examples.rb +11 -0
  72. data/spec/test_rubies +5 -0
  73. metadata +109 -85
  74. data/.gitignore +0 -28
  75. data/features/account.feature +0 -7
  76. data/features/client_contacts.feature +0 -23
  77. data/features/clients.feature +0 -29
  78. data/features/errors.feature +0 -25
  79. data/features/expense_categories.feature +0 -21
  80. data/features/expenses.feature +0 -55
  81. data/features/hardy_client.feature +0 -40
  82. data/features/projects.feature +0 -39
  83. data/features/reporting.feature +0 -72
  84. data/features/step_definitions/account_steps.rb +0 -7
  85. data/features/step_definitions/assignment_steps.rb +0 -100
  86. data/features/step_definitions/contact_steps.rb +0 -11
  87. data/features/step_definitions/debug_steps.rb +0 -3
  88. data/features/step_definitions/error_steps.rb +0 -113
  89. data/features/step_definitions/expenses_steps.rb +0 -46
  90. data/features/step_definitions/harvest_steps.rb +0 -8
  91. data/features/step_definitions/model_steps.rb +0 -90
  92. data/features/step_definitions/people_steps.rb +0 -4
  93. data/features/step_definitions/report_steps.rb +0 -91
  94. data/features/step_definitions/time_entry_steps.rb +0 -40
  95. data/features/support/env.rb +0 -37
  96. data/features/support/error_helpers.rb +0 -18
  97. data/features/support/fixtures/empty_clients.xml +0 -2
  98. data/features/support/fixtures/over_limit.xml +0 -8
  99. data/features/support/fixtures/receipt.png +0 -0
  100. data/features/support/fixtures/under_limit.xml +0 -8
  101. data/features/support/harvest_helpers.rb +0 -11
  102. data/features/support/inflections.rb +0 -9
  103. data/features/task_assignment.feature +0 -69
  104. data/features/tasks.feature +0 -25
  105. data/features/time_tracking.feature +0 -29
  106. data/features/user_assignments.feature +0 -33
  107. data/features/users.feature +0 -55
  108. data/lib/harvest/base_model.rb +0 -73
  109. data/spec/spec.default.opts +0 -1
@@ -1,4 +1,3 @@
1
1
  username: "my@email.com"
2
2
  password: "secure"
3
3
  subdomain: "my-domain"
4
- ssl: false
@@ -0,0 +1,44 @@
1
+ module HarvestedHelpers
2
+ def self.credentials
3
+ raise "You need a credentials file in support/harvest_credentials.yml!!" unless File.exist?("#{File.dirname(__FILE__)}/harvest_credentials.yml")
4
+ @credentials ||= YAML.load_file("#{File.dirname(__FILE__)}/harvest_credentials.yml")
5
+ end
6
+ def credentials; HarvestedHelpers.credentials; end
7
+
8
+ def self.simple_harvest
9
+ Harvest.client(credentials["subdomain"], credentials["username"], credentials["password"], :ssl => true)
10
+ end
11
+
12
+ # def connect_to_harvest
13
+ # @harvest = Harvest.hardy_client(credentials["subdomain"], credentials["username"], credentials["password"], :ssl => true)
14
+ # end
15
+
16
+ # def harvest; @harvest; end
17
+ def harvest; @harvest ||= HarvestedHelpers.simple_harvest; end
18
+
19
+ def hardy_harvest
20
+ Harvest.hardy_client(credentials["subdomain"], credentials["username"], credentials["password"], :ssl => true)
21
+ end
22
+
23
+ def self.clean_remote
24
+ harvest = simple_harvest
25
+ harvest.users.all.each do |u|
26
+ harvest.reports.expenses_by_user(u, Time.utc(2000, 1, 1), Time.utc(2011, 6,21)).each do |expense|
27
+ harvest.expenses.delete(expense, u)
28
+ end
29
+
30
+ harvest.reports.time_by_user(u, Time.utc(2000, 1, 1), Time.utc(2011, 6,21)).each do |time|
31
+ harvest.time.delete(time, u)
32
+ end
33
+
34
+ harvest.users.delete(u) if u.email != credentials["username"]
35
+ end
36
+
37
+ # we store expenses on this date in the tests
38
+ harvest.expenses.all(Time.utc(2009, 12, 28)).each {|e| harvest.expenses.delete(e) }
39
+
40
+ %w(expense_categories projects contacts clients tasks).each do |collection|
41
+ harvest.send(collection).all.each {|m| harvest.send(collection).delete(m) }
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,11 @@
1
+ shared_examples_for 'a json sanitizer' do |keys|
2
+ keys.each do |key|
3
+ it "doesn't include '#{key}' when serializing to json" do
4
+ instance = described_class.new
5
+ instance[key] = 10
6
+ instance.as_json[instance.class.json_root].keys.should_not include(key)
7
+ end
8
+ end
9
+ end
10
+
11
+ # it_behaves_like 'a json sanitizer', %w(cache_version)
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -o verbose
4
+ RBXOPT="-Xrbc.db" rvm ruby-1.8.7-p334,ruby-1.9.2-p180,rbx,jruby-1.6.2 exec bundle
5
+ RBXOPT="-Xrbc.db" rvm ruby-1.8.7-p334,ruby-1.9.2-p180,rbx,jruby-1.6.2 exec bundle exec rake spec
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: harvested
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
5
- prerelease: false
4
+ hash: 15
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
- - 3
9
- - 3
10
- version: 0.3.3
8
+ - 4
9
+ - 0
10
+ version: 0.4.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Zach Moazeni
@@ -15,41 +15,38 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-27 00:00:00 -05:00
18
+ date: 2011-08-04 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- name: rspec
23
22
  prerelease: false
24
23
  requirement: &id001 !ruby/object:Gem::Requirement
25
24
  none: false
26
25
  requirements:
27
26
  - - ">="
28
27
  - !ruby/object:Gem::Version
29
- hash: 13
28
+ hash: 3
30
29
  segments:
31
- - 1
32
- - 2
33
- - 9
34
- version: 1.2.9
35
- type: :development
30
+ - 0
31
+ version: "0"
32
+ type: :runtime
33
+ name: httparty
36
34
  version_requirements: *id001
37
35
  - !ruby/object:Gem::Dependency
38
- name: cucumber
39
36
  prerelease: false
40
37
  requirement: &id002 !ruby/object:Gem::Requirement
41
38
  none: false
42
39
  requirements:
43
- - - ">="
40
+ - - ~>
44
41
  - !ruby/object:Gem::Version
45
- hash: 3
42
+ hash: 1
46
43
  segments:
47
- - 0
48
- version: "0"
49
- type: :development
44
+ - 1
45
+ version: "1"
46
+ type: :runtime
47
+ name: hashie
50
48
  version_requirements: *id002
51
49
  - !ruby/object:Gem::Dependency
52
- name: ruby-debug
53
50
  prerelease: false
54
51
  requirement: &id003 !ruby/object:Gem::Requirement
55
52
  none: false
@@ -60,24 +57,24 @@ dependencies:
60
57
  segments:
61
58
  - 0
62
59
  version: "0"
63
- type: :development
60
+ type: :runtime
61
+ name: json
64
62
  version_requirements: *id003
65
63
  - !ruby/object:Gem::Dependency
66
- name: fakeweb
67
64
  prerelease: false
68
65
  requirement: &id004 !ruby/object:Gem::Requirement
69
66
  none: false
70
67
  requirements:
71
- - - ">="
68
+ - - ~>
72
69
  - !ruby/object:Gem::Version
73
- hash: 3
70
+ hash: 7
74
71
  segments:
75
- - 0
76
- version: "0"
72
+ - 2
73
+ version: "2"
77
74
  type: :development
75
+ name: rspec
78
76
  version_requirements: *id004
79
77
  - !ruby/object:Gem::Dependency
80
- name: httparty
81
78
  prerelease: false
82
79
  requirement: &id005 !ruby/object:Gem::Requirement
83
80
  none: false
@@ -88,10 +85,10 @@ dependencies:
88
85
  segments:
89
86
  - 0
90
87
  version: "0"
91
- type: :runtime
88
+ type: :development
89
+ name: ruby-debug
92
90
  version_requirements: *id005
93
91
  - !ruby/object:Gem::Dependency
94
- name: happymapper
95
92
  prerelease: false
96
93
  requirement: &id006 !ruby/object:Gem::Requirement
97
94
  none: false
@@ -102,10 +99,10 @@ dependencies:
102
99
  segments:
103
100
  - 0
104
101
  version: "0"
105
- type: :runtime
102
+ type: :development
103
+ name: ruby-debug19
106
104
  version_requirements: *id006
107
105
  - !ruby/object:Gem::Dependency
108
- name: builder
109
106
  prerelease: false
110
107
  requirement: &id007 !ruby/object:Gem::Requirement
111
108
  none: false
@@ -116,8 +113,51 @@ dependencies:
116
113
  segments:
117
114
  - 0
118
115
  version: "0"
119
- type: :runtime
116
+ type: :development
117
+ name: jruby-openssl
120
118
  version_requirements: *id007
119
+ - !ruby/object:Gem::Dependency
120
+ prerelease: false
121
+ requirement: &id008 !ruby/object:Gem::Requirement
122
+ none: false
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ hash: 3
127
+ segments:
128
+ - 0
129
+ version: "0"
130
+ type: :development
131
+ name: webmock
132
+ version_requirements: *id008
133
+ - !ruby/object:Gem::Dependency
134
+ prerelease: false
135
+ requirement: &id009 !ruby/object:Gem::Requirement
136
+ none: false
137
+ requirements:
138
+ - - ">="
139
+ - !ruby/object:Gem::Version
140
+ hash: 3
141
+ segments:
142
+ - 0
143
+ version: "0"
144
+ type: :development
145
+ name: vcr
146
+ version_requirements: *id009
147
+ - !ruby/object:Gem::Dependency
148
+ prerelease: false
149
+ requirement: &id010 !ruby/object:Gem::Requirement
150
+ none: false
151
+ requirements:
152
+ - - ">="
153
+ - !ruby/object:Gem::Version
154
+ hash: 3
155
+ segments:
156
+ - 0
157
+ version: "0"
158
+ type: :development
159
+ name: jeweler
160
+ version_requirements: *id010
121
161
  description: Harvested wraps the Harvest API concisely without the use of Rails dependencies. More information about the Harvest API can be found on their website (http://www.getharvest.com/api). For support hit up the Mailing List (http://groups.google.com/group/harvested)
122
162
  email: zach.moazeni@gmail.com
123
163
  executables: []
@@ -126,59 +166,33 @@ extensions: []
126
166
 
127
167
  extra_rdoc_files:
128
168
  - README.md
169
+ - TODO
129
170
  files:
130
171
  - .document
131
- - .gitignore
172
+ - Gemfile
132
173
  - HISTORY
133
174
  - MIT-LICENSE
134
175
  - README.md
135
176
  - Rakefile
177
+ - TODO
136
178
  - VERSION
137
179
  - examples/basics.rb
138
180
  - examples/clear_account.rb
139
181
  - examples/task_assignments.rb
140
182
  - examples/user_assignments.rb
141
- - features/account.feature
142
- - features/client_contacts.feature
143
- - features/clients.feature
144
- - features/errors.feature
145
- - features/expense_categories.feature
146
- - features/expenses.feature
147
- - features/hardy_client.feature
148
- - features/projects.feature
149
- - features/reporting.feature
150
- - features/step_definitions/account_steps.rb
151
- - features/step_definitions/assignment_steps.rb
152
- - features/step_definitions/contact_steps.rb
153
- - features/step_definitions/debug_steps.rb
154
- - features/step_definitions/error_steps.rb
155
- - features/step_definitions/expenses_steps.rb
156
- - features/step_definitions/harvest_steps.rb
157
- - features/step_definitions/model_steps.rb
158
- - features/step_definitions/people_steps.rb
159
- - features/step_definitions/report_steps.rb
160
- - features/step_definitions/time_entry_steps.rb
161
- - features/support/env.rb
162
- - features/support/error_helpers.rb
163
- - features/support/fixtures/empty_clients.xml
164
- - features/support/fixtures/over_limit.xml
165
- - features/support/fixtures/receipt.png
166
- - features/support/fixtures/under_limit.xml
167
- - features/support/harvest_credentials.example.yml
168
- - features/support/harvest_helpers.rb
169
- - features/support/inflections.rb
170
- - features/task_assignment.feature
171
- - features/tasks.feature
172
- - features/time_tracking.feature
173
- - features/user_assignments.feature
174
- - features/users.feature
175
183
  - harvested.gemspec
184
+ - lib/ext/array.rb
185
+ - lib/ext/date.rb
186
+ - lib/ext/hash.rb
187
+ - lib/ext/time.rb
176
188
  - lib/harvest/api/account.rb
177
189
  - lib/harvest/api/base.rb
178
190
  - lib/harvest/api/clients.rb
179
191
  - lib/harvest/api/contacts.rb
180
192
  - lib/harvest/api/expense_categories.rb
181
193
  - lib/harvest/api/expenses.rb
194
+ - lib/harvest/api/invoice_categories.rb
195
+ - lib/harvest/api/invoices.rb
182
196
  - lib/harvest/api/projects.rb
183
197
  - lib/harvest/api/reports.rb
184
198
  - lib/harvest/api/task_assignments.rb
@@ -187,7 +201,6 @@ files:
187
201
  - lib/harvest/api/user_assignments.rb
188
202
  - lib/harvest/api/users.rb
189
203
  - lib/harvest/base.rb
190
- - lib/harvest/base_model.rb
191
204
  - lib/harvest/behavior/activatable.rb
192
205
  - lib/harvest/behavior/crud.rb
193
206
  - lib/harvest/client.rb
@@ -197,6 +210,10 @@ files:
197
210
  - lib/harvest/expense.rb
198
211
  - lib/harvest/expense_category.rb
199
212
  - lib/harvest/hardy_client.rb
213
+ - lib/harvest/invoice.rb
214
+ - lib/harvest/invoice_category.rb
215
+ - lib/harvest/line_item.rb
216
+ - lib/harvest/model.rb
200
217
  - lib/harvest/project.rb
201
218
  - lib/harvest/rate_limit_status.rb
202
219
  - lib/harvest/task.rb
@@ -206,22 +223,40 @@ files:
206
223
  - lib/harvest/user.rb
207
224
  - lib/harvest/user_assignment.rb
208
225
  - lib/harvested.rb
226
+ - spec/functional/account_spec.rb
227
+ - spec/functional/clients_spec.rb
228
+ - spec/functional/errors_spec.rb
229
+ - spec/functional/expenses_spec.rb
230
+ - spec/functional/hardy_client_spec.rb
231
+ - spec/functional/invoice_spec.rb
232
+ - spec/functional/project_spec.rb
233
+ - spec/functional/reporting_spec.rb
234
+ - spec/functional/tasks_spec.rb
235
+ - spec/functional/time_tracking_spec.rb
236
+ - spec/functional/users_spec.rb
209
237
  - spec/harvest/base_spec.rb
210
238
  - spec/harvest/credentials_spec.rb
239
+ - spec/harvest/expense_category_spec.rb
211
240
  - spec/harvest/expense_spec.rb
241
+ - spec/harvest/invoice_spec.rb
242
+ - spec/harvest/project_spec.rb
212
243
  - spec/harvest/task_assignment_spec.rb
244
+ - spec/harvest/task_spec.rb
213
245
  - spec/harvest/time_entry_spec.rb
214
246
  - spec/harvest/user_assignment_spec.rb
215
247
  - spec/harvest/user_spec.rb
216
- - spec/spec.default.opts
217
248
  - spec/spec_helper.rb
249
+ - spec/support/harvest_credentials.example.yml
250
+ - spec/support/harvested_helpers.rb
251
+ - spec/support/json_examples.rb
252
+ - spec/test_rubies
218
253
  has_rdoc: true
219
254
  homepage: http://github.com/zmoazeni/harvested
220
255
  licenses: []
221
256
 
222
257
  post_install_message:
223
- rdoc_options:
224
- - --charset=UTF-8
258
+ rdoc_options: []
259
+
225
260
  require_paths:
226
261
  - lib
227
262
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -245,20 +280,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
245
280
  requirements: []
246
281
 
247
282
  rubyforge_project:
248
- rubygems_version: 1.3.7
283
+ rubygems_version: 1.6.2
249
284
  signing_key:
250
285
  specification_version: 3
251
286
  summary: A Ruby Wrapper for the Harvest API http://www.getharvest.com/
252
- test_files:
253
- - spec/harvest/base_spec.rb
254
- - spec/harvest/credentials_spec.rb
255
- - spec/harvest/expense_spec.rb
256
- - spec/harvest/task_assignment_spec.rb
257
- - spec/harvest/time_entry_spec.rb
258
- - spec/harvest/user_assignment_spec.rb
259
- - spec/harvest/user_spec.rb
260
- - spec/spec_helper.rb
261
- - examples/basics.rb
262
- - examples/clear_account.rb
263
- - examples/task_assignments.rb
264
- - examples/user_assignments.rb
287
+ test_files: []
288
+
data/.gitignore DELETED
@@ -1,28 +0,0 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## EMACS
9
- *~
10
- \#*
11
- .\#*
12
-
13
- ## VIM
14
- *.swp
15
-
16
- ## PROJECT::GENERAL
17
- coverage
18
- rdoc
19
- pkg
20
- spec.opts
21
- doc
22
- .yardoc
23
-
24
- ## PROJECT::SPECIFIC
25
- features/support/harvest_credentials.yml
26
-
27
- ## RUBYGEMS
28
- *.gem
@@ -1,7 +0,0 @@
1
- @clean
2
- Feature: Account API
3
-
4
- Scenario: Requesting Rate Limit
5
- Given I am using the credentials from "./support/harvest_credentials.yml"
6
- When I request the current rate limit I should get the following:
7
- | max_calls | 40 |
@@ -1,23 +0,0 @@
1
- @clean
2
- Feature: Managing Client Contacts
3
-
4
- Scenario: Adding, Updating, and Removing a Contact
5
- Given I am using the credentials from "./support/harvest_credentials.yml"
6
- And I create a client with the following:
7
- | name | Client Contacts |
8
- | details | Building API Widgets across the country |
9
- When I create a contact for the client "Client Contacts" with the following:
10
- | email | jane@doe.com |
11
- | first_name | Jane |
12
- | last_name | Doe |
13
- | phone_office | 555.123.4567 |
14
- | phone_mobile | 555.333.1111 |
15
- | fax | 555.222.1111 |
16
- Then there should be a contact "jane@doe.com"
17
- And there should be a contact "jane@doe.com" for the client "Client Contacts"
18
- When I update the contact "jane@doe.com" with the following:
19
- | last_name | Smith |
20
- Then the contact "jane@doe.com" should have the following attributes:
21
- | last_name | Smith |
22
- When I delete the contact "jane@doe.com"
23
- Then there should not be a contact "jane@doe.com"