afr_load 0.1.6 → 0.1.7

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: 04d01c44ccf97a3ad67fd6af23abaa8c24894e02
4
- data.tar.gz: 99ac4b134e24bb1246a98cdb7a53e4ff02c6516f
3
+ metadata.gz: 7cb1b1a9b4ae65c727b920d48bf19f6411b95066
4
+ data.tar.gz: 5207fc38ef56c79c1a7b8be94731117a696e7937
5
5
  SHA512:
6
- metadata.gz: dfbe32ce4d349466311861766b2a368c2c887b0d4d79b170f55a9ec0479156c3f2d869783b378d3c37582344e692be1777fb491dbca2eb2653e3d6af0a4f9e0a
7
- data.tar.gz: 9e10e57b40ca4d5faf6f629cde759345717bbfc10d8e5d92c6823cf9a6c45a1d5b83765f7b252a41e818b27ce31ede48f7222377d6d5a83441f85c903ece8beb
6
+ metadata.gz: 2356c23ebde539fea0af7cbcd46e07a4d741704fab4c5cb855925752386b8eb7ba8018eaa4d9175d62af4d3d589cd4ee0cf2d0b04a6802bb836ba07ea7f4b216
7
+ data.tar.gz: 3b71c9220a6ec11fdc412146e8fc10dcf4b1162dec13ca1b2dc3a53d6b0fa15365f5a5e8569b0ee97fb6d4e6d6a64de4544029c8e2734deacfccbb9295d38a90
@@ -3,47 +3,50 @@
3
3
  require "afr_load/tv_program"
4
4
 
5
5
  module AfrLoad
6
- module Parser
7
- class << self
8
- def parse(document)
9
- month_lineup_doc = get_month_lineup(document)
10
- month_lineup_doc.map do |lineup|
11
- parse_month_lineup(lineup)
12
- end
13
- end
6
+ module Parser
7
+ class << self
8
+ def parse(document)
9
+ month_lineup_doc = get_month_lineup(document)
10
+ month_lineup_doc.map do |lineup|
11
+ parse_month_lineup(lineup)
12
+ end
13
+ end
14
+
15
+ def get_month_lineup(document)
16
+ document.xpath("//div[@id='contents']/div").select do |contents_child|
17
+ is_month_lineup(contents_child)
18
+ end
19
+ end
14
20
 
15
- def get_month_lineup(document)
16
- document.xpath("//div[@id='contents']/div").select do |contents_child|
17
- is_month_lineup(contents_child)
18
- end
19
- end
20
-
21
- def is_month_lineup(contents_child)
22
- return false if contents_child.attribute("id") == nil
23
- if contents_child.attribute("id").value =~ /[0-9]{6}/
24
- true
25
- else
26
- false
27
- end
28
- end
21
+ def is_month_lineup(contents_child)
22
+ return false if contents_child.attribute("id") == nil
23
+ if contents_child.attribute("id").value =~ /[0-9]{6}/
24
+ true
25
+ else
26
+ false
27
+ end
28
+ end
29
29
 
30
- def parse_month_lineup(contents_child)
31
- contents_child.xpath("//div/div[@class='gogo_item']").map do |movie_node|
32
- data_block = movie_node.at_xpath("div[contains(@class, 'g_data_block')]")
33
- year_country = data_block.at_xpath("div/span[@class='g_country_year']").text.split("◆")
34
- performer = data_block.xpath("div/div/div[2]/span[2]").text
35
- tv_program = TvProgram.new do |info|
36
- info.on_air_date = movie_node.at_xpath("span[contains(@class, 'g_day')]").text
37
- info.title_ja = data_block.at_xpath("h3/span[@class='jp']").text
38
- info.title = data_block.at_xpath("h3/span[contains(@class, 'en')]").text
39
- info.released_year = year_country[0]
40
- info.released_country = year_country[1]
41
- info.movie_director = data_block.xpath("div/div/div[1]/span[2]").text
42
- info.leading_actor = performer.split("/")[0]
43
- info.supporting_actor = performer.split("/")[1]
44
- end
45
- end
46
- end
30
+ def parse_month_lineup(contents_child)
31
+ contents_child.xpath("//div/div[@class='gogo_item']").map do |movie_node|
32
+ data_block = movie_node.at_xpath("div[contains(@class, 'g_data_block')]")
33
+ year_country = data_block.at_xpath("div/span[@class='g_country_year']").text.split("◆")
34
+ performer = data_block.xpath("div/div/div[2]/span[2]").text
35
+ tv_program = TvProgram.new do |info|
36
+ #<div class="gogo_item" data-oaStart="2017053113350000" data-oaEnd="2017053115400000">
37
+ info.on_air_start = movie_node.get("data-oaStart")
38
+ info.on_air_end = movie_node.get("data-oaEnd")
39
+ info.on_air_date = movie_node.at_xpath("span[contains(@class, 'g_day')]").text
40
+ info.title_ja = data_block.at_xpath("h3/span[@class='jp']").text
41
+ info.title = data_block.at_xpath("h3/span[contains(@class, 'en')]").text
42
+ info.released_year = year_country[0]
43
+ info.released_country = year_country[1]
44
+ info.movie_director = data_block.xpath("div/div/div[1]/span[2]").text
45
+ info.leading_actor = performer.split("/")[0]
46
+ info.supporting_actor = performer.split("/")[1]
47
+ end
47
48
  end
49
+ end
48
50
  end
51
+ end
49
52
  end
@@ -1,28 +1,25 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module AfrLoad
4
- class TvProgram
5
- attr_accessor :on_air_date,
6
- :title_ja, :title,
7
- :released_year, :released_country,
8
- :movie_director,
9
- :leading_actor, :supporting_actor
4
+ class TvProgram
5
+ attr_accessor :on_air_date,
6
+ :on_air_start, :on_air_end,
7
+ :title_ja, :title,
8
+ :released_year, :released_country,
9
+ :movie_director,
10
+ :leading_actor, :supporting_actor
10
11
 
11
- def initialize()
12
- yield(self) if block_given?
13
- end
12
+ def initialize()
13
+ yield(self) if block_given?
14
+ end
14
15
 
15
- def show()
16
- puts <<"EOS"
17
- on_air_date: #{@on_air_date}, \
18
- title_ja: #{@title_ja}, \
19
- title: #{@title}, \
20
- released_year: #{@released_year}, \
21
- released_country: #{@released_country}, \
22
- movie_director: #{@movie_director}, \
23
- leading_actor: #{@leading_actor}, \
24
- supporting_actor: #{@supporting_actor}
25
- EOS
26
- end
16
+ def show()
17
+ instance_variables.each do |var|
18
+ k = var.to_s.tr("@","")
19
+ v = instance_variable_get(var)
20
+ print "#{k}: #{v}, "
21
+ end
22
+ puts
27
23
  end
24
+ end
28
25
  end
@@ -1,3 +1,3 @@
1
1
  module AfrLoad
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
data/lib/afr_load.rb CHANGED
@@ -3,40 +3,41 @@
3
3
  require "oga"
4
4
  require "httpclient"
5
5
 
6
+ require "bundler"
6
7
  Bundler.require(:default, :development)
7
8
  require "afr_load/version"
8
9
  require "afr_load/parser.rb"
9
10
 
10
11
  module AfrLoad
11
- class AfrLoad
12
- AFR_LOAD_URL = "http://www.tv-tokyo.co.jp/telecine/oa_afr_load/"
13
-
14
- attr_accessor :url
15
- attr_reader :programs, :document
16
-
17
- def initialize()
18
- @url = AFR_LOAD_URL
19
- @programs = Array.new()
20
- yield(self) if block_given?
21
- end
22
-
23
- def self.get_schedule()
24
- afr = self.new()
25
- afr.get_schedule()
26
- afr.get_program()
27
- end
28
-
29
- def get_schedule()
30
- if @url.start_with?("http")
31
- body = HTTPClient.get(@url).body.force_encoding("utf-8")
32
- else
33
- body = File.open(@url).read
34
- end
35
- @document = Oga.parse_html(body)
36
- end
37
-
38
- def get_program
39
- @programs = Parser.parse(@document).flatten
40
- end
12
+ class AfrLoad
13
+ AFR_LOAD_URL = "http://www.tv-tokyo.co.jp/telecine/oa_afr_load/"
14
+
15
+ attr_accessor :url
16
+ attr_reader :programs, :document
17
+
18
+ def initialize()
19
+ @url = AFR_LOAD_URL
20
+ @programs = Array.new()
21
+ yield(self) if block_given?
22
+ end
23
+
24
+ def self.get_schedule()
25
+ afr = self.new()
26
+ afr.get_schedule()
27
+ afr.get_program()
28
+ end
29
+
30
+ def get_schedule()
31
+ if @url.start_with?("http")
32
+ body = HTTPClient.get(@url).body.force_encoding("utf-8")
33
+ else
34
+ body = File.open(@url).read
35
+ end
36
+ @document = Oga.parse_html(body)
37
+ end
38
+
39
+ def get_program
40
+ @programs = Parser.parse(@document).flatten
41
41
  end
42
+ end
42
43
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: afr_load
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - iaia
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-25 00:00:00.000000000 Z
11
+ date: 2017-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler