snapcat 0.0.1 → 0.0.2
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.
- checksums.yaml +4 -4
- data/lib/snapcat/requestor.rb +1 -1
- data/lib/snapcat/response.rb +17 -10
- data/snapcat.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca9e5b503ceac5e5ca3718afb03247f4f4025ad5
|
4
|
+
data.tar.gz: 005d1017eb32f3d8e1d52174b77e4c984ab16a5b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd531769fa3d94fc41405dab785056cf51217c3959702cfe74bb534a457126731bc3ab28785fff7174d135c9940c00dcba72a37e784617cd09cd155886364c89
|
7
|
+
data.tar.gz: 6e49c51b8b707135607d4103034f42f77286547356ccdec2e433b122000c2bf1e863c05ee404456f54caec8e37e4a5af331a016c9fed5c10feaeb10743dadc2a
|
data/lib/snapcat/requestor.rb
CHANGED
data/lib/snapcat/response.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
module Snapcat
|
2
2
|
class Response
|
3
|
+
RECOGNIZED_CONTENT_TYPES = %w(application/json application/octet-stream)
|
3
4
|
attr_reader :code, :data, :http_success
|
4
5
|
|
5
6
|
def initialize(response, additional_fields = {})
|
@@ -22,22 +23,28 @@ module Snapcat
|
|
22
23
|
|
23
24
|
private
|
24
25
|
|
25
|
-
def
|
26
|
-
|
26
|
+
def format_recognized_content(content_type, content)
|
27
|
+
if content_type == 'application/json'
|
28
|
+
JSON.parse(content, symbolize_names: true)
|
29
|
+
elsif content_type == 'application/octet-stream'
|
30
|
+
{ media: Media.new(content) }
|
31
|
+
end
|
27
32
|
end
|
28
33
|
|
29
34
|
def formatted_result(response)
|
30
|
-
if !response_empty?(response)
|
31
|
-
|
32
|
-
{ media: Media.new(response.body) }
|
33
|
-
elsif response.content_type == 'application/json'
|
34
|
-
JSON.parse(response.body, symbolize_names: true)
|
35
|
-
else
|
36
|
-
{}
|
37
|
-
end
|
35
|
+
if !response_empty?(response) && recognized_content_type?(response.content_type)
|
36
|
+
format_recognized_content(response.content_type, response.body)
|
38
37
|
else
|
39
38
|
{}
|
40
39
|
end
|
41
40
|
end
|
41
|
+
|
42
|
+
def recognized_content_type?(content_type)
|
43
|
+
RECOGNIZED_CONTENT_TYPES.include? content_type
|
44
|
+
end
|
45
|
+
|
46
|
+
def response_empty?(response)
|
47
|
+
response.body.to_s.empty?
|
48
|
+
end
|
42
49
|
end
|
43
50
|
end
|
data/snapcat.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: snapcat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Neal Kemp
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-12-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httmultiparty
|
@@ -175,7 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
175
175
|
version: '0'
|
176
176
|
requirements: []
|
177
177
|
rubyforge_project:
|
178
|
-
rubygems_version: 2.0.
|
178
|
+
rubygems_version: 2.0.14
|
179
179
|
signing_key:
|
180
180
|
specification_version: 4
|
181
181
|
summary: Ruby wrapper for Snapchat's private API
|