uec_express_api 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +22 -0
- data/README.md +30 -0
- data/Rakefile +1 -0
- data/lib/uec_express_api.rb +71 -0
- data/lib/uec_express_api/version.rb +3 -0
- data/uec_express_api.gemspec +22 -0
- metadata +87 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 henteko
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# UecExpressApi
|
2
|
+
|
3
|
+
API library of the University of Electro-Communications class cancellation information.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'uec_express_api'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install uec_express_api
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
```example.rb
|
22
|
+
#!/usr/bin/ruby
|
23
|
+
require 'rubygems'
|
24
|
+
require 'uec_express_api'
|
25
|
+
|
26
|
+
uec_express = UECExpressApi.new()
|
27
|
+
uec_express.to_s
|
28
|
+
puts uec_express.to_json
|
29
|
+
```
|
30
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'open-uri'
|
3
|
+
require 'hpricot'
|
4
|
+
require 'json'
|
5
|
+
require 'uec_express_api/version.rb'
|
6
|
+
|
7
|
+
class UECExpressApi
|
8
|
+
|
9
|
+
attr_accessor :updated, :express
|
10
|
+
|
11
|
+
@@debug = false
|
12
|
+
def initialize()
|
13
|
+
|
14
|
+
@updated = ""
|
15
|
+
@express = Array.new
|
16
|
+
parse_UEC_express()
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_hash
|
20
|
+
{
|
21
|
+
:express => @express,
|
22
|
+
:updated => @updated
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
def to_json(*args)
|
27
|
+
to_hash().to_json(*args)
|
28
|
+
end
|
29
|
+
|
30
|
+
def to_s()
|
31
|
+
puts "-------------------------------------------------------------"
|
32
|
+
puts "| class | data | time | subject | staff | remark |"
|
33
|
+
@express.each do |ex|
|
34
|
+
puts "| " + ex[:class].to_s + " | " + ex[:data].to_s + " | " + ex[:data].to_s + " | " + ex[:subject].to_s + " | " + ex[:staff].to_s + " | " + ex[:remark].to_s + " |"
|
35
|
+
end
|
36
|
+
puts "Last Updated :" + @updated
|
37
|
+
puts "-------------------------------------------------------------"
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def parse_UEC_express()
|
43
|
+
url="http://kyoumu.ofFICE.uec.ac.jp/kyuukou/kyuukou.html"
|
44
|
+
puts "Getting URL="+url if @@debug
|
45
|
+
doc = Hpricot(open(url,'User-Agent' => 'ruby'))
|
46
|
+
express(doc.root)
|
47
|
+
updated(doc.root)
|
48
|
+
end
|
49
|
+
|
50
|
+
def updated(doc)
|
51
|
+
elements = doc/:p
|
52
|
+
if elements
|
53
|
+
@updated = elements.last.inner_html.to_s.encode('utf-8', 'sjis')
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def express(doc)
|
58
|
+
express_pass = [:class, :data, :time, :subject, :staff, :remark]
|
59
|
+
(doc/:tr).each_with_index do |element, i|
|
60
|
+
next if i == 0
|
61
|
+
ex = {}
|
62
|
+
(element/:td).each_with_index do |e, j|
|
63
|
+
ex[express_pass[j]] = e.inner_html.to_s.encode('utf-8', 'sjis')
|
64
|
+
end
|
65
|
+
@express << ex
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'uec_express_api/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "uec_express_api"
|
8
|
+
gem.version = UecExpressApi::VERSION
|
9
|
+
gem.authors = ["henteko"]
|
10
|
+
gem.email = ["henteko07@gmail.com"]
|
11
|
+
gem.description = %q{API library of the University of Electro-Communications class cancellation information.}
|
12
|
+
gem.summary = %q{API library of the University of Electro-Communications class cancellation information.}
|
13
|
+
gem.homepage = "http://henteko07.hatenablog.com/"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_runtime_dependency "hpricot"
|
21
|
+
gem.add_runtime_dependency "json"
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: uec_express_api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- henteko
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-12-04 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: hpricot
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: json
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description: API library of the University of Electro-Communications class cancellation
|
47
|
+
information.
|
48
|
+
email:
|
49
|
+
- henteko07@gmail.com
|
50
|
+
executables: []
|
51
|
+
extensions: []
|
52
|
+
extra_rdoc_files: []
|
53
|
+
files:
|
54
|
+
- .gitignore
|
55
|
+
- Gemfile
|
56
|
+
- LICENSE.txt
|
57
|
+
- README.md
|
58
|
+
- Rakefile
|
59
|
+
- lib/uec_express_api.rb
|
60
|
+
- lib/uec_express_api/version.rb
|
61
|
+
- uec_express_api.gemspec
|
62
|
+
homepage: http://henteko07.hatenablog.com/
|
63
|
+
licenses: []
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
70
|
+
requirements:
|
71
|
+
- - ! '>='
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
76
|
+
requirements:
|
77
|
+
- - ! '>='
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
requirements: []
|
81
|
+
rubyforge_project:
|
82
|
+
rubygems_version: 1.8.24
|
83
|
+
signing_key:
|
84
|
+
specification_version: 3
|
85
|
+
summary: API library of the University of Electro-Communications class cancellation
|
86
|
+
information.
|
87
|
+
test_files: []
|