enklawa 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.
- checksums.yaml +8 -8
- data/lib/enklawa/api.rb +1 -0
- data/lib/enklawa/api/forum_thread.rb +17 -0
- data/lib/enklawa/api/request.rb +20 -3
- data/lib/enklawa/api/response.rb +6 -0
- data/lib/enklawa/api/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NTM4N2E4MTY4ZmFiYzg1NmRmZjgxYjAzZDk2YzFlMTAwMGM3ZDUwNg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MWNhYWE5NmI0MDczMmE2YmVlMjZjMWUwODUzOWU0MjU0OTY3MjAzMw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NmE1YTljNTVhMmRhMWU5YjU0Nzk0ODA3NWFjOTFmODAzMmI0NDkzZGE0YzNh
|
10
|
+
NjY2MTFkMWUzYTAwZGUwNmNiYmE5NDE5YjFhZTlmM2UwY2Y3YmRlOGFjMTM4
|
11
|
+
OWNlODllZWEwYjk3MmNlNjM2N2NlYmI0ZDY0OWIyZGE1NTJlMTI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NmFlMjNmM2ExOWQxZGNkNGVjZDc3YzZjOWZmOTFiOTVlMWM3MzZhZjdlODRh
|
14
|
+
OGJkYTkyZjM4N2ViZDY5OWRjMTZhMDIyNTk2NWYyZDBlZGEwZmJkMDllMWVi
|
15
|
+
MTNhNTNjZDFkZTRiOGRmMzE5ZmVjNTE3YmIwNTVmOWRjMWEyNjU=
|
data/lib/enklawa/api.rb
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
module Enklawa
|
2
|
+
module Api
|
3
|
+
class ForumThread < Struct.new(:id, :title, :content, :pub_date, :link)
|
4
|
+
|
5
|
+
def to_h
|
6
|
+
{
|
7
|
+
id: id,
|
8
|
+
title: title,
|
9
|
+
content: content,
|
10
|
+
pub_date: pub_date.utc.iso8601,
|
11
|
+
link: link
|
12
|
+
}
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/enklawa/api/request.rb
CHANGED
@@ -4,14 +4,16 @@ require "sanitize"
|
|
4
4
|
module Enklawa
|
5
5
|
module Api
|
6
6
|
class Request
|
7
|
-
INFO_XML_URL
|
8
|
-
MAIN_PAGE_URL
|
7
|
+
INFO_XML_URL = "http://www.enklawa.net/info.xml"
|
8
|
+
MAIN_PAGE_URL = "http://enklawa.net"
|
9
|
+
FORUM_FEED_URL = "http://forum.enklawa.net/feed.php"
|
9
10
|
def initialize
|
10
11
|
|
11
12
|
end
|
12
13
|
|
13
14
|
def get!
|
14
15
|
@response = Response.new
|
16
|
+
get_forum_feeds!
|
15
17
|
get_categories!
|
16
18
|
get_info!
|
17
19
|
get_programs!
|
@@ -29,7 +31,7 @@ module Enklawa
|
|
29
31
|
category = Category.new
|
30
32
|
category.name = option.text
|
31
33
|
category.id = option[:value].to_i
|
32
|
-
|
34
|
+
|
33
35
|
@response.add_category(category)
|
34
36
|
end
|
35
37
|
end
|
@@ -69,6 +71,21 @@ module Enklawa
|
|
69
71
|
@response.programs.reject! { |program| program.episodes.empty? }
|
70
72
|
end
|
71
73
|
|
74
|
+
def get_forum_feeds!
|
75
|
+
feed = Feedjira::Feed.fetch_and_parse(FORUM_FEED_URL)
|
76
|
+
return if feed == 404
|
77
|
+
|
78
|
+
feed.entries.each do |entry|
|
79
|
+
thread = ForumThread.new
|
80
|
+
thread.id = entry.id
|
81
|
+
thread.title = entry.title
|
82
|
+
thread.link = entry.url
|
83
|
+
thread.content = entry.content
|
84
|
+
thread.pub_date = entry.published
|
85
|
+
@response.add_thread(thread)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
72
89
|
def build_episode_from_entry(entry, program)
|
73
90
|
episode = Episode.new
|
74
91
|
episode.id = entry.id
|
data/lib/enklawa/api/response.rb
CHANGED
@@ -5,6 +5,7 @@ module Enklawa
|
|
5
5
|
|
6
6
|
def initialize
|
7
7
|
@programs = []
|
8
|
+
@threads = []
|
8
9
|
@categories = []
|
9
10
|
end
|
10
11
|
|
@@ -20,12 +21,17 @@ module Enklawa
|
|
20
21
|
@categories << category
|
21
22
|
end
|
22
23
|
|
24
|
+
def add_thread(category)
|
25
|
+
@threads << category
|
26
|
+
end
|
27
|
+
|
23
28
|
def to_h
|
24
29
|
{
|
25
30
|
version: VERSION,
|
26
31
|
skype: skype,
|
27
32
|
phone: phone,
|
28
33
|
radio: radio,
|
34
|
+
forum: @threads.map(&:to_h),
|
29
35
|
categories: @categories.map(&:to_h),
|
30
36
|
programs: @programs.map(&:to_h)
|
31
37
|
}
|
data/lib/enklawa/api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: enklawa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arkadiusz Buras
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -184,6 +184,7 @@ files:
|
|
184
184
|
- lib/enklawa/api.rb
|
185
185
|
- lib/enklawa/api/category.rb
|
186
186
|
- lib/enklawa/api/episode.rb
|
187
|
+
- lib/enklawa/api/forum_thread.rb
|
187
188
|
- lib/enklawa/api/program.rb
|
188
189
|
- lib/enklawa/api/request.rb
|
189
190
|
- lib/enklawa/api/response.rb
|