brief 1.12.0 → 1.12.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7d3a25a4f211d9862e3c879242f4e83b92adc4ba
4
- data.tar.gz: b418898c05d11d75bf7c50fb3e17dc72816cfa81
3
+ metadata.gz: 051a957361e6211cc963ba70fb43de08580a8fa1
4
+ data.tar.gz: 306fa2c7c900fd8597cd90851d509a9eaf1bdf14
5
5
  SHA512:
6
- metadata.gz: 47ebd49ce1aabf8eacaa33b9eee6fc14c33f46df37018b72e2f37f79aef07670bdc21bd7282bf6f66c3c4f6fb2a5929991361489c0b9d27f990608b0c06f31b7
7
- data.tar.gz: d75ef3692fbf0b5a6f1139a6dba427f2f3047435275d7d9a64b2e770bd950440dc6a591317798443a20b3eafa6f24c403aab17a61f18dc1e9e5f15f1c6055304
6
+ metadata.gz: 944d478dc4580175f2a7e253126bedd094039424d2268afa86f48b87e97b38065b7072026cf2c83fe78b5ea07bff0f84353761193a114c0a424d20e8af449a6a
7
+ data.tar.gz: cc22749c16024de1f0994fabb3f0d14a533b8c2686a13abf433b3506316eafc54e83cc7a17f016e91f1ceae98e53a93ea94d2c8ec551f1c74db4f4535fdc1433
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- brief (1.12.0)
4
+ brief (1.12.1)
5
5
  activesupport (> 3.2)
6
6
  commander (~> 4.3)
7
7
  em-websocket (~> 0.5)
@@ -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
- schema_map = Brief.case(true).schema_map(!!!options.existing_models)
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
- output = if args.empty?
11
- schema_map.to_json
12
- else
13
- detail = schema_map.fetch(args.first.downcase, nil)
14
- detail.to_json if detail
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
@@ -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: Pathname(args.first || options.root))
11
- schema_map = briefcase.schema_map(true)
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
@@ -322,7 +322,7 @@ module Brief
322
322
  def writing_prompt(*args)
323
323
  _prompt = definition._prompt
324
324
  return _prompt.call(*args) if _prompt && _prompt.respond_to?(:call)
325
- example_body
325
+ example_content
326
326
  end
327
327
 
328
328
  def documentation(*args)
data/lib/brief/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Brief
2
- VERSION = '1.12.0'
2
+ VERSION = '1.12.1'
3
3
  end
@@ -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.example_body
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brief
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.12.0
4
+ version: 1.12.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Soeder