brief 1.11.10 → 1.12.0
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/cli/write.rb +8 -18
- data/lib/brief/model/definition.rb +5 -0
- data/lib/brief/model.rb +7 -1
- data/lib/brief/version.rb +1 -1
- data/spec/fixtures/example/models/concept.rb +4 -0
- data/spec/lib/brief/models/page_spec.rb +0 -1
- data/spec/lib/brief/models/writing_prompt_spec.rb +14 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d3a25a4f211d9862e3c879242f4e83b92adc4ba
|
4
|
+
data.tar.gz: b418898c05d11d75bf7c50fb3e17dc72816cfa81
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47ebd49ce1aabf8eacaa33b9eee6fc14c33f46df37018b72e2f37f79aef07670bdc21bd7282bf6f66c3c4f6fb2a5929991361489c0b9d27f990608b0c06f31b7
|
7
|
+
data.tar.gz: d75ef3692fbf0b5a6f1139a6dba427f2f3047435275d7d9a64b2e770bd950440dc6a591317798443a20b3eafa6f24c403aab17a61f18dc1e9e5f15f1c6055304
|
data/Gemfile.lock
CHANGED
data/lib/brief/cli/write.rb
CHANGED
@@ -6,37 +6,27 @@ command 'write' do |c|
|
|
6
6
|
# We could potential query the available model classes we are aware of
|
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)
|
12
|
+
|
10
13
|
type_alias = args.first
|
11
14
|
|
12
15
|
model_class = schema_map.fetch(type_alias) do
|
13
16
|
raise "Unknown model type: #{ type_alias }. Available types are: #{ schema_map.keys.join(',') }"
|
14
17
|
end
|
15
18
|
|
16
|
-
|
17
|
-
#
|
18
|
-
# We need to determine the initial content that gets put into the editor.
|
19
|
-
#
|
20
|
-
# Our options are:
|
21
|
-
#
|
22
|
-
# - use an example from the model, if one exists
|
23
|
-
# - deduce the content to use based on some combination of one or more of the items below:
|
24
|
-
# - specifics of the model
|
25
|
-
# - the state of the documents that exist for that model already
|
26
|
-
# - the arguments from the CLI
|
27
|
-
default_example = "---\ntype:#{type_alias}\n---\n\n# Enter some content"
|
28
|
-
|
29
|
-
content = ask_editor(model_class.to_mash.example || default_example)
|
19
|
+
content = ask_editor model_class.writing_prompt()
|
30
20
|
|
31
21
|
file = ask("Enter a filename")
|
32
22
|
|
33
23
|
if file.to_s.length == 0
|
34
|
-
rand_token = rand(36**36).to_s(36).slice(0,
|
24
|
+
rand_token = rand(36**36).to_s(36).slice(0,3)
|
35
25
|
file = "new-#{ type_alias }-#{ rand_token }.md"
|
36
26
|
end
|
37
27
|
|
38
|
-
folder =
|
39
|
-
folder = folder.exist? ? folder :
|
28
|
+
folder = briefcase.docs_path.join(type_alias.pluralize)
|
29
|
+
folder = folder.exist? ? folder : briefcase.docs_path
|
40
30
|
|
41
31
|
folder.join(file).open("w+") do |fh|
|
42
32
|
fh.write(content)
|
@@ -10,6 +10,7 @@ module Brief
|
|
10
10
|
:section_mappings,
|
11
11
|
:template_body,
|
12
12
|
:example_body,
|
13
|
+
:_prompt,
|
13
14
|
:documentation_path,
|
14
15
|
:example_path,
|
15
16
|
:template_path
|
@@ -117,6 +118,10 @@ module Brief
|
|
117
118
|
end
|
118
119
|
end
|
119
120
|
|
121
|
+
def prompt(&block)
|
122
|
+
self._prompt = block
|
123
|
+
end
|
124
|
+
|
120
125
|
def has_actions?
|
121
126
|
self.defined_actions.empty?
|
122
127
|
end
|
data/lib/brief/model.rb
CHANGED
@@ -319,6 +319,12 @@ module Brief
|
|
319
319
|
definition.send(:example_body, *args).to_s.strip
|
320
320
|
end
|
321
321
|
|
322
|
+
def writing_prompt(*args)
|
323
|
+
_prompt = definition._prompt
|
324
|
+
return _prompt.call(*args) if _prompt && _prompt.respond_to?(:call)
|
325
|
+
example_body
|
326
|
+
end
|
327
|
+
|
322
328
|
def documentation(*args)
|
323
329
|
definition.send(:documentation, *args)
|
324
330
|
end
|
@@ -346,7 +352,7 @@ module Brief
|
|
346
352
|
# these methods have a special effect on the behavior of the
|
347
353
|
# model definition. we need to make sure we call finalize after
|
348
354
|
# them
|
349
|
-
if %w(meta content template example actions helpers).include?(meth.to_s)
|
355
|
+
if %w(meta content template example actions helpers prompt).include?(meth.to_s)
|
350
356
|
definition.send(meth, *args, &block)
|
351
357
|
finalize
|
352
358
|
elsif %w(defined_helper_methods defined_actions).include?(meth.to_s)
|
data/lib/brief/version.rb
CHANGED
@@ -0,0 +1,14 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "The Page Document Type" do
|
4
|
+
let(:page) { Brief.page_document.model_class }
|
5
|
+
let(:concept) { Brief::Concept }
|
6
|
+
|
7
|
+
it "should return the example because there's no prompt defined" do
|
8
|
+
expect(page.writing_prompt).to eq page.example_body
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should return whatever is defined in the prompt dsl" do
|
12
|
+
expect(concept.writing_prompt).to eq "asdf"
|
13
|
+
end
|
14
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: brief
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Soeder
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashie
|
@@ -445,6 +445,7 @@ files:
|
|
445
445
|
- spec/lib/brief/models/diagram_spec.rb
|
446
446
|
- spec/lib/brief/models/page_spec.rb
|
447
447
|
- spec/lib/brief/models/release_spec.rb
|
448
|
+
- spec/lib/brief/models/writing_prompt_spec.rb
|
448
449
|
- spec/lib/brief/persistence_spec.rb
|
449
450
|
- spec/lib/brief/rendering_spec.rb
|
450
451
|
- spec/lib/brief/repository_spec.rb
|
@@ -542,6 +543,7 @@ test_files:
|
|
542
543
|
- spec/lib/brief/models/diagram_spec.rb
|
543
544
|
- spec/lib/brief/models/page_spec.rb
|
544
545
|
- spec/lib/brief/models/release_spec.rb
|
546
|
+
- spec/lib/brief/models/writing_prompt_spec.rb
|
545
547
|
- spec/lib/brief/persistence_spec.rb
|
546
548
|
- spec/lib/brief/rendering_spec.rb
|
547
549
|
- spec/lib/brief/repository_spec.rb
|