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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b210c7cfbfc6c61d2065de58511cd75b792e6183
4
- data.tar.gz: 8d5452b12855d0df0afcdd9dd705df8e8aee296a
3
+ metadata.gz: 492b8deb3666e930f5319091d35dd864a7978053
4
+ data.tar.gz: f87bb8973ab58226831c88c125ab0d52f1d6df31
5
5
  SHA512:
6
- metadata.gz: 1132ffc9ac404ebc966c101f218361bbd3026dd0fc1e2a66b84077cceb7a661f9889b6a95c06636ed55958a8fc6076a31a3733b44a04b74b8f68d1a21897e271
7
- data.tar.gz: 6ca953bc15a875623da13b0a67d330cc8890c195e72673091e3679bd51b332d6068d71c5d682d7fcc6b28bce4658f8ed947de1208047b8de2a37a77e4fac0715
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.13.2)
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 = line.strip
38
- level = line.count('#')
39
- text = line.gsub('#', '').strip
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
- heading.element.set_attribute('data-line-number', line_number)
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
@@ -292,6 +292,8 @@ module Brief
292
292
  @parser ||= begin
293
293
  structure.prescan
294
294
 
295
+ structure.assign_id_attributes_to_pre_tags
296
+
295
297
  structure.create_wrappers.tap do |f|
296
298
  transformer_for(f).all
297
299
  end
data/lib/brief/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Brief
2
- VERSION = '1.13.2'
2
+ VERSION = '1.14.0'
3
3
  end
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  type: concept
3
- needle: bw3bg25pgdk1dmlcc0i7vgfx8azujn0k7p17
3
+ needle: i5wt25dv3tug69u5at7k0mrd8buy41lbeub9
4
4
  ---
5
5
 
6
- # Modified Content v4lk5hmstxxb5abwdg1txe5utwwasdwhdhid
6
+ # Modified Content ponsmqgjrpttz2wxpszae6nfsapnqucwow3b
@@ -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,8 @@
1
+ class Brief::Persona
2
+ include Brief::Model
3
+
4
+ content do
5
+ msg "[data-random-attr='value']"
6
+ rando "#rando pre[lang='yaml'] code", :serialize => :yaml
7
+ end
8
+ end
@@ -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.13.2
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-18 00:00:00.000000000 Z
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