cocoafish 0.1.4 → 0.1.5
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.
- data/CHANGELOG.md +7 -0
- data/README.md +9 -3
- data/Rakefile +6 -5
- data/VERSION +1 -1
- data/cocoafish.gemspec +8 -7
- data/lib/cocoafish/connection.rb +12 -6
- metadata +29 -29
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -35,12 +35,16 @@ Then include it in your scripts:
|
|
35
35
|
|
36
36
|
## Usage
|
37
37
|
|
38
|
-
### Authenticating with
|
38
|
+
### Authenticating with Cocoafish
|
39
39
|
|
40
40
|
Find the OAuth consumer key and secret for your app on the [Cocoafish app management site](http://cocoafish.com/apps) and use them to set the credentials so that your app can talk to the Cocoafish API servers.
|
41
41
|
|
42
42
|
Cocoafish::Client.set_credentials('key', 'secret')
|
43
43
|
|
44
|
+
By default the Ruby Client uses http. If you wish to use https (SSL) to send requests to Cocoafish, you can use the hostname option:
|
45
|
+
|
46
|
+
Cocoafish::Client.set_credentials('key', 'secret', {:hostname=>"https://api.cocoafish.com"})
|
47
|
+
|
44
48
|
### Making Requests
|
45
49
|
|
46
50
|
Use the Cocoafish client http methods to store and retrive data with Cocoafish by passing a url path and optional parameters hash:
|
@@ -136,14 +140,16 @@ The following script shows how to perform actions required for a checkin app: cr
|
|
136
140
|
place_1_id = result.response.places[0].id
|
137
141
|
|
138
142
|
# checkin to the place with a photo and message
|
139
|
-
|
143
|
+
photo = File.new("/Users/mgoff/Desktop/atwork.jpg", "rb")
|
144
|
+
result = Cocoafish::Client.post("checkins/create.json", {:message => "Working hard!", :photo => photo, "photo_sync_sizes[]" => "large_1024", :place_id => place_1_id})
|
140
145
|
|
141
146
|
# create another place
|
142
147
|
result = Cocoafish::Client.post("places/create.json", {:name => "Kingdom of Dumpling", :address => "1713 Taraval St", :city => "San Francisco", :state => "CA", :postal_code => "94116", :latitude => 37.742640, :longitude => -122.484597})
|
143
148
|
place_2_id = result.response.places[0].id
|
144
149
|
|
145
150
|
# checkin to the place with a photo and message
|
146
|
-
|
151
|
+
photo = File.new("/Users/mgoff/Desktop/dumplings.jpg", "rb")
|
152
|
+
result = Cocoafish::Client.post("checkins/create.json", {:message => "Eating some awesome Chinese dumplings!", :photo => photo, "photo_sync_sizes[]" => "large_1024", :place_id => place_2_id})
|
147
153
|
|
148
154
|
# search for checkins from my current location in Union Square
|
149
155
|
result = Cocoafish::Client.get("checkins/search.json", {:latitude => 37.787930, :longitude => -122.407499})
|
data/Rakefile
CHANGED
@@ -13,12 +13,12 @@ require 'jeweler'
|
|
13
13
|
Jeweler::Tasks.new do |gem|
|
14
14
|
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
15
15
|
gem.name = "cocoafish"
|
16
|
-
gem.homepage = "http://
|
16
|
+
gem.homepage = "http://cocoafish.com"
|
17
17
|
gem.license = "MIT"
|
18
|
-
gem.summary = %Q{
|
19
|
-
gem.description = "Ruby client
|
20
|
-
gem.email = "
|
21
|
-
gem.authors = ["Wei Kong"]
|
18
|
+
gem.summary = %Q{Cocoafish Ruby Client}
|
19
|
+
gem.description = "A Ruby client for Cocoafish. For more information about Cocoafish, see http://cocoafish.com."
|
20
|
+
gem.email = "info@cocoafish.com"
|
21
|
+
gem.authors = ["Michael Goff", "Wei Kong"]
|
22
22
|
gem.files = Dir["{lib}/**/*", "./*"]
|
23
23
|
gem.add_runtime_dependency 'rest-client', '~> 1.6.3'
|
24
24
|
gem.add_runtime_dependency 'json_pure', '~> 1.4.6'
|
@@ -49,5 +49,6 @@ Rake::RDocTask.new do |rdoc|
|
|
49
49
|
rdoc.rdoc_dir = 'rdoc'
|
50
50
|
rdoc.title = "cocoafish #{version}"
|
51
51
|
rdoc.rdoc_files.include('README*')
|
52
|
+
rdoc.rdoc_files.include('CHANGELOG*')
|
52
53
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
53
54
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.5
|
data/cocoafish.gemspec
CHANGED
@@ -5,18 +5,19 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "cocoafish"
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Wei Kong"]
|
12
|
-
s.date = "2011-
|
13
|
-
s.description = "Ruby client
|
14
|
-
s.email = "
|
11
|
+
s.authors = ["Michael Goff", "Wei Kong"]
|
12
|
+
s.date = "2011-12-17"
|
13
|
+
s.description = "A Ruby client for Cocoafish. For more information about Cocoafish, see http://cocoafish.com."
|
14
|
+
s.email = "info@cocoafish.com"
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE.txt",
|
17
17
|
"README.md"
|
18
18
|
]
|
19
19
|
s.files = [
|
20
|
+
"./CHANGELOG.md",
|
20
21
|
"./Gemfile",
|
21
22
|
"./Gemfile.lock",
|
22
23
|
"./LICENSE.txt",
|
@@ -31,11 +32,11 @@ Gem::Specification.new do |s|
|
|
31
32
|
"lib/cocoafish/endpoint.rb",
|
32
33
|
"lib/cocoafish/objectified_hash.rb"
|
33
34
|
]
|
34
|
-
s.homepage = "http://
|
35
|
+
s.homepage = "http://cocoafish.com"
|
35
36
|
s.licenses = ["MIT"]
|
36
37
|
s.require_paths = ["lib"]
|
37
38
|
s.rubygems_version = "1.8.10"
|
38
|
-
s.summary = "
|
39
|
+
s.summary = "Cocoafish Ruby Client"
|
39
40
|
s.test_files = [
|
40
41
|
"test/helper.rb",
|
41
42
|
"test/test_cocoafish.rb"
|
data/lib/cocoafish/connection.rb
CHANGED
@@ -30,6 +30,17 @@ module Cocoafish
|
|
30
30
|
|
31
31
|
def request(method, endpoint, data)
|
32
32
|
|
33
|
+
if data
|
34
|
+
if !data.is_a?(Hash)
|
35
|
+
raise "data must be a hash of parameters"
|
36
|
+
end
|
37
|
+
data.each_pair do |k,v|
|
38
|
+
if v.is_a?(Hash) || v.is_a?(Array)
|
39
|
+
data[k] = v.to_json
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
33
44
|
# set the cookies to send with the header
|
34
45
|
if !@options.has_key?(:manage_cookies) || @options[:manage_cookies] != false
|
35
46
|
@header_cookies = @cookies
|
@@ -65,12 +76,6 @@ module Cocoafish
|
|
65
76
|
end
|
66
77
|
|
67
78
|
when :post, :put
|
68
|
-
|
69
|
-
data.each do |key,value|
|
70
|
-
if key.to_s == "photo" || key.to_s =~ /photos\[\d+\]/
|
71
|
-
data[key] = File.new(value, 'rb')
|
72
|
-
end
|
73
|
-
end
|
74
79
|
data.merge!(:multipart => true)
|
75
80
|
|
76
81
|
oauth_header = SimpleOAuth::Header.new(method, endpoint, nil, oauth_options)
|
@@ -100,6 +105,7 @@ module Cocoafish
|
|
100
105
|
|
101
106
|
return content
|
102
107
|
end
|
108
|
+
|
103
109
|
end
|
104
110
|
end
|
105
111
|
|
metadata
CHANGED
@@ -1,19 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocoafish
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
|
+
- Michael Goff
|
8
9
|
- Wei Kong
|
9
10
|
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
12
|
-
date: 2011-
|
13
|
+
date: 2011-12-17 00:00:00.000000000Z
|
13
14
|
dependencies:
|
14
15
|
- !ruby/object:Gem::Dependency
|
15
16
|
name: rest-client
|
16
|
-
requirement: &
|
17
|
+
requirement: &70101127320500 !ruby/object:Gem::Requirement
|
17
18
|
none: false
|
18
19
|
requirements:
|
19
20
|
- - ~>
|
@@ -21,10 +22,10 @@ dependencies:
|
|
21
22
|
version: 1.6.3
|
22
23
|
type: :runtime
|
23
24
|
prerelease: false
|
24
|
-
version_requirements: *
|
25
|
+
version_requirements: *70101127320500
|
25
26
|
- !ruby/object:Gem::Dependency
|
26
27
|
name: json_pure
|
27
|
-
requirement: &
|
28
|
+
requirement: &70101127319320 !ruby/object:Gem::Requirement
|
28
29
|
none: false
|
29
30
|
requirements:
|
30
31
|
- - ~>
|
@@ -32,10 +33,10 @@ dependencies:
|
|
32
33
|
version: 1.4.6
|
33
34
|
type: :runtime
|
34
35
|
prerelease: false
|
35
|
-
version_requirements: *
|
36
|
+
version_requirements: *70101127319320
|
36
37
|
- !ruby/object:Gem::Dependency
|
37
38
|
name: simple_oauth
|
38
|
-
requirement: &
|
39
|
+
requirement: &70101127318800 !ruby/object:Gem::Requirement
|
39
40
|
none: false
|
40
41
|
requirements:
|
41
42
|
- - ~>
|
@@ -43,10 +44,10 @@ dependencies:
|
|
43
44
|
version: 0.1.4
|
44
45
|
type: :runtime
|
45
46
|
prerelease: false
|
46
|
-
version_requirements: *
|
47
|
+
version_requirements: *70101127318800
|
47
48
|
- !ruby/object:Gem::Dependency
|
48
49
|
name: shoulda
|
49
|
-
requirement: &
|
50
|
+
requirement: &70101127317960 !ruby/object:Gem::Requirement
|
50
51
|
none: false
|
51
52
|
requirements:
|
52
53
|
- - ! '>='
|
@@ -54,10 +55,10 @@ dependencies:
|
|
54
55
|
version: '0'
|
55
56
|
type: :development
|
56
57
|
prerelease: false
|
57
|
-
version_requirements: *
|
58
|
+
version_requirements: *70101127317960
|
58
59
|
- !ruby/object:Gem::Dependency
|
59
60
|
name: bundler
|
60
|
-
requirement: &
|
61
|
+
requirement: &70101127317120 !ruby/object:Gem::Requirement
|
61
62
|
none: false
|
62
63
|
requirements:
|
63
64
|
- - ~>
|
@@ -65,10 +66,10 @@ dependencies:
|
|
65
66
|
version: 1.0.0
|
66
67
|
type: :development
|
67
68
|
prerelease: false
|
68
|
-
version_requirements: *
|
69
|
+
version_requirements: *70101127317120
|
69
70
|
- !ruby/object:Gem::Dependency
|
70
71
|
name: jeweler
|
71
|
-
requirement: &
|
72
|
+
requirement: &70101127316340 !ruby/object:Gem::Requirement
|
72
73
|
none: false
|
73
74
|
requirements:
|
74
75
|
- - ~>
|
@@ -76,10 +77,10 @@ dependencies:
|
|
76
77
|
version: 1.5.2
|
77
78
|
type: :development
|
78
79
|
prerelease: false
|
79
|
-
version_requirements: *
|
80
|
+
version_requirements: *70101127316340
|
80
81
|
- !ruby/object:Gem::Dependency
|
81
82
|
name: rcov
|
82
|
-
requirement: &
|
83
|
+
requirement: &70101127315620 !ruby/object:Gem::Requirement
|
83
84
|
none: false
|
84
85
|
requirements:
|
85
86
|
- - ! '>='
|
@@ -87,10 +88,10 @@ dependencies:
|
|
87
88
|
version: '0'
|
88
89
|
type: :development
|
89
90
|
prerelease: false
|
90
|
-
version_requirements: *
|
91
|
+
version_requirements: *70101127315620
|
91
92
|
- !ruby/object:Gem::Dependency
|
92
93
|
name: rest-client
|
93
|
-
requirement: &
|
94
|
+
requirement: &70101127315140 !ruby/object:Gem::Requirement
|
94
95
|
none: false
|
95
96
|
requirements:
|
96
97
|
- - ~>
|
@@ -98,10 +99,10 @@ dependencies:
|
|
98
99
|
version: 1.6.3
|
99
100
|
type: :runtime
|
100
101
|
prerelease: false
|
101
|
-
version_requirements: *
|
102
|
+
version_requirements: *70101127315140
|
102
103
|
- !ruby/object:Gem::Dependency
|
103
104
|
name: json_pure
|
104
|
-
requirement: &
|
105
|
+
requirement: &70101127314480 !ruby/object:Gem::Requirement
|
105
106
|
none: false
|
106
107
|
requirements:
|
107
108
|
- - ~>
|
@@ -109,10 +110,10 @@ dependencies:
|
|
109
110
|
version: 1.4.6
|
110
111
|
type: :runtime
|
111
112
|
prerelease: false
|
112
|
-
version_requirements: *
|
113
|
+
version_requirements: *70101127314480
|
113
114
|
- !ruby/object:Gem::Dependency
|
114
115
|
name: simple_oauth
|
115
|
-
requirement: &
|
116
|
+
requirement: &70101127313860 !ruby/object:Gem::Requirement
|
116
117
|
none: false
|
117
118
|
requirements:
|
118
119
|
- - ~>
|
@@ -120,15 +121,17 @@ dependencies:
|
|
120
121
|
version: 0.1.4
|
121
122
|
type: :runtime
|
122
123
|
prerelease: false
|
123
|
-
version_requirements: *
|
124
|
-
description: Ruby client
|
125
|
-
|
124
|
+
version_requirements: *70101127313860
|
125
|
+
description: A Ruby client for Cocoafish. For more information about Cocoafish, see
|
126
|
+
http://cocoafish.com.
|
127
|
+
email: info@cocoafish.com
|
126
128
|
executables: []
|
127
129
|
extensions: []
|
128
130
|
extra_rdoc_files:
|
129
131
|
- LICENSE.txt
|
130
132
|
- README.md
|
131
133
|
files:
|
134
|
+
- ./CHANGELOG.md
|
132
135
|
- ./Gemfile
|
133
136
|
- ./Gemfile.lock
|
134
137
|
- ./LICENSE.txt
|
@@ -146,7 +149,7 @@ files:
|
|
146
149
|
- README.md
|
147
150
|
- test/helper.rb
|
148
151
|
- test/test_cocoafish.rb
|
149
|
-
homepage: http://
|
152
|
+
homepage: http://cocoafish.com
|
150
153
|
licenses:
|
151
154
|
- MIT
|
152
155
|
post_install_message:
|
@@ -159,9 +162,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
159
162
|
- - ! '>='
|
160
163
|
- !ruby/object:Gem::Version
|
161
164
|
version: '0'
|
162
|
-
segments:
|
163
|
-
- 0
|
164
|
-
hash: -2104059489818044473
|
165
165
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
166
166
|
none: false
|
167
167
|
requirements:
|
@@ -173,7 +173,7 @@ rubyforge_project:
|
|
173
173
|
rubygems_version: 1.8.10
|
174
174
|
signing_key:
|
175
175
|
specification_version: 3
|
176
|
-
summary:
|
176
|
+
summary: Cocoafish Ruby Client
|
177
177
|
test_files:
|
178
178
|
- test/helper.rb
|
179
179
|
- test/test_cocoafish.rb
|