brief 1.12.0 → 1.12.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/brief/cli/schema.rb +33 -8
- data/lib/brief/cli/write.rb +2 -2
- data/lib/brief/model.rb +1 -1
- data/lib/brief/version.rb +1 -1
- data/spec/lib/brief/models/writing_prompt_spec.rb +5 -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: 051a957361e6211cc963ba70fb43de08580a8fa1
|
4
|
+
data.tar.gz: 306fa2c7c900fd8597cd90851d509a9eaf1bdf14
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 944d478dc4580175f2a7e253126bedd094039424d2268afa86f48b87e97b38065b7072026cf2c83fe78b5ea07bff0f84353761193a114c0a424d20e8af449a6a
|
7
|
+
data.tar.gz: cc22749c16024de1f0994fabb3f0d14a533b8c2686a13abf433b3506316eafc54e83cc7a17f016e91f1ceae98e53a93ea94d2c8ec551f1c74db4f4535fdc1433
|
data/Gemfile.lock
CHANGED
data/lib/brief/cli/schema.rb
CHANGED
@@ -1,19 +1,44 @@
|
|
1
1
|
command 'schema' do |c|
|
2
|
-
c.syntax = "brief schema"
|
2
|
+
c.syntax = "brief schema [MODEL_CLASS]"
|
3
3
|
c.description = "view information about the schema"
|
4
4
|
|
5
5
|
c.option '--existing-models', 'Include all models, not just those that have documents'
|
6
|
+
c.option '--format TYPE', String, 'Which format to present the information. json, or table'
|
6
7
|
|
7
8
|
c.action do |args, options|
|
8
|
-
|
9
|
+
options.default(format: 'table')
|
10
|
+
briefcase = Brief.case = Brief::Briefcase.new(root: Pathname(args.first || options.root))
|
11
|
+
schema_map = briefcase.schema_map(!!!options.existing_models)
|
9
12
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
13
|
+
payload = schema_map
|
14
|
+
|
15
|
+
if args.length > 0
|
16
|
+
payload = schema_map.fetch(args.first) do
|
17
|
+
raise "Invalid model."
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
if options.format == "json"
|
22
|
+
output = payload.to_json
|
23
|
+
|
24
|
+
if options.output
|
25
|
+
Pathname(options.output).open("w+") {|fh| fh.write(output) }
|
26
|
+
else
|
27
|
+
puts output
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
if options.format == "table"
|
32
|
+
rows = []
|
33
|
+
schema_map.each do |type, definition|
|
34
|
+
defined_in = definition.defined_in.to_s.split("/").reverse.slice(0,3).reverse.join("/")
|
35
|
+
rows.push [type, definition.name, defined_in]
|
36
|
+
end
|
37
|
+
|
38
|
+
require 'terminal-table'
|
39
|
+
table = Terminal::Table.new(:rows => rows, :headings => %w(Type Model Defined-In))
|
40
|
+
puts table
|
15
41
|
end
|
16
42
|
|
17
|
-
output
|
18
43
|
end
|
19
44
|
end
|
data/lib/brief/cli/write.rb
CHANGED
@@ -7,8 +7,8 @@ command 'write' do |c|
|
|
7
7
|
# and determine which CLI arguments those model classes may ask for.
|
8
8
|
c.action do |args, options|
|
9
9
|
options.default(root: Pathname(Brief.pwd))
|
10
|
-
briefcase = Brief.case = Brief::Briefcase.new(root:
|
11
|
-
schema_map = briefcase.schema_map(
|
10
|
+
briefcase = Brief.case = Brief::Briefcase.new(root: options.root)
|
11
|
+
schema_map = briefcase.schema_map()
|
12
12
|
|
13
13
|
type_alias = args.first
|
14
14
|
|
data/lib/brief/model.rb
CHANGED
data/lib/brief/version.rb
CHANGED
@@ -4,8 +4,12 @@ describe "The Page Document Type" do
|
|
4
4
|
let(:page) { Brief.page_document.model_class }
|
5
5
|
let(:concept) { Brief::Concept }
|
6
6
|
|
7
|
+
it "should have some example content" do
|
8
|
+
expect(page.example_content).not_to be_empty
|
9
|
+
end
|
10
|
+
|
7
11
|
it "should return the example because there's no prompt defined" do
|
8
|
-
expect(page.writing_prompt).to eq page.
|
12
|
+
expect(page.writing_prompt).to eq page.example_content
|
9
13
|
end
|
10
14
|
|
11
15
|
it "should return whatever is defined in the prompt dsl" do
|