platina_world 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9557d38b820b7e213ef3c6084f403dac05e80ece
4
- data.tar.gz: 13bfd726e4e2158d597c06487014565e1bf5c9a8
3
+ metadata.gz: 738e240a6d6087bf82cf85d136e1f4fe5a952fae
4
+ data.tar.gz: 8ed17ae1a95d3d3b98563e3d25479af09ffa8d2c
5
5
  SHA512:
6
- metadata.gz: e8967810b3c57eb43c32826f07320ee6a4c57480baf114aedc45ec82d1074c8d4fcd95a4f8ca3530fac379e9ac18928aad8b5501e7f6909343a6622a4faf4763
7
- data.tar.gz: abb3b3b03c4566ec86fbc914c0ebab688540605311eafbbad080723f3f9ede0158c30e8bc3883b9206fef9110e4f96f71a072f5a84b931a43e894770f0c171a8
6
+ metadata.gz: f5b024776558ee93af1385f50286a5bd1e77e2dcc829565d85085c571321653668c07f9562fed6809cefc604d1fa9ca2308ef610953753cd7458576bf2d73144
7
+ data.tar.gz: b5d8ce23316fecf4c6765ab05808141dbcc89c02e69442443c5b01bf0ca4b8d24a0f6d581515f13c22b54b6de4e3bef3c48e8f5e8141d51b631b524009b49b96
data/README.md CHANGED
@@ -42,11 +42,11 @@ If you want to create those directories and files
42
42
  └── spec_helper.rb
43
43
  ```
44
44
 
45
- Create a below file as `pw.yml`
45
+ Create a below file as `$HOME/.platina_world/ruby.yml`
46
46
 
47
47
  ```yml
48
48
  - lib:
49
- - paltinaworld
49
+ - paltinaworld:
50
50
  - paltinaworld.rb
51
51
  - spec:
52
52
  - paltinaworld:
@@ -59,16 +59,18 @@ Create a below file as `pw.yml`
59
59
  and run as below
60
60
 
61
61
  ```bash
62
- $ platinaworld -p pw.yml
62
+ $ platinaworld ruby
63
63
  ```
64
64
 
65
-
66
65
  ## TODO
67
66
 
68
67
  - [x] dry-run
69
68
  - [x] logger
70
69
  - [x] error class
71
70
  - [x] check file exist or not
71
+ - [x] dot file
72
+ - [x] usage
73
+ - [ ] manager spec
72
74
  - [ ] has contents
73
75
  - [ ] json parse
74
76
  - [ ] tree command json parse
@@ -2,6 +2,7 @@ require "optparse"
2
2
  require "platina_world/runners/dry"
3
3
  require "platina_world/runners/production"
4
4
  require "platina_world/file_loader"
5
+ require "platina_world/template_manager"
5
6
 
6
7
  module PlatinaWorld
7
8
  class Command
@@ -10,7 +11,14 @@ module PlatinaWorld
10
11
  end
11
12
 
12
13
  def call
13
- runner.run
14
+ case
15
+ when list?
16
+ template_manager.all
17
+ when setup?
18
+ template_manager.setup
19
+ else
20
+ runner.run
21
+ end
14
22
  end
15
23
 
16
24
  private
@@ -27,12 +35,35 @@ module PlatinaWorld
27
35
  end
28
36
  end
29
37
 
38
+ def template_manager
39
+ @tempalte_manager ||= TemplateManager.new
40
+ end
41
+
30
42
  def loaded_file
31
- @loaded_file ||= PlatinaWorld::FileLoader.new(file_path).load
43
+ PlatinaWorld::FileLoader.new(file_path).load
32
44
  end
33
45
 
34
46
  def file_path
35
- options["path"]
47
+ if template_path
48
+ template_manager.file(template_path)
49
+ else
50
+ options["path"]
51
+ end
52
+ end
53
+
54
+ def template_path
55
+ @template_path ||= begin
56
+ option_parser.permute!(@argv) # call #permute! to clear @argv
57
+ @argv.pop
58
+ end
59
+ end
60
+
61
+ def setup?
62
+ options["setup"]
63
+ end
64
+
65
+ def list?
66
+ options["list"]
36
67
  end
37
68
 
38
69
  def dry_run?
@@ -46,8 +77,14 @@ module PlatinaWorld
46
77
  def option_parser
47
78
  @optin_parser ||= OptionParser.new do |opt|
48
79
  opt.version = PlatinaWorld::VERSION
80
+ opt.banner = "Usage: platinaworld [options]\n platinawrold [boilerplate]"
81
+
82
+ opt.separator ""
83
+ opt.separator "Options:"
49
84
  opt.on("-p", "--path [file]", "Configuration file path")
50
85
  opt.on("-n", "--dry-run", "run in dry-run mode")
86
+ opt.on("-l", "--list", "show tempalte lists")
87
+ opt.on("-s", "--setup", "create tempalte directory as #{template_manager.root_path}")
51
88
  end
52
89
  end
53
90
  end
@@ -0,0 +1,43 @@
1
+ require "platina_world/path"
2
+
3
+ module PlatinaWorld
4
+ class TemplateManager
5
+ attr_reader :root_path, :template_file_pattern
6
+
7
+ def initialize
8
+ @root_path = "#{ENV['HOME']}/.platina_world".freeze
9
+ @template_file_pattern = "#{root_path}/*.{yml,yaml}".freeze
10
+ end
11
+
12
+ def all
13
+ @all ||= all_files.each do |file|
14
+ file.match(%r!#{root_path}/(?<attr>.*)\.(yml|yaml)!) do |m|
15
+ puts m[:attr]
16
+ end
17
+ end
18
+ end
19
+
20
+ def setup
21
+ if exist?
22
+ PlatinaWorld::FileStatus.skip(root_path)
23
+ else
24
+ Dir.mkdir(root_path)
25
+ PlatinaWorld::FileStatus.create(root_path)
26
+ end
27
+ end
28
+
29
+ def file(template)
30
+ "#{root_path}/#{template}.yml"
31
+ end
32
+
33
+ def exist?
34
+ ::File.exist?(root_path)
35
+ end
36
+
37
+ private
38
+
39
+ def all_files
40
+ @all_files ||= Dir.glob(template_file_pattern)
41
+ end
42
+ end
43
+ end
@@ -1,3 +1,3 @@
1
1
  module PlatinaWorld
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
File without changes
File without changes
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.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - ganmacs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-30 00:00:00.000000000 Z
11
+ date: 2015-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -86,11 +86,12 @@ files:
86
86
  - lib/platina_world/runners/base.rb
87
87
  - lib/platina_world/runners/dry.rb
88
88
  - lib/platina_world/runners/production.rb
89
+ - lib/platina_world/template_manager.rb
89
90
  - lib/platina_world/version.rb
90
91
  - platinaworld.gemspec
91
- - sample/ruby_world_sample.yml
92
- - sample/simple_sample.json
93
- - sample/simple_sample.yml
92
+ - samples/ruby_world_sample.yml
93
+ - samples/simple_sample.json
94
+ - samples/simple_sample.yml
94
95
  homepage: https://github.com/ganmacs/platina_world
95
96
  licenses: []
96
97
  metadata: {}