afr_load 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/Gemfile +7 -1
- data/Guardfile +70 -0
- data/lib/afr_load.rb +17 -21
- data/lib/afr_load/parser.rb +10 -10
- data/lib/afr_load/tv_program.rb +3 -13
- data/lib/afr_load/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fdfaced4f770914963c69e14d4f53a111f481ad1
|
4
|
+
data.tar.gz: efa5df0bdb5daa3bb4a97d624555b7e6479b0e31
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9b7820f13aaabfdc10c4b703fdc5a31230abe54fa3278d00d9635997bb36998ed9b3bd0efc86ed19db9e130254b623e7ce5d7a298c298a03db7be5ce7510a2b
|
7
|
+
data.tar.gz: 2f727ae31dc1ade0ac3e2d6c20f64e26e22f9e6e30a4194f8daaa6fe3d00252d5c7481c608e60a22e873f103c70faede09fcef5c867105aa15a969d6cdb37a71
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/Guardfile
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
## Uncomment and set this to only include directories you want to watch
|
5
|
+
# directories %w(app lib config test spec features) \
|
6
|
+
# .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
|
7
|
+
|
8
|
+
## Note: if you are using the `directories` clause above and you are not
|
9
|
+
## watching the project directory ('.'), then you will want to move
|
10
|
+
## the Guardfile to a watched dir and symlink it back, e.g.
|
11
|
+
#
|
12
|
+
# $ mkdir config
|
13
|
+
# $ mv Guardfile config/
|
14
|
+
# $ ln -s config/Guardfile .
|
15
|
+
#
|
16
|
+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
17
|
+
|
18
|
+
# Note: The cmd option is now required due to the increasing number of ways
|
19
|
+
# rspec may be run, below are examples of the most common uses.
|
20
|
+
# * bundler: 'bundle exec rspec'
|
21
|
+
# * bundler binstubs: 'bin/rspec'
|
22
|
+
# * spring: 'bin/rspec' (This will use spring if running and you have
|
23
|
+
# installed the spring binstubs per the docs)
|
24
|
+
# * zeus: 'zeus rspec' (requires the server to be started separately)
|
25
|
+
# * 'just' rspec: 'rspec'
|
26
|
+
|
27
|
+
guard :rspec, cmd: "bundle exec rspec" do
|
28
|
+
require "guard/rspec/dsl"
|
29
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
30
|
+
|
31
|
+
# Feel free to open issues for suggestions and improvements
|
32
|
+
|
33
|
+
# RSpec files
|
34
|
+
rspec = dsl.rspec
|
35
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
36
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
37
|
+
watch(rspec.spec_files)
|
38
|
+
|
39
|
+
# Ruby files
|
40
|
+
ruby = dsl.ruby
|
41
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
42
|
+
|
43
|
+
# Rails files
|
44
|
+
rails = dsl.rails(view_extensions: %w(erb haml slim))
|
45
|
+
dsl.watch_spec_files_for(rails.app_files)
|
46
|
+
dsl.watch_spec_files_for(rails.views)
|
47
|
+
|
48
|
+
watch(rails.controllers) do |m|
|
49
|
+
[
|
50
|
+
rspec.spec.call("routing/#{m[1]}_routing"),
|
51
|
+
rspec.spec.call("controllers/#{m[1]}_controller"),
|
52
|
+
rspec.spec.call("acceptance/#{m[1]}")
|
53
|
+
]
|
54
|
+
end
|
55
|
+
|
56
|
+
# Rails config changes
|
57
|
+
watch(rails.spec_helper) { rspec.spec_dir }
|
58
|
+
watch(rails.routes) { "#{rspec.spec_dir}/routing" }
|
59
|
+
watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
|
60
|
+
|
61
|
+
# Capybara features specs
|
62
|
+
watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
|
63
|
+
watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") }
|
64
|
+
|
65
|
+
# Turnip features and steps
|
66
|
+
watch(%r{^spec/acceptance/(.+)\.feature$})
|
67
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
|
68
|
+
Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
|
69
|
+
end
|
70
|
+
end
|
data/lib/afr_load.rb
CHANGED
@@ -2,45 +2,41 @@
|
|
2
2
|
|
3
3
|
require "oga"
|
4
4
|
require "httpclient"
|
5
|
+
require "byebug"
|
5
6
|
|
6
7
|
require "afr_load/version"
|
7
8
|
require "afr_load/parser.rb"
|
8
9
|
|
9
10
|
module AfrLoad
|
10
11
|
class AfrLoad
|
11
|
-
attr_reader :url, :programs, :document
|
12
|
-
|
13
12
|
AFR_LOAD_URL = "http://www.tv-tokyo.co.jp/telecine/oa_afr_load/"
|
14
13
|
|
15
|
-
|
16
|
-
|
17
|
-
@url = url
|
18
|
-
end
|
14
|
+
attr_accessor :url
|
15
|
+
attr_reader :programs, :document
|
19
16
|
|
20
|
-
def
|
21
|
-
@
|
22
|
-
|
17
|
+
def initialize()
|
18
|
+
@url = AFR_LOAD_URL
|
19
|
+
@programs = Array.new()
|
20
|
+
yield(self) if block_given?
|
23
21
|
end
|
24
22
|
|
25
|
-
def self.get_schedule(
|
26
|
-
afr = self.new(
|
23
|
+
def self.get_schedule()
|
24
|
+
afr = self.new()
|
27
25
|
afr.get_schedule()
|
26
|
+
afr.get_program()
|
28
27
|
end
|
29
28
|
|
30
|
-
def
|
31
|
-
@
|
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)
|
32
36
|
end
|
33
37
|
|
34
38
|
def get_program
|
35
39
|
@programs = Parser.parse(@document).flatten
|
36
40
|
end
|
37
|
-
|
38
|
-
def self.fetch_schedule(url = AFR_LOAD_URL)
|
39
|
-
Oga.parse_html(Enumerator.new do |yielder|
|
40
|
-
HTTPClient.get(url) do |chunk|
|
41
|
-
yielder << chunk.force_encoding("utf-8")
|
42
|
-
end
|
43
|
-
end)
|
44
|
-
end
|
45
41
|
end
|
46
42
|
end
|
data/lib/afr_load/parser.rb
CHANGED
@@ -32,16 +32,16 @@ module AfrLoad
|
|
32
32
|
data_block = movie_node.at_xpath("div[contains(@class, 'g_data_block')]")
|
33
33
|
year_country = data_block.at_xpath("div/span[@class='g_country_year']").text.split("◆")
|
34
34
|
performer = data_block.xpath("div/div/div[2]/span[2]").text
|
35
|
-
tv_program = TvProgram.new
|
36
|
-
on_air_date
|
37
|
-
title_ja
|
38
|
-
title
|
39
|
-
released_year
|
40
|
-
released_country
|
41
|
-
movie_director
|
42
|
-
leading_actor
|
43
|
-
supporting_actor
|
44
|
-
|
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
45
|
end
|
46
46
|
end
|
47
47
|
end
|
data/lib/afr_load/tv_program.rb
CHANGED
@@ -2,24 +2,14 @@
|
|
2
2
|
|
3
3
|
module AfrLoad
|
4
4
|
class TvProgram
|
5
|
-
|
5
|
+
attr_accessor :on_air_date,
|
6
6
|
:title_ja, :title,
|
7
7
|
:released_year, :released_country,
|
8
8
|
:movie_director,
|
9
9
|
:leading_actor, :supporting_actor
|
10
10
|
|
11
|
-
def initialize(
|
12
|
-
|
13
|
-
movie_director:,
|
14
|
-
leading_actor:, supporting_actor:)
|
15
|
-
@on_air_date = on_air_date
|
16
|
-
@title_ja = title_ja
|
17
|
-
@title = title
|
18
|
-
@released_year = released_year
|
19
|
-
@released_country = released_country
|
20
|
-
@movie_director = movie_director
|
21
|
-
@leading_actor = leading_actor
|
22
|
-
@supporting_actor = supporting_actor
|
11
|
+
def initialize()
|
12
|
+
yield(self) if block_given?
|
23
13
|
end
|
24
14
|
|
25
15
|
def show()
|
data/lib/afr_load/version.rb
CHANGED
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.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- iaia
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -92,6 +92,7 @@ files:
|
|
92
92
|
- ".travis.yml"
|
93
93
|
- CODE_OF_CONDUCT.md
|
94
94
|
- Gemfile
|
95
|
+
- Guardfile
|
95
96
|
- README.md
|
96
97
|
- Rakefile
|
97
98
|
- afr_load.gemspec
|
@@ -121,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
122
|
version: '0'
|
122
123
|
requirements: []
|
123
124
|
rubyforge_project:
|
124
|
-
rubygems_version: 2.
|
125
|
+
rubygems_version: 2.6.8
|
125
126
|
signing_key:
|
126
127
|
specification_version: 4
|
127
128
|
summary: Web Scraping for 午後のロードショー
|