brief 1.10.0 → 1.10.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: c99e43e2cb14081fa9dfb044d30bf1e21771225e
4
- data.tar.gz: 75be39413bbe58d8d0169eccc6ae936223635e92
3
+ metadata.gz: 34377388822fff11372135724730e1748dab72e4
4
+ data.tar.gz: 25da9b0127fb67a0ddd85bc8f9c88069b7dc02ae
5
5
  SHA512:
6
- metadata.gz: 2ee79d64d3b01159c7493672b4c7c13ad9bc7fdab0446253729fd037ed0e576a8813676e9d202ca2e26da33108dae58c1859fac7362953b689818e96c1719d0b
7
- data.tar.gz: 52992dd1e843eb9259d6210fa828d50c760d6866639280d823b8b2a8581530a38b837647cc21e9464c3a33f44dc591f75a9a241fb637eece79d31cc5a052edc5
6
+ metadata.gz: 954cb0e8ff81647ca21192495a65c825884076d63e95450d8afc578a30f243b417a42d1e9e941cffd6bbb647a2e4cf05fe1543c57b7392134e32a9ef95783ff1
7
+ data.tar.gz: 73b3977ab6e15e30dad59a52cc5c50b7b850ee56b99a9717c6ce5da908d81cdcf39fda99f0c0cfa08c2ebfe2e837f0fb60af5757a67bbed009945b194c0b7ee2
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- brief (1.10.0)
4
+ brief (1.10.1)
5
5
  activesupport (~> 4.0)
6
6
  commander (~> 4.3)
7
7
  em-websocket (= 0.5.1)
@@ -43,7 +43,8 @@ As a **User** I would like to **Do this** so that I can **succeed**
43
43
  define_section "Features" do
44
44
  each("h2").has(:title => "h2",
45
45
  :paragraph => "p:first-of-type",
46
- :components => "p:first-of-type strong"
46
+ :components => "p:first-of-type strong",
47
+ :tasks => "ul li"
47
48
  )
48
49
 
49
50
  each("h2").is_a :feature
@@ -192,7 +192,7 @@ module Brief
192
192
 
193
193
  def model_class_for(document)
194
194
  return generic_model_class_for(document) unless uses_app?
195
- app_models.find {|k| k.type_alias == document.document_type }
195
+ app_models.find {|k| k.type_alias == document.document_type } || generic_model_class_for(document)
196
196
  end
197
197
 
198
198
  def generic_model_class_for(document)
@@ -22,7 +22,7 @@ class Brief::Document::Section
22
22
  begin
23
23
  run
24
24
  rescue
25
- raise BuilderError
25
+ raise BuilderError, $!
26
26
  end
27
27
  end
28
28
 
@@ -46,7 +46,12 @@ class Brief::Document::Section
46
46
  until even? || maxed_out?
47
47
  source.map! do |item|
48
48
  level, fragments = item
49
- [level, fragments.first]
49
+
50
+ [level, (fragments && fragments.first)]
51
+ end
52
+
53
+ if source.any? {|i| i[1].nil? }
54
+ raise BuilderError, 'Fragments by level seems invalid'
50
55
  end
51
56
 
52
57
  source.each_with_index do |item, index|
@@ -98,11 +98,16 @@ module Brief
98
98
  level, group = item
99
99
  group.reject! { |i| i.text == "\n" }
100
100
 
101
+ #puts "Mapping! #{ level } group length: #{ group.length }"
102
+
101
103
  if level == 0
104
+ #puts "== Condition A"
102
105
  base_fragment = fragment = Nokogiri::HTML.fragment("<div class='brief top level'>#{ group.map(&:to_html).join('') }</div>")
103
106
  elsif level <= lowest_level
107
+ #puts "== Condition B"
104
108
  fragment = Nokogiri::HTML.fragment("<section>#{ group.map(&:to_html).join('') }</section>")
105
109
  elsif level > lowest_level
110
+ #puts "== Condition C"
106
111
  # should be able to look at the document section mappings and
107
112
  # apply custom css classes to these based on the name of the section
108
113
  fragment = Nokogiri::HTML.fragment("<article>#{ group.map(&:to_html).join('') }</article>")
@@ -114,6 +119,7 @@ module Brief
114
119
  begin
115
120
  self.fragment = Brief::Document::Section::Builder.run(mapping, low: lowest_level, high: highest_level)
116
121
  rescue Brief::Document::Section::BuilderError
122
+ ##puts "== Error, returning default fragment: #{ $! }"
117
123
  @fragment
118
124
  end
119
125
  end
@@ -24,7 +24,9 @@ module Brief::Model::Serializers
24
24
  sections: {},
25
25
  section_headings: [],
26
26
  }.tap do |h|
27
+
27
28
  h[:content] = document.combined_data_and_content if options[:content] || options[:include_content]
29
+
28
30
  h[:rendered] = document.to_html if options[:rendered] || options[:include_rendered]
29
31
 
30
32
  if options[:attachments] || options[:include_attachments]
@@ -41,10 +43,22 @@ module Brief::Model::Serializers
41
43
  schema_url: "/schema/#{ type }",
42
44
  actions_url: "/actions/:action/#{ doc_path }"
43
45
  } if options[:urls] || options[:include_urls]
44
- end.tap do |h|
46
+
45
47
  if document.has_sections?
46
48
  h[:section_headings] = document.section_headings
47
49
  h[:sections] = document.sections_data
50
+
51
+ structure = document.structure
52
+
53
+ h[:structure] = {
54
+ highest_level: structure.highest_level,
55
+ lowest_level: structure.lowest_level,
56
+ headings_by_level: (structure.levels.reduce({}) do |m, l|
57
+ headings = structure.headings_at_level(l.to_i)
58
+ m[l.to_s] = headings.map(&:heading)
59
+ m
60
+ end)
61
+ }
48
62
  end
49
63
  end
50
64
  end
data/lib/brief/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Brief
2
- VERSION = '1.10.0'
2
+ VERSION = '1.10.1'
3
3
  end
@@ -24,6 +24,12 @@ define "Outline" do
24
24
  end
25
25
  end
26
26
 
27
+ define "CustomModel" do
28
+ meta do
29
+ title
30
+ end
31
+ end
32
+
27
33
  define "Feature" do
28
34
  meta do
29
35
  title
@@ -0,0 +1,7 @@
1
+ ---
2
+ type: custom_model
3
+ title: Custom Model Example
4
+ ---
5
+
6
+ This document shows that even when you use an app, you can apply your
7
+ own per briefcase model definitions
@@ -55,7 +55,7 @@ describe "The Briefcase" do
55
55
  context "Document Mappings" do
56
56
  it "has all of the documents" do
57
57
  expect(briefcase.epics.length).to eq(1)
58
- expect(briefcase.documents.length).to eq(9)
58
+ expect(briefcase.documents.length).to be_greater_than(9)
59
59
  end
60
60
  end
61
61
  end
@@ -47,7 +47,7 @@ describe "The Brief Document Repository" do
47
47
 
48
48
  it "supports different operators" do
49
49
  query = repository.where(:type.neq => "epic")
50
- expect(query.length).to eq(8)
50
+ expect(query.length).to be_greater_than(8)
51
51
  end
52
52
 
53
53
  it "limits the results to the specified size" do
@@ -1,3 +1,13 @@
1
+ class Fixnum
2
+ def greater_than?(other)
3
+ self > other
4
+ end
5
+
6
+ def greater_than_or_equal_to?(other)
7
+ self >= other
8
+ end
9
+ end
10
+
1
11
  module TestHelpers
2
12
  def app
3
13
  Brief.testcase.server
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.10.0
4
+ version: 1.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Soeder
@@ -386,6 +386,7 @@ files:
386
386
  - spec/fixtures/example/brief.rb
387
387
  - spec/fixtures/example/data/items.json
388
388
  - spec/fixtures/example/docs/concept.html.md
389
+ - spec/fixtures/example/docs/custom_model.md
389
390
  - spec/fixtures/example/docs/epics/epic.html.md
390
391
  - spec/fixtures/example/docs/index.md
391
392
  - spec/fixtures/example/docs/page.html.md
@@ -482,6 +483,7 @@ test_files:
482
483
  - spec/fixtures/example/brief.rb
483
484
  - spec/fixtures/example/data/items.json
484
485
  - spec/fixtures/example/docs/concept.html.md
486
+ - spec/fixtures/example/docs/custom_model.md
485
487
  - spec/fixtures/example/docs/epics/epic.html.md
486
488
  - spec/fixtures/example/docs/index.md
487
489
  - spec/fixtures/example/docs/page.html.md