harvested 0.3.3 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +15 -0
- data/HISTORY +11 -0
- data/README.md +14 -6
- data/Rakefile +13 -31
- data/TODO +2 -0
- data/VERSION +1 -1
- data/examples/user_assignments.rb +1 -1
- data/harvested.gemspec +114 -126
- data/lib/ext/array.rb +52 -0
- data/lib/ext/date.rb +9 -0
- data/lib/ext/hash.rb +17 -0
- data/lib/ext/time.rb +5 -0
- data/lib/harvest/api/account.rb +8 -1
- data/lib/harvest/api/base.rb +32 -10
- data/lib/harvest/api/contacts.rb +1 -1
- data/lib/harvest/api/expenses.rb +3 -4
- data/lib/harvest/api/invoice_categories.rb +26 -0
- data/lib/harvest/api/invoices.rb +16 -0
- data/lib/harvest/api/projects.rb +2 -10
- data/lib/harvest/api/reports.rb +13 -16
- data/lib/harvest/api/task_assignments.rb +8 -6
- data/lib/harvest/api/tasks.rb +1 -1
- data/lib/harvest/api/time.rb +13 -13
- data/lib/harvest/api/user_assignments.rb +7 -5
- data/lib/harvest/base.rb +9 -1
- data/lib/harvest/behavior/activatable.rb +2 -2
- data/lib/harvest/behavior/crud.rb +15 -13
- data/lib/harvest/client.rb +18 -13
- data/lib/harvest/contact.rb +13 -11
- data/lib/harvest/errors.rb +6 -4
- data/lib/harvest/expense.rb +40 -14
- data/lib/harvest/expense_category.rb +10 -9
- data/lib/harvest/hardy_client.rb +1 -1
- data/lib/harvest/invoice.rb +103 -0
- data/lib/harvest/invoice_category.rb +18 -0
- data/lib/harvest/line_item.rb +12 -0
- data/lib/harvest/model.rb +120 -0
- data/lib/harvest/project.rb +55 -26
- data/lib/harvest/rate_limit_status.rb +9 -8
- data/lib/harvest/task.rb +17 -14
- data/lib/harvest/task_assignment.rb +27 -22
- data/lib/harvest/time_entry.rb +32 -30
- data/lib/harvest/user.rb +46 -22
- data/lib/harvest/user_assignment.rb +24 -17
- data/lib/harvested.rb +12 -5
- data/spec/functional/account_spec.rb +17 -0
- data/spec/functional/clients_spec.rb +58 -0
- data/spec/functional/errors_spec.rb +22 -0
- data/spec/functional/expenses_spec.rb +84 -0
- data/spec/functional/hardy_client_spec.rb +33 -0
- data/spec/functional/invoice_spec.rb +67 -0
- data/spec/functional/project_spec.rb +50 -0
- data/spec/functional/reporting_spec.rb +80 -0
- data/spec/functional/tasks_spec.rb +88 -0
- data/spec/functional/time_tracking_spec.rb +53 -0
- data/spec/functional/users_spec.rb +102 -0
- data/spec/harvest/base_spec.rb +1 -1
- data/spec/harvest/credentials_spec.rb +1 -1
- data/spec/harvest/expense_category_spec.rb +5 -0
- data/spec/harvest/expense_spec.rb +8 -5
- data/spec/harvest/invoice_spec.rb +47 -0
- data/spec/harvest/project_spec.rb +11 -0
- data/spec/harvest/task_assignment_spec.rb +4 -4
- data/spec/harvest/task_spec.rb +7 -0
- data/spec/harvest/time_entry_spec.rb +11 -10
- data/spec/harvest/user_assignment_spec.rb +3 -3
- data/spec/harvest/user_spec.rb +3 -1
- data/spec/spec_helper.rb +37 -6
- data/{features → spec}/support/harvest_credentials.example.yml +0 -1
- data/spec/support/harvested_helpers.rb +44 -0
- data/spec/support/json_examples.rb +11 -0
- data/spec/test_rubies +5 -0
- metadata +109 -85
- data/.gitignore +0 -28
- data/features/account.feature +0 -7
- data/features/client_contacts.feature +0 -23
- data/features/clients.feature +0 -29
- data/features/errors.feature +0 -25
- data/features/expense_categories.feature +0 -21
- data/features/expenses.feature +0 -55
- data/features/hardy_client.feature +0 -40
- data/features/projects.feature +0 -39
- data/features/reporting.feature +0 -72
- data/features/step_definitions/account_steps.rb +0 -7
- data/features/step_definitions/assignment_steps.rb +0 -100
- data/features/step_definitions/contact_steps.rb +0 -11
- data/features/step_definitions/debug_steps.rb +0 -3
- data/features/step_definitions/error_steps.rb +0 -113
- data/features/step_definitions/expenses_steps.rb +0 -46
- data/features/step_definitions/harvest_steps.rb +0 -8
- data/features/step_definitions/model_steps.rb +0 -90
- data/features/step_definitions/people_steps.rb +0 -4
- data/features/step_definitions/report_steps.rb +0 -91
- data/features/step_definitions/time_entry_steps.rb +0 -40
- data/features/support/env.rb +0 -37
- data/features/support/error_helpers.rb +0 -18
- data/features/support/fixtures/empty_clients.xml +0 -2
- data/features/support/fixtures/over_limit.xml +0 -8
- data/features/support/fixtures/receipt.png +0 -0
- data/features/support/fixtures/under_limit.xml +0 -8
- data/features/support/harvest_helpers.rb +0 -11
- data/features/support/inflections.rb +0 -9
- data/features/task_assignment.feature +0 -69
- data/features/tasks.feature +0 -25
- data/features/time_tracking.feature +0 -29
- data/features/user_assignments.feature +0 -33
- data/features/users.feature +0 -55
- data/lib/harvest/base_model.rb +0 -73
- data/spec/spec.default.opts +0 -1
data/Gemfile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
source :rubygems
|
2
|
+
|
3
|
+
gem 'httparty'
|
4
|
+
gem 'hashie', '~> 1'
|
5
|
+
gem 'json'
|
6
|
+
|
7
|
+
group :development, :test do
|
8
|
+
gem "rspec", "~> 2"
|
9
|
+
gem 'ruby-debug', :platform => [:mri_18, :jruby]
|
10
|
+
gem 'ruby-debug19', :platform => :mri_19, :require => 'ruby-debug'
|
11
|
+
gem 'jruby-openssl', :platform => [:jruby], :require => false
|
12
|
+
gem "webmock"
|
13
|
+
gem "vcr"
|
14
|
+
gem 'jeweler', :require => false
|
15
|
+
end
|
data/HISTORY
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
0.4.0 - August 4, 2011
|
2
|
+
* Large rewrite of codebase
|
3
|
+
* Rewrite of library to use JSON instead of XML
|
4
|
+
* Rewrite of tests to use rspec instead of cucumber
|
5
|
+
* Brought in VCR to help cache test responses
|
6
|
+
* Implemented more reporting functionality
|
7
|
+
* Implemented most of the invoice functionality. Creating/Editing/Updating is disabled due to Harvest API issue
|
8
|
+
* Consolidated various forks (thanks Chris Ritterdorf, bricooke, Michelle Moon Lee, tkwong, Steve McKinney, and others that helped but aren't in the git log!)
|
9
|
+
* Tests passing against MRI 1.8, 1.9, JRuby, and Rubinius
|
10
|
+
0.3.3 - January 27, 2010
|
11
|
+
* Adding fields to TaskAssignment (Quilted)
|
1
12
|
0.3.2 - January 27, 2010
|
2
13
|
* Add of_user support to Time Entry (Benjamin Wong - tkwong)
|
3
14
|
0.3.1 - October 14, 2010
|
data/README.md
CHANGED
@@ -26,12 +26,15 @@ Using `Harvested#client` your code needs to handle all these situations. However
|
|
26
26
|
harvest = Harvest.hardy_client('yoursubdomain', 'yourusername', 'yourpassword')
|
27
27
|
harvest.projects() # This will wait for the Rate Limit reset if you have gone over your limit
|
28
28
|
|
29
|
+
## Ruby support
|
30
|
+
|
31
|
+
Harvested's tests are currently passing for 1.8.7, 1.9.2, JRuby 1.6.2, and Rubinius
|
32
|
+
|
29
33
|
## Links
|
30
34
|
|
31
35
|
* [Harvested Documentation](http://rdoc.info/projects/zmoazeni/harvested)
|
32
36
|
* [Harvest API Documentation](http://www.getharvest.com/api)
|
33
37
|
* [Source Code for Harvested](http://github.com/zmoazeni/harvested)
|
34
|
-
* [Pivotal Tracker for Harvested](http://www.pivotaltracker.com/projects/63260)
|
35
38
|
* [Mailing List for Harvested](http://groups.google.com/group/harvested)
|
36
39
|
|
37
40
|
## How to Contribute
|
@@ -49,20 +52,25 @@ If you want to contribute an enhancement or a fix:
|
|
49
52
|
3. Commit the changes without messing with the Rakefile, VERSION, or history
|
50
53
|
4. Send me a pull request
|
51
54
|
|
52
|
-
Note on running tests: most
|
55
|
+
Note on running tests: most specs run against a live Harvest account. To run the suite, sign up for a free trial account and fill out `/spec/support/harvest_credentials.yml` *(a sample harvest_credentials.example.yml has been included)*.
|
56
|
+
|
57
|
+
The tests use [VCR](https://github.com/myronmarston/vcr) to cache the test responses. This is a great boon for running the tests offline. While uncommon, sometimes the Harvest API will send an erroneous response and VCR will cache it, then subsequent runs will use the incorrect cached response. In order to ignore VCR you can run the specs by passing CACHE=false (e.g. `CACHE=false bundle rake spec`).
|
58
|
+
|
59
|
+
Using [rvm](https://rvm.beginrescueend.com/) you can run the tests against the popular ruby runtimes by running:
|
60
|
+
|
61
|
+
./spec/test_rubies
|
62
|
+
|
63
|
+
Each runtime needs to be installed in rvm along with the bundler gem.
|
53
64
|
|
54
65
|
## TODO
|
55
66
|
|
56
67
|
* Write Documentation
|
57
|
-
* Implement Invoices
|
58
68
|
* Allow Timer Toggling
|
59
69
|
|
60
|
-
Other Roadmap items can be found on [Pivotal Tracker](http://www.pivotaltracker.com/projects/63260)
|
61
|
-
|
62
70
|
## Notes on Harvest Estimates
|
63
71
|
|
64
72
|
Estimates aren't currently supported due to lack of an API. If this opens up, harvested will include them.
|
65
73
|
|
66
74
|
## Copyright
|
67
75
|
|
68
|
-
Copyright (c) 2010 Zach Moazeni. See LICENSE for details.
|
76
|
+
Copyright (c) 2010-2011 Zach Moazeni. See LICENSE for details.
|
data/Rakefile
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'rake'
|
3
|
+
require "bundler/setup"
|
3
4
|
|
4
5
|
begin
|
5
6
|
require 'jeweler'
|
@@ -10,13 +11,6 @@ begin
|
|
10
11
|
gem.email = "zach.moazeni@gmail.com"
|
11
12
|
gem.homepage = "http://github.com/zmoazeni/harvested"
|
12
13
|
gem.authors = ["Zach Moazeni"]
|
13
|
-
gem.add_development_dependency "rspec", ">= 1.2.9"
|
14
|
-
gem.add_development_dependency "cucumber", ">= 0"
|
15
|
-
gem.add_development_dependency "ruby-debug", ">= 0"
|
16
|
-
gem.add_development_dependency "fakeweb", ">= 0"
|
17
|
-
gem.add_dependency "httparty", ">= 0"
|
18
|
-
gem.add_dependency "happymapper", ">= 0"
|
19
|
-
gem.add_dependency "builder", ">= 0"
|
20
14
|
end
|
21
15
|
Jeweler::GemcutterTasks.new
|
22
16
|
rescue LoadError => e
|
@@ -24,30 +18,8 @@ rescue LoadError => e
|
|
24
18
|
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
25
19
|
end
|
26
20
|
|
27
|
-
require '
|
28
|
-
|
29
|
-
spec.libs << 'lib' << 'spec'
|
30
|
-
spec.spec_files = FileList['spec/**/*_spec.rb']
|
31
|
-
end
|
32
|
-
|
33
|
-
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
34
|
-
spec.libs << 'lib' << 'spec'
|
35
|
-
spec.pattern = 'spec/**/*_spec.rb'
|
36
|
-
spec.rcov = true
|
37
|
-
end
|
38
|
-
|
39
|
-
task :spec => :check_dependencies
|
40
|
-
|
41
|
-
begin
|
42
|
-
require 'cucumber/rake/task'
|
43
|
-
Cucumber::Rake::Task.new(:features)
|
44
|
-
|
45
|
-
task :features => :check_dependencies
|
46
|
-
rescue LoadError
|
47
|
-
task :features do
|
48
|
-
abort "Cucumber is not available. In order to run features, you must: sudo gem install cucumber"
|
49
|
-
end
|
50
|
-
end
|
21
|
+
require 'rspec/core/rake_task'
|
22
|
+
RSpec::Core::RakeTask.new(:spec)
|
51
23
|
|
52
24
|
task :default => %w(spec features)
|
53
25
|
|
@@ -58,4 +30,14 @@ rescue LoadError
|
|
58
30
|
task :yardoc do
|
59
31
|
abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
|
60
32
|
end
|
33
|
+
end
|
34
|
+
|
35
|
+
desc 'Removes all data on harvest'
|
36
|
+
task 'clean_remote' do
|
37
|
+
require 'harvested'
|
38
|
+
require "spec/support/harvested_helpers"
|
39
|
+
HarvestedHelpers.clean_remote
|
40
|
+
end
|
41
|
+
|
42
|
+
task :foo do
|
61
43
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.0
|
@@ -16,7 +16,7 @@ project = harvest.projects.create(project)
|
|
16
16
|
|
17
17
|
harvest.projects.create_task(project, 'Bottling Glue')
|
18
18
|
|
19
|
-
user = Harvest::User.new(:first_name => 'Jane', :last_name => 'Doe', :email => 'jane@doe.com', :timezone => :est, :password => 'secure'
|
19
|
+
user = Harvest::User.new(:first_name => 'Jane', :last_name => 'Doe', :email => 'jane@doe.com', :timezone => :est, :password => 'secure')
|
20
20
|
user = harvest.users.create(user)
|
21
21
|
|
22
22
|
user_assignment = Harvest::UserAssignment.new(:user_id => user.id, :project_id => project.id)
|
data/harvested.gemspec
CHANGED
@@ -1,159 +1,147 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{harvested}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.4.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Zach Moazeni"]
|
12
|
-
s.date = %q{2011-
|
12
|
+
s.date = %q{2011-08-04}
|
13
13
|
s.description = %q{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)}
|
14
14
|
s.email = %q{zach.moazeni@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
16
|
-
"README.md"
|
16
|
+
"README.md",
|
17
|
+
"TODO"
|
17
18
|
]
|
18
19
|
s.files = [
|
19
20
|
".document",
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
"spec/harvest/task_assignment_spec.rb",
|
102
|
-
"spec/harvest/time_entry_spec.rb",
|
103
|
-
"spec/harvest/user_assignment_spec.rb",
|
104
|
-
"spec/harvest/user_spec.rb",
|
105
|
-
"spec/spec.default.opts",
|
106
|
-
"spec/spec_helper.rb"
|
21
|
+
"Gemfile",
|
22
|
+
"HISTORY",
|
23
|
+
"MIT-LICENSE",
|
24
|
+
"README.md",
|
25
|
+
"Rakefile",
|
26
|
+
"TODO",
|
27
|
+
"VERSION",
|
28
|
+
"examples/basics.rb",
|
29
|
+
"examples/clear_account.rb",
|
30
|
+
"examples/task_assignments.rb",
|
31
|
+
"examples/user_assignments.rb",
|
32
|
+
"harvested.gemspec",
|
33
|
+
"lib/ext/array.rb",
|
34
|
+
"lib/ext/date.rb",
|
35
|
+
"lib/ext/hash.rb",
|
36
|
+
"lib/ext/time.rb",
|
37
|
+
"lib/harvest/api/account.rb",
|
38
|
+
"lib/harvest/api/base.rb",
|
39
|
+
"lib/harvest/api/clients.rb",
|
40
|
+
"lib/harvest/api/contacts.rb",
|
41
|
+
"lib/harvest/api/expense_categories.rb",
|
42
|
+
"lib/harvest/api/expenses.rb",
|
43
|
+
"lib/harvest/api/invoice_categories.rb",
|
44
|
+
"lib/harvest/api/invoices.rb",
|
45
|
+
"lib/harvest/api/projects.rb",
|
46
|
+
"lib/harvest/api/reports.rb",
|
47
|
+
"lib/harvest/api/task_assignments.rb",
|
48
|
+
"lib/harvest/api/tasks.rb",
|
49
|
+
"lib/harvest/api/time.rb",
|
50
|
+
"lib/harvest/api/user_assignments.rb",
|
51
|
+
"lib/harvest/api/users.rb",
|
52
|
+
"lib/harvest/base.rb",
|
53
|
+
"lib/harvest/behavior/activatable.rb",
|
54
|
+
"lib/harvest/behavior/crud.rb",
|
55
|
+
"lib/harvest/client.rb",
|
56
|
+
"lib/harvest/contact.rb",
|
57
|
+
"lib/harvest/credentials.rb",
|
58
|
+
"lib/harvest/errors.rb",
|
59
|
+
"lib/harvest/expense.rb",
|
60
|
+
"lib/harvest/expense_category.rb",
|
61
|
+
"lib/harvest/hardy_client.rb",
|
62
|
+
"lib/harvest/invoice.rb",
|
63
|
+
"lib/harvest/invoice_category.rb",
|
64
|
+
"lib/harvest/line_item.rb",
|
65
|
+
"lib/harvest/model.rb",
|
66
|
+
"lib/harvest/project.rb",
|
67
|
+
"lib/harvest/rate_limit_status.rb",
|
68
|
+
"lib/harvest/task.rb",
|
69
|
+
"lib/harvest/task_assignment.rb",
|
70
|
+
"lib/harvest/time_entry.rb",
|
71
|
+
"lib/harvest/timezones.rb",
|
72
|
+
"lib/harvest/user.rb",
|
73
|
+
"lib/harvest/user_assignment.rb",
|
74
|
+
"lib/harvested.rb",
|
75
|
+
"spec/functional/account_spec.rb",
|
76
|
+
"spec/functional/clients_spec.rb",
|
77
|
+
"spec/functional/errors_spec.rb",
|
78
|
+
"spec/functional/expenses_spec.rb",
|
79
|
+
"spec/functional/hardy_client_spec.rb",
|
80
|
+
"spec/functional/invoice_spec.rb",
|
81
|
+
"spec/functional/project_spec.rb",
|
82
|
+
"spec/functional/reporting_spec.rb",
|
83
|
+
"spec/functional/tasks_spec.rb",
|
84
|
+
"spec/functional/time_tracking_spec.rb",
|
85
|
+
"spec/functional/users_spec.rb",
|
86
|
+
"spec/harvest/base_spec.rb",
|
87
|
+
"spec/harvest/credentials_spec.rb",
|
88
|
+
"spec/harvest/expense_category_spec.rb",
|
89
|
+
"spec/harvest/expense_spec.rb",
|
90
|
+
"spec/harvest/invoice_spec.rb",
|
91
|
+
"spec/harvest/project_spec.rb",
|
92
|
+
"spec/harvest/task_assignment_spec.rb",
|
93
|
+
"spec/harvest/task_spec.rb",
|
94
|
+
"spec/harvest/time_entry_spec.rb",
|
95
|
+
"spec/harvest/user_assignment_spec.rb",
|
96
|
+
"spec/harvest/user_spec.rb",
|
97
|
+
"spec/spec_helper.rb",
|
98
|
+
"spec/support/harvest_credentials.example.yml",
|
99
|
+
"spec/support/harvested_helpers.rb",
|
100
|
+
"spec/support/json_examples.rb",
|
101
|
+
"spec/test_rubies"
|
107
102
|
]
|
108
103
|
s.homepage = %q{http://github.com/zmoazeni/harvested}
|
109
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
110
104
|
s.require_paths = ["lib"]
|
111
|
-
s.rubygems_version = %q{1.
|
105
|
+
s.rubygems_version = %q{1.6.2}
|
112
106
|
s.summary = %q{A Ruby Wrapper for the Harvest API http://www.getharvest.com/}
|
113
|
-
s.test_files = [
|
114
|
-
"spec/harvest/base_spec.rb",
|
115
|
-
"spec/harvest/credentials_spec.rb",
|
116
|
-
"spec/harvest/expense_spec.rb",
|
117
|
-
"spec/harvest/task_assignment_spec.rb",
|
118
|
-
"spec/harvest/time_entry_spec.rb",
|
119
|
-
"spec/harvest/user_assignment_spec.rb",
|
120
|
-
"spec/harvest/user_spec.rb",
|
121
|
-
"spec/spec_helper.rb",
|
122
|
-
"examples/basics.rb",
|
123
|
-
"examples/clear_account.rb",
|
124
|
-
"examples/task_assignments.rb",
|
125
|
-
"examples/user_assignments.rb"
|
126
|
-
]
|
127
107
|
|
128
108
|
if s.respond_to? :specification_version then
|
129
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
130
109
|
s.specification_version = 3
|
131
110
|
|
132
111
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
133
|
-
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
134
|
-
s.add_development_dependency(%q<cucumber>, [">= 0"])
|
135
|
-
s.add_development_dependency(%q<ruby-debug>, [">= 0"])
|
136
|
-
s.add_development_dependency(%q<fakeweb>, [">= 0"])
|
137
112
|
s.add_runtime_dependency(%q<httparty>, [">= 0"])
|
138
|
-
s.add_runtime_dependency(%q<
|
139
|
-
s.add_runtime_dependency(%q<
|
113
|
+
s.add_runtime_dependency(%q<hashie>, ["~> 1"])
|
114
|
+
s.add_runtime_dependency(%q<json>, [">= 0"])
|
115
|
+
s.add_development_dependency(%q<rspec>, ["~> 2"])
|
116
|
+
s.add_development_dependency(%q<ruby-debug>, [">= 0"])
|
117
|
+
s.add_development_dependency(%q<ruby-debug19>, [">= 0"])
|
118
|
+
s.add_development_dependency(%q<jruby-openssl>, [">= 0"])
|
119
|
+
s.add_development_dependency(%q<webmock>, [">= 0"])
|
120
|
+
s.add_development_dependency(%q<vcr>, [">= 0"])
|
121
|
+
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
140
122
|
else
|
141
|
-
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
142
|
-
s.add_dependency(%q<cucumber>, [">= 0"])
|
143
|
-
s.add_dependency(%q<ruby-debug>, [">= 0"])
|
144
|
-
s.add_dependency(%q<fakeweb>, [">= 0"])
|
145
123
|
s.add_dependency(%q<httparty>, [">= 0"])
|
146
|
-
s.add_dependency(%q<
|
147
|
-
s.add_dependency(%q<
|
124
|
+
s.add_dependency(%q<hashie>, ["~> 1"])
|
125
|
+
s.add_dependency(%q<json>, [">= 0"])
|
126
|
+
s.add_dependency(%q<rspec>, ["~> 2"])
|
127
|
+
s.add_dependency(%q<ruby-debug>, [">= 0"])
|
128
|
+
s.add_dependency(%q<ruby-debug19>, [">= 0"])
|
129
|
+
s.add_dependency(%q<jruby-openssl>, [">= 0"])
|
130
|
+
s.add_dependency(%q<webmock>, [">= 0"])
|
131
|
+
s.add_dependency(%q<vcr>, [">= 0"])
|
132
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
148
133
|
end
|
149
134
|
else
|
150
|
-
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
151
|
-
s.add_dependency(%q<cucumber>, [">= 0"])
|
152
|
-
s.add_dependency(%q<ruby-debug>, [">= 0"])
|
153
|
-
s.add_dependency(%q<fakeweb>, [">= 0"])
|
154
135
|
s.add_dependency(%q<httparty>, [">= 0"])
|
155
|
-
s.add_dependency(%q<
|
156
|
-
s.add_dependency(%q<
|
136
|
+
s.add_dependency(%q<hashie>, ["~> 1"])
|
137
|
+
s.add_dependency(%q<json>, [">= 0"])
|
138
|
+
s.add_dependency(%q<rspec>, ["~> 2"])
|
139
|
+
s.add_dependency(%q<ruby-debug>, [">= 0"])
|
140
|
+
s.add_dependency(%q<ruby-debug19>, [">= 0"])
|
141
|
+
s.add_dependency(%q<jruby-openssl>, [">= 0"])
|
142
|
+
s.add_dependency(%q<webmock>, [">= 0"])
|
143
|
+
s.add_dependency(%q<vcr>, [">= 0"])
|
144
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
157
145
|
end
|
158
146
|
end
|
159
147
|
|
data/lib/ext/array.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# Shamelessly ripped from https://github.com/rails/rails/blob/master/activesupport/lib/active_support/core_ext/array/wrap.rb
|
2
|
+
|
3
|
+
unless Array.respond_to?(:wrap)
|
4
|
+
class Array
|
5
|
+
# Wraps its argument in an array unless it is already an array (or array-like).
|
6
|
+
#
|
7
|
+
# Specifically:
|
8
|
+
#
|
9
|
+
# * If the argument is +nil+ an empty list is returned.
|
10
|
+
# * Otherwise, if the argument responds to +to_ary+ it is invoked, and its result returned.
|
11
|
+
# * Otherwise, returns an array with the argument as its single element.
|
12
|
+
#
|
13
|
+
# Array.wrap(nil) # => []
|
14
|
+
# Array.wrap([1, 2, 3]) # => [1, 2, 3]
|
15
|
+
# Array.wrap(0) # => [0]
|
16
|
+
#
|
17
|
+
# This method is similar in purpose to <tt>Kernel#Array</tt>, but there are some differences:
|
18
|
+
#
|
19
|
+
# * If the argument responds to +to_ary+ the method is invoked. <tt>Kernel#Array</tt>
|
20
|
+
# moves on to try +to_a+ if the returned value is +nil+, but <tt>Arraw.wrap</tt> returns
|
21
|
+
# such a +nil+ right away.
|
22
|
+
# * If the returned value from +to_ary+ is neither +nil+ nor an +Array+ object, <tt>Kernel#Array</tt>
|
23
|
+
# raises an exception, while <tt>Array.wrap</tt> does not, it just returns the value.
|
24
|
+
# * It does not call +to_a+ on the argument, though special-cases +nil+ to return an empty array.
|
25
|
+
#
|
26
|
+
# The last point is particularly worth comparing for some enumerables:
|
27
|
+
#
|
28
|
+
# Array(:foo => :bar) # => [[:foo, :bar]]
|
29
|
+
# Array.wrap(:foo => :bar) # => [{:foo => :bar}]
|
30
|
+
#
|
31
|
+
# Array("foo\nbar") # => ["foo\n", "bar"], in Ruby 1.8
|
32
|
+
# Array.wrap("foo\nbar") # => ["foo\nbar"]
|
33
|
+
#
|
34
|
+
# There's also a related idiom that uses the splat operator:
|
35
|
+
#
|
36
|
+
# [*object]
|
37
|
+
#
|
38
|
+
# which returns <tt>[nil]</tt> for +nil+, and calls to <tt>Array(object)</tt> otherwise.
|
39
|
+
#
|
40
|
+
# Thus, in this case the behavior is different for +nil+, and the differences with
|
41
|
+
# <tt>Kernel#Array</tt> explained above apply to the rest of +object+s.
|
42
|
+
def self.wrap(object)
|
43
|
+
if object.nil?
|
44
|
+
[]
|
45
|
+
elsif object.respond_to?(:to_ary)
|
46
|
+
object.to_ary
|
47
|
+
else
|
48
|
+
[object]
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|