brief 1.9.0 → 1.9.1
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.lock +1 -1
- data/lib/brief/briefcase.rb +5 -3
- data/lib/brief/cli/01_extensions.rb +23 -13
- data/lib/brief/cli/all.rb +12 -17
- data/lib/brief/cli/export.rb +14 -21
- data/lib/brief/cli/parse.rb +6 -14
- data/lib/brief/cli/schema.rb +2 -12
- data/lib/brief/model/serializers.rb +3 -3
- data/lib/brief/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0457268f9d394e5149e2bc1b48189c5c6baf91b2
|
4
|
+
data.tar.gz: 429a4e214373841c3db8281246228f4b00b4d2ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8df3869a124d86b6554fc933648b686a0a308377f5399b79e4a93da25985e992e51283fbeb5f5a2cfb0d0230d8a171e75bd9b4cb537af5a0dc464f7df00303e9
|
7
|
+
data.tar.gz: 011ceb6a4b2c6cb359816b8acc708ed9d32f8095e9b613e14776930677c4b86e0998a4ce4baa235236795c51e50c1592d1ae5d7e68acbb4541d511831e4d4cc0
|
data/Gemfile.lock
CHANGED
data/lib/brief/briefcase.rb
CHANGED
@@ -59,11 +59,11 @@ module Brief
|
|
59
59
|
cache_key: briefcase.cache_key
|
60
60
|
}
|
61
61
|
|
62
|
-
if params[:include_schema]
|
62
|
+
if params[:include_schema] || params[:schema]
|
63
63
|
base[:schema] = schema_map
|
64
64
|
end
|
65
65
|
|
66
|
-
if params[:include_models]
|
66
|
+
if params[:include_models] || params[:models]
|
67
67
|
model_settings = {
|
68
68
|
docs_path: docs_path
|
69
69
|
}
|
@@ -73,6 +73,7 @@ module Brief
|
|
73
73
|
end
|
74
74
|
|
75
75
|
all = all_models.compact
|
76
|
+
|
76
77
|
base[:models] = all.map {|m| m.as_json(model_settings) }
|
77
78
|
end
|
78
79
|
|
@@ -80,7 +81,8 @@ module Brief
|
|
80
81
|
end
|
81
82
|
|
82
83
|
def as_full_export(options={})
|
83
|
-
|
84
|
+
options.reverse_merge!(content: true, rendered: true, models: true, schema: true)
|
85
|
+
as_default(options)
|
84
86
|
end
|
85
87
|
|
86
88
|
def use(module_type=:app, module_id)
|
@@ -1,29 +1,39 @@
|
|
1
1
|
class Commander::Command
|
2
|
-
def action(*
|
2
|
+
def action(*a, &block)
|
3
3
|
Brief.default_cli_options(self)
|
4
4
|
|
5
5
|
when_called do |args, options|
|
6
|
-
options.default(root: Brief.pwd)
|
7
|
-
Brief.case = Brief::Briefcase.new(root: Pathname(options.root))
|
6
|
+
options.default(root: Brief.pwd, config_filename: 'brief.rb', format: :printed)
|
8
7
|
|
9
|
-
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
8
|
+
root = Pathname(options.root)
|
13
9
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
options.default(root: Brief.pwd)
|
10
|
+
if root.join(options.config_filename).exist?
|
11
|
+
Brief.case = Brief::Briefcase.new(root: root)
|
12
|
+
end
|
18
13
|
|
19
|
-
|
14
|
+
result = block.call(args, options)
|
15
|
+
|
16
|
+
case
|
17
|
+
when options.output && options.format.to_sym == :json
|
18
|
+
Pathname(options.output).open("w+") do |fh|
|
19
|
+
fh.write(result.to_json)
|
20
|
+
end
|
21
|
+
when options.format.to_sym == :json
|
22
|
+
puts result.to_json
|
23
|
+
when options.format.to_sym == :printed
|
24
|
+
puts result
|
25
|
+
end
|
20
26
|
|
21
|
-
block.call(args, options)
|
22
27
|
end
|
23
28
|
end
|
29
|
+
end
|
24
30
|
|
31
|
+
module Brief
|
25
32
|
def self.default_cli_options(c)
|
26
33
|
c.option '--root DIRECTORY', String, 'The root for the briefcase'
|
27
34
|
c.option '--config FILE', String, 'Path to the config file for this briefcase'
|
35
|
+
c.option '--config-filename', String, 'The default filename for a briefcase config: brief.rb'
|
36
|
+
c.option '--output FILE', String, 'Save the output in the specified path'
|
37
|
+
c.option '--format FORMAT', String, 'How to format the CLI output: defaults to printed, accepts printed,json'
|
28
38
|
end
|
29
39
|
end
|
data/lib/brief/cli/all.rb
CHANGED
@@ -29,6 +29,8 @@ command 'change' do |c|
|
|
29
29
|
if options.dry_run
|
30
30
|
puts documents
|
31
31
|
end
|
32
|
+
|
33
|
+
documents
|
32
34
|
end
|
33
35
|
end
|
34
36
|
|
@@ -50,6 +52,8 @@ command 'init' do |c|
|
|
50
52
|
require 'brief/briefcase/initializer'
|
51
53
|
Brief::Briefcase.create_new_briefcase(root: root, app: options.app)
|
52
54
|
end
|
55
|
+
|
56
|
+
false
|
53
57
|
end
|
54
58
|
end
|
55
59
|
|
@@ -57,16 +61,15 @@ command "browse" do |c|
|
|
57
61
|
c.syntax = "brief browse FOLDER"
|
58
62
|
c.description = "Lists information about each of the briefcases in FOLDER"
|
59
63
|
|
60
|
-
c.option '--format FORMAT', String, 'Which format to render the output in? default: printed, or json'
|
61
|
-
c.option '--presenter-format FORMAT', String, 'Which presenter to use?'
|
62
64
|
c.option '--config-filename FILENAME', String, 'Which filename has the briefcase config? default(brief.rb)'
|
65
|
+
c.option '--presenter-format FORMAT', String, 'Which presenter to use?'
|
63
66
|
c.option '--include-schema', 'Include schema information'
|
64
67
|
c.option '--include-models', 'Include individual models as well'
|
65
68
|
c.option '--include-content', 'Gets passed to the model renderers if present'
|
66
69
|
c.option '--include-rendered', 'Gets passed to the model renderers if present'
|
67
70
|
c.option '--include-urls', 'Gets passed to the model renderers if present'
|
68
71
|
|
69
|
-
c.
|
72
|
+
c.action do |args, options|
|
70
73
|
folder = Pathname(args.first)
|
71
74
|
|
72
75
|
options.default(config_filename:'brief.rb', presenter_format: 'default')
|
@@ -77,20 +80,12 @@ command "browse" do |c|
|
|
77
80
|
|
78
81
|
briefcases = roots.map {|root| Brief::Briefcase.new(root: Pathname(root).realpath) }
|
79
82
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
models: options.include_models)
|
87
|
-
end
|
88
|
-
|
89
|
-
puts output.to_json
|
90
|
-
else
|
91
|
-
briefcases.each do |bc|
|
92
|
-
puts bc
|
93
|
-
end
|
83
|
+
briefcases.map do |b|
|
84
|
+
b.present(options.presenter_format, rendered: options.include_rendered,
|
85
|
+
content: options.include_content,
|
86
|
+
urls: options.include_urls,
|
87
|
+
schema: options.include_schema,
|
88
|
+
models: options.include_models)
|
94
89
|
end
|
95
90
|
end
|
96
91
|
end
|
data/lib/brief/cli/export.rb
CHANGED
@@ -2,31 +2,24 @@ command 'export' do |c|
|
|
2
2
|
c.syntax = 'brief export PATH [OPTIONS]'
|
3
3
|
c.description = 'export the briefcase found in PATH'
|
4
4
|
|
5
|
-
c.option '--
|
6
|
-
c.option '--
|
7
|
-
c.option '--
|
5
|
+
c.option '--presenter-format FORMAT', String, 'Which presenter to use?'
|
6
|
+
c.option '--include-schema', 'Include schema information'
|
7
|
+
c.option '--include-models', 'Include individual models as well'
|
8
|
+
c.option '--include-content', 'Gets passed to the model renderers if present'
|
9
|
+
c.option '--include-rendered', 'Gets passed to the model renderers if present'
|
10
|
+
c.option '--include-urls', 'Gets passed to the model renderers if present'
|
8
11
|
|
9
12
|
c.action do |args, options|
|
10
|
-
|
13
|
+
options.default(presenter_format: "full_export")
|
11
14
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
+
root = Pathname(args.first)
|
16
|
+
briefcase = Brief::Briefcase.new(root: root)
|
17
|
+
briefcase.present(options.presenter_format, rendered: options.include_rendered,
|
18
|
+
content: options.include_content,
|
19
|
+
urls: options.include_urls,
|
20
|
+
schema: options.include_schema,
|
21
|
+
models: options.include_models)
|
15
22
|
|
16
|
-
o[:app] = options.app if options.app
|
17
|
-
o[:config_path] = options.config if options.config
|
18
|
-
|
19
|
-
briefcase = Brief::Briefcase.new(o)
|
20
|
-
|
21
|
-
export = briefcase.as_full_export.to_json
|
22
|
-
|
23
|
-
if options.output
|
24
|
-
output = Pathname(options.output)
|
25
|
-
output = output.join(briefcase.slug + ".json") if output.directory?
|
26
|
-
output.open("w+") {|fh| fh.write(export) }
|
27
|
-
else
|
28
|
-
puts export
|
29
|
-
end
|
30
23
|
end
|
31
24
|
end
|
32
25
|
|
data/lib/brief/cli/parse.rb
CHANGED
@@ -2,21 +2,17 @@ command 'parse' do |c|
|
|
2
2
|
c.syntax = 'brief parse PATH [OPTIONS]'
|
3
3
|
c.description = 'parse the briefcase path'
|
4
4
|
|
5
|
-
c.option '--
|
6
|
-
c.option '--
|
7
|
-
c.option '--app APP', String, 'Use the specified app to get our models etc'
|
8
|
-
c.option '--config PATH', String, 'Use the specified config file'
|
9
|
-
c.option '--type TYPE', String, 'Valid options: hash, array; Output as a hash keyed by path, or an array. Defaults to array.'
|
5
|
+
c.option '--output-type TYPE', String, 'Valid options: hash, array; Output as a hash keyed by path, or an array. Defaults to array.'
|
6
|
+
c.option '--config-path FILE', String, 'Path to the config file for the briefcase'
|
10
7
|
|
11
8
|
c.action do |args, options|
|
12
|
-
options.default(root: Pathname(Brief.pwd),
|
9
|
+
options.default(root: Pathname(Brief.pwd), output_type: "array")
|
13
10
|
|
14
11
|
o = {
|
15
12
|
root: options.root
|
16
13
|
}
|
17
14
|
|
18
|
-
o[:
|
19
|
-
o[:config_path] = options.config if options.config
|
15
|
+
o[:config_path] = options.config_path if options.config_path
|
20
16
|
|
21
17
|
briefcase = Brief::Briefcase.new(o)
|
22
18
|
|
@@ -33,7 +29,7 @@ command 'parse' do |c|
|
|
33
29
|
end.flatten
|
34
30
|
end
|
35
31
|
|
36
|
-
if options.
|
32
|
+
if options.output_type == "hash"
|
37
33
|
parsed = parsed.inject({}) do |memo, obj|
|
38
34
|
path = obj[:path]
|
39
35
|
memo[path] = obj
|
@@ -41,10 +37,6 @@ command 'parse' do |c|
|
|
41
37
|
end
|
42
38
|
end
|
43
39
|
|
44
|
-
|
45
|
-
Pathname(options.output).open("w+") {|fh| fh.write(parsed.to_json) }
|
46
|
-
else
|
47
|
-
puts parsed.to_json
|
48
|
-
end
|
40
|
+
parsed
|
49
41
|
end
|
50
42
|
end
|
data/lib/brief/cli/schema.rb
CHANGED
@@ -2,13 +2,9 @@ command 'schema' do |c|
|
|
2
2
|
c.syntax = "brief schema"
|
3
3
|
c.description = "view information about the schema"
|
4
4
|
|
5
|
-
Brief.default_cli_options(c)
|
6
|
-
|
7
|
-
c.option '--output FILE', String, 'Output the contents to the specified file'
|
8
5
|
c.option '--all-models', 'Include all models, not just those that have documents'
|
9
|
-
c.option '--list-types', 'Only list the types'
|
10
6
|
|
11
|
-
|
7
|
+
c.action do |args, options|
|
12
8
|
schema_map = Brief.case.schema_map(options.all_models)
|
13
9
|
|
14
10
|
output = if args.empty?
|
@@ -18,12 +14,6 @@ command 'schema' do |c|
|
|
18
14
|
detail.to_json if detail
|
19
15
|
end
|
20
16
|
|
21
|
-
|
22
|
-
Pathname(options.output).open "w+" do |fh|
|
23
|
-
fh.write(output.chomp)
|
24
|
-
end
|
25
|
-
else
|
26
|
-
puts output
|
27
|
-
end
|
17
|
+
output
|
28
18
|
end
|
29
19
|
end
|
@@ -24,8 +24,8 @@ module Brief::Model::Serializers
|
|
24
24
|
sections: {},
|
25
25
|
section_headings: [],
|
26
26
|
}.tap do |h|
|
27
|
-
h[:content] = document.combined_data_and_content if options[:content]
|
28
|
-
h[:rendered] = document.to_html if options[:rendered]
|
27
|
+
h[:content] = document.combined_data_and_content if options[:content] || options[:include_content]
|
28
|
+
h[:rendered] = document.to_html if options[:rendered] || options[:include_rendered]
|
29
29
|
|
30
30
|
h[:urls] = {
|
31
31
|
view_content_url: "/view/content/#{ doc_path }",
|
@@ -35,7 +35,7 @@ module Brief::Model::Serializers
|
|
35
35
|
remove_url: "/remove/#{ doc_path }",
|
36
36
|
schema_url: "/schema/#{ type }",
|
37
37
|
actions_url: "/actions/:action/#{ doc_path }"
|
38
|
-
} if options[:urls]
|
38
|
+
} if options[:urls] || options[:include_urls]
|
39
39
|
end.tap do |h|
|
40
40
|
if document.has_sections?
|
41
41
|
h[:section_headings] = document.section_headings
|
data/lib/brief/version.rb
CHANGED