kandianying 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4181cfc366f1cc1f689792160a867bb983f991d9
4
+ data.tar.gz: b65db717527dd283012f36a673e091327326a714
5
+ SHA512:
6
+ metadata.gz: e6daed77e55ec70cbfe9b58de2f0ea9a2f1fcc3bbd61135e44278e973cbd572fd3b665ea135a00e67d7674f807a9e1abe16d798e2962539e6b4ff49bdfc32038
7
+ data.tar.gz: e01da39bbdd68836b4a279c1a062301663f548f58549a69ea5118264457131797029f2aa33491ac1f72ad6b8ad979b43a2c1cc06cf66bda135063cd9559f3b09
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ *.gem
2
+ Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://www.rubygems.org'
2
+
3
+ ruby '2.2.1'
4
+
5
+ gemspec
data/LICENSE ADDED
File without changes
data/README.md ADDED
@@ -0,0 +1 @@
1
+ # Hsinchu_Movie
data/Rakefile ADDED
File without changes
data/bin/kandianying ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../lib/kandianying'
3
+
4
+ movie = HsinChuMovie.new(ARGV[1].to_s)
5
+ movie.movie_table_output
@@ -0,0 +1,24 @@
1
+ $LOAD_PATH.push File.expand_path('../lib', __FILE__)
2
+ require 'kandianying/version'
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = 'kandianying'
6
+ s.version = KanDianYing::VERSION
7
+ s.date = KanDianYing::DATE
8
+ s.executables << 'kandianying'
9
+ s.summary = 'Get movie information in Hsin Chu'
10
+ s.description = 'Get movie information in Hsin Chu'
11
+ s.authors = %w(stonegold546 huangjr pengyuchen stozuka)
12
+ s.email = %w(stonegold546@gmail.com jr@nlplab.cc
13
+ pengyu@gmail.com stozuka@gmail.com)
14
+ s.files = `git ls-files`.split("\n")
15
+ # s.test_files = `git ls-files spec/*`.split("\n")
16
+ s.homepage = 'https://github.com/SOAupstart2/Hsinchu_Movie'
17
+ s.license = 'MIT'
18
+
19
+ # s.add_development_dependency 'minitest'
20
+ # s.add_development_dependency 'minitest-rg'
21
+ # s.add_development_dependency 'vcr'
22
+ # s.add_development_dependency 'webmock'
23
+ s.add_runtime_dependency 'nokogiri'
24
+ end
data/lib/.DS_Store ADDED
Binary file
@@ -0,0 +1,10 @@
1
+ require_relative './kandianying/vieshow'
2
+
3
+ # class for crawling movie information
4
+ class HsinChuMovie
5
+ include VieShow
6
+
7
+ def movie_table_output
8
+ puts to_json
9
+ end
10
+ end
@@ -0,0 +1,5 @@
1
+ # Gem info
2
+ module KanDianYing
3
+ VERSION = '0.0.1'
4
+ DATE = '2015-10-24'
5
+ end
@@ -0,0 +1,56 @@
1
+ require 'open-uri'
2
+ require 'nokogiri'
3
+ require 'json'
4
+
5
+ # Scraper for VieShow
6
+ module VieShow
7
+ # initialize movie_table with url
8
+ def initialize(visCinemaID)
9
+ url = 'http://sales.vscinemas.com.tw/ticketing/visPrintShowTimes.aspx?'\
10
+ 'visCinemaID=' + visCinemaID
11
+ open_doc = open(url, 'Cookie' => 'AspxAutoDetectCookieSupport=1')
12
+ doc = Nokogiri::HTML(open_doc)
13
+ @table = doc.xpath("//*[@class='PrintShowTimesTable']//td"\
14
+ "[@class='PrintShowTimesFilm' "\
15
+ "or @class='PrintShowTimesDay' "\
16
+ "or @class='PrintShowTimesSession']")
17
+ @movie_table = Hash.new { |hash, key| hash[key] = [] }
18
+ make_movie_table
19
+ end
20
+
21
+ # make movie_table like the structure {"name"=>[[day,time],"name2".....}
22
+ def make_movie_table
23
+ current_movie = ''
24
+ @table.each do |td|
25
+ current_movie = movie_conditions(td, current_movie)
26
+ end
27
+ end
28
+
29
+ # make make_movie_table simple
30
+ def movie_conditions(td, current_movie)
31
+ case td.first[1]
32
+ when 'PrintShowTimesFilm'
33
+ current_movie = td.text
34
+ when 'PrintShowTimesDay'
35
+ @movie_table[current_movie] << [td.text]
36
+ when 'PrintShowTimesSession'
37
+ @movie_table[current_movie][-1] << td.text
38
+ end
39
+ current_movie
40
+ end
41
+
42
+ # get all movies' names
43
+ def movie_name
44
+ @movie_table.keys
45
+ end
46
+
47
+ # fetch movie_table
48
+ def movie_table
49
+ @movie_table
50
+ end
51
+
52
+ # get json format from movie_table
53
+ def to_json
54
+ @movie_table.to_json
55
+ end
56
+ end
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kandianying
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - stonegold546
8
+ - huangjr
9
+ - pengyuchen
10
+ - stozuka
11
+ autorequire:
12
+ bindir: bin
13
+ cert_chain: []
14
+ date: 2015-10-24 00:00:00.000000000 Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: nokogiri
18
+ requirement: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ description: Get movie information in Hsin Chu
31
+ email:
32
+ - stonegold546@gmail.com
33
+ - jr@nlplab.cc
34
+ - pengyu@gmail.com
35
+ - stozuka@gmail.com
36
+ executables:
37
+ - kandianying
38
+ extensions: []
39
+ extra_rdoc_files: []
40
+ files:
41
+ - ".gitignore"
42
+ - Gemfile
43
+ - LICENSE
44
+ - README.md
45
+ - Rakefile
46
+ - bin/kandianying
47
+ - kandianying.gemspec
48
+ - lib/.DS_Store
49
+ - lib/kandianying.rb
50
+ - lib/kandianying/version.rb
51
+ - lib/kandianying/vieshow.rb
52
+ homepage: https://github.com/SOAupstart2/Hsinchu_Movie
53
+ licenses:
54
+ - MIT
55
+ metadata: {}
56
+ post_install_message:
57
+ rdoc_options: []
58
+ require_paths:
59
+ - lib
60
+ required_ruby_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ requirements: []
71
+ rubyforge_project:
72
+ rubygems_version: 2.4.6
73
+ signing_key:
74
+ specification_version: 4
75
+ summary: Get movie information in Hsin Chu
76
+ test_files: []