qb 0.1.47 → 0.1.48
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +1 -0
- data/lib/qb.rb +36 -7
- data/lib/qb/options.rb +3 -0
- data/lib/qb/role.rb +62 -3
- data/lib/qb/util.rb +28 -0
- data/lib/qb/version.rb +1 -1
- data/qb.gemspec +1 -0
- data/roles/qb.gitignore/meta/qb +4 -0
- data/roles/qb.install/meta/qb.yml +11 -2
- data/roles/qb.qb_role/templates/qb.yml.j2 +4 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0eb9c603416537655809bf3a2147a55cd35e1833
|
4
|
+
data.tar.gz: f6c6ae61026428b672ee0dd61a01dddfddd492bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65c50309bd1d3501a14228cced913d84351d8192df54b13f777d9e99c50fbabefd757d384c6bfdecfbe8b9725f60fc48b0d85a44660af08851a459cdd60a9b24
|
7
|
+
data.tar.gz: c719eb898d4fc602559396028dcd7fb6b98534b96645d718ccad76d40cbcd388dc11ddff24669ac385778c8db164f53b15be3f2f71a828c679eb1b5d54927cff
|
data/.yardopts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--markup markdown
|
data/lib/qb.rb
CHANGED
@@ -43,24 +43,40 @@ module QB
|
|
43
43
|
options: options
|
44
44
|
|
45
45
|
key = 'default_dir'
|
46
|
-
|
47
|
-
|
46
|
+
value = role.meta[key]
|
47
|
+
case value
|
48
|
+
when nil
|
48
49
|
# there is no get_dir info in meta/qb.yml, can't get the dir
|
49
50
|
raise "unable to infer default directory: no '#{ key }' key in meta/qb.yml"
|
50
|
-
|
51
|
+
|
52
|
+
when false
|
53
|
+
# this method should not get called when the value is false (an entire
|
54
|
+
# section is skipped in exe/qb when `default_dir = false`)
|
55
|
+
raise "role does not use default directory (meta/qb.yml:default_dir = false)"
|
56
|
+
|
51
57
|
when 'git_root'
|
52
58
|
debug "returning the git root relative to cwd"
|
53
59
|
NRSER.git_root cwd
|
54
60
|
|
55
61
|
when 'cwd'
|
56
|
-
debug "
|
62
|
+
debug "returning current working directory"
|
57
63
|
cwd
|
58
64
|
|
59
65
|
when Hash
|
60
66
|
debug "qb meta option is a Hash"
|
61
67
|
|
62
|
-
|
63
|
-
|
68
|
+
unless value.length == 1
|
69
|
+
raise "#{ role.meta_path.to_s }:default_dir invalid: #{ value.inspect }"
|
70
|
+
end
|
71
|
+
|
72
|
+
hash_key, hash_value = value.first
|
73
|
+
|
74
|
+
case hash_key
|
75
|
+
when 'exe'
|
76
|
+
exe_path = hash_value
|
77
|
+
|
78
|
+
# supply the options to the exe so it can make work off those values
|
79
|
+
# if it wants.
|
64
80
|
exe_input_data = Hash[
|
65
81
|
options.map {|option|
|
66
82
|
[option.cli_option_name, option.value]
|
@@ -78,8 +94,21 @@ module QB
|
|
78
94
|
Cmds.chomp! exe_path do
|
79
95
|
JSON.dump exe_input_data
|
80
96
|
end
|
97
|
+
|
98
|
+
when 'find_up'
|
99
|
+
filename = hash_value
|
100
|
+
|
101
|
+
unless filename.is_a? String
|
102
|
+
raise "find_up filename must be string, found #{ filename.inspect }"
|
103
|
+
end
|
104
|
+
|
105
|
+
debug "found 'find_up', looking for file named #{ filename }"
|
106
|
+
|
107
|
+
Util.find_up filename
|
108
|
+
|
81
109
|
else
|
82
|
-
raise "
|
110
|
+
raise "bad key: #{ hash_key } in #{ role.meta_path.to_s }:default_dir"
|
111
|
+
|
83
112
|
end
|
84
113
|
end
|
85
114
|
end # get_default_dir
|
data/lib/qb/options.rb
CHANGED
data/lib/qb/role.rb
CHANGED
@@ -3,9 +3,20 @@ require 'cmds'
|
|
3
3
|
require 'parseconfig'
|
4
4
|
|
5
5
|
module QB
|
6
|
+
# contains info on a QB role.
|
7
|
+
#
|
8
|
+
#
|
6
9
|
class Role
|
10
|
+
# attrs
|
11
|
+
# =====
|
12
|
+
|
7
13
|
attr_accessor :path, :name, :rel_path
|
8
14
|
|
15
|
+
# @!attribute [r] meta_path
|
16
|
+
# @return [String, nil] the path qb metadata was load from. `nil` if it's
|
17
|
+
# never been loaded or doesn't exist.
|
18
|
+
attr_accessor :meta_path
|
19
|
+
|
9
20
|
# errors
|
10
21
|
# ======
|
11
22
|
|
@@ -273,6 +284,9 @@ module QB
|
|
273
284
|
end
|
274
285
|
|
275
286
|
@name = path.to_s.split(File::SEPARATOR).last
|
287
|
+
|
288
|
+
# gets filled in when {#meta_load}
|
289
|
+
@meta_path = nil
|
276
290
|
end
|
277
291
|
|
278
292
|
def to_s
|
@@ -300,13 +314,18 @@ module QB
|
|
300
314
|
#
|
301
315
|
# if `cache` is true caches it as `@meta`
|
302
316
|
#
|
303
|
-
def load_meta cache = true
|
317
|
+
def load_meta cache = true
|
304
318
|
meta = if (@path + 'meta' + 'qb').exist?
|
305
|
-
|
319
|
+
@meta_path = @path + 'meta' + 'qb'
|
320
|
+
YAML.load(Cmds.out!(@meta_path.realpath.to_s)) || {}
|
321
|
+
|
306
322
|
elsif (@path + 'meta' + 'qb.yml').exist?
|
307
|
-
|
323
|
+
@meta_path = @path + 'meta' + 'qb.yml'
|
324
|
+
YAML.load(@meta_path.read) || {}
|
325
|
+
|
308
326
|
else
|
309
327
|
{}
|
328
|
+
|
310
329
|
end
|
311
330
|
|
312
331
|
if cache
|
@@ -422,6 +441,46 @@ module QB
|
|
422
441
|
lines.join("\n")
|
423
442
|
end
|
424
443
|
|
444
|
+
def examples
|
445
|
+
@meta['examples']
|
446
|
+
end
|
447
|
+
|
448
|
+
# format the `meta.examples` hash into a string suitable for cli
|
449
|
+
# output.
|
450
|
+
#
|
451
|
+
# @return [String]
|
452
|
+
# the CLI-formatted examples.
|
453
|
+
#
|
454
|
+
def format_examples
|
455
|
+
examples.
|
456
|
+
map {|title, body|
|
457
|
+
[
|
458
|
+
"#{ title }:",
|
459
|
+
body.lines.map {|l|
|
460
|
+
# only indent non-empty lines
|
461
|
+
# makes compacting newline sequences easier (see below)
|
462
|
+
if l.match(/^\s*$/)
|
463
|
+
l
|
464
|
+
else
|
465
|
+
' ' + l
|
466
|
+
end
|
467
|
+
},
|
468
|
+
''
|
469
|
+
]
|
470
|
+
}.
|
471
|
+
flatten.
|
472
|
+
join("\n").
|
473
|
+
# compact newline sequences
|
474
|
+
gsub(/\n\n+/, "\n\n")
|
475
|
+
end
|
476
|
+
|
477
|
+
# examples text
|
478
|
+
def puts_examples
|
479
|
+
return unless examples
|
480
|
+
|
481
|
+
puts "\n" + format_examples + "\n"
|
482
|
+
end
|
483
|
+
|
425
484
|
private
|
426
485
|
|
427
486
|
# get the value at the first found of the keys or the default.
|
data/lib/qb/util.rb
CHANGED
@@ -50,5 +50,33 @@ module QB
|
|
50
50
|
# shouldn't ever happen
|
51
51
|
raise "resolution failed: #{ segments.inspect }"
|
52
52
|
end
|
53
|
+
|
54
|
+
# find `filename` in `from` or closest parent directory.
|
55
|
+
#
|
56
|
+
# @param [String] filename
|
57
|
+
# name of file to search for.
|
58
|
+
#
|
59
|
+
# @param [Pathname] from (Pathname.pwd)
|
60
|
+
# directory to start from.
|
61
|
+
#
|
62
|
+
# @return [Pathname]
|
63
|
+
# Pathname of found file.
|
64
|
+
#
|
65
|
+
# @raise
|
66
|
+
# if file is not found in `from` or any of it's parent directories.
|
67
|
+
#
|
68
|
+
def self.find_up filename, from = Pathname.pwd
|
69
|
+
path = from + filename
|
70
|
+
|
71
|
+
return from if path.exist?
|
72
|
+
|
73
|
+
parent = from.parent
|
74
|
+
|
75
|
+
if from == parent
|
76
|
+
raise "not found in current or any parent directories: #{ filename }"
|
77
|
+
end
|
78
|
+
|
79
|
+
return find_up filename, parent
|
80
|
+
end # .find_up
|
53
81
|
end # Util
|
54
82
|
end # QB
|
data/lib/qb/version.rb
CHANGED
data/qb.gemspec
CHANGED
@@ -91,6 +91,7 @@ Gem::Specification.new do |spec|
|
|
91
91
|
spec.add_development_dependency "bundler", "~> 1.10"
|
92
92
|
spec.add_development_dependency "rake", "~> 10.0"
|
93
93
|
spec.add_development_dependency "rspec"
|
94
|
+
spec.add_development_dependency "yard"
|
94
95
|
|
95
96
|
spec.add_dependency "cmds",'~> 0.0', ">= 0.0.9"
|
96
97
|
spec.add_dependency "nrser-extras", '~> 0.0', ">= 0.0.3"
|
data/roles/qb.gitignore/meta/qb
CHANGED
@@ -38,6 +38,13 @@ default_user: null
|
|
38
38
|
# set to false to not save options in .qb-options.yml files
|
39
39
|
save_options: false
|
40
40
|
|
41
|
+
examples:
|
42
|
+
create a new role backed by a GitHub repo: >
|
43
|
+
|
44
|
+
qb install --create --name=nrser.blah
|
45
|
+
|
46
|
+
(`name` needs to have the namespace attached if one is desired)
|
47
|
+
|
41
48
|
options:
|
42
49
|
# - name: example
|
43
50
|
# description: an example of a variable.
|
@@ -46,7 +53,9 @@ options:
|
|
46
53
|
# short: e
|
47
54
|
|
48
55
|
- name: name
|
49
|
-
description:
|
56
|
+
description: >
|
57
|
+
name of role to install.
|
58
|
+
include namespace if desired (nrser.blah vs blah).
|
50
59
|
required: true
|
51
60
|
type: string
|
52
61
|
short: n
|
@@ -64,7 +73,7 @@ options:
|
|
64
73
|
short: v
|
65
74
|
|
66
75
|
- name: path
|
67
|
-
description: path to
|
76
|
+
description: path to install roles at.
|
68
77
|
required: false
|
69
78
|
type: string
|
70
79
|
short: p
|
@@ -30,6 +30,10 @@ var_prefix: null
|
|
30
30
|
# - invoke an execuable, passing a JSON serialization of the options
|
31
31
|
# mapping their CLI names to values. path can be relative to role
|
32
32
|
# directory.
|
33
|
+
# - {find_up: FILENAME}
|
34
|
+
# - starting at the current direcotry and climbing up to parent
|
35
|
+
# directories, use the first one that contains FILENAME. error
|
36
|
+
# if none is found.
|
33
37
|
default_dir: null
|
34
38
|
|
35
39
|
# default user to become for play
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.48
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nrser
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: yard
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: cmds
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -140,6 +154,7 @@ executables:
|
|
140
154
|
extensions: []
|
141
155
|
extra_rdoc_files: []
|
142
156
|
files:
|
157
|
+
- ".yardopts"
|
143
158
|
- LICENSE.txt
|
144
159
|
- README.md
|
145
160
|
- ansible.cfg
|