smogon_dex 1.0.3 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/smogon_dex +33 -15
- data/lib/smogon_dex.rb +16 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 616a7c4d2d855b51ba2b4ecd98cf8c6414c20f6f
|
4
|
+
data.tar.gz: 2a6d9065e956e4db1904bab15184f2ca5fc3b0af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d4d42edc4a09911a02cad12bf223dcaf78e1f5bdd14a9183328dcc9b2eb02569cf1227cafe3481c449a0f8f205dd567d5914f2118244e53fd05218db2a6f71c
|
7
|
+
data.tar.gz: da3298962ea4b685e5665cc9023a3433549b2ee0962e4ca4682dd31f86a9ce389e51512b3261a00e74d60390ac478d2588b85ea3ecba7aa478529a3f309f6286
|
data/bin/smogon_dex
CHANGED
@@ -2,26 +2,44 @@
|
|
2
2
|
require "launchy"
|
3
3
|
require "smogon_dex"
|
4
4
|
include SmogonDex
|
5
|
-
gen,
|
5
|
+
$gen, $catagory = nil
|
6
6
|
|
7
|
-
ARGV.each do |
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
ARGV.each do |given|
|
8
|
+
done = false
|
9
|
+
if given =~ /\A\-\-/
|
10
|
+
arg = given.gsub /\A\-\-/, ""
|
11
|
+
if arg == "home"
|
12
|
+
homepage
|
13
|
+
exit
|
12
14
|
end
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
Generations.each do |generation|
|
16
|
+
if arg == generation and $gen.nil?
|
17
|
+
$gen, done = generation, true
|
18
|
+
break
|
19
|
+
end
|
20
|
+
end
|
21
|
+
Catagories.each do |catagory|
|
22
|
+
if arg == catagory and $catagory.nil?
|
23
|
+
$catagory = catagory
|
24
|
+
break
|
25
|
+
end
|
26
|
+
end unless done
|
27
|
+
elsif given =~ /\A\-/ and $catagory.nil?
|
28
|
+
$catagory = case given
|
29
|
+
when /a/ then "abilities"
|
30
|
+
when /m/ then "moves"
|
31
|
+
when /p/ then "pokemon"
|
32
|
+
when /i/ then "items"
|
33
|
+
when /f/ then "formats"
|
34
|
+
when /t/ then "types"
|
35
|
+
else raise "unknown switch: #{given}"
|
18
36
|
end
|
37
|
+
elsif $query.nil?
|
38
|
+
$query = given
|
39
|
+
else warn "Unknown argument: #{given}"
|
19
40
|
end
|
20
41
|
end
|
21
|
-
|
22
|
-
search_catagory ||= "pokemon"
|
23
|
-
gen ||= "xy"
|
24
|
-
Launchy.open url(gen, search_catagory, query)
|
42
|
+
search(gen: $gen, catagory: $catagory, query: $query)
|
25
43
|
|
26
44
|
|
27
45
|
|
data/lib/smogon_dex.rb
CHANGED
@@ -1,8 +1,22 @@
|
|
1
|
+
require "launchy"
|
1
2
|
module SmogonDex
|
2
3
|
Catagories = %w(pokemon moves abilities items formats types)
|
3
4
|
Generations = %w(xy dp gs bw rb rs)
|
5
|
+
|
6
|
+
GEN_ARGS = Generations.map {|gen| "--#{gen}"}
|
7
|
+
CAT_ARGS = Catagories.map {|catagory| "-#{catagory}"}
|
8
|
+
|
4
9
|
module_function
|
5
|
-
def
|
6
|
-
|
10
|
+
def search(data=Hash.new)
|
11
|
+
data[:gen] ||= "xy"
|
12
|
+
data[:catagory] ||= "pokemon"
|
13
|
+
data[:query] ||= String.new
|
14
|
+
|
15
|
+
raise ArgumentError, "#{data[:gen]} is not a valid generation" unless Generations.include? data[:gen]
|
16
|
+
raise ArgumentError, "#{data[:catagory]} is not a valid catagory." unless Catagories.include? data[:catagory]
|
17
|
+
Launchy.open "https://www.smogon.com/dex/#{ data.fetch :gen }/#{ data.fetch :catagory }/#{ data.fetch :query }"
|
18
|
+
end
|
19
|
+
def homepage
|
20
|
+
Launchy.open "https://www.smogon.com/dex"
|
7
21
|
end
|
8
22
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smogon_dex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zachary R. Perlmutter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: launchy
|