lyne 0.0.2.3 → 0.0.2.5
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 +4 -4
- data/README.md +11 -2
- data/lib/lyne/page/character.rb +14 -0
- data/lib/lyne/parser/home.rb +12 -3
- data/lib/lyne/session/browser.rb +11 -0
- data/lib/lyne/session/screen_transitions.rb +11 -3
- data/lib/lyne/version.rb +1 -1
- data/spec/account.yaml.example +7 -0
- data/spec/character/info_spec.rb +16 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea1d82a183033607f858c72013a2525cc4c8511f
|
4
|
+
data.tar.gz: 7269371389a1217d40c60ce4cc97e3a550e5b695
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04830c3f87a9369e6f3451b875980fd462a7d3f17b913bbc08dc431f66af85d98aa288175377dd56114779718d497008dabef145036f36cda1a5a87028626024
|
7
|
+
data.tar.gz: 356c406dec1a188e0fd8ef63312f4112de4c32c0ad180268a24ff0f979cbb140b3b0fa56ae14b7604ec0d9479e9c089275d33e253679ad5d7d9dff54581aa748
|
data/README.md
CHANGED
@@ -15,7 +15,7 @@ $ brew update && brew install phantomjs
|
|
15
15
|
# use
|
16
16
|
|
17
17
|
```bash
|
18
|
-
$ gem install
|
18
|
+
$ gem install lyne
|
19
19
|
```
|
20
20
|
```
|
21
21
|
gem 'lyne'
|
@@ -34,9 +34,18 @@ dqx = Lyne::Account.new(
|
|
34
34
|
character_id: 975829418411224
|
35
35
|
)
|
36
36
|
|
37
|
-
|
37
|
+
chara = dqx.character
|
38
|
+
|
39
|
+
info = chara.info
|
38
40
|
info.id #=> "TV327-610"
|
39
41
|
info.name #=> "ソプラナ"
|
42
|
+
# フレンド申請おk
|
43
|
+
|
44
|
+
house = chara.house
|
45
|
+
house.country #=> "アズラン住宅村"
|
46
|
+
house.city #=> "おごそかな林道地区"
|
47
|
+
house.house_number #=> "3849丁目 6番地 (Sサイズ)"
|
48
|
+
# 遊びにきておk
|
40
49
|
```
|
41
50
|
|
42
51
|
# test
|
data/lib/lyne/page/character.rb
CHANGED
@@ -58,6 +58,20 @@ module Lyne::Page
|
|
58
58
|
@character = Lyne::Page::Character::Base.new(session)
|
59
59
|
end
|
60
60
|
|
61
|
+
def change character_id
|
62
|
+
@session.character_change character_id
|
63
|
+
@character = Lyne::Page::Character::Base.new(@session)
|
64
|
+
|
65
|
+
# CCのタイミングで存在するインスタンス変数を削除
|
66
|
+
Lyne::Page::Character::Target.constants.each do |target|
|
67
|
+
formatted_name = target.to_s.downcase
|
68
|
+
if instance_variable_defined?("@#{formatted_name}")
|
69
|
+
remove_instance_variable("@#{formatted_name}")
|
70
|
+
end
|
71
|
+
end
|
72
|
+
self
|
73
|
+
end
|
74
|
+
|
61
75
|
Lyne::Page::Character::Target.constants.each do |target|
|
62
76
|
formatted_name = target.to_s.downcase
|
63
77
|
define_method(formatted_name) do
|
data/lib/lyne/parser/home.rb
CHANGED
@@ -56,15 +56,18 @@ module Lyne::Parser
|
|
56
56
|
|
57
57
|
class House < Home
|
58
58
|
def country
|
59
|
-
get_parse_data(index: 3)
|
59
|
+
text = get_parse_data(index: 3)
|
60
|
+
text.split[0].scan(/.*住宅村/)[0] if text.present?
|
60
61
|
end
|
61
62
|
|
62
63
|
def city
|
63
|
-
get_parse_data(index: 3)
|
64
|
+
text = get_parse_data(index: 3)
|
65
|
+
text.split[0].gsub(/#{country}/,'') if text.present?
|
64
66
|
end
|
65
67
|
|
66
68
|
def house_number
|
67
|
-
get_parse_data(index: 3)
|
69
|
+
text = get_parse_data(index: 3)
|
70
|
+
text.split[1] if text.present?
|
68
71
|
end
|
69
72
|
|
70
73
|
def setting
|
@@ -76,6 +79,12 @@ module Lyne::Parser
|
|
76
79
|
end
|
77
80
|
|
78
81
|
private
|
82
|
+
def get_parse_data option
|
83
|
+
super(option)
|
84
|
+
rescue
|
85
|
+
nil
|
86
|
+
end
|
87
|
+
|
79
88
|
def parse_target_xpath
|
80
89
|
"//div[@id='myHouseStage']"
|
81
90
|
end
|
data/lib/lyne/session/browser.rb
CHANGED
@@ -16,6 +16,8 @@ module Lyne::Session
|
|
16
16
|
Capybara.default_selector = :xpath
|
17
17
|
@page = Capybara::Session.new(:poltergeist)
|
18
18
|
@page.driver.headers = {'User-Agent' => @options[:user_agent]}
|
19
|
+
|
20
|
+
setup_cache
|
19
21
|
end
|
20
22
|
|
21
23
|
def start!
|
@@ -41,6 +43,11 @@ module Lyne::Session
|
|
41
43
|
@page.html
|
42
44
|
end
|
43
45
|
|
46
|
+
def character_change character_id
|
47
|
+
go :charaselect
|
48
|
+
go_to_home character_id
|
49
|
+
end
|
50
|
+
|
44
51
|
private
|
45
52
|
def default_options
|
46
53
|
{
|
@@ -63,5 +70,9 @@ module Lyne::Session
|
|
63
70
|
def character_select_url?
|
64
71
|
@page.current_path == "/sc/login/characterselect/"
|
65
72
|
end
|
73
|
+
|
74
|
+
def setup_cache
|
75
|
+
@cache = {}
|
76
|
+
end
|
66
77
|
end
|
67
78
|
end
|
@@ -6,6 +6,7 @@ module Lyne::Session
|
|
6
6
|
@page.fill_in '_pr_confData_sqexid', with: @options[:account]
|
7
7
|
@page.fill_in '_pr_confData_passwd', with: @options[:password]
|
8
8
|
@page.find(:xpath, ".//a[@id='btLogin']").click
|
9
|
+
@page.html
|
9
10
|
end
|
10
11
|
end
|
11
12
|
|
@@ -15,15 +16,21 @@ module Lyne::Session
|
|
15
16
|
end
|
16
17
|
end
|
17
18
|
|
18
|
-
def go_to_home
|
19
|
+
def go_to_home character_id=''
|
19
20
|
move_to do
|
20
|
-
@page.find(:xpath, "//a[@rel='#{@options[:character_id]}']").click
|
21
|
+
@page.find(:xpath, "//a[@rel='#{character_id.presence || @options[:character_id]}']").click
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def go_to_charaselect
|
26
|
+
move_to do
|
27
|
+
@page.find(:xpath, "//a[@href='/sc/home/characterchange/']").click
|
21
28
|
end
|
22
29
|
end
|
23
30
|
|
24
31
|
def visit_to_home
|
25
32
|
move_to do
|
26
|
-
@page.visit('sc/home/')
|
33
|
+
@page.visit('/sc/home/')
|
27
34
|
end
|
28
35
|
end
|
29
36
|
|
@@ -31,6 +38,7 @@ module Lyne::Session
|
|
31
38
|
def move_to
|
32
39
|
yield
|
33
40
|
sleep(2)
|
41
|
+
@cache[@page.current_path] = @page.html
|
34
42
|
end
|
35
43
|
end
|
36
44
|
end
|
data/lib/lyne/version.rb
CHANGED
data/spec/account.yaml.example
CHANGED
data/spec/character/info_spec.rb
CHANGED
@@ -10,7 +10,7 @@ describe Lyne::Page::Character do
|
|
10
10
|
dqx = Lyne::Account.new({
|
11
11
|
account: @account[:name],
|
12
12
|
password: @account[:password],
|
13
|
-
character_id: @account[:character_id]
|
13
|
+
character_id: @account[:character_id][0]
|
14
14
|
})
|
15
15
|
@character = dqx.character
|
16
16
|
end
|
@@ -46,5 +46,20 @@ describe Lyne::Page::Character do
|
|
46
46
|
it { expect(subject.house_number).to match(/.*サイズ)$/) }
|
47
47
|
end
|
48
48
|
end
|
49
|
+
|
50
|
+
if YAML.load_file("./spec/account.yaml")['account']['character_id'][1]
|
51
|
+
context 'キャラチェンジできる' do
|
52
|
+
before(:all) do
|
53
|
+
@id = @character.info.id
|
54
|
+
@other_character = @character.change(@account[:character_id][1])
|
55
|
+
end
|
56
|
+
subject{ @other_character.info }
|
57
|
+
|
58
|
+
context 'キャラチェンジ後とinfo.idが違う' do
|
59
|
+
it { expect(subject.id).not_to match(@id) }
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
49
64
|
end
|
50
65
|
end
|