oreilly-snippets 0.0.15 → 0.0.16

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 1d3e3c29a72469016a1400732a8e020cddee9599
4
- data.tar.gz: e9377684d7ba0e2bc9f4f5ae65e8514be72b57a1
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MGFjOWM2NzE1ZjY0MGE4Y2RiM2I2OGUzMjI1MjhjYWNkMzFjZWM4MA==
5
+ data.tar.gz: !binary |-
6
+ OTA1NTAwZDE0N2FkMmVmZWI2ZmJmNzBhODNlZmZmYTY3YTMyYjZmMg==
5
7
  SHA512:
6
- metadata.gz: cd8d103b247334041ef4b2e487b5f4002ff56444495c2d5ca32b10c846c4911cea0648d63c1e3e61af3be9aaaba6381505e3d24377a3a3fce964892da09435a1
7
- data.tar.gz: b8fd891e2fbbb6c5becc3429d8916bbd84ca7853431d9a282da3ad86d0da91f200d2ec4cb13c19395f9225bc0b0ba2a815e87948291a5dcf957a9850eec1ce93
8
+ metadata.gz: !binary |-
9
+ YmUwZDg3ZDEyNmQ2N2NlYTk4ZmI4YzA0NDQ5NTU5YzIwZDk5YWUyNjQ1NTk1
10
+ YmQ0N2ZiZWQ1YTU1ODk0MjNlNzU1MzAxZmFhNWIxMDlmOGExYmQ2Y2M3NjI2
11
+ MmE2NmIwZjcyY2RlMjAyYzUyYjIwZTYwNTgzMDAzMTgxNDE2NTM=
12
+ data.tar.gz: !binary |-
13
+ NmU2ZWIzYTBlMmE4NzNmN2MxODViMjE3ZmJhODAxYjU3MGRkMTQ0YjI4OWJh
14
+ ZTY4MDA4NWIzOGJiYTQyODU2N2FiNjBiZTdmNDJlMmY1MmI0Mzc1YmI3MWM3
15
+ YjI1NGZhOWI4ZDI0NmZmZTBmZDYyNDVhNjU5NWI1MmRkODBhZGI=
@@ -1,5 +1,5 @@
1
1
  module Oreilly
2
2
  module Snippets
3
- VERSION = "0.0.15"
3
+ VERSION = "0.0.16"
4
4
  end
5
5
  end
@@ -24,6 +24,7 @@ module Oreilly
24
24
  numbers = s[:lines]
25
25
  flatten = s[:flatten]
26
26
  normcallouts = s[:normcallouts]
27
+ callouts_prefix = s[:callouts_prefix]
27
28
  callouts = s[:callouts]
28
29
 
29
30
  contents = nil
@@ -73,7 +74,7 @@ module Oreilly
73
74
  end
74
75
 
75
76
  if callouts
76
- rv = process_callouts( rv, callouts )
77
+ rv = process_callouts( rv, callouts, callouts_prefix )
77
78
  elsif normcallouts
78
79
  rv = normalize_callouts( rv )
79
80
  end
@@ -83,11 +84,10 @@ module Oreilly
83
84
  rv
84
85
  end
85
86
 
86
- def self.process_callouts( input, callouts )
87
+ def self.process_callouts( input, callouts, comment_character = nil )
87
88
  rv = nil
88
89
  # Strip them out and figure out the comment character
89
- comment_character = nil
90
- rv = input.gsub( /([#\/]\/?) ?<\d+>/ ) { |c| comment_character = $1; '' }
90
+ rv = input.gsub( /([#\/]\/?) ?<\d+>/ ) { |c| comment_character ||= $1; '' }
91
91
 
92
92
  unless comment_character
93
93
  # OK, we need to scan for it and hope to figure it out
data/spec/process_spec.rb CHANGED
@@ -66,7 +66,6 @@ snippet~~~~
66
66
  snippet~~~~
67
67
  END
68
68
 
69
-
70
69
  REALLY_LONG_CALLOUTS_JS = <<"END"
71
70
  [filename="spec/fixtures/normalize_callouts_long.js", callouts="1,10,15"]
72
71
  snippet~~~~
@@ -74,6 +73,12 @@ snippet~~~~
74
73
  snippet~~~~
75
74
  END
76
75
 
76
+ CALLOUTS_PREFIX_JS = <<"END"
77
+ [filename="spec/fixtures/normalize_callouts_long.js", callouts_prefix="#", callouts="1,10,15"]
78
+ snippet~~~~
79
+ ...
80
+ snippet~~~~
81
+ END
77
82
 
78
83
  NORMALIZE_CALLOUTS_JS = <<"END"
79
84
  [filename="spec/fixtures/normalize_callouts.js", normcallouts="true"]
@@ -276,6 +281,14 @@ describe Oreilly::Snippets do
276
281
  lines[14].should match( /<3>/ )
277
282
  end
278
283
 
284
+ it "should add a prefix character to a callout to makes sure the code is runnable" do
285
+ output = Oreilly::Snippets.process( CALLOUTS_PREFIX_JS )
286
+ lines = output.split /\n/
287
+ lines[0].should match( /# <1>/ )
288
+ lines[9].should match( /# <2>/ )
289
+ lines[14].should match( /# <3>/ )
290
+ end
291
+
279
292
  it "should add callouts using a default comment" do
280
293
  output = Oreilly::Snippets.process( REALLY_LONG_CALLOUTS_JS )
281
294
  lines = output.split /\n/
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oreilly-snippets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 0.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Dawson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-31 00:00:00.000000000 Z
11
+ date: 2015-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -28,28 +28,28 @@ dependencies:
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ! '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ! '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ! '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ! '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  description: Use O'Reilly style snippets inside your markup (asciidoc or markdown)
@@ -91,17 +91,17 @@ require_paths:
91
91
  - lib
92
92
  required_ruby_version: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '>='
94
+ - - ! '>='
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  required_rubygems_version: !ruby/object:Gem::Requirement
98
98
  requirements:
99
- - - '>='
99
+ - - ! '>='
100
100
  - !ruby/object:Gem::Version
101
101
  version: '0'
102
102
  requirements: []
103
103
  rubyforge_project:
104
- rubygems_version: 2.2.2
104
+ rubygems_version: 2.2.5
105
105
  signing_key:
106
106
  specification_version: 4
107
107
  summary: See the README