holysugar-www-enbujyo 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/LICENSE +20 -0
- data/README.mkdn +17 -0
- data/Rakefile +56 -0
- data/VERSION +1 -0
- data/lib/enbujyo.rb +1 -0
- data/lib/www/enbujyo/deck.rb +93 -0
- data/lib/www/enbujyo/game.rb +39 -0
- data/lib/www/enbujyo/location.rb +17 -0
- data/lib/www/enbujyo/player.rb +45 -0
- data/lib/www/enbujyo/util.rb +26 -0
- data/lib/www/enbujyo.rb +189 -0
- data/test/test_helper.rb +10 -0
- data/test/www-enbujyo_test.rb +43 -0
- data/www-enbujyo.gemspec +52 -0
- metadata +69 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 holysugar
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.mkdn
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "www-enbujyo"
|
8
|
+
gem.summary = %Q{TODO}
|
9
|
+
gem.email = "holysugar@gmail.com"
|
10
|
+
gem.homepage = "http://github.com/holysugar/www-enbujyo"
|
11
|
+
gem.authors = ["holysugar"]
|
12
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
13
|
+
end
|
14
|
+
|
15
|
+
rescue LoadError
|
16
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
17
|
+
end
|
18
|
+
|
19
|
+
require 'rake/testtask'
|
20
|
+
Rake::TestTask.new(:test) do |test|
|
21
|
+
test.libs << 'lib' << 'test'
|
22
|
+
test.pattern = 'test/**/*_test.rb'
|
23
|
+
test.verbose = true
|
24
|
+
end
|
25
|
+
|
26
|
+
begin
|
27
|
+
require 'rcov/rcovtask'
|
28
|
+
Rcov::RcovTask.new do |test|
|
29
|
+
test.libs << 'test'
|
30
|
+
test.pattern = 'test/**/*_test.rb'
|
31
|
+
test.verbose = true
|
32
|
+
end
|
33
|
+
rescue LoadError
|
34
|
+
task :rcov do
|
35
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
task :default => :test
|
41
|
+
|
42
|
+
require 'rake/rdoctask'
|
43
|
+
Rake::RDocTask.new do |rdoc|
|
44
|
+
if File.exist?('VERSION.yml')
|
45
|
+
config = YAML.load(File.read('VERSION.yml'))
|
46
|
+
version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
|
47
|
+
else
|
48
|
+
version = ""
|
49
|
+
end
|
50
|
+
|
51
|
+
rdoc.rdoc_dir = 'rdoc'
|
52
|
+
rdoc.title = "www-enbujyo #{version}"
|
53
|
+
rdoc.rdoc_files.include('README*')
|
54
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
55
|
+
end
|
56
|
+
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.5
|
data/lib/enbujyo.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'www/enbujyo'
|
@@ -0,0 +1,93 @@
|
|
1
|
+
# -*- mode:ruby; coding:utf-8 -*-
|
2
|
+
|
3
|
+
module WWW
|
4
|
+
class Enbujyo
|
5
|
+
class Deck
|
6
|
+
attr_accessor :cards, :gcards
|
7
|
+
def initialize
|
8
|
+
@cards = []
|
9
|
+
@gcards = []
|
10
|
+
end
|
11
|
+
|
12
|
+
def to_s
|
13
|
+
[
|
14
|
+
@cards.collect{|c| c.to_s }.join("\n"),
|
15
|
+
@gcards.collect{|c| "軍師:" + c.to_s }.join("\n")
|
16
|
+
].join("\n")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class Gunshi
|
21
|
+
attr_accessor :name, :rarity, :image, :team, :level,
|
22
|
+
:strategy, :attribute, :ex
|
23
|
+
def initialize(options = {})
|
24
|
+
@image = options[:image]
|
25
|
+
@level = options[:level]
|
26
|
+
@name = options[:name]
|
27
|
+
@rarity = options[:rarity]
|
28
|
+
@team = options[:team]
|
29
|
+
@attribute = options[:attribute]
|
30
|
+
@strategy = options[:strategy]
|
31
|
+
@ex = options[:ex]
|
32
|
+
|
33
|
+
unless /^http/ =~ @image
|
34
|
+
@image = 'http://enbujyo.3594t.com/img/game/cards/' + @image
|
35
|
+
end
|
36
|
+
if options[:longname]
|
37
|
+
_, @team, @rarity, @name = options[:longname].match(/(.+?)([A-Z]{1,2})(.*)/u).to_a
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def to_s
|
42
|
+
"#{team}#{rarity}#{name}"
|
43
|
+
end
|
44
|
+
|
45
|
+
def description
|
46
|
+
"#{team}#{rarity}#{name} #{attribute}/#{strategy}/Lv.#{level}"
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
class Card
|
52
|
+
attr_accessor :name, :cost, :strength, :intelligence, :attribute,
|
53
|
+
:icon, :image, :team, :rarity
|
54
|
+
def initialize(options = {})
|
55
|
+
@name = options[:name]
|
56
|
+
@cost = options[:cost]
|
57
|
+
@strength = options[:strength]
|
58
|
+
@intelligence = options[:intelligence]
|
59
|
+
@attribute = options[:attribute]
|
60
|
+
@icon = options[:icon]
|
61
|
+
@image = options[:image]
|
62
|
+
@team = options[:team]
|
63
|
+
@rarity = options[:rarity]
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.parse_from_jsonstr(string)
|
67
|
+
# SAMPLE: arcade_icon_yarihei_gun.gif,1.0,3,,1,群C程遠志,天,4b5ea861463d15dc.gif
|
68
|
+
icon, cost, strength, _, intelligence, longname, attribute, image = string.split(/,/)
|
69
|
+
_, team, rarity, name = longname.match(/(.+?)([A-Z]{1,2})(.*)/u).to_a
|
70
|
+
|
71
|
+
Card.new({
|
72
|
+
:name => name,
|
73
|
+
:cost => cost,
|
74
|
+
:strength => strength,
|
75
|
+
:intelligence => intelligence,
|
76
|
+
:attribute => attribute,
|
77
|
+
:icon => 'http://enbujyo.3594t.com/img/game/ico/' + icon,
|
78
|
+
:image => 'http://enbujyo.3594t.com/img/game/cards/' + image,
|
79
|
+
:team => team,
|
80
|
+
:rarity => rarity,
|
81
|
+
})
|
82
|
+
end
|
83
|
+
|
84
|
+
def to_s
|
85
|
+
"#{team}#{rarity}#{name}"
|
86
|
+
end
|
87
|
+
def description
|
88
|
+
"#{team}#{rarity}#{name} #{cost}/#{strength}/#{intelligence}/#{attribute}"
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'time'
|
2
|
+
|
3
|
+
module WWW
|
4
|
+
class Enbujyo
|
5
|
+
class Game
|
6
|
+
attr_reader :player0, :deck0, :location0, :player1, :deck1, :location1
|
7
|
+
|
8
|
+
def initialize(p0, p0deck, p0loc, p1, p1deck, p1loc, options = {})
|
9
|
+
@player0 = p0
|
10
|
+
@deck0 = p0deck
|
11
|
+
@location0 = p0loc
|
12
|
+
@player1 = p1
|
13
|
+
@deck1 = p1deck
|
14
|
+
@location1 = p1loc
|
15
|
+
|
16
|
+
@date = Time.parse(options[:date]) if options[:date]
|
17
|
+
case options[:p0result]
|
18
|
+
when 'lose'
|
19
|
+
@winner = 1
|
20
|
+
when 'win'
|
21
|
+
@winner = 0
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def to_s
|
26
|
+
return <<-EOD
|
27
|
+
#{player0} #{"「#{player0.team}」" if player0.team}
|
28
|
+
#{location0}
|
29
|
+
#{deck0}
|
30
|
+
----
|
31
|
+
#{player1} #{"「#{player1.team}」" if player1.team}
|
32
|
+
#{location1}
|
33
|
+
#{deck1}
|
34
|
+
EOD
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'www/enbujyo/util'
|
2
|
+
|
3
|
+
module WWW
|
4
|
+
class Enbujyo
|
5
|
+
class Player
|
6
|
+
attr_reader :name, :name_image_url, :pclass, :title,
|
7
|
+
:brave, :brave_desc, :seibou, :rank, :team,
|
8
|
+
:wins, :loses, :games, :draws, :rate
|
9
|
+
|
10
|
+
def initialize(attr)
|
11
|
+
@name = attr[:name]
|
12
|
+
@name_image_url = 'http://enbujyo.3594t.com' + attr[:name_image_url]
|
13
|
+
@accesscode = attr[:accesscode]
|
14
|
+
@team = attr[:team]
|
15
|
+
|
16
|
+
@title = attr[:title]
|
17
|
+
@brave = attr[:brave]
|
18
|
+
@brave_desc = attr[:brave_desc]
|
19
|
+
@seibou = attr[:seibou]
|
20
|
+
@rank = attr[:rank]
|
21
|
+
|
22
|
+
@games = attr[:games]
|
23
|
+
@wins = attr[:wins]
|
24
|
+
@loses = attr[:loses]
|
25
|
+
@draws = attr[:draws]
|
26
|
+
@rate = attr[:rate]
|
27
|
+
end
|
28
|
+
|
29
|
+
def akashi?
|
30
|
+
@brave_desc == '証'
|
31
|
+
end
|
32
|
+
|
33
|
+
def to_s
|
34
|
+
"#{@name} #{@brave_desc}:#{@brave}"
|
35
|
+
end
|
36
|
+
|
37
|
+
def description
|
38
|
+
"#{@name} #{@brave_desc}:#{@brave}\n" +
|
39
|
+
"#{@wins}勝 #{@loses}負 勝率#{@rate}%"
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- mode:ruby; coding:utf-8 -*-
|
2
|
+
|
3
|
+
module WWW
|
4
|
+
class Enbujyo
|
5
|
+
module Util
|
6
|
+
ch_number_table = {
|
7
|
+
'〇' => 0,
|
8
|
+
'一' => 1,
|
9
|
+
'二' => 2,
|
10
|
+
'三' => 3,
|
11
|
+
'四' => 4,
|
12
|
+
'五' => 5,
|
13
|
+
'六' => 6,
|
14
|
+
'七' => 7,
|
15
|
+
'八' => 8,
|
16
|
+
'九' => 9,
|
17
|
+
'十' => 10,
|
18
|
+
}
|
19
|
+
def self.ch_to_i(chinesenumber)
|
20
|
+
ch_number_table[chinesenumber]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
|
data/lib/www/enbujyo.rb
ADDED
@@ -0,0 +1,189 @@
|
|
1
|
+
# -*- mode:ruby; coding:utf-8 -*-
|
2
|
+
$KCODE = 'u'
|
3
|
+
|
4
|
+
require 'mechanize'
|
5
|
+
require 'logger'
|
6
|
+
require 'tempfile'
|
7
|
+
require 'fileutils'
|
8
|
+
require 'nkf'
|
9
|
+
require 'json'
|
10
|
+
|
11
|
+
require 'www/enbujyo/player'
|
12
|
+
require 'www/enbujyo/deck'
|
13
|
+
require 'www/enbujyo/location'
|
14
|
+
require 'www/enbujyo/game'
|
15
|
+
|
16
|
+
#
|
17
|
+
# SEGA の三国志大戦公式サイトへアクセスするライブラリ.
|
18
|
+
#
|
19
|
+
module WWW
|
20
|
+
class Enbujyo
|
21
|
+
attr_accessor :mail, :password
|
22
|
+
attr_reader :agent
|
23
|
+
|
24
|
+
class LoginError < RuntimeError; end
|
25
|
+
|
26
|
+
def initialize(options = {})
|
27
|
+
@agent = options.delete(:agent)
|
28
|
+
@mail = options.delete(:mail)
|
29
|
+
@password = options.delete(:password)
|
30
|
+
@options = options
|
31
|
+
unless @agent
|
32
|
+
@agent = WWW::Mechanize.new
|
33
|
+
@agent.user_agent_alias = 'Windows Mozilla'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def login
|
38
|
+
@agent.get('http://enbujyo.3594t.com/')
|
39
|
+
@agent.page.form_with(:action => '/action.cgi') {|f|
|
40
|
+
f.field_with(:name => 'mail').value = @mail
|
41
|
+
f.field_with(:name => 'password').value = @password
|
42
|
+
f.click_button
|
43
|
+
}
|
44
|
+
raise LoginError if /error/i =~ @agent.page.uri.to_s
|
45
|
+
true
|
46
|
+
end
|
47
|
+
|
48
|
+
def get_player_user(reload = false)
|
49
|
+
if reload or not @player_user
|
50
|
+
auth_get(@agent, 'http://enbujyo.3594t.com/members/player/index.html')
|
51
|
+
@player_user = get_player_data(@agent)
|
52
|
+
end
|
53
|
+
@player_user
|
54
|
+
end
|
55
|
+
|
56
|
+
def get_player_data(page_loaded_agent)
|
57
|
+
player = {}
|
58
|
+
|
59
|
+
div1 = page_loaded_agent.page.search('div.st_block_info3')[0]
|
60
|
+
div1text = div1.text
|
61
|
+
player[:name_image_url] = div1.search('img')[0]['src']
|
62
|
+
player[:name] = div1text.scan(/\b君主名:(.*)\s/)[0][0]
|
63
|
+
player[:accesscode] = div1text.scan(/\bACCESS CODE:(\d+)\s/)[0][0]
|
64
|
+
|
65
|
+
div2 = page_loaded_agent.page.search('div.st_block_info3_body')[0]
|
66
|
+
div2text = div2.text
|
67
|
+
player[:title] = div2text.scan(/\b称号:(.*)\s/)[0][0]
|
68
|
+
player[:brave_desc], player[:brave] = div2text.scan(/\b(証|武勇):(.*)\s/)[0]
|
69
|
+
player[:seibou] = div2text.scan(/\b声望値:(.*%)\s/)[0][0] rescue nil
|
70
|
+
|
71
|
+
div3 = page_loaded_agent.page.search('div.st_block_info3_body')[1]
|
72
|
+
div3text = div3.text
|
73
|
+
#/全(\d+)戦(\d+)勝\s*(\d+)敗\s*(\d+)分.*連勝数:(\d+)連勝\s*最高連勝数:(\d+)連勝\s*最新10戦:(.+)\s*全国順位:(\d+)位/m =~ div3.text
|
74
|
+
|
75
|
+
player[:games] = div3text.scan(/全(\d+)戦/)[0][0].to_i rescue nil
|
76
|
+
player[:wins] = div3text.scan(/(\d+)勝/)[0][0].to_i rescue nil
|
77
|
+
player[:loses] = div3text.scan(/(\d+)敗/)[0][0].to_i rescue nil
|
78
|
+
player[:draws] = div3text.scan(/(\d+)分/)[0][0].to_i rescue nil
|
79
|
+
player[:rate] = div3text.scan(/勝率:([\d\.]+)%/)[0][0] rescue nil
|
80
|
+
player[:consecutive_wins] = div3text.scan(/連勝数:(\d+)連勝/)[0][0].to_i rescue nil
|
81
|
+
player[:max_consecutive_wins] = div3text.scan(/最高連勝数:(\d+)連勝/)[0][0].to_i rescue nil
|
82
|
+
player[:ten_games] = div3text.scan(/最新10戦:(.+)/)[0][0] rescue nil
|
83
|
+
player[:rank] = div3text.scan(/全国順位:(\d+)位/)[0][0].to_i rescue nil
|
84
|
+
|
85
|
+
Player.new(player)
|
86
|
+
end
|
87
|
+
|
88
|
+
def get_selection_info
|
89
|
+
@agent.post('http://enbujyo.3594t.com/members/selection/selection.cgi', {
|
90
|
+
'mode' => 'latest',
|
91
|
+
'version' => 1
|
92
|
+
})
|
93
|
+
json = hack_json(@agent.page.body)
|
94
|
+
obj = JSON.parse(json)
|
95
|
+
rep = obj['replay'][0]
|
96
|
+
|
97
|
+
p0, p0deck, p0loc = get_selection_info_build('p0', rep)
|
98
|
+
p1, p1deck, p1loc = get_selection_info_build('p1', rep)
|
99
|
+
|
100
|
+
game = WWW::Enbujyo::Game.new(p0, p0deck, p0loc, p1, p1deck, p1loc, rep)
|
101
|
+
game
|
102
|
+
end
|
103
|
+
|
104
|
+
def get_selection_info_build(prefix, rep)
|
105
|
+
deck = Deck.new
|
106
|
+
rep.keys.grep(/#{prefix}card_params_\d/).sort.each{|k|
|
107
|
+
deck.cards.push WWW::Enbujyo::Card.parse_from_jsonstr(rep[k])
|
108
|
+
}
|
109
|
+
deck.gcards.push(WWW::Enbujyo::Gunshi.new(
|
110
|
+
:image => rep[prefix+'staff_image'],
|
111
|
+
:level => rep[prefix+'staff_level'],
|
112
|
+
:longname => rep[prefix+'staff_name'],
|
113
|
+
:team => rep[prefix+'staff_seiryoku_name'],
|
114
|
+
:attribute => rep[prefix+'staff_zokusei_name'],
|
115
|
+
:strategy => rep[prefix+'strategy_name'],
|
116
|
+
:ex => rep[prefix+'skill_ex_name']
|
117
|
+
))
|
118
|
+
player = WWW::Enbujyo::Player.new(
|
119
|
+
:name => rep[prefix+'name'],
|
120
|
+
:name_image_url => rep[prefix+'image'],
|
121
|
+
:team => rep[prefix+'team_name'],
|
122
|
+
:title => rep[prefix+'grade_name'],
|
123
|
+
:brave => rep[prefix+'brave'],
|
124
|
+
:brave_desc => rep[prefix+'brave_desc'],
|
125
|
+
:rank => rep[prefix+'rank'],
|
126
|
+
:wins => rep[prefix+'win'],
|
127
|
+
:loses => rep[prefix+'lose'],
|
128
|
+
:rate => rep[prefix+'win_rate']
|
129
|
+
)
|
130
|
+
location = WWW::Enbujyo::Location.new(
|
131
|
+
:pref => rep[prefix+'pref_name'],
|
132
|
+
:office => rep[prefix+'office']
|
133
|
+
)
|
134
|
+
return [player, deck, location]
|
135
|
+
end
|
136
|
+
|
137
|
+
def download_selection(movie_type = 's')
|
138
|
+
movie_date = (Time.now - 60*60*17).strftime("%Y%m%d") # 17時で切り替え/JST前提
|
139
|
+
auth_get(@agent, 'http://enbujyo.3594t.com/members/selection/index.html')
|
140
|
+
|
141
|
+
tmpname = "_enbujyo_download.#{random_string}.wmv"
|
142
|
+
open(tmpname, 'w'){|tmp|
|
143
|
+
tmp.print @agent.get_file("http://download.enbujyo.3594t.com/selection_download.cgi?date=#{movie_date}&type=#{movie_type}")
|
144
|
+
}
|
145
|
+
filename = "selection_#{movie_date}.wmv"
|
146
|
+
if @agent.page.response['content-disposition']
|
147
|
+
/filename="(.*\.wmv)"/ =~ @agent.page.response['content-disposition']
|
148
|
+
filename = windows? ? $1 : NKF.nkf('-Sw', $1)
|
149
|
+
end
|
150
|
+
FileUtils.mv(tmpname, filename)
|
151
|
+
puts "Downloading #{filename} has finished." unless silent?
|
152
|
+
end
|
153
|
+
|
154
|
+
private
|
155
|
+
def random_string(length = 10, strings = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789')
|
156
|
+
Array.new(length).map{ strings[rand(strings.size),1] }.join
|
157
|
+
end
|
158
|
+
|
159
|
+
def windows?
|
160
|
+
RUBY_PLATFORM.downcase =~ /mswin(?!ce)|mingw|cygwin|bccwin/
|
161
|
+
end
|
162
|
+
|
163
|
+
def silent?
|
164
|
+
@options[:silent]
|
165
|
+
end
|
166
|
+
|
167
|
+
def auto_relogin?
|
168
|
+
@options[:auto_relogin]
|
169
|
+
end
|
170
|
+
|
171
|
+
def auth_get(agent, url)
|
172
|
+
ret = agent.get(url)
|
173
|
+
if /error/i =~ agent.page.uri.to_s or /エラー/ =~ agent.page.title
|
174
|
+
if auto_relogin?
|
175
|
+
login
|
176
|
+
else
|
177
|
+
raise LoginError
|
178
|
+
end
|
179
|
+
end
|
180
|
+
ret
|
181
|
+
end
|
182
|
+
|
183
|
+
def hack_json(jsonstr)
|
184
|
+
jsonstr.sub(/^\w+=/,'').gsub(/\},.*\]/m, '}]')
|
185
|
+
end
|
186
|
+
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
class WwwEnbujyoTest < Test::Unit::TestCase
|
5
|
+
context "WWW::Enbujyo instance" do
|
6
|
+
setup do
|
7
|
+
param = YAML.load_file("#{ENV['HOME']}/.enbujyorc")
|
8
|
+
@agent = WWW::Enbujyo.new(
|
9
|
+
:mail => param['mail'],
|
10
|
+
:password => param['password']
|
11
|
+
)
|
12
|
+
end
|
13
|
+
|
14
|
+
context "login method" do
|
15
|
+
should "return true" do
|
16
|
+
assert @agent.login
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context "player_user method" do
|
21
|
+
should "return valid player hashdata" do
|
22
|
+
@agent.login
|
23
|
+
player = @agent.get_player_user
|
24
|
+
assert player.name
|
25
|
+
assert player.title
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context "get_selection_info method" do
|
30
|
+
should "return valid game data" do
|
31
|
+
@agent.login
|
32
|
+
game = @agent.get_selection_info
|
33
|
+
assert game.player0.is_a? WWW::Enbujyo::Player
|
34
|
+
assert game.player1.is_a? WWW::Enbujyo::Player
|
35
|
+
assert game.deck0.is_a? WWW::Enbujyo::Deck
|
36
|
+
assert game.deck1.is_a? WWW::Enbujyo::Deck
|
37
|
+
assert game.location0.is_a? WWW::Enbujyo::Location
|
38
|
+
assert game.location1.is_a? WWW::Enbujyo::Location
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
data/www-enbujyo.gemspec
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{www-enbujyo}
|
5
|
+
s.version = "0.1.5"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["holysugar"]
|
9
|
+
s.date = %q{2009-06-17}
|
10
|
+
s.email = %q{holysugar@gmail.com}
|
11
|
+
s.extra_rdoc_files = [
|
12
|
+
"LICENSE",
|
13
|
+
"README.mkdn"
|
14
|
+
]
|
15
|
+
s.files = [
|
16
|
+
".gitignore",
|
17
|
+
"LICENSE",
|
18
|
+
"README.mkdn",
|
19
|
+
"Rakefile",
|
20
|
+
"VERSION",
|
21
|
+
"lib/enbujyo.rb",
|
22
|
+
"lib/www/enbujyo.rb",
|
23
|
+
"lib/www/enbujyo/deck.rb",
|
24
|
+
"lib/www/enbujyo/game.rb",
|
25
|
+
"lib/www/enbujyo/location.rb",
|
26
|
+
"lib/www/enbujyo/player.rb",
|
27
|
+
"lib/www/enbujyo/util.rb",
|
28
|
+
"test/test_helper.rb",
|
29
|
+
"test/www-enbujyo_test.rb",
|
30
|
+
"www-enbujyo.gemspec"
|
31
|
+
]
|
32
|
+
s.has_rdoc = true
|
33
|
+
s.homepage = %q{http://github.com/holysugar/www-enbujyo}
|
34
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
35
|
+
s.require_paths = ["lib"]
|
36
|
+
s.rubygems_version = %q{1.3.1}
|
37
|
+
s.summary = %q{TODO}
|
38
|
+
s.test_files = [
|
39
|
+
"test/test_helper.rb",
|
40
|
+
"test/www-enbujyo_test.rb"
|
41
|
+
]
|
42
|
+
|
43
|
+
if s.respond_to? :specification_version then
|
44
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
45
|
+
s.specification_version = 2
|
46
|
+
|
47
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
48
|
+
else
|
49
|
+
end
|
50
|
+
else
|
51
|
+
end
|
52
|
+
end
|
metadata
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: holysugar-www-enbujyo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.5
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- holysugar
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-06-17 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description:
|
17
|
+
email: holysugar@gmail.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- LICENSE
|
24
|
+
- README.mkdn
|
25
|
+
files:
|
26
|
+
- .gitignore
|
27
|
+
- LICENSE
|
28
|
+
- README.mkdn
|
29
|
+
- Rakefile
|
30
|
+
- VERSION
|
31
|
+
- lib/enbujyo.rb
|
32
|
+
- lib/www/enbujyo.rb
|
33
|
+
- lib/www/enbujyo/deck.rb
|
34
|
+
- lib/www/enbujyo/game.rb
|
35
|
+
- lib/www/enbujyo/location.rb
|
36
|
+
- lib/www/enbujyo/player.rb
|
37
|
+
- lib/www/enbujyo/util.rb
|
38
|
+
- test/test_helper.rb
|
39
|
+
- test/www-enbujyo_test.rb
|
40
|
+
- www-enbujyo.gemspec
|
41
|
+
has_rdoc: true
|
42
|
+
homepage: http://github.com/holysugar/www-enbujyo
|
43
|
+
post_install_message:
|
44
|
+
rdoc_options:
|
45
|
+
- --charset=UTF-8
|
46
|
+
require_paths:
|
47
|
+
- lib
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: "0"
|
53
|
+
version:
|
54
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: "0"
|
59
|
+
version:
|
60
|
+
requirements: []
|
61
|
+
|
62
|
+
rubyforge_project:
|
63
|
+
rubygems_version: 1.2.0
|
64
|
+
signing_key:
|
65
|
+
specification_version: 2
|
66
|
+
summary: TODO
|
67
|
+
test_files:
|
68
|
+
- test/test_helper.rb
|
69
|
+
- test/www-enbujyo_test.rb
|