active_public_resources 0.2.3 → 0.2.4

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: 07d3ce1f36d3fa7105c64a1b3ea1d40d31d53a80
4
- data.tar.gz: dc691ba007d31feedd149d2e61af45caddbfa160
3
+ metadata.gz: 750a849ad37794a269bab5b663992a2ee9101a10
4
+ data.tar.gz: 17a0f5735242ebd52b93b020a3deb4a931ae3376
5
5
  SHA512:
6
- metadata.gz: 5ac6ae00e93f87bb890ae4ef42b883f54dec4219da4484b72177011c70f5e367a30b0173366b1a0ca5bb335093b9ff79ecf12bcbd45fce79ef0b2a91263bdb16
7
- data.tar.gz: 4c7985ebe114f26c931abba3f162c305211a395caacfb7836c8df12f35d7ad25b6028e9e076d0c875ab343914a22540d969990d3c5654e9bae0150b4ded1cf14
6
+ metadata.gz: d859e2ffb42e9b9dfa2b0e2bca4401de468d0e5aa34aeeb65e90b5a622436af796fadfe6014c1104b45fd12bdf10b77f10e032c8cd4c205f62aff20977b0e37d
7
+ data.tar.gz: 9953aebb19aa8ea776f35d8b98e74d4e90115781f0cb8f8e47390baa67965231be473f841b4047dde577fadb4d7fa495d99bb0259dd66838d4f16a37713f55c5
@@ -18,21 +18,21 @@ module ActivePublicResources
18
18
  def perform_request(request_criteria)
19
19
  request_criteria.set_default_criteria!(@default_request_criteria)
20
20
  unless request_criteria.validate_presence(:query) || request_criteria.validate_presence(:channel)
21
- raise ArgumentError "you must specify at least a query or a channel"
21
+ raise ArgumentError "You must specify at least a query or channel"
22
22
  end
23
23
 
24
24
  uri = URI('https://www.googleapis.com/youtube/v3/search')
25
25
  params = {
26
- 'q' => request_criteria.query,
27
- 'part' => 'snippet',
28
- 'type' => 'video',
29
- 'order' => sort(request_criteria.sort),
30
- 'safeSearch' => content_filter(request_criteria.content_filter),
31
- 'maxResults' => request_criteria.per_page || 25,
32
- 'key' => API_KEY
26
+ q: request_criteria.query,
27
+ part: 'snippet',
28
+ type: 'video',
29
+ order: sort(request_criteria.sort),
30
+ safeSearch: content_filter(request_criteria.content_filter),
31
+ maxResults: request_criteria.per_page || 25,
32
+ key: API_KEY
33
33
  }
34
34
 
35
- params['pageToken'] = request_criteria.page if request_criteria.is_a? String
35
+ params['pageToken'] = request_criteria.page if request_criteria.page && request_criteria.page != 1
36
36
  params['userIp'] = request_criteria.remote_ip if request_criteria.remote_ip
37
37
  params['channelId'] = channel_id(request_criteria.channel_name) if channel_id(request_criteria.channel_name)
38
38
 
@@ -50,10 +50,10 @@ module ActivePublicResources
50
50
  if channel_name
51
51
  uri = URI('https://www.googleapis.com/youtube/v3/search')
52
52
  params = {
53
- 'q' => channel_name,
54
- 'part' => 'id',
55
- 'type' => 'channel',
56
- 'key' => API_KEY
53
+ q: channel_name,
54
+ part: 'id',
55
+ type: 'channel',
56
+ key: API_KEY
57
57
  }
58
58
  uri.query = URI.encode_www_form(params)
59
59
  res = Net::HTTP.get_response(uri)
@@ -64,7 +64,6 @@ module ActivePublicResources
64
64
  return false
65
65
  end
66
66
 
67
-
68
67
  def video_details(request_criteria, results)
69
68
  video_ids = results['items'].map { |item| item['id']['videoId']}
70
69
  uri = URI('https://www.googleapis.com/youtube/v3/videos')
@@ -101,25 +100,23 @@ module ActivePublicResources
101
100
 
102
101
  def parse_results(request_criteria, results, videos)
103
102
  @driver_response = DriverResponse.new(
104
- :criteria => request_criteria,
105
- :next_criteria => next_criteria(request_criteria, results),
106
- :total_items => results['pageInfo']['totalResults'].to_i,
107
- :items => videos.map { |video| parse_video(video) }
103
+ criteria: request_criteria,
104
+ next_criteria: next_criteria(request_criteria, results),
105
+ total_items: results['pageInfo']['totalResults'].to_i,
106
+ items: videos.map { |video| parse_video(video) }
108
107
  )
109
108
  end
110
109
 
111
110
  def next_criteria(request_criteria, results)
112
111
  if results['nextPageToken']
113
112
  return RequestCriteria.new({
114
- :query => request_criteria.query,
115
- :page => results['nextPageToken'],
116
- :per_page => results['pageInfo']['resultsPerPage'].to_i
113
+ query: request_criteria.query,
114
+ page: results['nextPageToken'],
115
+ per_page: results['pageInfo']['resultsPerPage'].to_i
117
116
  })
118
117
  end
119
118
  end
120
119
 
121
-
122
-
123
120
  def parse_video(item)
124
121
  video_id = item['id']
125
122
  snippet = item['snippet']
@@ -143,20 +140,20 @@ module ActivePublicResources
143
140
 
144
141
  # Return Types
145
142
  video.return_types << APR::ReturnTypes::Url.new(
146
- :driver => DRIVER_NAME,
147
- :remote_id => video.id,
148
- :url => video.url,
149
- :text => video.title,
150
- :title => video.title
143
+ driver: DRIVER_NAME,
144
+ remote_id: video.id,
145
+ url: video.url,
146
+ text: video.title,
147
+ title: video.title
151
148
  )
152
149
  video.return_types << APR::ReturnTypes::Iframe.new(
153
- :driver => DRIVER_NAME,
154
- :remote_id => video.id,
155
- :url => video.embed_url,
156
- :text => video.title,
157
- :title => video.title,
158
- :width => 640,
159
- :height => 360
150
+ driver: DRIVER_NAME,
151
+ remote_id: video.id,
152
+ url: video.embed_url,
153
+ text: video.title,
154
+ title: video.title,
155
+ width: 640,
156
+ height: 360
160
157
  )
161
158
 
162
159
  video
@@ -1,3 +1,3 @@
1
1
  module ActivePublicResources
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_public_resources
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Berry
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-26 00:00:00.000000000 Z
11
+ date: 2017-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport