valanga 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/lib/valanga/client.rb +5 -4
- data/lib/valanga/difficulty/base.rb +12 -0
- data/lib/valanga/music_search.rb +14 -5
- data/lib/valanga/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30f3d50c38df00da1f3e548631ce0095ebc2d1f6
|
4
|
+
data.tar.gz: fd5b7fa4a329dd838808372ed47a2fd664e86e37
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d673cc1558adf2dfd5a07e3e9d88b74113b16674599eb9ec13bf651ebb6d67eb8449fb16c945c6651c8147fad1c62f9f563fb3119d89dcb95d80db64924353a3
|
7
|
+
data.tar.gz: e2ec20c5b598f9974f3504f4d279e551c9b5dafb5b0e68d779114bb05a3cbf9a8f8c6bb18a3673866e1785ef41ddb3147f252528832d5ad11fd6e832c4d160d7
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
# Version 0.2.0
|
2
|
+
* Supports environment variable login for `ENV['KONAMI_ID']` `ENV['KONAMI_PASSWORD']`.
|
3
|
+
* Caches the search query and url, Second time result is directly access to cached url.
|
4
|
+
|
5
|
+
# Version 0.1.0
|
6
|
+
* Logins id or email & password.
|
7
|
+
* Supports `Valanga::Client#list_musics`, `Valanga::Client#[]`.
|
data/lib/valanga/client.rb
CHANGED
@@ -7,14 +7,15 @@ module Valanga
|
|
7
7
|
|
8
8
|
LOGIN_PAGE = "https://p.eagate.573.jp/gate/p/login.html"
|
9
9
|
|
10
|
-
attr_reader :session
|
10
|
+
attr_reader :session, :pages
|
11
11
|
|
12
|
-
def initialize(username, password)
|
12
|
+
def initialize(username = nil, password = nil)
|
13
13
|
Capybara.register_driver :poltergeist do |app|
|
14
14
|
Capybara::Poltergeist::Driver.new(app, js_errors: false)
|
15
15
|
end
|
16
16
|
|
17
17
|
@session = Capybara::Session.new(:poltergeist)
|
18
|
+
@pages = {}
|
18
19
|
|
19
20
|
login!(username, password)
|
20
21
|
end
|
@@ -24,8 +25,8 @@ module Valanga
|
|
24
25
|
def login!(username, password)
|
25
26
|
@session.visit LOGIN_PAGE
|
26
27
|
|
27
|
-
@session.fill_in 'KID', with: username
|
28
|
-
@session.fill_in 'pass', with: password
|
28
|
+
@session.fill_in 'KID', with: username || ENV['KONAMI_ID']
|
29
|
+
@session.fill_in 'pass', with: password || ENV['KONAMI_PASSWORD']
|
29
30
|
|
30
31
|
@session.click_on "規約に同意してログイン"
|
31
32
|
|
@@ -52,6 +52,18 @@ module Valanga
|
|
52
52
|
def full_combo
|
53
53
|
groovin.full_combo || collete.full_combo
|
54
54
|
end
|
55
|
+
|
56
|
+
def cleared?
|
57
|
+
achievement_rate && 70.0 <= achievement_rate
|
58
|
+
end
|
59
|
+
|
60
|
+
def played?
|
61
|
+
play_count > 0
|
62
|
+
end
|
63
|
+
|
64
|
+
def full_combo?
|
65
|
+
! full_combo.nil?
|
66
|
+
end
|
55
67
|
end
|
56
68
|
end
|
57
69
|
end
|
data/lib/valanga/music_search.rb
CHANGED
@@ -19,7 +19,11 @@ module Valanga
|
|
19
19
|
musics.flatten
|
20
20
|
end
|
21
21
|
|
22
|
-
def
|
22
|
+
def search(music_name)
|
23
|
+
if url = pages[music_name]
|
24
|
+
return create_music(url)
|
25
|
+
end
|
26
|
+
|
23
27
|
page_sessions do |session|
|
24
28
|
begin
|
25
29
|
session.within("#music_table1") do
|
@@ -27,19 +31,24 @@ module Valanga
|
|
27
31
|
end
|
28
32
|
|
29
33
|
src = session.find(:css, "iframe")['src']
|
30
|
-
|
34
|
+
pages[music_name] = info_url(src)
|
31
35
|
|
32
|
-
return
|
36
|
+
return create_music(info_url(src))
|
33
37
|
rescue Capybara::ElementNotFound
|
34
38
|
# if link is not found, go next page.
|
35
39
|
end
|
36
40
|
end
|
37
41
|
end
|
38
|
-
alias_method :
|
39
|
-
alias_method :find_music, :
|
42
|
+
alias_method :[], :search
|
43
|
+
alias_method :find_music, :search
|
40
44
|
|
41
45
|
private
|
42
46
|
|
47
|
+
def create_music(info_url)
|
48
|
+
session.visit(info_url)
|
49
|
+
Music.new(session.html)
|
50
|
+
end
|
51
|
+
|
43
52
|
def page_sessions(&block)
|
44
53
|
page = 1
|
45
54
|
|
data/lib/valanga/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: valanga
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mgi166
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -133,6 +133,7 @@ files:
|
|
133
133
|
- ".gitignore"
|
134
134
|
- ".rspec"
|
135
135
|
- ".travis.yml"
|
136
|
+
- CHANGELOG.md
|
136
137
|
- Gemfile
|
137
138
|
- LICENSE.txt
|
138
139
|
- README.md
|