taskrabbit 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md ADDED
@@ -0,0 +1,4 @@
1
+ ## v0.0.2
2
+
3
+ * add api_key to config
4
+ * rename client\_secret to api\_secret
data/README.md CHANGED
@@ -4,9 +4,11 @@ Ruby wrapper for TaskRabbit API.
4
4
 
5
5
  ## Installation
6
6
 
7
- I have not published the gem yet so you will either have to vendor it or use a Gemfile:
7
+ gem install taskrabbit
8
8
 
9
- gem 'taskrabbit', :git => 'git://github.com/jrichardlai/taskrabbit.git'
9
+ Or in a Gemfile:
10
+
11
+ gem 'taskrabbit'
10
12
 
11
13
 
12
14
  ## Usage Example
@@ -16,13 +18,17 @@ I have not published the gem yet so you will either have to vendor it or use a G
16
18
  In an initializer file.
17
19
 
18
20
  Taskrabbit.configure do |config|
19
- config.client_secret = 'your-client-secret'
21
+ config.api_secret = 'your-client-secret'
22
+ config.api_key = 'your-client-key'
23
+ config.base_uri = 'https://sandbox.com'
24
+ config.endpoint = 'api/v2'
20
25
  end
21
26
 
22
27
  Available configuration options:
23
28
 
24
- * client_secret: client secret that has been given to you by TaskRabbit
25
- * base_uri: uri of the server (not mandatory, default to www.taskrabbit.com)
29
+ * api_secret: client secret that has been given to you by TaskRabbit
30
+ * api_key: client key that has been given by TaskRabbit
31
+ * base_uri: uri of the server (not mandatory, default to https://www.taskrabbit.com)
26
32
  * endpoint: endpoint (not mandatory, default to api/v1)
27
33
 
28
34
  ## Task
@@ -31,7 +37,7 @@ Available configuration options:
31
37
 
32
38
  tr = Taskrabbit::Api.new
33
39
 
34
- or with a user token
40
+ or with a user token returned by TaskRabbit.
35
41
 
36
42
  tr = Taskrabbit::Api.new(user_token)
37
43
 
@@ -80,7 +86,7 @@ or
80
86
 
81
87
  ### Error for tasks creation or update
82
88
 
83
- tr = Taskrabbit::Api.new(client_secret)
89
+ tr = Taskrabbit::Api.new(user_token)
84
90
  task = tr.tasks.new
85
91
  unless task.save
86
92
  task.error # => "Task title can't be blank, \nAmount you are willing to pay is not a number"
@@ -92,7 +98,7 @@ or
92
98
 
93
99
  In some case TaskRabbit will return an url which should be used for further operations (i.e: when the user doesn't have a credit card).
94
100
 
95
- tr = Taskrabbit::Api.new(client_secret)
101
+ tr = Taskrabbit::Api.new(user_token)
96
102
  task = tr.tasks.new
97
103
  unless task.save
98
104
  if task.redirect?
@@ -102,7 +108,7 @@ In some case TaskRabbit will return an url which should be used for further oper
102
108
 
103
109
  ## User account
104
110
 
105
- tr = Taskrabbit::Api.new(client_secret)
111
+ tr = Taskrabbit::Api.new(user_token)
106
112
  tr.account # => Taskrabbit::User object
107
113
 
108
114
  tr.account.tasks # => List of tasks
@@ -35,7 +35,7 @@ module Taskrabbit
35
35
  :extra_body => options,
36
36
  :extra_request => {
37
37
  :headers => {
38
- 'X-Client-Application' => client_secret.to_s,
38
+ 'X-Client-Application' => api_secret.to_s,
39
39
  'Authorization' => "OAuth #{user_token.to_s}"
40
40
  },
41
41
  :endpoint => endpoint.to_s,
@@ -1,12 +1,14 @@
1
1
  module Taskrabbit
2
2
  module Config
3
- DEFAULT_BASE_URI = 'http://www.taskrabbit.com'
4
- DEFAULT_END_POINT = 'api/v1'
5
- DEFAULT_CLIENT_SECRET = nil
3
+ DEFAULT_BASE_URI = 'http://www.taskrabbit.com'
4
+ DEFAULT_END_POINT = 'api/v1'
5
+ DEFAULT_API_SECRET = nil
6
+ DEFAULT_API_KEY = nil
6
7
 
7
8
  VALID_OPTIONS_KEYS = [
8
9
  :base_uri,
9
- :client_secret,
10
+ :api_key,
11
+ :api_secret,
10
12
  :endpoint
11
13
  ]
12
14
 
@@ -33,9 +35,10 @@ module Taskrabbit
33
35
  # Reset all configuration options to defaults
34
36
  def reset
35
37
  self.tap do |c|
36
- c.base_uri = DEFAULT_BASE_URI
37
- c.endpoint = DEFAULT_END_POINT
38
- c.client_secret = DEFAULT_CLIENT_SECRET
38
+ c.base_uri = DEFAULT_BASE_URI
39
+ c.endpoint = DEFAULT_END_POINT
40
+ c.api_secret = DEFAULT_API_SECRET
41
+ c.api_key = DEFAULT_API_KEY
39
42
  end
40
43
  end
41
44
 
@@ -1,3 +1,3 @@
1
1
  module Taskrabbit
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/spec/spec_helper.rb CHANGED
@@ -17,9 +17,9 @@ TR_USERS = {
17
17
  module Taskrabbit
18
18
  module Config
19
19
  remove_const(:DEFAULT_BASE_URI)
20
- remove_const(:DEFAULT_CLIENT_SECRET)
21
- DEFAULT_BASE_URI = 'http://localhost:3000'
22
- DEFAULT_CLIENT_SECRET = 'euqmQpzV04GmN1dJTY639PdI7eiSjCjI3lKTkPWn'
20
+ remove_const(:DEFAULT_API_SECRET)
21
+ DEFAULT_BASE_URI = 'http://localhost:3000'
22
+ DEFAULT_API_SECRET = 'euqmQpzV04GmN1dJTY639PdI7eiSjCjI3lKTkPWn'
23
23
  end
24
24
  end
25
25
  Taskrabbit.reset
@@ -16,13 +16,13 @@ describe Taskrabbit::Api do
16
16
  end
17
17
 
18
18
  it "should return an error if the client is not set" do
19
- secret = Taskrabbit.client_secret
20
- Taskrabbit.client_secret = nil
19
+ secret = Taskrabbit.api_secret
20
+ Taskrabbit.api_secret = nil
21
21
  tr = Taskrabbit::Api.new
22
22
  VCR.use_cassette('tasks/without_client', :record => :new_episodes) do
23
23
  expect { tr.tasks.all }.to raise_error(Taskrabbit::Error, 'Missing valid client application')
24
24
  end
25
- Taskrabbit.client_secret = secret
25
+ Taskrabbit.api_secret = secret
26
26
  end
27
27
 
28
28
  it "should return an error if the client is not set" do
@@ -23,9 +23,9 @@ describe Taskrabbit do
23
23
  end
24
24
 
25
25
  describe "api defaults" do
26
- it "should be able to set the client_secret" do
27
- Taskrabbit.client_secret = 'asecret'
28
- Taskrabbit.client_secret.should == 'asecret'
26
+ it "should be able to set the api_secret" do
27
+ Taskrabbit.api_secret = 'asecret'
28
+ Taskrabbit.api_secret.should == 'asecret'
29
29
  end
30
30
  end
31
31
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: taskrabbit
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jean-Richard Lai
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-06-19 00:00:00 -07:00
18
+ date: 2012-06-21 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -62,6 +62,7 @@ extra_rdoc_files: []
62
62
  files:
63
63
  - .gitignore
64
64
  - .rspec
65
+ - CHANGELOG.md
65
66
  - Gemfile
66
67
  - Guardfile
67
68
  - README.md