boxspring 0.0.3 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8cc9d3cfbbce05c4b5efe672a7b694189685af1b
4
- data.tar.gz: a2ce99f4d150b42a5d6d6aed1a8a941cd2a03cb6
3
+ metadata.gz: 679f26a51cb69b455bd097b1fcfbdd32f0dfe9e7
4
+ data.tar.gz: 5d89c2bb387be76e3a71a1747cd2b29d7b16df39
5
5
  SHA512:
6
- metadata.gz: 4853f2beffd0b9a8f410d6ba7a21b83dc5486da98f76ae8a3705942f72eee43762e041b04298e4dddc0faaa529d14deafc61177b7e8c4be58e96432d4951dcae
7
- data.tar.gz: 51b8318aee2f792dde22f5f5f52d211dc13c53646732fa2332b114243ed421befb65a02cb65cacaddeebcbdab607898c6c9bb671f9629a7671446b6b47b4eae2
6
+ metadata.gz: 0110905ac756256abfd2b2e25a08c5cf34fc2b2991056f47ce26495f6cb247f92c962e97ce93da9a2fab0334fdc780d998f98f8f93e6fbe41d60fe450db66fd5
7
+ data.tar.gz: f9ff213556dc2ebdb9748d5ec02b989e5e5b5ab7f37f9a4104f6f9617e462e53932b7311ee80459431a56565f88550f79433e0d3273622772f0905873a6b748f
@@ -2,6 +2,8 @@ module Boxspring
2
2
 
3
3
  class Attribution < Base
4
4
 
5
+ include Taggable
6
+
5
7
  field :created_at
6
8
  field :updated_at
7
9
 
@@ -99,7 +99,7 @@ module Boxspring
99
99
  end
100
100
  end
101
101
 
102
- def videos( parameters )
102
+ def videos( parameters = {} )
103
103
  response = @api_interface.get( "/videos", parameters )
104
104
  if ( response.success? )
105
105
  response.content.map do | video |
@@ -112,6 +112,19 @@ module Boxspring
112
112
  end
113
113
  end
114
114
 
115
+ def shows_videos( parameters = {} )
116
+ response = @api_interface.get( "/shows/videos", parameters )
117
+ if ( response.success? )
118
+ response.content.map do | video |
119
+ Video.new( video )
120
+ end
121
+ elsif ( response.code == '404' )
122
+ nil
123
+ else
124
+ raise response.error
125
+ end
126
+ end
127
+
115
128
  def video_by_id( id )
116
129
  response = @api_interface.get( "/videos/#{id}" )
117
130
  if ( response.success? )
@@ -1,4 +1,5 @@
1
1
  require 'net/https'
2
+ require 'addressable/uri'
2
3
 
3
4
  module Boxspring
4
5
 
@@ -31,9 +32,7 @@ module Boxspring
31
32
  Response.new( @http.get( compose_request_path( path, parameters ) ) )
32
33
 
33
34
  rescue Timeout::Error
34
-
35
35
  response = nil
36
-
37
36
  end
38
37
 
39
38
  response
@@ -53,13 +52,15 @@ module Boxspring
53
52
  end
54
53
 
55
54
  response =
56
- Response.new( @http.post( compose_request_path( path ),
57
- data.join( '&' ) ) )
55
+ Response.new(
56
+ @http.post(
57
+ compose_request_path( path ),
58
+ data.join( '&' )
59
+ )
60
+ )
58
61
 
59
62
  rescue Timeout::Error
60
-
61
63
  response = nil
62
-
63
64
  end
64
65
 
65
66
  response
@@ -67,29 +68,15 @@ module Boxspring
67
68
  end
68
69
 
69
70
  protected; def compose_request_path( path, parameters = {} )
70
-
71
- # the query
72
- query = ""
73
71
 
74
- # url encode the parameters
75
- ( @default_parameters.merge( parameters.stringify_keys ) ).each do | key, value |
76
- query << "#{key}=#{value}&"
77
- end
78
-
79
- # chop the trailing '&'
80
- query.chop!
81
-
82
- # does path include parameters?
83
- unless path.include?( '?' )
84
- # if not, append the query to the url
85
- path = path + '?' + query
86
- else
87
- # if so, append the query to the existing query
88
- path = path + '&' + query
89
- end
72
+ addressable = Addressable::URI.new
90
73
 
91
- path
92
-
74
+ addressable.path = path
75
+ addressable.query =
76
+ @default_parameters.merge( parameters.stringify_keys ).to_param
77
+
78
+ addressable.to_s
79
+
93
80
  end
94
81
 
95
82
  end
@@ -2,6 +2,8 @@ module Boxspring
2
2
 
3
3
  class Show < Base
4
4
 
5
+ include Taggable
6
+
5
7
  field :created_at
6
8
  field :updated_at
7
9
  field :published_at
@@ -2,6 +2,8 @@ module Boxspring
2
2
 
3
3
  class TagCollection < Base
4
4
 
5
+ include Taggable
6
+
5
7
  field :created_at
6
8
  field :updated_at
7
9
 
@@ -9,16 +11,6 @@ module Boxspring
9
11
  field :code_name
10
12
  field :name
11
13
 
12
- def tags
13
- @_tags ||= begin
14
- self.attributes.include?( :tags ) ?
15
- self.attributes[ :tags ].map do | tag |
16
- Tag.new( tag )
17
- end :
18
- nil
19
- end
20
- end
21
-
22
14
  end
23
15
 
24
16
  end
@@ -0,0 +1,17 @@
1
+ module Boxspring
2
+
3
+ module Taggable
4
+
5
+ def tags
6
+ @_tags ||= begin
7
+ self.attributes.include?( :tags ) ?
8
+ self.attributes[ :tags ].map do | tag |
9
+ Tag.new( tag )
10
+ end :
11
+ nil
12
+ end
13
+ end
14
+
15
+ end
16
+
17
+ end
@@ -1,3 +1,3 @@
1
1
  module Boxspring
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.5'
3
3
  end
@@ -2,6 +2,8 @@ module Boxspring
2
2
 
3
3
  class Video < Base
4
4
 
5
+ include Taggable
6
+
5
7
  field :created_at
6
8
  field :updated_at
7
9
  field :uploaded_at
@@ -40,6 +42,14 @@ module Boxspring
40
42
  field :react_actions_counts
41
43
  field :views_count
42
44
 
45
+ def show
46
+ @_show ||= begin
47
+ self.attributes.include?( :show ) ?
48
+ Show.new( show ) :
49
+ nil
50
+ end
51
+ end
52
+
43
53
  end
44
54
 
45
55
  end
data/lib/boxspring.rb CHANGED
@@ -7,9 +7,10 @@ require 'boxspring/response'
7
7
  require 'boxspring/request'
8
8
 
9
9
  require 'boxspring/base'
10
+ require 'boxspring/tag'
11
+ require 'boxspring/taggable'
10
12
  require 'boxspring/attribution'
11
13
  require 'boxspring/show'
12
- require 'boxspring/tag'
13
14
  require 'boxspring/tag_collection'
14
15
  require 'boxspring/user_agent'
15
16
  require 'boxspring/theme_environment'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: boxspring
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kristoph Cichocki-Romanov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-07 00:00:00.000000000 Z
11
+ date: 2014-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -84,6 +84,7 @@ files:
84
84
  - lib/boxspring/show.rb
85
85
  - lib/boxspring/tag.rb
86
86
  - lib/boxspring/tag_collection.rb
87
+ - lib/boxspring/taggable.rb
87
88
  - lib/boxspring/theme.rb
88
89
  - lib/boxspring/theme_environment.rb
89
90
  - lib/boxspring/user_agent.rb