polytexnic 1.0.beta6 → 1.0.beta7

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: b8214313558b4c38e7812a1372478a5efde8e597
4
- data.tar.gz: 1ef44af2eeed1ba0492745434c360bf4b3dc2e87
3
+ metadata.gz: eb76407e7ba54b0fb488ef09aec322e872b71d75
4
+ data.tar.gz: e53153e7c347134405ead39bf70f6cd397964a2a
5
5
  SHA512:
6
- metadata.gz: db0b6d8db2eb0528020c968f5c09b48d6c466353f6f9a0cd7e72ac5ac6670403c2fbf378a5064cf34baf50c225363cf1a57f081cf62f4a39ab3a01eb983fc4bb
7
- data.tar.gz: cb41614488b7185e7ed03a93599c4f85bf7897a29c684fc8dd28bdccba83da131354f77b25b9cd9a36e659b6313d8e720a8d16128e1d8935c5cde86ed820fcc2
6
+ metadata.gz: 987622308529332e85a94441ed056a17ef6be8774a961b2310d8b7b9b32c5163c4b74e963c2d2ead5d9ebab3b8358c4e9c067055c36a3d075d09716784edd7c6
7
+ data.tar.gz: af9ce3e2739c1aa4383f9925c1dc3c179235394998654c87b746b8132fc0e6edd6f140bef05dc6b6452b81d26220e1d76c6f95832f4f502529f25ffefa2aaa9d
@@ -4,25 +4,59 @@ module CodeInclusion
4
4
  class SubsetException < CodeInclusionException; end;
5
5
 
6
6
 
7
- # Converts the input line into:
8
- # Retrieval Args:
9
- # filename: filename # required
10
- # git: { tag: tagname } # optional
11
- # section: sectionname, # 'section:' and 'line_numbers:'
12
- # line_numbers: 1,4-6,8,14 # are optional and mutually exclusive
7
+ # Converts the CodeInclusion line to a set of arguments, i.e.:
8
+ # '%= <<(file.rb[6-14,37], git: {repo: repo_path/.git, tag: 1.0}, lang: tex, options: "hl_lines": [5]))'
9
+ # becomes:
10
+ # Args#retrieval
11
+ # { filename: "file.rb",
12
+ # line_numbers: "6-14,37",
13
+ # git: { tag: '1.0', repo: 'repo_path/.git' }
14
+ # }
15
+ # Args#render
16
+ # { custom_language: "tex",
17
+ # highlight: ', options: "hl_lines": [5])'}
13
18
  #
14
- # Render Args:
15
- # custom_language: 'ruby'
16
- # hightlight: '"hl_lines": [1, 2], "linenos": true'
19
+ # and
20
+ # '%= <<(file.rb[section_x], git: {tag: 1.0}'
21
+ # becomes:
22
+ # Args#retrieval
23
+ # { filename: "file.rb",
24
+ # section: "section_x",
25
+ # git: { tag: '1.0'}
26
+ # }
27
+ # Args#render
28
+ # { }
29
+ #
30
+ #
31
+ # Notes for retrieval args
32
+ # filename is required
33
+ #
34
+ # line_numbers/section names are specified in [] following the filename,
35
+ # foo.rb[1,4-6,8,14] or foo.rb[section_x]
36
+ # Thus, line_numbers and section names are mutually exclusive.
37
+ #
38
+ # keyword git: is optional and within it
39
+ #
40
+ # keyword tag: is optional
41
+ # If present tag refers to an existing tag in the repo.
42
+ # Tags may optionally quoted.
43
+ #
44
+ # keyword repo: is optional
45
+ # If present it contains the full path to a git repo,
46
+ # full/path/to/repo/.git
47
+ # If absent, git commands default to the current repository.
48
+ # Repos may be optionally quoted.
49
+ #
50
+ # TODO we're dying for a real parser here.
17
51
  class Args
18
52
  CODE_REGEX =
19
- /^\s*%=\s+<<\s*\( # opening
20
- \s*([^\s]+?) # path to file
21
- (?:\[(.+?)\])? # optional section or line numbers
22
- (?:,\s*git:\s*([ \w\.\/\-\{\}:]+?))? # optional git tag
23
- (?:,\s*lang:\s*(\w+))? # optional lang
24
- (,\s*options:\s*.*)? # optional options
25
- \s*\) # closing paren
53
+ /^\s*%=\s+<<\s*\( # opening
54
+ \s*([^\s]+?) # path to file
55
+ (?:\[(.+?)\])? # optional section, line numbers
56
+ (?:,\s*git:\s*([ ,"'\w\.\/\-\{\}:]+?))? # optional git tag, repo
57
+ (?:,\s*lang:\s*(\w+))? # optional lang
58
+ (,\s*options:\s*.*)? # optional options
59
+ \s*\) # closing paren
26
60
  /x
27
61
 
28
62
  attr_reader :input, :retrieval, :render, :match
@@ -36,6 +70,10 @@ module CodeInclusion
36
70
  extract
37
71
  end
38
72
 
73
+ def parse
74
+ CODE_REGEX.match(input)
75
+ end
76
+
39
77
  def extract
40
78
  return unless code_inclusion_line?
41
79
 
@@ -43,7 +81,7 @@ module CodeInclusion
43
81
 
44
82
  if specifies_line_numbers?
45
83
  retrieval[:line_numbers] = match[2]
46
- else
84
+ elsif specifies_section?
47
85
  retrieval[:section] = match[2]
48
86
  end
49
87
 
@@ -53,26 +91,53 @@ module CodeInclusion
53
91
  render[:highlight] = match[5]
54
92
  end
55
93
 
94
+ def code_inclusion_line?
95
+ !match.nil?
96
+ end
97
+
98
+ def specifies_section?
99
+ match[2] && !specifies_line_numbers?
100
+ end
101
+
56
102
  def specifies_line_numbers?
57
103
  whitespace_digits_dashes_and_commas.match(match[2])
58
104
  end
59
105
 
60
- def parse
61
- CODE_REGEX.match(input)
106
+ def extract_git(git_args)
107
+ { tag: extract_git_option('tag', git_args),
108
+ repo: extract_git_option('repo', git_args)}
62
109
  end
63
110
 
64
- def code_inclusion_line?
65
- !match.nil?
111
+ def extract_git_option(keyword, args)
112
+ if (match = git_option_regex(keyword).match(args))
113
+ match[1]
114
+ end
66
115
  end
67
116
 
68
- def whitespace_digits_dashes_and_commas
69
- /\s*\d[-,\d\s]*$/
117
+ def git_option_regex(keyword)
118
+ /#{start}#{keyword}:#{space}#{quote}(.*?)#{quote}#{finish}/
70
119
  end
71
120
 
72
- def extract_git(git_args)
73
- # only expect tag:, but could easily extract branch: or repo:
74
- tag = /\s?{\s?tag:\s(.*)\s?}/.match(git_args)[1]
75
- {tag: tag}
121
+ def start
122
+ "\.*?"
123
+ end
124
+
125
+ def space
126
+ "\s?"
127
+ end
128
+
129
+ # single or double quotes are optional but permitted
130
+ def quote
131
+ %q[(?:"|')?]
132
+ end
133
+
134
+ # comma or } (with optional leading space) ends things
135
+ def finish
136
+ "\s?(,|})"
137
+ end
138
+
139
+ def whitespace_digits_dashes_and_commas
140
+ /^\s*\d[-,\d\s]*$/
76
141
  end
77
142
  end
78
143
 
@@ -138,17 +203,17 @@ module CodeInclusion
138
203
  end
139
204
  end
140
205
 
141
- # Listing.for takes a set of retrieval args and returns an array of
142
- # source code lines to be included in the book.
143
- #
144
- # Listing is responsible for retrieving the file you're including
145
- # (the 'FullListing') and for extracting individual lines from that file
146
- # (the 'Subset').
206
+ # Listing.for takes a set of retrieval args and returns an array of
207
+ # source code lines to be included in the book.
208
+ #
209
+ # Listing is responsible for retrieving the file you're including
210
+ # (the 'FullListing') and for extracting individual lines from that file
211
+ # (the 'Subset').
147
212
 
148
- # It contains factory methods to choose the correct FullListing and Subset
149
- # classes and the code to wire them together. If you add new FullListing or
150
- # Subset objects, you'll need to wire them together here.
151
- class Listing
213
+ # It contains factory methods to choose the correct FullListing and Subset
214
+ # classes and the code to wire them together. If you add new FullListing or
215
+ # Subset objects, you'll need to wire them together here.
216
+ class Listing
152
217
 
153
218
  # Returns the lines of code to be included or
154
219
  # an exception containing the error message.
@@ -230,17 +295,23 @@ class Listing
230
295
  GitCmd.new
231
296
  end
232
297
 
233
- attr_reader :filename, :tag, :git_cmd
298
+ attr_reader :filename, :tag, :repository, :git_cmd
234
299
 
235
300
  def initialize(args, git_cmd=self.class.git_cmd)
236
- @filename = args[:filename]
237
- @tag = args[:git][:tag]
301
+ @filename = args[:filename]
302
+ @tag = args[:git][:tag]
303
+ @repository = args[:git][:repo]
304
+
238
305
  @git_cmd = git_cmd
306
+
307
+ git_cmd.repository = repository
308
+ git_cmd.tagname = tag
309
+ git_cmd.filename = filename
239
310
  end
240
311
 
241
312
  def lines
242
313
  ensure_exists!
243
- result = git_cmd.show(filename, tag)
314
+ result = git_cmd.show
244
315
 
245
316
  if git_cmd.succeeded?
246
317
  result.split("\n")
@@ -252,14 +323,19 @@ class Listing
252
323
  private
253
324
 
254
325
  def ensure_exists!
255
- unless git_cmd.tag_exists?(tag)
326
+ unless git_cmd.repository_exists?
327
+ raise(RetrievalException, "Repository '#{repository}' does not exist.")
328
+ end
329
+ unless git_cmd.tag_exists?
256
330
  raise(RetrievalException, "Tag '#{tag}' does not exist.")
257
331
  end
258
332
  end
259
333
 
260
334
  class GitCmd
261
- def show(filename, tagname)
262
- `git show #{tagname}:#{filename}`
335
+ attr_accessor :repository, :tagname, :filename
336
+
337
+ def show
338
+ `git #{git_dir} show #{tagname}:#{filename}`
263
339
  end
264
340
 
265
341
  def succeeded?
@@ -267,10 +343,22 @@ class Listing
267
343
  end
268
344
 
269
345
  def tags
270
- `git tag`
346
+ `git #{git_dir} tag`
347
+ end
348
+
349
+ def log
350
+ `git #{git_dir} log -1`
351
+ end
352
+
353
+ def git_dir
354
+ %Q[--git-dir="#{repository}"] if repository
355
+ end
356
+
357
+ def repository_exists?
358
+ !log.include?("Not a git repository")
271
359
  end
272
360
 
273
- def tag_exists?(tagname)
361
+ def tag_exists?
274
362
  tags.split("\n").include?(tagname)
275
363
  end
276
364
  end
@@ -925,7 +925,8 @@ module Polytexnic
925
925
  def hrefs(doc)
926
926
  doc.xpath('//xref').each do |node|
927
927
  node.name = 'a'
928
- node['href'] = unescape_underscores(literal_cache[node['url']])
928
+ node['href'] = unescape_special_chars(literal_cache[node['url']])
929
+ node['target'] = '_blank' # open in new window/tab
929
930
  # Put a class on hrefs containing TeX to allow a style override.
930
931
  node.traverse do |descendant|
931
932
  if descendant['class'] == 'texhtml'
@@ -937,9 +938,9 @@ module Polytexnic
937
938
  end
938
939
  end
939
940
 
940
- # Unescapes underscores, which are escaped by kramdown.
941
- def unescape_underscores(url)
942
- url.gsub(/\\_/, '_')
941
+ # Unescapes some special characters that are escaped by kramdown.
942
+ def unescape_special_chars(url)
943
+ url.gsub(/\\_/, '_').gsub(/\\#/, '#')
943
944
  end
944
945
 
945
946
  # Handles both \includegraphics and figure environments.
@@ -1,3 +1,3 @@
1
1
  module Polytexnic
2
- VERSION = "1.0.beta6"
2
+ VERSION = "1.0.beta7"
3
3
  end
data/polytexnic.gemspec CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |gem|
19
19
  gem.require_paths = ["lib"]
20
20
 
21
21
  gem.add_dependency 'nokogiri', '~> 1.6.0'
22
- gem.add_dependency 'pygments.rb', '~> 0.4.2'
22
+ gem.add_dependency 'pygments.rb', '~> 0.6.0'
23
23
  gem.add_dependency 'msgpack', '~> 0.4.2'
24
24
  gem.add_dependency 'kramdown', '~> 1.3.2'
25
25
  gem.add_dependency 'json', '~> 1.8.1'
@@ -205,24 +205,31 @@ describe 'Polytexnic::Pipeline#to_html' do
205
205
 
206
206
  context "standard URL" do
207
207
  let(:polytex) { '\href{http://example.com/}{Example Site}' }
208
- let(:output) { '<a href="http://example.com/">Example Site</a>' }
209
- it { should resemble output }
208
+ it { should include '<a href="http://example.com/"' }
209
+ it { should include '>Example Site</a>' }
210
210
  end
211
211
 
212
- context "URL containing TeX" do
212
+ context "containing TeX" do
213
213
  let(:polytex) { '\href{http://example.com/}{\emph{\TeX}}' }
214
- let(:output) { '<a href="http://example.com/" class="tex">' }
215
- it { should resemble output }
214
+ it { should include '<a href="http://example.com/"' }
215
+ it { should include 'class="tex"' }
216
216
  end
217
217
 
218
- context "URL containing escaped text" do
218
+ context "containing escaped text" do
219
219
  let(:polytex) { '\href{http://example.com/escaped\_text}{Example Site}' }
220
- it { should include '<a href="http://example.com/escaped_text">Example Site</a>' }
220
+ it { should include '<a href="http://example.com/escaped_text"' }
221
+ it { should include '>Example Site</a>' }
221
222
  end
222
223
 
223
224
  context "self-linking URL" do
224
225
  let(:polytex) { '\url{http://example.com/}' }
225
- it { should include '<a href="http://example.com/">http://example.com/</a>' }
226
+ it { should include '<a href="http://example.com/"' }
227
+ it { should include '>http://example.com/</a>' }
228
+ end
229
+
230
+ context "with a # sign" do
231
+ let(:polytex) { '\href{http://example.com/\#email}{email link}' }
232
+ it { should include 'http://example.com/#email' }
226
233
  end
227
234
  end
228
235
 
@@ -44,10 +44,10 @@ def bar(): return "bar"
44
44
  let(:bar_html) do
45
45
  '<div class="code"><div class="highlight"><pre><span class="k">def</span> <span class="nf">bar</span><span class="p">():'
46
46
  end
47
- let(:href_html) { '<a href="http://example.com/">example</a>' }
48
47
 
49
48
  it { should include foo_html }
50
49
  it { should include bar_html }
51
- it { should include href_html }
50
+ it { should include '<a href="http://example.com/"' }
51
+ it { should include '>example</a>' }
52
52
  end
53
53
  end
@@ -1,6 +1,92 @@
1
1
  # encoding=utf-8
2
2
  require 'spec_helper'
3
3
 
4
+ describe "CodeInclusion::Args" do
5
+
6
+ context "file only" do
7
+ let(:line) {'%= <<(file.rb)'}
8
+ subject { CodeInclusion::Args.new(line).retrieval}
9
+
10
+ it {should eq({filename: "file.rb"})}
11
+ end
12
+
13
+ context "file and section" do
14
+ let(:line) {'%= <<(file.rb[section1])'}
15
+ subject { CodeInclusion::Args.new(line).retrieval}
16
+
17
+ it {should eq({filename: "file.rb", section: 'section1'})}
18
+ end
19
+
20
+ context "file and line numbers" do
21
+ let(:line) {'%= <<(file.rb[6,14-37,80])'}
22
+ subject { CodeInclusion::Args.new(line).retrieval}
23
+
24
+ it {should eq({filename: "file.rb",
25
+ line_numbers: "6,14-37,80"})}
26
+ end
27
+
28
+ context "file and unquoted git repo" do
29
+ let(:line) {'%= <<(file.rb, git: {repo: repo_path/.git})'}
30
+ subject { CodeInclusion::Args.new(line).retrieval}
31
+
32
+ it {should eq({ filename: "file.rb",
33
+ git: { tag: nil, repo: 'repo_path/.git' }})}
34
+ end
35
+
36
+ context "file and double quoted git repo" do
37
+ let(:line) {'%= <<(file.rb, git: {repo: "repo_path/.git"})'}
38
+ subject { CodeInclusion::Args.new(line).retrieval}
39
+
40
+ it {should eq({ filename: "file.rb",
41
+ git: { tag: nil, repo: 'repo_path/.git' }})}
42
+ end
43
+
44
+ context "file and single quoted git repo" do
45
+ let(:line) {"%= <<(file.rb, git: {repo: 'repo_path/.git'})"}
46
+ subject { CodeInclusion::Args.new(line).retrieval}
47
+
48
+ it {should eq({ filename: "file.rb",
49
+ git: { tag: nil, repo: 'repo_path/.git' }})}
50
+ end
51
+
52
+ context "file and git tag/repo" do
53
+ let(:line) {'%= <<(file.rb, git: {tag: 1.0, repo: "repo_path/.git"})'}
54
+ subject { CodeInclusion::Args.new(line).retrieval}
55
+
56
+ it {should eq({ filename: "file.rb",
57
+ git: { tag: '1.0', repo: 'repo_path/.git' }})}
58
+ end
59
+
60
+ context "file and git repo/tag" do
61
+ let(:line) {'%= <<(file.rb, git: {repo: "repo_path/.git", tag: 1.0})'}
62
+ subject { CodeInclusion::Args.new(line).retrieval}
63
+
64
+ it {should eq({ filename: "file.rb",
65
+ git: { tag: '1.0', repo: 'repo_path/.git' }})}
66
+ end
67
+
68
+ context "nearly everything" do
69
+ let(:line) {'%= <<(file.rb[6-14,37], git: {repo: "repo_path/.git", tag: 1.0}, lang: tex, options: "hl_lines": [5]))'}
70
+
71
+ describe "retrival args" do
72
+ subject { CodeInclusion::Args.new(line).retrieval}
73
+
74
+ it {should eq({ filename: "file.rb",
75
+ line_numbers: "6-14,37",
76
+ git: { tag: '1.0', repo: 'repo_path/.git' }})}
77
+ end
78
+
79
+ describe "render args" do
80
+ subject { CodeInclusion::Args.new(line).render}
81
+
82
+ it {should eq({ custom_language: "tex",
83
+ highlight: ', options: "hl_lines": [5])'})}
84
+
85
+ end
86
+ end
87
+ end
88
+
89
+
4
90
  describe "full listing" do
5
91
 
6
92
  describe "file" do
@@ -26,10 +112,13 @@ describe "full listing" do
26
112
  context "file exists" do
27
113
  before(:all) do
28
114
  class FakeGitCmd < CodeInclusion::FullListing::GitTag::GitCmd
29
- def show(_, _)
115
+ def show
30
116
  "Real data\nsecond line"
31
117
  end
32
- def tag_exists?(tagname)
118
+ def repository_exists?
119
+ true
120
+ end
121
+ def tag_exists?
33
122
  true
34
123
  end
35
124
  def succeeded?
@@ -48,7 +137,10 @@ describe "full listing" do
48
137
  context "tag does not exist" do
49
138
  before(:all) do
50
139
  class FakeGitCmd < CodeInclusion::FullListing::GitTag::GitCmd
51
- def tag_exists?(tagname)
140
+ def repository_exists?
141
+ true
142
+ end
143
+ def tag_exists?
52
144
  false
53
145
  end
54
146
  end
@@ -64,13 +156,34 @@ describe "full listing" do
64
156
  ) }
65
157
  end
66
158
 
159
+ context "repo does not exist" do
160
+ before(:all) do
161
+ class FakeGitCmd < CodeInclusion::FullListing::GitTag::GitCmd
162
+ def repository_exists?
163
+ false
164
+ end
165
+ end
166
+ end
167
+
168
+ let(:args) { { filename: "irreleventfile", git: {repo: "baddir/.git"} } }
169
+ subject { lambda {
170
+ CodeInclusion::FullListing::GitTag.new(args, FakeGitCmd.new).lines } }
171
+
172
+ it { should raise_exception(
173
+ CodeInclusion::RetrievalException,
174
+ "Repository 'baddir/.git' does not exist.") }
175
+ end
176
+
67
177
  context "file does not exist" do
68
178
  before(:all) do
69
179
  class FakeGitCmd < CodeInclusion::FullListing::GitTag::GitCmd
70
- def show(filename, tag)
180
+ def show
71
181
  "fatal: Path 'badfile' does not exist in 'goodtag'"
72
182
  end
73
- def tag_exists?(tagname)
183
+ def repository_exists?
184
+ true
185
+ end
186
+ def tag_exists?
74
187
  true
75
188
  end
76
189
  def succeeded?
@@ -79,7 +192,8 @@ describe "full listing" do
79
192
  end
80
193
  end
81
194
 
82
- let(:args) { { filename: "badfile", git: {tag: "goodtag"} } }
195
+ let(:args) { { filename: "badfile",
196
+ git: {tag: "goodtag"} } }
83
197
  subject { lambda {
84
198
  CodeInclusion::FullListing::GitTag.new(args, FakeGitCmd.new).lines } }
85
199
 
@@ -133,4 +247,4 @@ describe "subset" do
133
247
 
134
248
  it { should eq(input)}
135
249
  end
136
- end
250
+ end
@@ -250,13 +250,16 @@ describe Polytexnic::Pipeline do
250
250
  end
251
251
  end
252
252
 
253
- context "the tag and file exist" do
253
+ context "the repo, tag and file exist" do
254
254
  before(:all) do
255
255
  class FakeGitCmd < CodeInclusion::FullListing::GitTag::GitCmd
256
- def show(_, _)
256
+ def show
257
257
  "Fake data\nsecond line"
258
258
  end
259
- def tag_exists?(tagname)
259
+ def repository_exists?
260
+ true
261
+ end
262
+ def tag_exists?
260
263
  true
261
264
  end
262
265
  def succeeded?
@@ -265,6 +268,24 @@ describe Polytexnic::Pipeline do
265
268
  end
266
269
  end
267
270
 
271
+ context "with repo only" do
272
+ let(:polytex) do <<-'EOS'
273
+ %= <<(file.rb, git: {repo: "repo_path/.git"})
274
+ EOS
275
+ end
276
+ let(:output) do <<-'EOS'
277
+ <div class="code">
278
+ <div class="highlight">
279
+ <pre>
280
+ <span class="no">Fake</span> <span class="n">data</span>
281
+ <span class="n">second</span> <span class="n">line</span>
282
+ </pre>
283
+ </div>
284
+ EOS
285
+ end
286
+ it_behaves_like "an inclusion"
287
+ end
288
+
268
289
  context "with tag only" do
269
290
  let(:polytex) do <<-'EOS'
270
291
  %= <<(tagged_file.rb, git: {tag: fake_tag.1.0})
@@ -283,6 +304,24 @@ describe Polytexnic::Pipeline do
283
304
  it_behaves_like "an inclusion"
284
305
  end
285
306
 
307
+ context "with repo and tag" do
308
+ let(:polytex) do <<-'EOS'
309
+ %= <<(tagged_file.rb, git: {tag: fake_tag.1.0, repo:"repo_path/.git"})
310
+ EOS
311
+ end
312
+ let(:output) do <<-'EOS'
313
+ <div class="code">
314
+ <div class="highlight">
315
+ <pre>
316
+ <span class="no">Fake</span> <span class="n">data</span>
317
+ <span class="n">second</span> <span class="n">line</span>
318
+ </pre>
319
+ </div>
320
+ EOS
321
+ end
322
+ it_behaves_like "an inclusion"
323
+ end
324
+
286
325
  context "with other params" do
287
326
  let(:output) do <<-'EOS'
288
327
  <div class="code">
@@ -296,6 +335,14 @@ describe Polytexnic::Pipeline do
296
335
  EOS
297
336
  end
298
337
 
338
+ context "with repo and lang" do
339
+ let(:polytex) do <<-'EOS'
340
+ %= <<(file.rb, git: {repo:"repo_path/.git"}, lang: tex)
341
+ EOS
342
+ end
343
+ it_behaves_like "an inclusion"
344
+ end
345
+
299
346
  context "with tag and lang" do
300
347
  let(:polytex) do <<-'EOS'
301
348
  %= <<(tagged_file.rb, git: {tag: slashes/and-dashes-are/ok/too}, lang: tex)
@@ -304,9 +351,9 @@ describe Polytexnic::Pipeline do
304
351
  it_behaves_like "an inclusion"
305
352
  end
306
353
 
307
- context "with tag, lang and options" do
354
+ context "with repo, tag, lang and options" do
308
355
  let(:polytex) do <<-'EOS'
309
- %= <<(tagged_file.rb, git: {tag: v0.9.4}, lang: tex, options: "hl_lines": [5])
356
+ %= <<(tagged_file.rb, git: {tag: v0.9.4, repo:"repo_path/.git"}, lang: tex, options: "hl_lines": [5])
310
357
  EOS
311
358
  end
312
359
  it_behaves_like "an inclusion"
@@ -314,13 +361,49 @@ describe Polytexnic::Pipeline do
314
361
  end
315
362
  end
316
363
 
364
+ context "the repo does not exist" do
365
+ before(:all) do
366
+ class FakeGitCmd < CodeInclusion::FullListing::GitTag::GitCmd
367
+ def show
368
+ ''
369
+ end
370
+ def repository_exists?
371
+ false
372
+ end
373
+ def tag_exists?
374
+ false
375
+ end
376
+ def succeeded?
377
+ false
378
+ end
379
+ end
380
+ end
381
+
382
+ let(:polytex) do <<-'EOS'
383
+ %= <<(file.rb, git: {repo: "non_existent_repo"})
384
+ EOS
385
+ end
386
+ let(:output) do <<-'EOS'
387
+ <p>
388
+ <span class="inline_verbatim">
389
+ ERROR: Repository 'non_existent_repo' does not exist.
390
+ </span>
391
+ </p>
392
+ EOS
393
+ end
394
+ it_behaves_like "an inclusion"
395
+ end
396
+
317
397
  context "the tag does not exist" do
318
398
  before(:all) do
319
399
  class FakeGitCmd < CodeInclusion::FullListing::GitTag::GitCmd
320
- def show(_, _)
400
+ def show
321
401
  ''
322
402
  end
323
- def tag_exists?(tagname)
403
+ def repository_exists?
404
+ true
405
+ end
406
+ def tag_exists?
324
407
  false
325
408
  end
326
409
  def succeeded?
@@ -347,10 +430,13 @@ describe Polytexnic::Pipeline do
347
430
  context "the file does not exist" do
348
431
  before(:all) do
349
432
  class FakeGitCmd < CodeInclusion::FullListing::GitTag::GitCmd
350
- def show(filename, _)
433
+ def show
351
434
  "fatal: Path 'path/to/non_existent_file.rb' does not exist in 'v0.9.9'"
352
435
  end
353
- def tag_exists?(tagname)
436
+ def repository_exists?
437
+ true
438
+ end
439
+ def tag_exists?
354
440
  true
355
441
  end
356
442
  def succeeded?
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polytexnic
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.beta6
4
+ version: 1.0.beta7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Hartl
@@ -9,104 +9,104 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-08-28 00:00:00.000000000 Z
12
+ date: 2014-09-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ~>
18
+ - - "~>"
19
19
  - !ruby/object:Gem::Version
20
20
  version: 1.6.0
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - ~>
25
+ - - "~>"
26
26
  - !ruby/object:Gem::Version
27
27
  version: 1.6.0
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: pygments.rb
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - ~>
32
+ - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: 0.4.2
34
+ version: 0.6.0
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - ~>
39
+ - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: 0.4.2
41
+ version: 0.6.0
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: msgpack
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - ~>
46
+ - - "~>"
47
47
  - !ruby/object:Gem::Version
48
48
  version: 0.4.2
49
49
  type: :runtime
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - ~>
53
+ - - "~>"
54
54
  - !ruby/object:Gem::Version
55
55
  version: 0.4.2
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: kramdown
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - ~>
60
+ - - "~>"
61
61
  - !ruby/object:Gem::Version
62
62
  version: 1.3.2
63
63
  type: :runtime
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - ~>
67
+ - - "~>"
68
68
  - !ruby/object:Gem::Version
69
69
  version: 1.3.2
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: json
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
- - - ~>
74
+ - - "~>"
75
75
  - !ruby/object:Gem::Version
76
76
  version: 1.8.1
77
77
  type: :runtime
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
- - - ~>
81
+ - - "~>"
82
82
  - !ruby/object:Gem::Version
83
83
  version: 1.8.1
84
84
  - !ruby/object:Gem::Dependency
85
85
  name: rspec
86
86
  requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
- - - ~>
88
+ - - "~>"
89
89
  - !ruby/object:Gem::Version
90
90
  version: 2.14.1
91
91
  type: :development
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
94
94
  requirements:
95
- - - ~>
95
+ - - "~>"
96
96
  - !ruby/object:Gem::Version
97
97
  version: 2.14.1
98
98
  - !ruby/object:Gem::Dependency
99
99
  name: simplecov
100
100
  requirement: !ruby/object:Gem::Requirement
101
101
  requirements:
102
- - - ~>
102
+ - - "~>"
103
103
  - !ruby/object:Gem::Version
104
104
  version: 0.8.2
105
105
  type: :development
106
106
  prerelease: false
107
107
  version_requirements: !ruby/object:Gem::Requirement
108
108
  requirements:
109
- - - ~>
109
+ - - "~>"
110
110
  - !ruby/object:Gem::Version
111
111
  version: 0.8.2
112
112
  description: Core translation engine for the polytexnic gem
@@ -116,97 +116,97 @@ executables: []
116
116
  extensions: []
117
117
  extra_rdoc_files: []
118
118
  files:
119
- - .gitignore
120
- - .pull_requests/1371777257
121
- - .pull_requests/1371927975
122
- - .pull_requests/1372804345
123
- - .pull_requests/1374784075
124
- - .pull_requests/1375304853
125
- - .pull_requests/1375408308
126
- - .pull_requests/1375409462
127
- - .pull_requests/1375410668
128
- - .pull_requests/1375472132
129
- - .pull_requests/1375485496
130
- - .pull_requests/1375487548
131
- - .pull_requests/1375492835
132
- - .pull_requests/1375497765
133
- - .pull_requests/1375559547
134
- - .pull_requests/1375589063
135
- - .pull_requests/1375841786
136
- - .pull_requests/1376352634
137
- - .pull_requests/1376353299
138
- - .pull_requests/1376449284
139
- - .pull_requests/1376452696
140
- - .pull_requests/1376454166
141
- - .pull_requests/1376532291
142
- - .pull_requests/1376625487
143
- - .pull_requests/1376690108
144
- - .pull_requests/1376699046
145
- - .pull_requests/1376707642
146
- - .pull_requests/1377230284
147
- - .pull_requests/1379118478
148
- - .pull_requests/1379123150
149
- - .pull_requests/1380221847
150
- - .pull_requests/1380589654
151
- - .pull_requests/1380673142
152
- - .pull_requests/1380850800
153
- - .pull_requests/1381001264
154
- - .pull_requests/1381005204
155
- - .pull_requests/1381103022
156
- - .pull_requests/1381252832
157
- - .pull_requests/1381276624
158
- - .pull_requests/1381344234
159
- - .pull_requests/1381385297
160
- - .pull_requests/1381427498
161
- - .pull_requests/1381429761
162
- - .pull_requests/1381873684
163
- - .pull_requests/1382045490
164
- - .pull_requests/1382056384
165
- - .pull_requests/1382405223
166
- - .pull_requests/1382478400
167
- - .pull_requests/1382479780
168
- - .pull_requests/1382485483
169
- - .pull_requests/1382569911
170
- - .pull_requests/1382646199
171
- - .pull_requests/1382649778
172
- - .pull_requests/1382660987
173
- - .pull_requests/1382743927
174
- - .pull_requests/1382840347
175
- - .pull_requests/1383077676
176
- - .pull_requests/1383086948
177
- - .pull_requests/1383161978
178
- - .pull_requests/1383263695
179
- - .pull_requests/1383274008
180
- - .pull_requests/1383327328
181
- - .pull_requests/1384446851
182
- - .pull_requests/1384800466
183
- - .pull_requests/1384811507
184
- - .pull_requests/1385061501
185
- - .pull_requests/1385598040
186
- - .pull_requests/1385601533
187
- - .pull_requests/1385778060
188
- - .pull_requests/1385928695
189
- - .pull_requests/1386022309
190
- - .pull_requests/1386036048
191
- - .pull_requests/1386105869
192
- - .pull_requests/1386184858
193
- - .pull_requests/1386718874
194
- - .pull_requests/1386936855
195
- - .pull_requests/1387316123
196
- - .pull_requests/1387337421
197
- - .pull_requests/1387418273
198
- - .pull_requests/1387507486
199
- - .pull_requests/1387590643
200
- - .pull_requests/1387944167
201
- - .pull_requests/1388090414
202
- - .pull_requests/1388112504
203
- - .pull_requests/1388430185
204
- - .pull_requests/1388440664
205
- - .pull_requests/1388802190
206
- - .pull_requests/1389652617
207
- - .pull_requests/1395697424
208
- - .pull_requests/1403381407
209
- - .rspec
119
+ - ".gitignore"
120
+ - ".pull_requests/1371777257"
121
+ - ".pull_requests/1371927975"
122
+ - ".pull_requests/1372804345"
123
+ - ".pull_requests/1374784075"
124
+ - ".pull_requests/1375304853"
125
+ - ".pull_requests/1375408308"
126
+ - ".pull_requests/1375409462"
127
+ - ".pull_requests/1375410668"
128
+ - ".pull_requests/1375472132"
129
+ - ".pull_requests/1375485496"
130
+ - ".pull_requests/1375487548"
131
+ - ".pull_requests/1375492835"
132
+ - ".pull_requests/1375497765"
133
+ - ".pull_requests/1375559547"
134
+ - ".pull_requests/1375589063"
135
+ - ".pull_requests/1375841786"
136
+ - ".pull_requests/1376352634"
137
+ - ".pull_requests/1376353299"
138
+ - ".pull_requests/1376449284"
139
+ - ".pull_requests/1376452696"
140
+ - ".pull_requests/1376454166"
141
+ - ".pull_requests/1376532291"
142
+ - ".pull_requests/1376625487"
143
+ - ".pull_requests/1376690108"
144
+ - ".pull_requests/1376699046"
145
+ - ".pull_requests/1376707642"
146
+ - ".pull_requests/1377230284"
147
+ - ".pull_requests/1379118478"
148
+ - ".pull_requests/1379123150"
149
+ - ".pull_requests/1380221847"
150
+ - ".pull_requests/1380589654"
151
+ - ".pull_requests/1380673142"
152
+ - ".pull_requests/1380850800"
153
+ - ".pull_requests/1381001264"
154
+ - ".pull_requests/1381005204"
155
+ - ".pull_requests/1381103022"
156
+ - ".pull_requests/1381252832"
157
+ - ".pull_requests/1381276624"
158
+ - ".pull_requests/1381344234"
159
+ - ".pull_requests/1381385297"
160
+ - ".pull_requests/1381427498"
161
+ - ".pull_requests/1381429761"
162
+ - ".pull_requests/1381873684"
163
+ - ".pull_requests/1382045490"
164
+ - ".pull_requests/1382056384"
165
+ - ".pull_requests/1382405223"
166
+ - ".pull_requests/1382478400"
167
+ - ".pull_requests/1382479780"
168
+ - ".pull_requests/1382485483"
169
+ - ".pull_requests/1382569911"
170
+ - ".pull_requests/1382646199"
171
+ - ".pull_requests/1382649778"
172
+ - ".pull_requests/1382660987"
173
+ - ".pull_requests/1382743927"
174
+ - ".pull_requests/1382840347"
175
+ - ".pull_requests/1383077676"
176
+ - ".pull_requests/1383086948"
177
+ - ".pull_requests/1383161978"
178
+ - ".pull_requests/1383263695"
179
+ - ".pull_requests/1383274008"
180
+ - ".pull_requests/1383327328"
181
+ - ".pull_requests/1384446851"
182
+ - ".pull_requests/1384800466"
183
+ - ".pull_requests/1384811507"
184
+ - ".pull_requests/1385061501"
185
+ - ".pull_requests/1385598040"
186
+ - ".pull_requests/1385601533"
187
+ - ".pull_requests/1385778060"
188
+ - ".pull_requests/1385928695"
189
+ - ".pull_requests/1386022309"
190
+ - ".pull_requests/1386036048"
191
+ - ".pull_requests/1386105869"
192
+ - ".pull_requests/1386184858"
193
+ - ".pull_requests/1386718874"
194
+ - ".pull_requests/1386936855"
195
+ - ".pull_requests/1387316123"
196
+ - ".pull_requests/1387337421"
197
+ - ".pull_requests/1387418273"
198
+ - ".pull_requests/1387507486"
199
+ - ".pull_requests/1387590643"
200
+ - ".pull_requests/1387944167"
201
+ - ".pull_requests/1388090414"
202
+ - ".pull_requests/1388112504"
203
+ - ".pull_requests/1388430185"
204
+ - ".pull_requests/1388440664"
205
+ - ".pull_requests/1388802190"
206
+ - ".pull_requests/1389652617"
207
+ - ".pull_requests/1395697424"
208
+ - ".pull_requests/1403381407"
209
+ - ".rspec"
210
210
  - Gemfile
211
211
  - Guardfile
212
212
  - LICENSE.txt
@@ -281,17 +281,17 @@ require_paths:
281
281
  - lib
282
282
  required_ruby_version: !ruby/object:Gem::Requirement
283
283
  requirements:
284
- - - '>='
284
+ - - ">="
285
285
  - !ruby/object:Gem::Version
286
286
  version: '0'
287
287
  required_rubygems_version: !ruby/object:Gem::Requirement
288
288
  requirements:
289
- - - '>'
289
+ - - ">"
290
290
  - !ruby/object:Gem::Version
291
291
  version: 1.3.1
292
292
  requirements: []
293
293
  rubyforge_project:
294
- rubygems_version: 2.3.0
294
+ rubygems_version: 2.2.2
295
295
  signing_key:
296
296
  specification_version: 4
297
297
  summary: Convert from PolyTeX & Markdown to HTML & LaTeX