ggxrd-frames 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 10ae466d4cc334725219d86d6e1a9cacc29269fe
4
+ data.tar.gz: c3b36784fdc7013fa02073d6e919720dd553cfd1
5
+ SHA512:
6
+ metadata.gz: 6b238b62b28ddd268805634c7bd335bc8a144af3bc6d14d9a18305123775850a56ea46cb899c00a8799bfd17dc8a85a89f80349461ae0157eb726f0bc1d8de1a
7
+ data.tar.gz: c5150f6ea286d2b578e4f3468860dd7c6d7a00578432d6fabd90d67c65af95f60c929841c6fa664d444f60df34a6621e7edf39db3b94909b497d4fa2f1d04fee
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ .idea
11
+ /vendor/bundle
12
+ .DS_Store
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.0
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ggxrd-frames.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 megane42
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,77 @@
1
+ # GGXrd::Frames
2
+
3
+ This gem scrapes GGXrd official frame data page (http://www.4gamer.net/guide/ggxrd/) and gives you the result as a hash.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'ggxrd-frames'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install ggxrd-frames
20
+
21
+ ## Usage
22
+
23
+ ```ruby
24
+ require 'ggxrd/frames'
25
+
26
+ client = GGXrd::Frames.new
27
+ pp client.frame_of('SO')[25]
28
+
29
+ ## ==>
30
+ ## {"name"=>"ヴォルカニックヴァイパー(HS)",
31
+ ## "damage"=>"40・25",
32
+ ## "tension"=>"300 / 480・720",
33
+ ## "attack_lv"=>"2",
34
+ ## "risc_lv"=>"-7 / +10",
35
+ ## "prorate"=>"―",
36
+ ## "attribute"=>"上",
37
+ ## "startup"=>"5",
38
+ ## "active"=>"2(3)18",
39
+ ## "recovery"=>"29+着地後8",
40
+ ## "frame_adv"=>"- 41",
41
+ ## "invincibility"=>"1〜6無,7〜11打,7〜空",
42
+ ## "remarks"=>""}
43
+ ```
44
+
45
+ The argumet is the abbrev. of each character name. You can confirm all names by:
46
+
47
+ ```ruby
48
+ pp GGXrd::Frames::CHARACTERS.keys
49
+
50
+ ## ==>
51
+ ## [:SO,
52
+ ## :SO_DI,
53
+ ## :KY,
54
+ ## :MA,
55
+ ## :MI,
56
+ ## :ZT,
57
+ ## :PO,
58
+ ## ...]
59
+ ```
60
+
61
+ ## Caveat
62
+
63
+ The result is written in Japanese because the official site is written in Japanese.
64
+
65
+ ## Development
66
+
67
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
68
+
69
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
70
+
71
+ ## Contributing
72
+
73
+ 1. Fork it ( https://github.com/[my-github-username]/ggxrd-frames/fork )
74
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
75
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
76
+ 4. Push to the branch (`git push origin my-new-feature`)
77
+ 5. Create a new Pull Request
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList['test/**/*.rb']
8
+ end
9
+
10
+ task :default => :test
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "ggxrd/frames"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ggxrd/frames/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ggxrd-frames"
8
+ spec.version = GGXrd::Frames::VERSION
9
+ spec.authors = ["megane42"]
10
+ spec.email = ["h.kzm.gm@gmail.com"]
11
+
12
+ if spec.respond_to?(:metadata)
13
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
14
+ end
15
+
16
+ spec.summary = "Unofficial gem which scrapes GGXrd official frame data page"
17
+ spec.description = "This gem scrapes GGXrd official frame data page (http://www.4gamer.net/guide/ggxrd/) and gives you the result as a hash."
18
+ spec.homepage = "https://github.com/megane42/ggxrd-frames"
19
+ spec.license = "MIT"
20
+
21
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
22
+ spec.bindir = "exe"
23
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
+ spec.require_paths = ["lib"]
25
+
26
+ spec.add_runtime_dependency "mechanize", "~> 2.7"
27
+
28
+ spec.add_development_dependency "bundler", "~> 1.8"
29
+ spec.add_development_dependency "rake", "~> 10.0"
30
+ spec.add_development_dependency "minitest", "~> 5.8"
31
+ spec.add_development_dependency "webmock", "~> 3.3"
32
+ end
@@ -0,0 +1,41 @@
1
+ require "ggxrd/frames/version"
2
+ require "ggxrd/frames/characters"
3
+ require "ggxrd/frames/column"
4
+ require "ggxrd/frames/error"
5
+ require "mechanize"
6
+
7
+ module GGXrd
8
+ class Frames
9
+ def frame_of (character)
10
+
11
+ raise ArgumentError.new('The argument must be a String or a Symbol') unless character.is_a?(String) || character.is_a?(Symbol)
12
+
13
+ character = character.to_sym
14
+
15
+ raise ArgumentError.new('The argument must be an abbrev of a character name, like "SO", "KY", ...') unless GGXrd::Frames::CHARACTERS[character]
16
+
17
+ url = GGXrd::Frames::CHARACTERS[character][:url]
18
+ res = Mechanize.new.get(url)
19
+
20
+ # scraping
21
+ table = res.at(GGXrd::Frames::CHARACTERS[character][:selector])
22
+ raise GGXrd::Frames::ScrapingError.new('Frame data is "Download Complete", but failed to scrape it') unless table
23
+
24
+ data = (
25
+ table.search('tr').to_a.map do |row|
26
+ row.search('td').to_a.map do |el|
27
+ (el.at('img') ? el.at('img').attribute('alt') : '').to_s + el.content.strip
28
+ end
29
+ end
30
+ )
31
+
32
+ # screening
33
+ data.select! {|row| row != []}
34
+
35
+ # convert to hash
36
+ data.map do |row|
37
+ Hash[*([GGXrd::Frames::COLUMN, row].transpose.flatten)]
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,32 @@
1
+ module GGXrd
2
+ class Frames
3
+ CHARACTERS = {
4
+ :SO => {url: 'http://www.4gamer.net/guide/ggxrd/031723018/', selector: 'div#table_result_1 table'},
5
+ :SO_DI => {url: 'http://www.4gamer.net/guide/ggxrd/031723018/', selector: 'div#table_result_2 table'},
6
+ :KY => {url: 'http://www.4gamer.net/guide/ggxrd/031723018/', selector: 'div#table_result_3 table'},
7
+ :MA => {url: 'http://www.4gamer.net/guide/ggxrd/031723018/', selector: 'div#table_result_4 table'},
8
+ :MI => {url: 'http://www.4gamer.net/guide/ggxrd/031723018/', selector: 'div#table_result_5 table'},
9
+ :ZT => {url: 'http://www.4gamer.net/guide/ggxrd/031723018/', selector: 'div#table_result_6 table'},
10
+ :PO => {url: 'http://www.4gamer.net/guide/ggxrd/031723018/', selector: 'div#table_result_7 table'},
11
+ :CH => {url: 'http://www.4gamer.net/guide/ggxrd/031723018/', selector: 'div#table_result_8 table'},
12
+ :FA => {url: 'http://www.4gamer.net/guide/ggxrd/031723018/', selector: 'div#table_result_9 table'},
13
+ :AX => {url: 'http://www.4gamer.net/guide/ggxrd/031723018/', selector: 'div#table_result_10 table'},
14
+ :VE => {url: 'http://www.4gamer.net/guide/ggxrd/031723018/', selector: 'div#table_result_11 table'},
15
+ :SL => {url: 'http://www.4gamer.net/guide/ggxrd/031723018/', selector: 'div#table_result_12 table'},
16
+ :IN => {url: 'http://www.4gamer.net/guide/ggxrd/031723018/', selector: 'div#table_result_13 table'},
17
+ :BE => {url: 'http://www.4gamer.net/guide/ggxrd/031723018/', selector: 'div#table_result_14 table'},
18
+ :RA => {url: 'http://www.4gamer.net/guide/ggxrd/031723052/', selector: 'div#table_result_15 table'},
19
+ :SI => {url: 'http://www.4gamer.net/guide/ggxrd/031723052/', selector: 'div#table_result_16 table'},
20
+ :EL => {url: 'http://www.4gamer.net/guide/ggxrd/031723052/', selector: 'div#table_result_17 table'},
21
+ :LE => {url: 'http://www.4gamer.net/guide/ggxrd/031723052/', selector: 'div#table_result_18 table'},
22
+ :JO => {url: 'http://www.4gamer.net/guide/ggxrd/031723052/', selector: 'div#table_result_19 table'},
23
+ :JC => {url: 'http://www.4gamer.net/guide/ggxrd/031723052/', selector: 'div#table_result_20 table'},
24
+ :JA => {url: 'http://www.4gamer.net/guide/ggxrd/031723052/', selector: 'div#table_result_21 table'},
25
+ :RV => {url: 'http://www.4gamer.net/guide/ggxrd/031723052/', selector: 'div#table_result_22 table'},
26
+ :KU => {url: 'http://www.4gamer.net/guide/ggxrd/031723052/', selector: 'div#table_result_23 table'},
27
+ :DI => {url: 'http://www.4gamer.net/guide/ggxrd/031723052/', selector: 'div#table_result_24 table'},
28
+ :BA => {url: 'http://www.4gamer.net/guide/ggxrd/031723052/', selector: 'div#table_result_25 table'},
29
+ :AS => {url: 'http://www.4gamer.net/guide/ggxrd/031723052/', selector: 'div#table_result_26 table'},
30
+ }
31
+ end
32
+ end
@@ -0,0 +1,19 @@
1
+ module GGXrd
2
+ class Frames
3
+ COLUMN = [
4
+ 'name',
5
+ 'damage',
6
+ 'tension',
7
+ 'attack_lv',
8
+ 'risc_lv',
9
+ 'prorate',
10
+ 'attribute',
11
+ 'startup',
12
+ 'active',
13
+ 'recovery',
14
+ 'frame_adv',
15
+ 'invincibility',
16
+ 'remarks',
17
+ ]
18
+ end
19
+ end
@@ -0,0 +1,5 @@
1
+ module GGXrd
2
+ class Frames
3
+ class ScrapingError < StandardError; end
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module GGXrd
2
+ class Frames
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,131 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ggxrd-frames
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - megane42
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-02-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: mechanize
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.7'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.8'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.8'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '5.8'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '5.8'
69
+ - !ruby/object:Gem::Dependency
70
+ name: webmock
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.3'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.3'
83
+ description: This gem scrapes GGXrd official frame data page (http://www.4gamer.net/guide/ggxrd/)
84
+ and gives you the result as a hash.
85
+ email:
86
+ - h.kzm.gm@gmail.com
87
+ executables: []
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - ".travis.yml"
93
+ - CODE_OF_CONDUCT.md
94
+ - Gemfile
95
+ - LICENSE.txt
96
+ - README.md
97
+ - Rakefile
98
+ - bin/console
99
+ - bin/setup
100
+ - ggxrd-frames.gemspec
101
+ - lib/ggxrd/frames.rb
102
+ - lib/ggxrd/frames/characters.rb
103
+ - lib/ggxrd/frames/column.rb
104
+ - lib/ggxrd/frames/error.rb
105
+ - lib/ggxrd/frames/version.rb
106
+ homepage: https://github.com/megane42/ggxrd-frames
107
+ licenses:
108
+ - MIT
109
+ metadata:
110
+ allowed_push_host: https://rubygems.org
111
+ post_install_message:
112
+ rdoc_options: []
113
+ require_paths:
114
+ - lib
115
+ required_ruby_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ requirements: []
126
+ rubyforge_project:
127
+ rubygems_version: 2.6.11
128
+ signing_key:
129
+ specification_version: 4
130
+ summary: Unofficial gem which scrapes GGXrd official frame data page
131
+ test_files: []