redvine 0.0.6 → 0.0.7

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/lib/redvine.rb CHANGED
@@ -47,6 +47,12 @@ class Redvine
47
47
  get_request_data('timelines/users/' + uid, opts)
48
48
  end
49
49
 
50
+ def single_post(pid)
51
+ raise(ArgumentError, 'You must specify a post id') if !pid
52
+ response = get_request_data('/timelines/posts/' + pid)
53
+ return response.kind_of?(Array) ? response.first : response
54
+ end
55
+
50
56
 
51
57
  private
52
58
  def validate_connect_args(opts={})
@@ -68,12 +74,13 @@ class Redvine
68
74
  query.merge!(:size => 20) if query.has_key?(:page) && !query.has_key?(:size)
69
75
  args = {:headers => session_headers}
70
76
  args.merge!(:query => query) if query != {}
71
- response = HTTParty.get(@@baseUrl + endpoint, args)
72
- if response.parsed_response['success'] == false
73
- response.parsed_response['error'] = true
74
- return Hashie::Mash.new(response.parsed_response)
77
+ response = HTTParty.get(@@baseUrl + endpoint, args).parsed_response
78
+ return Hashie::Mash.new(JSON.parse('{"success": false}')) if response.kind_of?(String)
79
+ if response['success'] == false
80
+ response['error'] = true
81
+ return Hashie::Mash.new(response)
75
82
  else
76
- records ? Hashie::Mash.new(response.parsed_response).data.records : Hashie::Mash.new(response.parsed_response).data
83
+ records ? Hashie::Mash.new(response).data.records : Hashie::Mash.new(response).data
77
84
  end
78
85
  end
79
86
 
@@ -1,3 +1,3 @@
1
1
  class Redvine
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
data/spec/redvine_spec.rb CHANGED
@@ -216,6 +216,39 @@ describe Redvine do
216
216
  client = setup_client()
217
217
  vines = client.user_timeline('965095451261071400')
218
218
  expect(vines.success).to be_false
219
+ vines = client.user_timeline('XXX')
220
+ expect(vines.success).to be_false
221
+ end
222
+ end
223
+
224
+ end
225
+
226
+ describe '.single_post' do
227
+
228
+ it 'should respond to a single_post method' do
229
+ expect(Redvine.new).to respond_to(:single_post)
230
+ end
231
+
232
+ it 'should require a post id as an argument' do
233
+ client = Redvine.new
234
+ expect { client.single_post() }.to raise_error(ArgumentError)
235
+ end
236
+
237
+ it 'should return a single media result with a valid post id' do
238
+ VCR.use_cassette('redvine', :record => :new_episodes) do
239
+ client = setup_client()
240
+ vine = client.single_post('1015405623653113856')
241
+ expect(vine.videoUrl).to be_an_instance_of(String)
242
+ end
243
+ end
244
+
245
+ it 'should not break if no post exists with that id' do
246
+ VCR.use_cassette('redvine', :record => :new_episodes) do
247
+ client = setup_client()
248
+ vine = client.single_post('397923400300')
249
+ expect(vine.success).to be_false
250
+ vine2 = client.single_post('XXX')
251
+ expect(vine2.success).to be_false
219
252
  end
220
253
  end
221
254
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redvine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-05 00:00:00.000000000 Z
12
+ date: 2013-11-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty