totter 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Rakefile +0 -5
- data/Readme.markdown +11 -0
- data/lib/totter/client.rb +24 -5
- data/lib/totter/version.rb +1 -1
- data/test/totter/client_test.rb +13 -0
- data/totter.gemspec +1 -1
- metadata +9 -15
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 03da894c649ab5b6964fa4706ced06e1e9611267
|
4
|
+
data.tar.gz: b0122b38cb1d56a61736d0035218e81f1048428f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 06e327a8188d254058933565df74521ab9ba9e1a2e5f83efef9e77edc2d37aceb727856e1c5ccc8227515bd6f1dbaa741112c7b468b665bd8fab80b10f25d720
|
7
|
+
data.tar.gz: 93ac291640eee5a6eebd9ef52c1edad0fd944a66c07054f4fc29cac5ecd63cb93480a386fd7f988bfc677e0afc2c2ab0812a0576637abf6a3cd0a851207f4aed
|
data/Rakefile
CHANGED
data/Readme.markdown
CHANGED
@@ -26,6 +26,17 @@ Or install it yourself as:
|
|
26
26
|
$ gem install totter
|
27
27
|
```
|
28
28
|
|
29
|
+
## Configuration
|
30
|
+
|
31
|
+
Should you wish to configure the client in an initializer, you can do the following:
|
32
|
+
|
33
|
+
``` ruby
|
34
|
+
Totter::Client.configure do |client|
|
35
|
+
client.api_host = "some.api-host.com"
|
36
|
+
client.api_scheme = "http"
|
37
|
+
end
|
38
|
+
```
|
39
|
+
|
29
40
|
## Usage
|
30
41
|
|
31
42
|
A client takes an optional access token when you initialize it. If you don't provide one, you can still use it to make unauthenticated requests. If you do provide one, it will set the authorization header for all requests.
|
data/lib/totter/client.rb
CHANGED
@@ -22,21 +22,40 @@ module Totter
|
|
22
22
|
attr_reader :api_version
|
23
23
|
attr_reader :transport
|
24
24
|
|
25
|
-
# global stubbing toggle for use in tests
|
26
25
|
@@stubbed = false
|
27
26
|
|
27
|
+
DEFAULTS = {
|
28
|
+
:api_scheme => 'https',
|
29
|
+
:api_host => 'api.seesaw.co',
|
30
|
+
:api_version => '1',
|
31
|
+
:transport => :http
|
32
|
+
}
|
33
|
+
|
34
|
+
def self.options
|
35
|
+
@options ||= Hashie::Mash.new(DEFAULTS.dup)
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.options=(val)
|
39
|
+
@options = val
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.configure
|
43
|
+
yield options
|
44
|
+
end
|
45
|
+
|
28
46
|
# Initialize a new client.
|
29
47
|
#
|
30
48
|
# @param options [Hash] optionally specify `:access_token`, `:api_scheme`, `:api_host`, `:api_version`, `:client_token`, or `:transport`.
|
31
49
|
def initialize(options = {})
|
32
50
|
options = { :access_token => options } if options.is_a? String
|
51
|
+
options = self.class.options.merge(options)
|
33
52
|
|
34
53
|
@access_token = options[:access_token] if options[:access_token]
|
35
|
-
@api_scheme =
|
36
|
-
@api_host =
|
37
|
-
@api_version =
|
54
|
+
@api_scheme = options[:api_scheme]
|
55
|
+
@api_host = options[:api_host]
|
56
|
+
@api_version = options[:api_version]
|
38
57
|
@client_token = options[:client_token] if options[:client_token]
|
39
|
-
@transport =
|
58
|
+
@transport = options[:transport]
|
40
59
|
|
41
60
|
# Include transport
|
42
61
|
transport_module = Totter::Transport::TRANSPORT_MAP[@transport]
|
data/lib/totter/version.rb
CHANGED
data/test/totter/client_test.rb
CHANGED
@@ -39,4 +39,17 @@ class ClientTest < Totter::TestCase
|
|
39
39
|
|
40
40
|
Totter::Client.unstub!
|
41
41
|
end
|
42
|
+
|
43
|
+
def test_configuration
|
44
|
+
Totter::Client.configure do |client|
|
45
|
+
client.api_host = 'blah'
|
46
|
+
client.api_scheme = 'gopher'
|
47
|
+
end
|
48
|
+
|
49
|
+
assert_equal 'blah', Totter::Client.new.api_host
|
50
|
+
assert_equal 'gopher', Totter::Client.new.api_scheme
|
51
|
+
|
52
|
+
# forcibly reset the configuration
|
53
|
+
Totter::Client.options = nil
|
54
|
+
end
|
42
55
|
end
|
data/totter.gemspec
CHANGED
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: totter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
5
|
-
prerelease:
|
4
|
+
version: 0.3.4
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Sam Soffes
|
@@ -11,28 +10,25 @@ authors:
|
|
11
10
|
autorequire:
|
12
11
|
bindir: bin
|
13
12
|
cert_chain: []
|
14
|
-
date: 2013-03-
|
13
|
+
date: 2013-03-18 00:00:00.000000000 Z
|
15
14
|
dependencies:
|
16
15
|
- !ruby/object:Gem::Dependency
|
17
16
|
name: multi_json
|
18
17
|
requirement: !ruby/object:Gem::Requirement
|
19
|
-
none: false
|
20
18
|
requirements:
|
21
19
|
- - ~>
|
22
20
|
- !ruby/object:Gem::Version
|
23
|
-
version: 1.
|
21
|
+
version: '1.6'
|
24
22
|
type: :runtime
|
25
23
|
prerelease: false
|
26
24
|
version_requirements: !ruby/object:Gem::Requirement
|
27
|
-
none: false
|
28
25
|
requirements:
|
29
26
|
- - ~>
|
30
27
|
- !ruby/object:Gem::Version
|
31
|
-
version: 1.
|
28
|
+
version: '1.6'
|
32
29
|
- !ruby/object:Gem::Dependency
|
33
30
|
name: hashie
|
34
31
|
requirement: !ruby/object:Gem::Requirement
|
35
|
-
none: false
|
36
32
|
requirements:
|
37
33
|
- - ~>
|
38
34
|
- !ruby/object:Gem::Version
|
@@ -40,7 +36,6 @@ dependencies:
|
|
40
36
|
type: :runtime
|
41
37
|
prerelease: false
|
42
38
|
version_requirements: !ruby/object:Gem::Requirement
|
43
|
-
none: false
|
44
39
|
requirements:
|
45
40
|
- - ~>
|
46
41
|
- !ruby/object:Gem::Version
|
@@ -135,27 +130,26 @@ files:
|
|
135
130
|
homepage: https://github.com/seesawco/totter-rb
|
136
131
|
licenses:
|
137
132
|
- MIT
|
133
|
+
metadata: {}
|
138
134
|
post_install_message:
|
139
135
|
rdoc_options: []
|
140
136
|
require_paths:
|
141
137
|
- lib
|
142
138
|
required_ruby_version: !ruby/object:Gem::Requirement
|
143
|
-
none: false
|
144
139
|
requirements:
|
145
|
-
- -
|
140
|
+
- - '>='
|
146
141
|
- !ruby/object:Gem::Version
|
147
142
|
version: 1.8.7
|
148
143
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
149
|
-
none: false
|
150
144
|
requirements:
|
151
|
-
- -
|
145
|
+
- - '>='
|
152
146
|
- !ruby/object:Gem::Version
|
153
147
|
version: '0'
|
154
148
|
requirements: []
|
155
149
|
rubyforge_project:
|
156
|
-
rubygems_version:
|
150
|
+
rubygems_version: 2.0.0
|
157
151
|
signing_key:
|
158
|
-
specification_version:
|
152
|
+
specification_version: 4
|
159
153
|
summary: Ruby gem for working with the Seesaw API.
|
160
154
|
test_files:
|
161
155
|
- test/cassettes/avatars/create.yml
|