yamwow 0.0.7 → 0.0.8
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/yamwow/facade.rb +6 -0
- data/lib/yamwow/topics_request.rb +50 -0
- data/lib/yamwow/topics_response.rb +11 -0
- data/lib/yamwow.rb +1 -2
- metadata +6 -4
data/lib/yamwow/facade.rb
CHANGED
@@ -23,6 +23,12 @@ module YamWow
|
|
23
23
|
response.topic
|
24
24
|
end
|
25
25
|
|
26
|
+
def topics
|
27
|
+
request = TopicsRequest.new @client
|
28
|
+
response = request.send
|
29
|
+
response.topics
|
30
|
+
end
|
31
|
+
|
26
32
|
def group(group_name)
|
27
33
|
request = GroupRequest.new @client, group_name
|
28
34
|
response = request.send
|
@@ -0,0 +1,50 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
require_relative 'topic'
|
4
|
+
require_relative 'topics_response'
|
5
|
+
|
6
|
+
module YamWow
|
7
|
+
class TopicsRequest
|
8
|
+
|
9
|
+
def initialize(client)
|
10
|
+
@client = client
|
11
|
+
end
|
12
|
+
|
13
|
+
def send
|
14
|
+
@topics = []
|
15
|
+
process_range '0', '9'
|
16
|
+
process_range 'a', 'z'
|
17
|
+
build_response
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def process_range(first, last)
|
23
|
+
(first..last).each do |current|
|
24
|
+
response_data = send_autocomplete_request current
|
25
|
+
topics_data = response_data['topics'] || []
|
26
|
+
topics = topics_data.map { |t| build_topic t }
|
27
|
+
@topics += topics
|
28
|
+
process_range current + first, current + last if topics.length == 50
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def send_autocomplete_request(prefix)
|
33
|
+
@client.get_autocomplete prefix: prefix.downcase
|
34
|
+
end
|
35
|
+
|
36
|
+
def build_response
|
37
|
+
topics = @topics.uniq { |t| t.id }
|
38
|
+
topics = topics.sort { |x, y| x.name.downcase <=> y.name.downcase }
|
39
|
+
TopicsResponse.new topics
|
40
|
+
end
|
41
|
+
|
42
|
+
def build_topic(topic_data)
|
43
|
+
t = Topic.new
|
44
|
+
t.id = topic_data['id']
|
45
|
+
t.name = topic_data['name']
|
46
|
+
t
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
data/lib/yamwow.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yamwow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-02-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: yam
|
16
|
-
requirement: &
|
16
|
+
requirement: &70341913725080 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70341913725080
|
25
25
|
description:
|
26
26
|
email: matthew-github@matthewriley.name
|
27
27
|
executables: []
|
@@ -45,6 +45,8 @@ files:
|
|
45
45
|
- lib/yamwow/topic.rb
|
46
46
|
- lib/yamwow/topic_request.rb
|
47
47
|
- lib/yamwow/topic_response.rb
|
48
|
+
- lib/yamwow/topics_request.rb
|
49
|
+
- lib/yamwow/topics_response.rb
|
48
50
|
- lib/yamwow/user.rb
|
49
51
|
- lib/yamwow.rb
|
50
52
|
homepage: http://rubygems.org/gems/yamwow
|