milc 0.1.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -1
- data/lib/milc.rb +4 -3
- data/lib/milc/base.rb +4 -48
- data/lib/milc/command.rb +57 -0
- data/lib/milc/dsl/gcloud.rb +2 -0
- data/lib/milc/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5735bc7e72aa87ca2f8f91bae8fd2b6394454549
|
4
|
+
data.tar.gz: 93a8cfaf9d61bebbfcf4278706fb9512d4f2e4d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2cc1f200024d564b9b8e70d4a4798d023b2233195b182844593d6da0ae9aea84c96242242b4c7b90d09f49d61a7b2bbfa6b00d2567bd8e9682ffa5126d152865
|
7
|
+
data.tar.gz: d64616db530bc58b0bb1f2e33f9aff441f0258e70564e6a5e8cfb806a413eca33f1923a5dc2286ffa45e594c2530f6c155765404cd4a84dcc3a48542a3890cef
|
data/.travis.yml
CHANGED
data/lib/milc.rb
CHANGED
@@ -3,10 +3,11 @@ require "milc/version"
|
|
3
3
|
require 'logger'
|
4
4
|
|
5
5
|
module Milc
|
6
|
-
autoload :Base, 'milc/base'
|
7
|
-
autoload :Dsl
|
6
|
+
autoload :Base , 'milc/base'
|
7
|
+
autoload :Dsl , 'milc/dsl'
|
8
|
+
autoload :Gcloud , 'milc/gcloud'
|
8
9
|
|
9
|
-
autoload :
|
10
|
+
autoload :Command, 'milc/command'
|
10
11
|
|
11
12
|
class << self
|
12
13
|
attr_accessor :dry_run
|
data/lib/milc/base.rb
CHANGED
@@ -2,11 +2,8 @@
|
|
2
2
|
|
3
3
|
require "milc"
|
4
4
|
|
5
|
-
require 'json'
|
6
5
|
require 'erb'
|
7
6
|
require 'yaml'
|
8
|
-
require 'optparse'
|
9
|
-
require 'shellwords'
|
10
7
|
|
11
8
|
require 'logger_pipe'
|
12
9
|
|
@@ -19,10 +16,6 @@ end
|
|
19
16
|
|
20
17
|
module Milc
|
21
18
|
module Base
|
22
|
-
include Milc::Dsl::Gcloud
|
23
|
-
include Milc::Dsl::Mgcloud
|
24
|
-
|
25
|
-
include Milc::Dsl::Ansible
|
26
19
|
|
27
20
|
def logger
|
28
21
|
Milc.logger
|
@@ -34,28 +27,19 @@ module Milc
|
|
34
27
|
block_given? ? yield(res) : res
|
35
28
|
end
|
36
29
|
|
37
|
-
|
38
|
-
@config = YAML.load_file_with_erb(yaml_path)
|
39
|
-
load_config
|
40
|
-
end
|
41
|
-
|
42
|
-
attr_reader :config
|
30
|
+
attr_accessor :config
|
43
31
|
attr_reader :project
|
44
32
|
|
45
33
|
def dry_run
|
46
34
|
Milc.dry_run
|
47
35
|
end
|
48
36
|
|
37
|
+
# overriden
|
49
38
|
def load_config
|
50
39
|
@project = config['PROJECT'] || ENV['PROJECT']
|
51
40
|
end
|
52
41
|
|
53
|
-
|
54
|
-
## シェルスクリプトのUsage
|
55
|
-
$stderr.puts help_message
|
56
|
-
exit 1
|
57
|
-
end
|
58
|
-
|
42
|
+
# overriden
|
59
43
|
def help_message
|
60
44
|
## スクリプト名
|
61
45
|
cmdname = File.basename($0) # $PROGRAM_NAME を推奨
|
@@ -63,36 +47,8 @@ module Milc
|
|
63
47
|
"Usage: #{cmdname} -c CONF_FILE"
|
64
48
|
end
|
65
49
|
|
66
|
-
|
67
|
-
"nVc:" # n と V と c: は必須
|
68
|
-
end
|
69
|
-
|
50
|
+
# overriden
|
70
51
|
def load_options(options)
|
71
|
-
if options["c"]
|
72
|
-
load_from_yaml(options["c"])
|
73
|
-
else
|
74
|
-
show_help_and_exit1
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def setup(args)
|
79
|
-
# ARGV.getopts については以下を参照
|
80
|
-
# http://d.hatena.ne.jp/zariganitosh/20140819/ruby_optparser_true_power
|
81
|
-
# http://docs.ruby-lang.org/ja/2.1.0/method/OptionParser=3a=3aArguable/i/getopts.html
|
82
|
-
args.extend(OptionParser::Arguable) unless args.is_a?(OptionParser::Arguable)
|
83
|
-
options = args.getopts(command_options)
|
84
|
-
show_help_and_exit1 unless args.empty?
|
85
|
-
|
86
|
-
Milc.dry_run = !!options["n"]
|
87
|
-
Milc.verbose = !!options["V"]
|
88
|
-
|
89
|
-
load_options(options)
|
90
|
-
end
|
91
|
-
|
92
|
-
def run(args)
|
93
|
-
setup(args)
|
94
|
-
process
|
95
|
-
# exit 0
|
96
52
|
end
|
97
53
|
|
98
54
|
end
|
data/lib/milc/command.rb
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require 'milc'
|
3
|
+
|
4
|
+
require 'optparse'
|
5
|
+
|
6
|
+
module Milc
|
7
|
+
class Command
|
8
|
+
|
9
|
+
attr_reader :logic
|
10
|
+
def initialize(logic)
|
11
|
+
@logic = logic
|
12
|
+
end
|
13
|
+
|
14
|
+
def run(args)
|
15
|
+
setup(args)
|
16
|
+
logic.process
|
17
|
+
# exit 0
|
18
|
+
end
|
19
|
+
|
20
|
+
def setup(args)
|
21
|
+
# ARGV.getopts については以下を参照
|
22
|
+
# http://d.hatena.ne.jp/zariganitosh/20140819/ruby_optparser_true_power
|
23
|
+
# http://docs.ruby-lang.org/ja/2.1.0/method/OptionParser=3a=3aArguable/i/getopts.html
|
24
|
+
args.extend(OptionParser::Arguable) unless args.is_a?(OptionParser::Arguable)
|
25
|
+
options = args.getopts(command_options)
|
26
|
+
show_help_and_exit1 unless args.empty?
|
27
|
+
|
28
|
+
Milc.dry_run = !!options["n"]
|
29
|
+
Milc.verbose = !!options["V"]
|
30
|
+
|
31
|
+
load_options(options)
|
32
|
+
end
|
33
|
+
|
34
|
+
# overriden
|
35
|
+
def command_options
|
36
|
+
"nVc:" # n と V と c: は必須
|
37
|
+
end
|
38
|
+
|
39
|
+
def show_help_and_exit1
|
40
|
+
## シェルスクリプトのUsage
|
41
|
+
$stderr.puts logic.help_message
|
42
|
+
exit 1
|
43
|
+
end
|
44
|
+
|
45
|
+
def load_options(options)
|
46
|
+
if options["c"]
|
47
|
+
yaml_path = options["c"]
|
48
|
+
logic.config = YAML.load_file_with_erb(yaml_path)
|
49
|
+
logic.load_config
|
50
|
+
else
|
51
|
+
show_help_and_exit1
|
52
|
+
end
|
53
|
+
logic.load_options(options)
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
end
|
data/lib/milc/dsl/gcloud.rb
CHANGED
data/lib/milc/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: milc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- akm
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logger_pipe
|
@@ -101,6 +101,7 @@ files:
|
|
101
101
|
- exe/milc
|
102
102
|
- lib/milc.rb
|
103
103
|
- lib/milc/base.rb
|
104
|
+
- lib/milc/command.rb
|
104
105
|
- lib/milc/dsl.rb
|
105
106
|
- lib/milc/dsl/ansible.rb
|
106
107
|
- lib/milc/dsl/gcloud.rb
|