enklawa 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NGRmMzc5NDJjOWRkM2JlYWQzOTFmNDFmYjE2NDMyMjRhMGU3YzM5ZQ==
4
+ NTM4N2E4MTY4ZmFiYzg1NmRmZjgxYjAzZDk2YzFlMTAwMGM3ZDUwNg==
5
5
  data.tar.gz: !binary |-
6
- MTRjMmFmYzA2ZGI4MzAyYWFhZTI3NTU2MGM1OGUzYTY0NTAwOWE0Mw==
6
+ MWNhYWE5NmI0MDczMmE2YmVlMjZjMWUwODUzOWU0MjU0OTY3MjAzMw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ODY0OTRhYjA4NzFmMDI4YzQ3MTEwYzFhYmU5MzcwNmIwYzQ2YTU2ZTE4NzNm
10
- MDVkZTg4NzFhMzA4ZDIwZjVhOGM0NzA1MzkzYzE1M2JkNzAzODUxMTQ0Nzcy
11
- NjM5NWI4YTFiNDZlMWQxZmY5YTcxNTM4ZTMxNzAxYjNmODE3MjI=
9
+ NmE1YTljNTVhMmRhMWU5YjU0Nzk0ODA3NWFjOTFmODAzMmI0NDkzZGE0YzNh
10
+ NjY2MTFkMWUzYTAwZGUwNmNiYmE5NDE5YjFhZTlmM2UwY2Y3YmRlOGFjMTM4
11
+ OWNlODllZWEwYjk3MmNlNjM2N2NlYmI0ZDY0OWIyZGE1NTJlMTI=
12
12
  data.tar.gz: !binary |-
13
- MmNlZDk1OTZkMWYxZWYxZWU2Zjc4OTU3N2UyYzRjMGRjYjUzMTIzZWZiNGNk
14
- NmE5MTJkYzNjNWFmMTE5NGMzNTMyNjg1NTQzYjRhMDFjMzdjNWQ5ZmZkMTI1
15
- OTMzYzY1OWE4ZmJlNzViMzJjNGFjMTgyNzhjYWVkZWFmNWZlYTE=
13
+ NmFlMjNmM2ExOWQxZGNkNGVjZDc3YzZjOWZmOTFiOTVlMWM3MzZhZjdlODRh
14
+ OGJkYTkyZjM4N2ViZDY5OWRjMTZhMDIyNTk2NWYyZDBlZGEwZmJkMDllMWVi
15
+ MTNhNTNjZDFkZTRiOGRmMzE5ZmVjNTE3YmIwNTVmOWRjMWEyNjU=
@@ -4,6 +4,7 @@ require "enklawa/api/program"
4
4
  require "enklawa/api/category"
5
5
  require "enklawa/api/episode"
6
6
  require "enklawa/api/request"
7
+ require "enklawa/api/forum_thread"
7
8
  require "open-uri"
8
9
  require "nokogiri"
9
10
  require "json"
@@ -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
@@ -4,14 +4,16 @@ require "sanitize"
4
4
  module Enklawa
5
5
  module Api
6
6
  class Request
7
- INFO_XML_URL = "http://www.enklawa.net/info.xml"
8
- MAIN_PAGE_URL = "http://enklawa.net"
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
@@ -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
  }
@@ -1,5 +1,5 @@
1
1
  module Enklawa
2
2
  module Api
3
- VERSION = "0.0.6"
3
+ VERSION = "0.0.7"
4
4
  end
5
5
  end
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.6
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-10 00:00:00.000000000 Z
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