brief 1.12.9 → 1.13.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e029139c4d4b69a786ce3fc4c93710cae1e67af4
4
- data.tar.gz: 6fae60ab3d35eb214cca44e2a5d10b5a360cd989
3
+ metadata.gz: d3968688e5ae49cef9636811719c29cc5c1daf89
4
+ data.tar.gz: 5da2122fc2a71f3878370db8ee26feba3fde0330
5
5
  SHA512:
6
- metadata.gz: 97f4ea6389de3ac57a42765ba49852f045188ab2fc87bd022506bcd69df808c938961c098bdb1bdf7c3385e5d1a525af8438f947dd91567d645756c61f4bca71
7
- data.tar.gz: 2ea9f5d4cbb2d3c20daae79344dccbe891eeb5e138b2331cc010464e661612134dd67ff4d49816dfbed3a5aa1c029f5311d72fb59d988f0e94429de0cbfd1f2a
6
+ metadata.gz: f7cab87cbc755465bf708e72ba6da50bbb171dd15293e6eb0c1939f137668e058d6db04d227f1cc51a39f53a30e70e8041e46dce863aa1045a1fdc85ef52e11b
7
+ data.tar.gz: 27650f973ec79d0e9ea9299d2b54379c1ab90f3a5dfdb12e8383c9fe80215ff22d95e36c444186f9a75443cdaeec90b086f7bbd580b9011fec834f113dd7c355
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- brief (1.12.9)
4
+ brief (1.13.1)
5
5
  activesupport (> 3.2)
6
6
  commander (~> 4.3)
7
7
  em-websocket (~> 0.5)
@@ -30,9 +30,12 @@ GEM
30
30
  descendants_tracker (~> 0.0.4)
31
31
  ice_nine (~> 0.11.0)
32
32
  thread_safe (~> 0.3, >= 0.3.1)
33
+ byebug (5.0.0)
34
+ columnize (= 0.9.0)
33
35
  coderay (1.1.0)
34
36
  coercible (1.0.0)
35
37
  descendants_tracker (~> 0.0.1)
38
+ columnize (0.9.0)
36
39
  commander (4.3.4)
37
40
  highline (~> 1.7.2)
38
41
  daemons (1.2.2)
@@ -112,6 +115,7 @@ PLATFORMS
112
115
  DEPENDENCIES
113
116
  brief!
114
117
  bundler (~> 1.3)
118
+ byebug (~> 5.0.0)
115
119
  octokit (~> 3.0)
116
120
  pry (~> 0.10)
117
121
  rack-test (~> 0.6)
@@ -0,0 +1,52 @@
1
+ class Brief::Apps
2
+ class Blueprint::MiddlemanExtension < ::Middleman::Extension
3
+
4
+ option :blueprint_root, nil, 'Which path to use for the blueprint?'
5
+
6
+ def initialize(app, options_hash = {}, &block)
7
+ super
8
+
9
+ app.set(:blueprint_root, options_hash.fetch(:blueprint_root) { ENV['BLUEPRINT_ROOT'] || "./blueprint" })
10
+
11
+ # import the blueprint assets into the sprockets path
12
+ app.ready do
13
+ logger.info "== Adding blueprint assets to sprockets paths"
14
+ patterns = [
15
+ '.png', '.gif', '.jpg', '.jpeg', '.svg', # Images
16
+ '.eot', '.otf', '.svc', '.woff', '.ttf', # Fonts
17
+ '.js', # Javascript
18
+ ].map { |e| File.join(blueprint.assets_path, "**", "*#{e}" ) }
19
+
20
+ sprockets.prepend_path(blueprint.assets_path)
21
+
22
+ patterns.map! {|p| Dir[p] }
23
+ patterns.flatten!
24
+
25
+ patterns.each do |f|
26
+ sprockets.import_asset(Pathname.new(f).relative_path_from(Pathname.new(blueprint.assets_path)))
27
+ end
28
+ end
29
+ end
30
+
31
+ helpers do
32
+ def blueprint_model_groups
33
+ blueprint.model_classes.map {|m| m.name.to_s.pluralize }
34
+ end
35
+
36
+ def blueprint
37
+ return @blueprint if @blueprint && !development?
38
+
39
+ @blueprint = get_briefcase.tap do |b|
40
+ b.href_builder = ->(uri) {uri = uri.to_s; uri.gsub('brief://','').gsub(/\.\w+$/,'.html').gsub(b.docs_path.to_s,'') }
41
+ b.asset_finder = ->(asset) { needle = asset.relative_path_from(b.assets_path).to_s; image_path(needle) }
42
+ end
43
+ end
44
+
45
+ def get_briefcase
46
+ Brief::Briefcase.new(root: blueprint_root, caching: !development?)
47
+ end
48
+ end
49
+ end
50
+ end if defined?(::Middleman)
51
+
52
+ ::Middleman::Extensions.register(:blueprint, Brief::Apps::Blueprint::MiddlemanExtension) if defined?(::Middleman)
data/brief.gemspec CHANGED
@@ -41,6 +41,7 @@ Gem::Specification.new do |spec|
41
41
  spec.add_development_dependency "bundler", "~> 1.3"
42
42
  spec.add_development_dependency "rake", "~> 0"
43
43
  spec.add_development_dependency "pry", "~> 0.10"
44
+ spec.add_development_dependency "byebug", "~> 5.0.0"
44
45
  spec.add_development_dependency "rspec", "~> 3.0"
45
46
  spec.add_development_dependency "rack-test", "~> 0.6"
46
47
  spec.add_development_dependency 'octokit', "~> 3.0"
@@ -12,17 +12,17 @@ command 'write' do |c|
12
12
 
13
13
  model_class = briefcase.model_classes.find {|c| c.type_alias == type_alias }
14
14
 
15
- if !model_class.nil?
16
- content = ask_editor model_class.writing_prompt()
17
- else
15
+ content = if model_class.nil?
18
16
  model_class = briefcase.schema_map.fetch(type_alias, nil)
19
- content = ask_editor(model_class.example)
17
+ ask_editor(model_class.example)
18
+ else
19
+ ask_editor(model_class.new_doc_template)
20
20
  end
21
21
 
22
22
  raise "Inavlid model class. Run the schema command to see what is available." if model_class.nil?
23
23
 
24
24
 
25
- file = ask("Enter a filename")
25
+ file = ask("Enter a filename: ") { |q| q.default = model_class.new_doc_name }
26
26
 
27
27
  if file.to_s.length == 0
28
28
  rand_token = rand(36**36).to_s(36).slice(0,3)
data/lib/brief/model.rb CHANGED
@@ -319,10 +319,24 @@ 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_content
322
+ def new_doc_template(&block)
323
+ if block
324
+ definition.new_doc_template_block = block
325
+ elsif definition.new_doc_template_block
326
+ definition.new_doc_template_block.call
327
+ else
328
+ example_content
329
+ end
330
+ end
331
+
332
+ def new_doc_name(&block)
333
+ if block
334
+ definition.new_doc_name_block = block
335
+ elsif definition.new_doc_name_block
336
+ definition.new_doc_name_block.call
337
+ else
338
+ "#{ self.type_alias }-#{ DateTime.now.strftime("%Y-%m-%d") }.md"
339
+ end
326
340
  end
327
341
 
328
342
  def documentation(*args)
@@ -352,7 +366,7 @@ module Brief
352
366
  # these methods have a special effect on the behavior of the
353
367
  # model definition. we need to make sure we call finalize after
354
368
  # them
355
- if %w(meta content template example actions helpers prompt).include?(meth.to_s)
369
+ if %w(meta content template example actions helpers).include?(meth.to_s)
356
370
  definition.send(meth, *args, &block)
357
371
  finalize
358
372
  elsif %w(defined_helper_methods defined_actions).include?(meth.to_s)
@@ -10,7 +10,8 @@ module Brief
10
10
  :section_mappings,
11
11
  :template_body,
12
12
  :example_body,
13
- :_prompt,
13
+ :new_doc_name_block,
14
+ :new_doc_template_block,
14
15
  :documentation_path,
15
16
  :example_path,
16
17
  :template_path
@@ -118,10 +119,6 @@ module Brief
118
119
  end
119
120
  end
120
121
 
121
- def prompt(&block)
122
- self._prompt = block
123
- end
124
-
125
122
  def has_actions?
126
123
  self.defined_actions.empty?
127
124
  end
data/lib/brief/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Brief
2
- VERSION = '1.12.9'
2
+ VERSION = '1.13.1'
3
3
  end
@@ -12,7 +12,11 @@ class Brief::Concept
12
12
  title "h1:first-of-type"
13
13
  end
14
14
 
15
- prompt do
16
- "asdf"
15
+ new_doc_template do
16
+ "The concept new doc template"
17
+ end
18
+
19
+ new_doc_name do
20
+ "somecustomname.md"
17
21
  end
18
22
  end
@@ -0,0 +1,26 @@
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 have some example content" do
8
+ expect(page.example_content).not_to be_empty
9
+ end
10
+
11
+ it "should return the example because there's no new_doc_template defined" do
12
+ expect(page.new_doc_template).to eq page.example_content
13
+ end
14
+
15
+ it "should return whatever is defined in the new_doc_template dsl" do
16
+ expect(concept.new_doc_template).to eq "The concept new doc template"
17
+ end
18
+
19
+ it "should return the default document name because there's no new_doc_name defined" do
20
+ expect(page.new_doc_name).to eq "page-2015-06-17.md"
21
+ end
22
+
23
+ it "should return the new document name if new_doc_name is defined" do
24
+ expect(concept.new_doc_name).to eq "somecustomname.md"
25
+ end
26
+ 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.12.9
4
+ version: 1.13.1
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-17 00:00:00.000000000 Z
11
+ date: 2015-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashie
@@ -234,6 +234,20 @@ dependencies:
234
234
  - - "~>"
235
235
  - !ruby/object:Gem::Version
236
236
  version: '0.10'
237
+ - !ruby/object:Gem::Dependency
238
+ name: byebug
239
+ requirement: !ruby/object:Gem::Requirement
240
+ requirements:
241
+ - - "~>"
242
+ - !ruby/object:Gem::Version
243
+ version: 5.0.0
244
+ type: :development
245
+ prerelease: false
246
+ version_requirements: !ruby/object:Gem::Requirement
247
+ requirements:
248
+ - - "~>"
249
+ - !ruby/object:Gem::Version
250
+ version: 5.0.0
237
251
  - !ruby/object:Gem::Dependency
238
252
  name: rspec
239
253
  requirement: !ruby/object:Gem::Requirement
@@ -328,6 +342,7 @@ files:
328
342
  - apps/blueprint/examples/roadmap.md
329
343
  - apps/blueprint/examples/sitemap.md
330
344
  - apps/blueprint/examples/wireframe.md
345
+ - apps/blueprint/extensions/middleman.rb
331
346
  - apps/blueprint/models/concept.rb
332
347
  - apps/blueprint/models/diagram.rb
333
348
  - apps/blueprint/models/epic.rb
@@ -443,9 +458,9 @@ files:
443
458
  - spec/lib/brief/hashing_spec.rb
444
459
  - spec/lib/brief/model_spec.rb
445
460
  - spec/lib/brief/models/diagram_spec.rb
461
+ - spec/lib/brief/models/new_doc_content_spec.rb
446
462
  - spec/lib/brief/models/page_spec.rb
447
463
  - spec/lib/brief/models/release_spec.rb
448
- - spec/lib/brief/models/writing_prompt_spec.rb
449
464
  - spec/lib/brief/persistence_spec.rb
450
465
  - spec/lib/brief/rendering_spec.rb
451
466
  - spec/lib/brief/repository_spec.rb
@@ -541,9 +556,9 @@ test_files:
541
556
  - spec/lib/brief/hashing_spec.rb
542
557
  - spec/lib/brief/model_spec.rb
543
558
  - spec/lib/brief/models/diagram_spec.rb
559
+ - spec/lib/brief/models/new_doc_content_spec.rb
544
560
  - spec/lib/brief/models/page_spec.rb
545
561
  - spec/lib/brief/models/release_spec.rb
546
- - spec/lib/brief/models/writing_prompt_spec.rb
547
562
  - spec/lib/brief/persistence_spec.rb
548
563
  - spec/lib/brief/rendering_spec.rb
549
564
  - spec/lib/brief/repository_spec.rb
@@ -1,18 +0,0 @@
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 have some example content" do
8
- expect(page.example_content).not_to be_empty
9
- end
10
-
11
- it "should return the example because there's no prompt defined" do
12
- expect(page.writing_prompt).to eq page.example_content
13
- end
14
-
15
- it "should return whatever is defined in the prompt dsl" do
16
- expect(concept.writing_prompt).to eq "asdf"
17
- end
18
- end