conquest 0.0.1

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.
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (C) 2012 Vinny Diehl
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ this software and associated documentation files (the "Software"), to deal in
5
+ the Software without restriction, including without limitation the rights to
6
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7
+ of the Software, and to permit persons to whom the Software is furnished to do
8
+ so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
File without changes
@@ -0,0 +1,5 @@
1
+ require "bundler"
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ task dist: :build
5
+ task default: :build
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ case ARGV[0]
4
+ when "-v"
5
+ require "conquest/version"
6
+ puts "Conquest Version #{Conquest::VERSION} on Ruby #{RUBY_VERSION}"
7
+ when "-g"
8
+ begin
9
+ require "conquest/gtk"
10
+ rescue LoadError
11
+ STDERR.puts "Install the conquest-gtk gem to run in graphical mode."
12
+ exit 1
13
+ end
14
+
15
+ Conquest::run_gui
16
+ else
17
+ require "conquest"
18
+ Conquest::run_cli
19
+ end
@@ -0,0 +1,25 @@
1
+ require File.expand_path("../lib/conquest/version", __FILE__)
2
+
3
+ Gem::Specification.new do |gem|
4
+ gem.name = "conquest"
5
+ gem.version = Conquest::VERSION
6
+
7
+ gem.author = "Vinny Diehl"
8
+ gem.email = "gbchaosmaster926@gmail.com"
9
+ gem.homepage = "https://github.com/gbchaosmaster/conquest"
10
+
11
+ gem.license = "MIT"
12
+
13
+ gem.summary = "Fetches and compiles Pokemon Conquest hex data."
14
+ gem.description = "Gathers data from Serebii's Pokemon Conquest page and " +
15
+ "uses it to generate ARDS codes."
16
+
17
+ gem.bindir = "bin"
18
+ gem.executables = "conquest"
19
+
20
+ gem.require_paths = %w[lib]
21
+ gem.files = Dir["lib/**/*"] + %w[LICENSE Rakefile README.md conquest.gemspec]
22
+
23
+ gem.add_dependency "nokogiri", "~> 1.5"
24
+ gem.add_dependency "nutella", "~> 0.4"
25
+ end
@@ -0,0 +1,7 @@
1
+ require "conquest/cli"
2
+
3
+ module Conquest
4
+ def self.run_cli
5
+ CLI.start
6
+ end
7
+ end
@@ -0,0 +1,34 @@
1
+ require "conquest/data"
2
+ require "conquest/parser"
3
+
4
+ require "nutella"
5
+
6
+ module Conquest
7
+ class CLI
8
+ def self.start
9
+ print "Downloading data..."
10
+ parser = Parser.new DATA_URL
11
+ puts "\nFinished!"
12
+ puts
13
+
14
+ puts <<-EOS.heredoc
15
+ Please enter where you would like to save your files.
16
+ Enter paths relative to the current directory.
17
+ EOS
18
+ print "Hex List: "
19
+ save_hex_list = STDIN.gets.strip
20
+ print "ARDS Code: "
21
+ save_ards_code = STDIN.gets.strip
22
+
23
+ File.open(save_hex_list, "w") { |f| f << parser.hex_list }
24
+ File.open(save_ards_code, "w") { |f| f << parser.ards_code }
25
+
26
+ puts
27
+ puts <<-EOS.heredoc
28
+ 2 files written:
29
+ #{save_hex_list}
30
+ #{save_ards_code}
31
+ EOS
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,3 @@
1
+ module Conquest
2
+ DATA_URL = "http://www.serebii.net/conquest/pokemon.shtml"
3
+ end
@@ -0,0 +1,34 @@
1
+ require "conquest/pkmn_info"
2
+
3
+ require "nokogiri"
4
+ require "open-uri"
5
+ require "nutella"
6
+
7
+ module Conquest
8
+ class Parser
9
+ def initialize(url)
10
+ # Grab all of the rows from the table containing all of the Pokemon.
11
+ # Drop the first two because they just have header data.
12
+ @pkmn = Nokogiri::HTML(open(url)).css("table.tab > tr").drop(1).map do |p|
13
+ PkmnInfo.new p.children[0].text[1..-1].to_i, p.children[4].text
14
+ end
15
+ end
16
+
17
+ def hex_list
18
+ @pkmn.each_with_index.
19
+ map { |p, i| "%03d - %.2X - %s" % [p.id, i, p.name] }.
20
+ join "\n"
21
+ end
22
+
23
+ def ards_code
24
+ @pkmn.each_with_index.map do |p, i|
25
+ <<-EOS.heredoc % i
26
+ ::#{p.name}
27
+ 52045804 E2431001
28
+ 02045808 E3A060%.2X
29
+ D2000000 00000000
30
+ EOS
31
+ end.join "\n"
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,3 @@
1
+ module Conquest
2
+ PkmnInfo = Struct.new :id, :name
3
+ end
@@ -0,0 +1,3 @@
1
+ module Conquest
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: conquest
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Vinny Diehl
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-10-02 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: nokogiri
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.5'
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: '1.5'
30
+ - !ruby/object:Gem::Dependency
31
+ name: nutella
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '0.4'
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.4'
46
+ description: Gathers data from Serebii's Pokemon Conquest page and uses it to generate
47
+ ARDS codes.
48
+ email: gbchaosmaster926@gmail.com
49
+ executables:
50
+ - conquest
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - lib/conquest/version.rb
55
+ - lib/conquest/cli.rb
56
+ - lib/conquest/parser.rb
57
+ - lib/conquest/pkmn_info.rb
58
+ - lib/conquest/data.rb
59
+ - lib/conquest.rb
60
+ - LICENSE
61
+ - Rakefile
62
+ - README.md
63
+ - conquest.gemspec
64
+ - bin/conquest
65
+ homepage: https://github.com/gbchaosmaster/conquest
66
+ licenses:
67
+ - MIT
68
+ post_install_message:
69
+ rdoc_options: []
70
+ require_paths:
71
+ - lib
72
+ required_ruby_version: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
+ none: false
80
+ requirements:
81
+ - - ! '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ requirements: []
85
+ rubyforge_project:
86
+ rubygems_version: 1.8.24
87
+ signing_key:
88
+ specification_version: 3
89
+ summary: Fetches and compiles Pokemon Conquest hex data.
90
+ test_files: []
91
+ has_rdoc: