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 +4 -4
- data/Gemfile.lock +1 -1
- data/apps/blueprint/models/epic.rb +2 -1
- data/lib/brief/briefcase.rb +1 -1
- data/lib/brief/document/section/builder.rb +7 -2
- data/lib/brief/document/structure.rb +6 -0
- data/lib/brief/model/serializers.rb +15 -1
- data/lib/brief/version.rb +1 -1
- data/spec/fixtures/example/brief.rb +6 -0
- data/spec/fixtures/example/docs/custom_model.md +7 -0
- data/spec/lib/brief/briefcase_spec.rb +1 -1
- data/spec/lib/brief/repository_spec.rb +1 -1
- data/spec/support/test_helpers.rb +10 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34377388822fff11372135724730e1748dab72e4
|
4
|
+
data.tar.gz: 25da9b0127fb67a0ddd85bc8f9c88069b7dc02ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 954cb0e8ff81647ca21192495a65c825884076d63e95450d8afc578a30f243b417a42d1e9e941cffd6bbb647a2e4cf05fe1543c57b7392134e32a9ef95783ff1
|
7
|
+
data.tar.gz: 73b3977ab6e15e30dad59a52cc5c50b7b850ee56b99a9717c6ce5da908d81cdcf39fda99f0c0cfa08c2ebfe2e837f0fb60af5757a67bbed009945b194c0b7ee2
|
data/Gemfile.lock
CHANGED
@@ -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
|
data/lib/brief/briefcase.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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
@@ -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
|
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
|
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
|
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.
|
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
|