enklawa 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +3 -0
- data/lib/enklawa/api.rb +1 -0
- data/lib/enklawa/api/category.rb +13 -0
- data/lib/enklawa/api/program.rb +2 -1
- data/lib/enklawa/api/request.rb +16 -2
- data/lib/enklawa/api/response.rb +8 -1
- 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
|
+
YWI0YzdjNGNhNmJkY2M0ZTA3ZjdhNDRhNGU0M2E4OWViNzYxOGZiZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MmZkMjgyYTYyMzA4OGNjNWU3M2I4YjAyOGFkZjA4MGJmNjVmZDcwMA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NTNlODU4NDM2YzNkMTAzZDM2NjEzNzhkNWM0NWFiYzgzNGEyMDBiYWRjNTUz
|
10
|
+
OGZlMmExNzY4NDJlOWE5MzA3ZGZiNDQ5NDkxZGZjYzIxYmNjYWVmY2I0NWJi
|
11
|
+
N2UzNDAyNjFiZDBiZWJmYzgzZjhlMTE2NWIxNzk0NTVmMmZlMGI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZjQwY2Y5MDUwYjI3ZDllM2Q5NTM4YTk1ZTI0NTFiZmIxNTg5YThkZmRhYjI1
|
14
|
+
N2YzMGZhMjk1NzIzYjBlYjBkN2IxYWI1ZjAwNmI3YjUzZDlmNmU5MWI0OWZj
|
15
|
+
MWI5MDE4YjAzMGIxMTRlM2I4ZTk5OTYyZTkzZGI2MWY2YTA3Yjc=
|
data/README.md
CHANGED
data/lib/enklawa/api.rb
CHANGED
data/lib/enklawa/api/program.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Enklawa
|
2
2
|
module Api
|
3
|
-
class Program < Struct.new(:id, :name, :description, :author, :live)
|
3
|
+
class Program < Struct.new(:id, :name, :description, :author, :live, :category_id)
|
4
4
|
attr_accessor :episodes
|
5
5
|
|
6
6
|
def initialize
|
@@ -28,6 +28,7 @@ module Enklawa
|
|
28
28
|
live: live,
|
29
29
|
image: image,
|
30
30
|
feed_url: feed_url,
|
31
|
+
category_id: category_id,
|
31
32
|
episodes: episodes.map(&:to_h)
|
32
33
|
}
|
33
34
|
end
|
data/lib/enklawa/api/request.rb
CHANGED
@@ -4,14 +4,15 @@ require "sanitize"
|
|
4
4
|
module Enklawa
|
5
5
|
module Api
|
6
6
|
class Request
|
7
|
-
INFO_XML_URL
|
8
|
-
|
7
|
+
INFO_XML_URL = "http://www.enklawa.net/info.xml"
|
8
|
+
MAIN_PAGE_URL = "http://enklawa.net"
|
9
9
|
def initialize
|
10
10
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def get!
|
14
14
|
@response = Response.new
|
15
|
+
get_categories!
|
15
16
|
get_info!
|
16
17
|
get_programs!
|
17
18
|
get_episodes!
|
@@ -21,6 +22,18 @@ module Enklawa
|
|
21
22
|
|
22
23
|
private
|
23
24
|
|
25
|
+
def get_categories!
|
26
|
+
doc = Nokogiri::HTML(open(MAIN_PAGE_URL))
|
27
|
+
|
28
|
+
doc.search("select#ProgramsSelector option").each do |option|
|
29
|
+
category = Category.new
|
30
|
+
category.name = option.text
|
31
|
+
category.id = option[:value].to_i
|
32
|
+
|
33
|
+
@response.add_category(category)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
24
37
|
def get_info!
|
25
38
|
@info_xml_doc = Nokogiri::XML(open(INFO_XML_URL).read)
|
26
39
|
|
@@ -38,6 +51,7 @@ module Enklawa
|
|
38
51
|
program.name = program_node.search("name").text
|
39
52
|
program.description = program_node.search("description").text
|
40
53
|
program.author = program_node.search("author").text
|
54
|
+
program.category_id = program_node.search("cat").text.to_i
|
41
55
|
program.live = program_node.search("live").size > 0
|
42
56
|
@response.programs << program
|
43
57
|
end
|
data/lib/enklawa/api/response.rb
CHANGED
@@ -4,7 +4,8 @@ module Enklawa
|
|
4
4
|
attr_accessor :skype, :phone, :radio
|
5
5
|
|
6
6
|
def initialize
|
7
|
-
@programs
|
7
|
+
@programs = []
|
8
|
+
@categories = []
|
8
9
|
end
|
9
10
|
|
10
11
|
def programs
|
@@ -15,11 +16,17 @@ module Enklawa
|
|
15
16
|
@programs << program
|
16
17
|
end
|
17
18
|
|
19
|
+
def add_category(category)
|
20
|
+
@categories << category
|
21
|
+
end
|
22
|
+
|
18
23
|
def to_h
|
19
24
|
{
|
25
|
+
version: VERSION,
|
20
26
|
skype: skype,
|
21
27
|
phone: phone,
|
22
28
|
radio: radio,
|
29
|
+
categories: @categories.map(&:to_h),
|
23
30
|
programs: @programs.map(&:to_h)
|
24
31
|
}
|
25
32
|
end
|
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.3
|
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-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -182,6 +182,7 @@ files:
|
|
182
182
|
- bin/enklawa
|
183
183
|
- enklawa-api.gemspec
|
184
184
|
- lib/enklawa/api.rb
|
185
|
+
- lib/enklawa/api/category.rb
|
185
186
|
- lib/enklawa/api/episode.rb
|
186
187
|
- lib/enklawa/api/program.rb
|
187
188
|
- lib/enklawa/api/request.rb
|