platina_world 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rspec +3 -0
- data/.rubocop.yml +50 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/README.md +64 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/platinaworld +5 -0
- data/bin/setup +7 -0
- data/lib/platina_world/command.rb +31 -0
- data/lib/platina_world/file_generator.rb +38 -0
- data/lib/platina_world/file_loader.rb +39 -0
- data/lib/platina_world/path.rb +47 -0
- data/lib/platina_world/path_builder.rb +36 -0
- data/lib/platina_world/runner.rb +33 -0
- data/lib/platina_world/version.rb +3 -0
- data/lib/platina_world.rb +5 -0
- data/platinaworld.gemspec +24 -0
- data/sample/ruby_world_sample.yml +11 -0
- data/sample/simple_sample.yml +5 -0
- metadata +106 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f31d00b3ea593d1fa7c061549b79b11d97ee355b
|
4
|
+
data.tar.gz: bbac5d46e8c508e5f9edd4e70478e0c8f61e6e89
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: eacb10bc3083672ecae9303924db160f0183de885d8efc2693cae61ba4c9fc45e551997dfe16b64ac034401a2e6c24eaf22ab1ecc059d0d5083c4f839bdc03b9
|
7
|
+
data.tar.gz: 8104a3ec927bbbce3586436b20fef34482ab4071b8941ac38f96ebd6427d669d4eb96fa6f23311ac173078d7438810cec5599f880b60dd197d983c5983db9867
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
StringLiterals:
|
2
|
+
EnforcedStyle: double_quotes
|
3
|
+
|
4
|
+
Metrics/LineLength:
|
5
|
+
Max: 120
|
6
|
+
|
7
|
+
Metrics/CyclomaticComplexity:
|
8
|
+
Enabled: false
|
9
|
+
|
10
|
+
Metrics/ClassLength:
|
11
|
+
Enabled: false
|
12
|
+
|
13
|
+
Metrics/AbcSize:
|
14
|
+
Max: 40
|
15
|
+
|
16
|
+
Metrics/MethodLength:
|
17
|
+
CountComments: false
|
18
|
+
Max: 19
|
19
|
+
|
20
|
+
Style/Documentation:
|
21
|
+
Enabled: false
|
22
|
+
|
23
|
+
Style/AsciiComments:
|
24
|
+
Enabled: false
|
25
|
+
|
26
|
+
Style/SignalException:
|
27
|
+
Enabled: false
|
28
|
+
|
29
|
+
Style/DoubleNegation:
|
30
|
+
Enabled: false
|
31
|
+
|
32
|
+
Style/GuardClause:
|
33
|
+
Enabled: false
|
34
|
+
|
35
|
+
Style/PercentLiteralDelimiters:
|
36
|
+
Enabled: false
|
37
|
+
|
38
|
+
RegexpLiteral:
|
39
|
+
MaxSlashes: 0
|
40
|
+
|
41
|
+
Style/AndOr:
|
42
|
+
Enabled: false
|
43
|
+
|
44
|
+
Style/FormatString:
|
45
|
+
Enabled: false
|
46
|
+
|
47
|
+
Style/PredicateName:
|
48
|
+
NamePrefixBlacklist:
|
49
|
+
- is_
|
50
|
+
- have_
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# PlatinaWorld
|
2
|
+
|
3
|
+
<a href="https://codeclimate.com/github/ganmacs/platina_world"><img src="https://codeclimate.com/github/ganmacs/platina_world/badges/gpa.svg" /></a>
|
4
|
+
[![Build Status](https://travis-ci.org/ganmacs/platina_world.svg)](https://travis-ci.org/ganmacs/platina_world)
|
5
|
+
|
6
|
+
platina_world Creates platina world in a moment
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem 'platina_world'
|
14
|
+
```
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
```bash
|
19
|
+
$ bundle
|
20
|
+
```
|
21
|
+
|
22
|
+
Or install it yourself as:
|
23
|
+
|
24
|
+
```bash
|
25
|
+
$ gem install platina_world
|
26
|
+
```
|
27
|
+
|
28
|
+
## Usage
|
29
|
+
|
30
|
+
If you want to create those directories and files
|
31
|
+
|
32
|
+
```
|
33
|
+
.
|
34
|
+
├── .gitignore
|
35
|
+
├── .rspec
|
36
|
+
├── lib
|
37
|
+
│ ├── platina_world
|
38
|
+
│ └── platina_world.rb
|
39
|
+
└── spec
|
40
|
+
├── platina_world
|
41
|
+
│ └── platinaworld_spec.rb
|
42
|
+
└── spec_helper.rb
|
43
|
+
```
|
44
|
+
|
45
|
+
Create a below file as `pw.yml`
|
46
|
+
|
47
|
+
```yml
|
48
|
+
- lib:
|
49
|
+
- paltinaworld
|
50
|
+
- paltinaworld.rb
|
51
|
+
- spec:
|
52
|
+
- paltinaworld:
|
53
|
+
- platinaworld_spec.rb
|
54
|
+
- spec_helper.rb
|
55
|
+
- .rspec
|
56
|
+
- .gitignore
|
57
|
+
```
|
58
|
+
|
59
|
+
and run as below
|
60
|
+
|
61
|
+
```bash
|
62
|
+
$ platinaworld -p pw.yml
|
63
|
+
```
|
64
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "platina_world"
|
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
|
data/bin/platinaworld
ADDED
data/bin/setup
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require "optparse"
|
2
|
+
require "platina_world/runner"
|
3
|
+
|
4
|
+
module PlatinaWorld
|
5
|
+
class Command
|
6
|
+
def initialize(argv = ARGV)
|
7
|
+
@argv = argv
|
8
|
+
end
|
9
|
+
|
10
|
+
def call
|
11
|
+
runner.run
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def runner
|
17
|
+
@runner ||= PlatinaWorld::Runner.new(options)
|
18
|
+
end
|
19
|
+
|
20
|
+
def options
|
21
|
+
@options ||= option_parser.getopts(@argv)
|
22
|
+
end
|
23
|
+
|
24
|
+
def option_parser
|
25
|
+
@optin_parser ||= OptionParser.new do |opt|
|
26
|
+
opt.version = PlatinaWorld::VERSION
|
27
|
+
opt.on("-p", "--path [file]", "Configuration file path") { |file_path| file_path }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require "platina_world/path_builder"
|
2
|
+
require "fileutils"
|
3
|
+
|
4
|
+
module PlatinaWorld
|
5
|
+
class FileGenerator
|
6
|
+
def initialize(paths)
|
7
|
+
@paths = paths
|
8
|
+
end
|
9
|
+
|
10
|
+
def call
|
11
|
+
@paths.each do |path|
|
12
|
+
case
|
13
|
+
when path.directory?
|
14
|
+
generate_directory(path)
|
15
|
+
when path.has_directory?
|
16
|
+
generate_file_with_dir(path)
|
17
|
+
else
|
18
|
+
generate_file(path)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def generate_directory(path)
|
26
|
+
FileUtils.mkdir_p(path.directory_name)
|
27
|
+
end
|
28
|
+
|
29
|
+
def generate_file(path)
|
30
|
+
FileUtils.touch(path.file_name)
|
31
|
+
end
|
32
|
+
|
33
|
+
def generate_file_with_dir(path)
|
34
|
+
FileUtils.mkdir_p(path.directory_name)
|
35
|
+
FileUtils.touch("#{path.directory_name}/#{path.file_name}")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require "yaml"
|
2
|
+
|
3
|
+
module PlatinaWorld
|
4
|
+
class FileLoader
|
5
|
+
DEFAULT_FILE_PATH = "./platina_world.yml".freeze
|
6
|
+
ACCEPT_EXT_NAMES = %w(.yml .yaml).freeze
|
7
|
+
|
8
|
+
def initialize(file_path = DEFAULT_FILE_PATH)
|
9
|
+
@file_path = file_path
|
10
|
+
end
|
11
|
+
|
12
|
+
def load
|
13
|
+
case
|
14
|
+
when !exist_file?
|
15
|
+
raise "#{file_path} is not found."
|
16
|
+
when !valid_ext_name?
|
17
|
+
raise "Ext name is invalid. plase pass .yml or .yaml file"
|
18
|
+
else
|
19
|
+
file_load
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
attr_reader :file_path
|
26
|
+
|
27
|
+
def file_load
|
28
|
+
YAML.load_file(file_path)
|
29
|
+
end
|
30
|
+
|
31
|
+
def exist_file?
|
32
|
+
File.exist?(file_path)
|
33
|
+
end
|
34
|
+
|
35
|
+
def valid_ext_name?
|
36
|
+
ACCEPT_EXT_NAMES.include?(File.extname(file_path))
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module PlatinaWorld
|
2
|
+
class Path
|
3
|
+
def initialize(file_path)
|
4
|
+
@file_path = file_path
|
5
|
+
end
|
6
|
+
|
7
|
+
def file_name
|
8
|
+
path[:file]
|
9
|
+
end
|
10
|
+
|
11
|
+
def directory_name
|
12
|
+
path[:directory]
|
13
|
+
end
|
14
|
+
|
15
|
+
def directory?
|
16
|
+
file_name == ""
|
17
|
+
end
|
18
|
+
|
19
|
+
def has_directory?
|
20
|
+
directory_name != ""
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
attr_reader :file_path
|
26
|
+
|
27
|
+
# Return file name and dirctory name as Array
|
28
|
+
# @params [String] file path (e.g "a/b/c")
|
29
|
+
# @return [[String, String]] first is file path name and second is directory path name
|
30
|
+
#
|
31
|
+
# Examples.
|
32
|
+
# file_and_dir_name("a/b/c") => ["a/b", "c"]
|
33
|
+
# file_and_dir_name("a/b/c/") => ["a/b/c", ""]
|
34
|
+
def path
|
35
|
+
@path ||= begin
|
36
|
+
path = file_path.split("/", -1)
|
37
|
+
file_name = path.pop
|
38
|
+
directory_name = path.join("/")
|
39
|
+
|
40
|
+
{
|
41
|
+
file: file_name,
|
42
|
+
directory: directory_name
|
43
|
+
}
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require "platina_world/path"
|
2
|
+
|
3
|
+
module PlatinaWorld
|
4
|
+
class PathBuilder
|
5
|
+
def initialize(loaded_data)
|
6
|
+
@loaded_data = loaded_data
|
7
|
+
end
|
8
|
+
|
9
|
+
def build
|
10
|
+
generate_paths(@loaded_data).flat_map do |file_path|
|
11
|
+
PlatinaWorld::Path.new(file_path)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def generate_paths(paths)
|
18
|
+
case paths
|
19
|
+
when Array
|
20
|
+
paths.flat_map { |p| generate_paths(p) }
|
21
|
+
when Hash
|
22
|
+
dir = paths.keys.first
|
23
|
+
files_in_dir = paths.values.first
|
24
|
+
|
25
|
+
if files_in_dir
|
26
|
+
v = generate_paths(files_in_dir)
|
27
|
+
v.map { |e| "#{dir}/#{e}" }
|
28
|
+
else
|
29
|
+
"#{dir}/"
|
30
|
+
end
|
31
|
+
else
|
32
|
+
[paths]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require "platina_world/file_loader"
|
2
|
+
require "platina_world/file_generator"
|
3
|
+
require "platina_world/path_builder"
|
4
|
+
|
5
|
+
module PlatinaWorld
|
6
|
+
class Runner
|
7
|
+
def initialize(options)
|
8
|
+
@options = options
|
9
|
+
end
|
10
|
+
|
11
|
+
def run
|
12
|
+
file_generator.call
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def file_generator
|
18
|
+
PlatinaWorld::FileGenerator.new(paths)
|
19
|
+
end
|
20
|
+
|
21
|
+
def paths
|
22
|
+
@paths ||= PlatinaWorld::PathBuilder.new(loaded_data).build
|
23
|
+
end
|
24
|
+
|
25
|
+
def loaded_data
|
26
|
+
@loaded_data ||= PlatinaWorld::FileLoader.new(file_path).load
|
27
|
+
end
|
28
|
+
|
29
|
+
def file_path
|
30
|
+
@options["file"]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "platina_world/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "platina_world"
|
8
|
+
spec.version = PlatinaWorld::VERSION
|
9
|
+
spec.authors = ["ganmacs"]
|
10
|
+
spec.email = ["ganmacs@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = "Creating platina world in a moment"
|
13
|
+
spec.description = "Creating platina world in a moment"
|
14
|
+
spec.homepage = "https://github.com/ganmacs/platina_world"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.9"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "rspec"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: platina_world
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- ganmacs
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-08-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.9'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.9'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Creating platina world in a moment
|
56
|
+
email:
|
57
|
+
- ganmacs@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".rspec"
|
64
|
+
- ".rubocop.yml"
|
65
|
+
- ".travis.yml"
|
66
|
+
- Gemfile
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- bin/console
|
70
|
+
- bin/platinaworld
|
71
|
+
- bin/setup
|
72
|
+
- lib/platina_world.rb
|
73
|
+
- lib/platina_world/command.rb
|
74
|
+
- lib/platina_world/file_generator.rb
|
75
|
+
- lib/platina_world/file_loader.rb
|
76
|
+
- lib/platina_world/path.rb
|
77
|
+
- lib/platina_world/path_builder.rb
|
78
|
+
- lib/platina_world/runner.rb
|
79
|
+
- lib/platina_world/version.rb
|
80
|
+
- platinaworld.gemspec
|
81
|
+
- sample/ruby_world_sample.yml
|
82
|
+
- sample/simple_sample.yml
|
83
|
+
homepage: https://github.com/ganmacs/platina_world
|
84
|
+
licenses: []
|
85
|
+
metadata: {}
|
86
|
+
post_install_message:
|
87
|
+
rdoc_options: []
|
88
|
+
require_paths:
|
89
|
+
- lib
|
90
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
requirements: []
|
101
|
+
rubyforge_project:
|
102
|
+
rubygems_version: 2.4.5
|
103
|
+
signing_key:
|
104
|
+
specification_version: 4
|
105
|
+
summary: Creating platina world in a moment
|
106
|
+
test_files: []
|