showdown-team-import 0.4.2 → 0.5.0
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/VERSION +1 -1
- data/bin/showdown-team-export +61 -0
- data/bin/showdown-team-import +3 -2
- data/showdown-team-import.gemspec +4 -3
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5aa2f0d684be87cb36dde99df21150b458348567
|
4
|
+
data.tar.gz: e3afbed055033562daa27ad6e846ac6c8362bd40
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f64034944a2cbe06228af606581e5c998c4f3e1ac5ae2ca57495027c2a3d5d6d7bb9a62e753436e4c945ae90c4b70037469c3a520ae75a2332f32ef6f6210ac
|
7
|
+
data.tar.gz: 57c811863e35a5601ae88499fdce8fc4fe518944c9aa47024935c9d47abcbde102690b27010905ff9c33afe55e58ed0b43b24e003b551440f9c4861b4e5afadb
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.5.0
|
@@ -0,0 +1,61 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'fileutils'
|
4
|
+
require 'showdown-team-import'
|
5
|
+
require 'optparse'
|
6
|
+
|
7
|
+
@options = {:silent => false,
|
8
|
+
:path => nil,
|
9
|
+
:no_dirs => false}
|
10
|
+
|
11
|
+
@teams = Array.new
|
12
|
+
|
13
|
+
OptionParser.new do |opts|
|
14
|
+
opts.banner = "Usage:" + " #{File.basename(__FILE__)}" + " [options] <File to output backup in>"
|
15
|
+
opts.on('-p', '--path [path]', 'Path to search in') {|v| @options[:path] = v}
|
16
|
+
opts.on( '-h', '--help', 'Display this screen' ) {puts opts; exit}
|
17
|
+
opts.on( '-n', '--no-dirs', 'Use this flag if you used the --no-dirs option while importing') {@options[:no_dirs] = true}
|
18
|
+
end.parse!
|
19
|
+
|
20
|
+
(puts "Output file needed. Run \"#{File.basename(__FILE__)} -h\" for more information."; exit) if ARGV.empty?
|
21
|
+
(puts "Output is an existing directory. Run \"#{File.basename(__FILE__)} -h\" for more information."; exit) if File.exists?(ARGV[0]) && !File.file?(ARGV[0])
|
22
|
+
(puts "Path needed. Run \"#{File.basename(__FILE__)} -h\" for more information. (Use './' to search in current path.)"; exit) if @options[:path].nil?
|
23
|
+
(puts "Path doesn't exist. Run \"#{File.basename(__FILE__)} -h\" for more information."; exit) unless File.exists?(@options[:path])
|
24
|
+
|
25
|
+
|
26
|
+
unless @options[:no_dirs]
|
27
|
+
entries = Dir.entries(@options[:path]).select {|elem| File.directory?(elem)}
|
28
|
+
entries.each do |directory|
|
29
|
+
next if directory == "." || directory == ".."
|
30
|
+
files = Dir.entries(File.join(@options[:path], directory))
|
31
|
+
tier = directory
|
32
|
+
|
33
|
+
files.each do |file|
|
34
|
+
next if file == "." || file == ".." || file == ARGV[0]
|
35
|
+
unless tier == "others"
|
36
|
+
header = "=== [#{tier}] #{file[0..-6]} ===\n\n"
|
37
|
+
else
|
38
|
+
header = "=== #{file[0..-6]} ===\n\n"
|
39
|
+
end
|
40
|
+
|
41
|
+
content = File.read(File.join(@options[:path], directory, file))
|
42
|
+
|
43
|
+
@teams << header + content
|
44
|
+
end
|
45
|
+
end
|
46
|
+
else
|
47
|
+
files = Dir.entries(@options[:path])
|
48
|
+
files.each do |file|
|
49
|
+
next if file == "." || file == ".." || file == ARGV[0]
|
50
|
+
|
51
|
+
header = "=== #{file[0..-6]} ===\n\n"
|
52
|
+
content = File.read(File.join(@options[:path], file))
|
53
|
+
|
54
|
+
@teams << header + content
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
export = @teams.join("\n\n")
|
59
|
+
export << "\n\n"
|
60
|
+
|
61
|
+
File.write(ARGV[0], export)
|
data/bin/showdown-team-import
CHANGED
@@ -49,7 +49,7 @@ teams.each do |team| # actual file writing
|
|
49
49
|
FileUtils::mkdir_p File.join(dir, team.tier)
|
50
50
|
else
|
51
51
|
FileUtils::mkdir_p dir
|
52
|
-
filename = "[#{team.tier}] " + filename
|
52
|
+
filename = "[#{team.tier}] " + filename unless team.tier == 'others'
|
53
53
|
end
|
54
54
|
location = File.join(dir, filename) # saving in specified directory
|
55
55
|
else # saving in current directory
|
@@ -57,7 +57,8 @@ teams.each do |team| # actual file writing
|
|
57
57
|
FileUtils::mkdir_p team.tier
|
58
58
|
location = filename
|
59
59
|
else
|
60
|
-
|
60
|
+
filename = "[#{team.tier}] " + filename unless team.tier == 'others'
|
61
|
+
location = filename
|
61
62
|
end
|
62
63
|
end
|
63
64
|
|
@@ -2,11 +2,11 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: showdown-team-import 0.
|
5
|
+
# stub: showdown-team-import 0.5.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "showdown-team-import"
|
9
|
-
s.version = "0.
|
9
|
+
s.version = "0.5.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
|
|
14
14
|
s.date = "2015-09-11"
|
15
15
|
s.description = "A basic ruby gem which takes a Pokemon Showdown! team backup file and writes each team as a separate file inside the specified directory (or in the current directory). Teams will be organized by \ntier."
|
16
16
|
s.email = "aptyget@gmail.com"
|
17
|
-
s.executables = ["showdown-team-import"]
|
17
|
+
s.executables = ["showdown-team-export", "showdown-team-import"]
|
18
18
|
s.extra_rdoc_files = [
|
19
19
|
"LICENSE.txt",
|
20
20
|
"README.md"
|
@@ -27,6 +27,7 @@ Gem::Specification.new do |s|
|
|
27
27
|
"README.md",
|
28
28
|
"Rakefile",
|
29
29
|
"VERSION",
|
30
|
+
"bin/showdown-team-export",
|
30
31
|
"bin/showdown-team-import",
|
31
32
|
"lib/showdown-team-import.rb",
|
32
33
|
"showdown-team-import.gemspec"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: showdown-team-import
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- apt-get
|
@@ -57,6 +57,7 @@ description: "A basic ruby gem which takes a Pokemon Showdown! team backup file
|
|
57
57
|
directory). Teams will be organized by \ntier."
|
58
58
|
email: aptyget@gmail.com
|
59
59
|
executables:
|
60
|
+
- showdown-team-export
|
60
61
|
- showdown-team-import
|
61
62
|
extensions: []
|
62
63
|
extra_rdoc_files:
|
@@ -70,6 +71,7 @@ files:
|
|
70
71
|
- README.md
|
71
72
|
- Rakefile
|
72
73
|
- VERSION
|
74
|
+
- bin/showdown-team-export
|
73
75
|
- bin/showdown-team-import
|
74
76
|
- lib/showdown-team-import.rb
|
75
77
|
- showdown-team-import.gemspec
|