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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 05aa8958fb9aa8dd12bce798c8aa606b372e9ddb
4
- data.tar.gz: 39193fddf1af3048a2208be447518d587bfde131
3
+ metadata.gz: 7d3a25a4f211d9862e3c879242f4e83b92adc4ba
4
+ data.tar.gz: b418898c05d11d75bf7c50fb3e17dc72816cfa81
5
5
  SHA512:
6
- metadata.gz: 7bf1ba3cc48969be2e07a589f7d12d26d4d6bbc5b4e36011b9b52bda9a542f1994504419c533f4ecc54b1edfa6a3bf82051a0216276c2ee6ae7e6ed6d64f397a
7
- data.tar.gz: 48c8a6cd07a18b573a7e8bfa7efe668b43520a190eb86f24aa00188e27293faf75f36858b4fa6df4bfb1b6c678f81f947e61d43502d78d299071085c60a5e79f
6
+ metadata.gz: 47ebd49ce1aabf8eacaa33b9eee6fc14c33f46df37018b72e2f37f79aef07670bdc21bd7282bf6f66c3c4f6fb2a5929991361489c0b9d27f990608b0c06f31b7
7
+ data.tar.gz: d75ef3692fbf0b5a6f1139a6dba427f2f3047435275d7d9a64b2e770bd950440dc6a591317798443a20b3eafa6f24c403aab17a61f18dc1e9e5f15f1c6055304
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- brief (1.11.10)
4
+ brief (1.12.0)
5
5
  activesupport (> 3.2)
6
6
  commander (~> 4.3)
7
7
  em-websocket (~> 0.5)
@@ -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
- schema_map = Brief.case(true).schema_map(true)
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
- # TODO
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,6)
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 = Brief.case(true).docs_path.join(type_alias.pluralize)
39
- folder = folder.exist? ? folder : Brief.case.docs_path
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
@@ -1,3 +1,3 @@
1
1
  module Brief
2
- VERSION = '1.11.10'
2
+ VERSION = '1.12.0'
3
3
  end
@@ -11,4 +11,8 @@ class Brief::Concept
11
11
  content do
12
12
  title "h1:first-of-type"
13
13
  end
14
+
15
+ prompt do
16
+ "asdf"
17
+ end
14
18
  end
@@ -15,6 +15,5 @@ describe "The Page Document Type" do
15
15
  expect(page.extracted_content_data.title).to eq("Summary")
16
16
  expect(page.extracted_content_data.paragraph).not_to be_nil
17
17
  end
18
-
19
18
  end
20
19
 
@@ -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.11.10
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-14 00:00:00.000000000 Z
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