brief 1.13.2 → 1.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +4 -1
- data/lib/brief/document/structure.rb +47 -4
- data/lib/brief/document.rb +2 -0
- data/lib/brief/version.rb +1 -1
- data/spec/fixtures/example/docs/concept.html.md +2 -2
- data/spec/fixtures/example/docs/persona.html.md +10 -0
- data/spec/fixtures/example/models/persona.rb +8 -0
- data/spec/lib/brief/dom_attribute_assignment_spec.rb +18 -0
- data/spec/spec_helper.rb +6 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 492b8deb3666e930f5319091d35dd864a7978053
|
4
|
+
data.tar.gz: f87bb8973ab58226831c88c125ab0d52f1d6df31
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0cf34a058eeb298b8ed33ed6a766d8e24367317194cda8e5151477ec47a44c4588705cf75b282224ca4d6eaacd509e58edbe2a138f2dd134a14148f9cedeefc8
|
7
|
+
data.tar.gz: 3d93821f75f88cded4e5a16d48c1ecf13ae71a8bcb8d37ed8792d4333608d24f59f57e18eeb158b3cc293078e25ce5798bc6db3afc1e7eddb06a49397760f8e9
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
brief (1.
|
4
|
+
brief (1.14.0)
|
5
5
|
activesupport (> 3.2)
|
6
6
|
commander (~> 4.3)
|
7
7
|
em-websocket (~> 0.5)
|
@@ -121,3 +121,6 @@ DEPENDENCIES
|
|
121
121
|
rack-test (~> 0.6)
|
122
122
|
rake (~> 0)
|
123
123
|
rspec (~> 3.0)
|
124
|
+
|
125
|
+
BUNDLED WITH
|
126
|
+
1.10.4
|
@@ -32,18 +32,57 @@ module Brief
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def prescan
|
35
|
+
set_markings_on_headers
|
36
|
+
assign_id_attributes_to_pre_tags
|
37
|
+
end
|
38
|
+
|
39
|
+
def assign_id_attributes_to_pre_tags
|
40
|
+
pres = fragment.css('pre[lang]')
|
41
|
+
|
42
|
+
pres.each do |pre|
|
43
|
+
lang = pre.attr('lang')
|
44
|
+
|
45
|
+
if match_data = lang.match(/\((\w+)\)/)
|
46
|
+
pre.set_attribute 'id', match_data.captures.first
|
47
|
+
pre.set_attribute 'lang', lang.gsub(/\((\w+)\)/,'')
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def set_markings_on_headers
|
35
53
|
content_lines.each_with_index do |line, index|
|
36
54
|
if line.match(/^#/)
|
37
|
-
line
|
38
|
-
level
|
39
|
-
text
|
55
|
+
line = line.strip
|
56
|
+
level = line.count('#')
|
57
|
+
text = line.gsub('#', '').strip
|
40
58
|
|
41
59
|
if level > 0 && text.length > 0
|
42
60
|
line_number = index + 1
|
61
|
+
|
43
62
|
heading = find_heading_by(level, text)
|
44
63
|
|
64
|
+
# If it is a heading element, we map it to a line number in
|
65
|
+
# the content that produced it. We also look for the special
|
66
|
+
# syntax {attribute: value; other-attribute: value} which
|
67
|
+
# lets us set attributes on the header
|
45
68
|
if heading
|
46
|
-
|
69
|
+
set_attributes = {"data-line-number" => line_number}
|
70
|
+
|
71
|
+
if attribute_matchers = line.match(/\{(.*)\}/)
|
72
|
+
attributes = attribute_matchers.captures.first.strip
|
73
|
+
attributes.split(';').each do |pair|
|
74
|
+
key, value = pair.split(':')
|
75
|
+
set_attributes[key.to_s.strip] = value.to_s.strip
|
76
|
+
end
|
77
|
+
|
78
|
+
value = heading.element.text.to_s.split(/\{.*\}/).join("").strip
|
79
|
+
heading.element.inner_html = value
|
80
|
+
heading.element.set_attribute('data-heading', value)
|
81
|
+
end
|
82
|
+
|
83
|
+
set_attributes.each do |k,v|
|
84
|
+
heading.element.set_attribute(k, v)
|
85
|
+
end
|
47
86
|
end
|
48
87
|
end
|
49
88
|
end
|
@@ -163,6 +202,10 @@ module Brief
|
|
163
202
|
end
|
164
203
|
end
|
165
204
|
|
205
|
+
def find_pre_by_lang(lang)
|
206
|
+
fragment.css("pre[lang='#{lang}']").first
|
207
|
+
end
|
208
|
+
|
166
209
|
def find_heading_by(level, heading)
|
167
210
|
heading_elements.find do |el|
|
168
211
|
el.level.to_s == level.to_s && heading.to_s.strip == el.heading.to_s.strip
|
data/lib/brief/document.rb
CHANGED
data/lib/brief/version.rb
CHANGED
@@ -3,3 +3,13 @@ type: persona
|
|
3
3
|
title: Blueprint Persona Example
|
4
4
|
subheading: A description of a typical user of the software
|
5
5
|
---
|
6
|
+
|
7
|
+
# Blueprint Persona Example
|
8
|
+
|
9
|
+
## Random Heading {id: randoms; data-random-attr: value}
|
10
|
+
|
11
|
+
what up son?
|
12
|
+
|
13
|
+
```yaml(rando)
|
14
|
+
setting: value
|
15
|
+
```
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "DOM Attribute Assignment" do
|
4
|
+
let(:doc) { Brief.persona_document }
|
5
|
+
let(:model) { doc.to_model }
|
6
|
+
|
7
|
+
it "should make targeting elements easier" do
|
8
|
+
binding.pry
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should assign attributes to the headings" do
|
12
|
+
expect(doc.css('[data-random-attr="value"]').length).to eq(1)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should not include the attribute syntax in the text" do
|
16
|
+
expect(doc.css('h2').text).to eq('Random Heading')
|
17
|
+
end
|
18
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -18,6 +18,12 @@ module Brief
|
|
18
18
|
testcase.document_at(path)
|
19
19
|
end
|
20
20
|
|
21
|
+
def self.persona_document
|
22
|
+
path = Brief.example_path.join("docs","persona.html.md")
|
23
|
+
testcase.document_at(path)
|
24
|
+
end
|
25
|
+
|
26
|
+
|
21
27
|
def self.page_document
|
22
28
|
path = Brief.example_path.join("docs","page.html.md")
|
23
29
|
testcase.document_at(path)
|
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.14.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-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashie
|
@@ -443,6 +443,7 @@ files:
|
|
443
443
|
- spec/fixtures/example/models/concept.rb
|
444
444
|
- spec/fixtures/example/models/epic.rb
|
445
445
|
- spec/fixtures/example/models/page.rb
|
446
|
+
- spec/fixtures/example/models/persona.rb
|
446
447
|
- spec/fixtures/example/settings.yml
|
447
448
|
- spec/fixtures/example/templates/user_story.md.erb
|
448
449
|
- spec/fixtures/structures/one.html.md
|
@@ -454,6 +455,7 @@ files:
|
|
454
455
|
- spec/lib/brief/content_transformation_spec.rb
|
455
456
|
- spec/lib/brief/data_spec.rb
|
456
457
|
- spec/lib/brief/document_spec.rb
|
458
|
+
- spec/lib/brief/dom_attribute_assignment_spec.rb
|
457
459
|
- spec/lib/brief/dsl_spec.rb
|
458
460
|
- spec/lib/brief/hashing_spec.rb
|
459
461
|
- spec/lib/brief/model_spec.rb
|
@@ -541,6 +543,7 @@ test_files:
|
|
541
543
|
- spec/fixtures/example/models/concept.rb
|
542
544
|
- spec/fixtures/example/models/epic.rb
|
543
545
|
- spec/fixtures/example/models/page.rb
|
546
|
+
- spec/fixtures/example/models/persona.rb
|
544
547
|
- spec/fixtures/example/settings.yml
|
545
548
|
- spec/fixtures/example/templates/user_story.md.erb
|
546
549
|
- spec/fixtures/structures/one.html.md
|
@@ -552,6 +555,7 @@ test_files:
|
|
552
555
|
- spec/lib/brief/content_transformation_spec.rb
|
553
556
|
- spec/lib/brief/data_spec.rb
|
554
557
|
- spec/lib/brief/document_spec.rb
|
558
|
+
- spec/lib/brief/dom_attribute_assignment_spec.rb
|
555
559
|
- spec/lib/brief/dsl_spec.rb
|
556
560
|
- spec/lib/brief/hashing_spec.rb
|
557
561
|
- spec/lib/brief/model_spec.rb
|