platina_world 0.1.4 → 0.1.5
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/Gemfile +2 -0
- data/README.md +14 -2
- data/lib/platina_world/command.rb +12 -12
- data/lib/platina_world/fetchable.rb +31 -0
- data/lib/platina_world/fetcher_builder.rb +27 -0
- data/lib/platina_world/fetchers/base.rb +28 -0
- data/lib/platina_world/fetchers/local.rb +30 -0
- data/lib/platina_world/fetchers/net.rb +18 -0
- data/lib/platina_world/path.rb +38 -13
- data/lib/platina_world/runners/base.rb +31 -7
- data/lib/platina_world/runners/dry.rb +11 -4
- data/lib/platina_world/runners/production.rb +14 -4
- data/lib/platina_world/template_manager.rb +12 -12
- data/lib/platina_world/version.rb +1 -1
- data/samples/contents_sample.yml +3 -0
- metadata +8 -5
- data/lib/platina_world/generators/base.rb +0 -51
- data/lib/platina_world/generators/file.rb +0 -23
- data/lib/platina_world/generators/mock.rb +0 -21
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3068308554e89e3ec93d81b86855bda168c5fd23
|
|
4
|
+
data.tar.gz: d44ea71922386356b1a58e6b94ea372d2f044e8a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 537f2bf6cf2c990629df77cfe161c2db6c69699e76b8b880a632f77e06c2831fbd58667322fc1dfe892433e4c4d45a6a2e616c54f0f0602aa749ee7adee0b9a2
|
|
7
|
+
data.tar.gz: aea445a02ff7cdc04544b730c7f182dec98b9962ef3406d346554b6fb73808b0b7c57f3c70dc92378ff5c03de0d43b64005ac713f359b2e774c6c98b96e4cd7b
|
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
<a href="https://codeclimate.com/github/ganmacs/platina_world"><img src="https://codeclimate.com/github/ganmacs/platina_world/badges/gpa.svg" /></a>
|
|
4
4
|
[](https://travis-ci.org/ganmacs/platina_world)
|
|
5
|
+
[](https://codeclimate.com/github/ganmacs/platina_world/coverage)
|
|
5
6
|
|
|
6
7
|
platina_world Creates platina world in a moment
|
|
7
8
|
|
|
@@ -62,6 +63,17 @@ and run as below
|
|
|
62
63
|
$ platinaworld ruby
|
|
63
64
|
```
|
|
64
65
|
|
|
66
|
+
#### Contents
|
|
67
|
+
|
|
68
|
+
If you want to create file which has contents, then use `@` literal as below.
|
|
69
|
+
|
|
70
|
+
```yml
|
|
71
|
+
- .rspec@https://filepath.com
|
|
72
|
+
- .gitignore@$HOME/.platina_world/t/ruby/.gitignore
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
then create `.rspec` file which contents get from `http://filepaht.com`, and `.gitignore` file which contents get from `$HOME/.platina_world/t/ruby/.gitignore.paltinaworld`
|
|
76
|
+
|
|
65
77
|
## TODO
|
|
66
78
|
|
|
67
79
|
- [x] dry-run
|
|
@@ -70,8 +82,8 @@ $ platinaworld ruby
|
|
|
70
82
|
- [x] check file exist or not
|
|
71
83
|
- [x] dot file
|
|
72
84
|
- [x] usage
|
|
73
|
-
- [
|
|
74
|
-
- [
|
|
85
|
+
- [x] has contents( @postion syntax ?)
|
|
86
|
+
- [x] manager spec
|
|
75
87
|
- [ ] json parse
|
|
76
88
|
- [ ] tree command json parse
|
|
77
89
|
- [ ] easy format
|
|
@@ -13,7 +13,7 @@ module PlatinaWorld
|
|
|
13
13
|
def call
|
|
14
14
|
case
|
|
15
15
|
when list?
|
|
16
|
-
template_manager.
|
|
16
|
+
template_manager.show_items
|
|
17
17
|
when setup?
|
|
18
18
|
template_manager.setup
|
|
19
19
|
else
|
|
@@ -29,9 +29,9 @@ module PlatinaWorld
|
|
|
29
29
|
|
|
30
30
|
def runner_class
|
|
31
31
|
if dry_run?
|
|
32
|
-
PlatinaWorld::
|
|
32
|
+
PlatinaWorld::Runner::Dry
|
|
33
33
|
else
|
|
34
|
-
PlatinaWorld::
|
|
34
|
+
PlatinaWorld::Runner::Production
|
|
35
35
|
end
|
|
36
36
|
end
|
|
37
37
|
|
|
@@ -40,22 +40,22 @@ module PlatinaWorld
|
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
def loaded_file
|
|
43
|
-
PlatinaWorld::FileLoader.new(
|
|
43
|
+
@loaded_file ||= PlatinaWorld::FileLoader.new(tempalte_path).load
|
|
44
44
|
end
|
|
45
45
|
|
|
46
|
-
def
|
|
47
|
-
if
|
|
48
|
-
template_manager.
|
|
46
|
+
def tempalte_path
|
|
47
|
+
if tempalte_name
|
|
48
|
+
template_manager.expand(tempalte_name)
|
|
49
49
|
else
|
|
50
50
|
options["path"]
|
|
51
51
|
end
|
|
52
52
|
end
|
|
53
53
|
|
|
54
|
-
def
|
|
55
|
-
@
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
def tempalte_name
|
|
55
|
+
@tempalte_name ||= begin
|
|
56
|
+
option_parser.permute!(@argv) # call #permute! to clear @argv
|
|
57
|
+
@argv.pop
|
|
58
|
+
end
|
|
59
59
|
end
|
|
60
60
|
|
|
61
61
|
def setup?
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
module PlatinaWorld
|
|
2
|
+
module Fetchable
|
|
3
|
+
def contents
|
|
4
|
+
@contents ||= (contents_fetcher && contents_fetcher.fetch)
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def has_contents?
|
|
8
|
+
!!contents
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
private
|
|
12
|
+
|
|
13
|
+
def contents_path
|
|
14
|
+
fail NotImplementedError
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def has_contents_path?
|
|
18
|
+
!!contents_path
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def contents_fetcher
|
|
22
|
+
return @contents_fetcher if instance_variable_defined?(:@contents_fetcher)
|
|
23
|
+
@contents_fetcher =
|
|
24
|
+
if has_contents_path?
|
|
25
|
+
FetcherBuilder.new(contents_path).build
|
|
26
|
+
else
|
|
27
|
+
nil
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
require "platina_world/fetchers/local"
|
|
2
|
+
require "platina_world/fetchers/net"
|
|
3
|
+
|
|
4
|
+
module PlatinaWorld
|
|
5
|
+
class FetcherBuilder
|
|
6
|
+
def initialize(uri)
|
|
7
|
+
@uri = URI.parse(uri)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def build
|
|
11
|
+
fetcher_class.new(@uri)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
private
|
|
15
|
+
|
|
16
|
+
def fetcher_class
|
|
17
|
+
case @uri
|
|
18
|
+
when URI::HTTP, URI::HTTPS
|
|
19
|
+
::PlatinaWorld::Fetcher::Net
|
|
20
|
+
when URI::Generic
|
|
21
|
+
::PlatinaWorld::Fetcher::Local
|
|
22
|
+
else
|
|
23
|
+
raise "Unknow URI type: #{@uri.class}(#{@uri})"
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
module PlatinaWorld
|
|
2
|
+
module Fetcher
|
|
3
|
+
class Base
|
|
4
|
+
# @uri [URI::HTTP, URI::HTTPS, URI:Generic]
|
|
5
|
+
def initialize(uri)
|
|
6
|
+
@uri = uri
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def fetch
|
|
10
|
+
if valid?
|
|
11
|
+
fetch_contents
|
|
12
|
+
else
|
|
13
|
+
fail "invalid file path: #{@uri}"
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
private
|
|
18
|
+
|
|
19
|
+
def valid?
|
|
20
|
+
raise NotImplementedError
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def fetch_contents
|
|
24
|
+
raise NotImplementedError
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require "platina_world/fetchers/base"
|
|
2
|
+
|
|
3
|
+
module PlatinaWorld
|
|
4
|
+
module Fetcher
|
|
5
|
+
class Local < Base
|
|
6
|
+
CONVERT_TABLE = {
|
|
7
|
+
"$HOME" => ENV["HOME"],
|
|
8
|
+
"$ROOT" => "#{ENV['HOME']}/.platina_world"
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
private
|
|
12
|
+
|
|
13
|
+
def valid?
|
|
14
|
+
exist_resouce?
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def fetch_contents
|
|
18
|
+
File.read(expanded_uri)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def expanded_uri
|
|
22
|
+
@expanded_uri ||= @uri.to_s.gsub(%r(\$[^/]+), CONVERT_TABLE)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def exist_resouce?
|
|
26
|
+
::File.exist?(expanded_uri)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
data/lib/platina_world/path.rb
CHANGED
|
@@ -1,35 +1,60 @@
|
|
|
1
|
+
require "platina_world/fetcher_builder"
|
|
2
|
+
require "platina_world/fetchable"
|
|
3
|
+
|
|
1
4
|
module PlatinaWorld
|
|
2
5
|
class Path
|
|
3
|
-
|
|
6
|
+
include Fetchable
|
|
4
7
|
|
|
8
|
+
# file_path [String]
|
|
5
9
|
def initialize(file_path)
|
|
6
|
-
@file_path = file_path
|
|
10
|
+
@file_path, @contents_path = split_path(file_path)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def to_s
|
|
14
|
+
@file_path
|
|
7
15
|
end
|
|
8
16
|
|
|
9
17
|
# @return [String] file name
|
|
10
|
-
def
|
|
11
|
-
|
|
18
|
+
def filename
|
|
19
|
+
path_info[:file]
|
|
12
20
|
end
|
|
13
21
|
|
|
14
22
|
# @return [String] directory path
|
|
15
|
-
def
|
|
16
|
-
|
|
23
|
+
def dirname
|
|
24
|
+
path_info[:directory]
|
|
17
25
|
end
|
|
18
26
|
|
|
19
27
|
# @return [True, False] path is directory or not
|
|
20
28
|
def directory?
|
|
21
|
-
|
|
29
|
+
filename == ""
|
|
22
30
|
end
|
|
23
31
|
|
|
24
32
|
# @return [True, False] path has directory path or not
|
|
25
33
|
def has_directory?
|
|
26
|
-
|
|
34
|
+
dirname != ""
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def exist?
|
|
38
|
+
::File.exist?(@file_path)
|
|
27
39
|
end
|
|
28
40
|
|
|
29
41
|
private
|
|
30
42
|
|
|
31
|
-
|
|
32
|
-
|
|
43
|
+
# override
|
|
44
|
+
def contents_path
|
|
45
|
+
@contents_path
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def split_path(path)
|
|
49
|
+
if path.include?("@")
|
|
50
|
+
path.split("@")
|
|
51
|
+
else
|
|
52
|
+
[path, nil]
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def path_info
|
|
57
|
+
@path_info ||= file_and_directory_name
|
|
33
58
|
end
|
|
34
59
|
|
|
35
60
|
# Return file name and dirctory name as Array
|
|
@@ -37,12 +62,12 @@ module PlatinaWorld
|
|
|
37
62
|
#
|
|
38
63
|
# Examples.
|
|
39
64
|
# file_path = "a/b/c"
|
|
40
|
-
# file_and_directory_name => { directory: "a/b", file: "c"}
|
|
65
|
+
# file_and_directory_name(file_path) # => { directory: "a/b", file: "c"}
|
|
41
66
|
#
|
|
42
67
|
# file_path = "a/b/c/"
|
|
43
|
-
# file_and_directory_name(
|
|
68
|
+
# file_and_directory_name(file_path) # => { directory: "a/b/c", file: ""}
|
|
44
69
|
def file_and_directory_name
|
|
45
|
-
path = file_path.split("/", -1)
|
|
70
|
+
path = @file_path.split("/", -1)
|
|
46
71
|
file_name = path.pop
|
|
47
72
|
directory_name = path.join("/")
|
|
48
73
|
|
|
@@ -1,28 +1,52 @@
|
|
|
1
1
|
require "platina_world/path_builder"
|
|
2
2
|
|
|
3
3
|
module PlatinaWorld
|
|
4
|
-
module
|
|
4
|
+
module Runner
|
|
5
5
|
class Base
|
|
6
6
|
def initialize(loaded_file)
|
|
7
7
|
@loaded_file = loaded_file
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
def run
|
|
11
|
-
|
|
11
|
+
paths.each do |path|
|
|
12
|
+
file_path = path.to_s
|
|
13
|
+
|
|
14
|
+
if path.exist?
|
|
15
|
+
PlatinaWorld::FileStatus.skip(file_path)
|
|
16
|
+
else
|
|
17
|
+
generate(path)
|
|
18
|
+
PlatinaWorld::FileStatus.create(file_path)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
12
21
|
end
|
|
13
22
|
|
|
14
23
|
private
|
|
15
24
|
|
|
16
|
-
def
|
|
25
|
+
def paths
|
|
26
|
+
@paths ||= PlatinaWorld::PathBuilder.new(@loaded_file).build
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def generate(path)
|
|
30
|
+
case
|
|
31
|
+
when path.directory?
|
|
32
|
+
generate_directory(path)
|
|
33
|
+
when path.has_directory?
|
|
34
|
+
generate_file_with_dir(path)
|
|
35
|
+
else
|
|
36
|
+
generate_file(path)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def generate_directory(path)
|
|
17
41
|
raise NotImplementedError
|
|
18
42
|
end
|
|
19
43
|
|
|
20
|
-
def
|
|
21
|
-
|
|
44
|
+
def generate_file_with_dir(path)
|
|
45
|
+
raise NotImplementedError
|
|
22
46
|
end
|
|
23
47
|
|
|
24
|
-
def
|
|
25
|
-
|
|
48
|
+
def generate_file(path)
|
|
49
|
+
raise NotImplementedError
|
|
26
50
|
end
|
|
27
51
|
end
|
|
28
52
|
end
|
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
require "platina_world/runners/base"
|
|
2
|
-
require "platina_world/generators/mock"
|
|
3
2
|
|
|
4
3
|
module PlatinaWorld
|
|
5
|
-
module
|
|
4
|
+
module Runner
|
|
6
5
|
class Dry < Base
|
|
7
6
|
private
|
|
8
7
|
|
|
9
|
-
def
|
|
10
|
-
|
|
8
|
+
def generate_directory(path)
|
|
9
|
+
# noop
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def generate_file_with_dir(path)
|
|
13
|
+
# noop
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def generate_file(path)
|
|
17
|
+
# noop
|
|
11
18
|
end
|
|
12
19
|
end
|
|
13
20
|
end
|
|
@@ -1,13 +1,23 @@
|
|
|
1
1
|
require "platina_world/runners/base"
|
|
2
|
-
require
|
|
2
|
+
require 'fileutils'
|
|
3
3
|
|
|
4
4
|
module PlatinaWorld
|
|
5
|
-
module
|
|
5
|
+
module Runner
|
|
6
6
|
class Production < Base
|
|
7
7
|
private
|
|
8
8
|
|
|
9
|
-
def
|
|
10
|
-
|
|
9
|
+
def generate_directory(path)
|
|
10
|
+
FileUtils.mkdir_p(path.to_s)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def generate_file_with_dir(path)
|
|
14
|
+
FileUtils.mkdir_p(path.dirname)
|
|
15
|
+
generate_file(path)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def generate_file(path)
|
|
19
|
+
FileUtils.touch(path.to_s)
|
|
20
|
+
::File.write(path.to_s, path.contents) if path.has_contents?
|
|
11
21
|
end
|
|
12
22
|
end
|
|
13
23
|
end
|
|
@@ -2,14 +2,13 @@ require "platina_world/path"
|
|
|
2
2
|
|
|
3
3
|
module PlatinaWorld
|
|
4
4
|
class TemplateManager
|
|
5
|
-
attr_reader :
|
|
5
|
+
attr_reader :template_file_pattern
|
|
6
6
|
|
|
7
7
|
def initialize
|
|
8
|
-
@root_path = "#{ENV['HOME']}/.platina_world".freeze
|
|
9
8
|
@template_file_pattern = "#{root_path}/*.{yml,yaml}".freeze
|
|
10
9
|
end
|
|
11
10
|
|
|
12
|
-
def
|
|
11
|
+
def show_items
|
|
13
12
|
@all ||= all_files.each do |file|
|
|
14
13
|
file.match(%r!#{root_path}/(?<attr>.*)\.(yml|yaml)!) do |m|
|
|
15
14
|
puts m[:attr]
|
|
@@ -17,23 +16,24 @@ module PlatinaWorld
|
|
|
17
16
|
end
|
|
18
17
|
end
|
|
19
18
|
|
|
19
|
+
def root_path
|
|
20
|
+
@root_path ||= Path.new("#{ENV['HOME']}/.platina_world".freeze)
|
|
21
|
+
end
|
|
22
|
+
|
|
20
23
|
def setup
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
path = root_path.to_s
|
|
25
|
+
if root_path.exist?
|
|
26
|
+
PlatinaWorld::FileStatus.skip(path)
|
|
23
27
|
else
|
|
24
|
-
Dir.mkdir(
|
|
25
|
-
PlatinaWorld::FileStatus.create(
|
|
28
|
+
Dir.mkdir(path)
|
|
29
|
+
PlatinaWorld::FileStatus.create(path)
|
|
26
30
|
end
|
|
27
31
|
end
|
|
28
32
|
|
|
29
|
-
def
|
|
33
|
+
def expand(template)
|
|
30
34
|
"#{root_path}/#{template}.yml"
|
|
31
35
|
end
|
|
32
36
|
|
|
33
|
-
def exist?
|
|
34
|
-
::File.exist?(root_path)
|
|
35
|
-
end
|
|
36
|
-
|
|
37
37
|
private
|
|
38
38
|
|
|
39
39
|
def all_files
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: platina_world
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- ganmacs
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-
|
|
11
|
+
date: 2015-10-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -73,10 +73,12 @@ files:
|
|
|
73
73
|
- lib/platina_world/errors/base.rb
|
|
74
74
|
- lib/platina_world/errors/file_path_error.rb
|
|
75
75
|
- lib/platina_world/errors/invalid_extension_error.rb
|
|
76
|
+
- lib/platina_world/fetchable.rb
|
|
77
|
+
- lib/platina_world/fetcher_builder.rb
|
|
78
|
+
- lib/platina_world/fetchers/base.rb
|
|
79
|
+
- lib/platina_world/fetchers/local.rb
|
|
80
|
+
- lib/platina_world/fetchers/net.rb
|
|
76
81
|
- lib/platina_world/file_loader.rb
|
|
77
|
-
- lib/platina_world/generators/base.rb
|
|
78
|
-
- lib/platina_world/generators/file.rb
|
|
79
|
-
- lib/platina_world/generators/mock.rb
|
|
80
82
|
- lib/platina_world/logger.rb
|
|
81
83
|
- lib/platina_world/loggers/base.rb
|
|
82
84
|
- lib/platina_world/loggers/file_status.rb
|
|
@@ -89,6 +91,7 @@ files:
|
|
|
89
91
|
- lib/platina_world/template_manager.rb
|
|
90
92
|
- lib/platina_world/version.rb
|
|
91
93
|
- platinaworld.gemspec
|
|
94
|
+
- samples/contents_sample.yml
|
|
92
95
|
- samples/ruby_world_sample.yml
|
|
93
96
|
- samples/simple_sample.json
|
|
94
97
|
- samples/simple_sample.yml
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
module PlatinaWorld
|
|
2
|
-
module Generators
|
|
3
|
-
class Base
|
|
4
|
-
def initialize(paths)
|
|
5
|
-
@paths = paths
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
def call
|
|
9
|
-
@paths.each do |path|
|
|
10
|
-
file_path = path.file_path
|
|
11
|
-
|
|
12
|
-
if file_exist?(file_path)
|
|
13
|
-
PlatinaWorld::FileStatus.skip(file_path)
|
|
14
|
-
else
|
|
15
|
-
generate(path)
|
|
16
|
-
PlatinaWorld::FileStatus.create(file_path)
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
private
|
|
22
|
-
|
|
23
|
-
def generate(path)
|
|
24
|
-
case
|
|
25
|
-
when path.directory?
|
|
26
|
-
generate_directory(path)
|
|
27
|
-
when path.has_directory?
|
|
28
|
-
generate_file_with_dir(path)
|
|
29
|
-
else
|
|
30
|
-
generate_file(path)
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def file_exist?(file_path)
|
|
35
|
-
::File.exist?(file_path)
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def generate_directory(path)
|
|
39
|
-
raise NotImplementedError
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def generate_file_with_dir(path)
|
|
43
|
-
raise NotImplementedError
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def generate_file(path)
|
|
47
|
-
raise NotImplementedError
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
end
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
require "platina_world/generators/base"
|
|
2
|
-
require "fileutils"
|
|
3
|
-
|
|
4
|
-
module PlatinaWorld
|
|
5
|
-
module Generators
|
|
6
|
-
class File < Base
|
|
7
|
-
private
|
|
8
|
-
|
|
9
|
-
def generate_directory(path)
|
|
10
|
-
FileUtils.mkdir_p(path.directory_name)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def generate_file_with_dir(path)
|
|
14
|
-
FileUtils.mkdir_p(path.directory_name)
|
|
15
|
-
FileUtils.touch("#{path.directory_name}/#{path.file_name}")
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def generate_file(path)
|
|
19
|
-
FileUtils.touch(path.file_name)
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
require "platina_world/generators/base"
|
|
2
|
-
|
|
3
|
-
module PlatinaWorld
|
|
4
|
-
module Generators
|
|
5
|
-
class Mock < Base
|
|
6
|
-
private
|
|
7
|
-
|
|
8
|
-
def generate_directory(path)
|
|
9
|
-
# noop
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def generate_file_with_dir(path)
|
|
13
|
-
# noop
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def generate_file(path)
|
|
17
|
-
# noop
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|