gimli 0.1.8 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
data/README.textile CHANGED
@@ -17,6 +17,16 @@ h3. Markup
17
17
 
18
18
  Markup files may be written in any format supported by GitHub-Markup (except roff).
19
19
 
20
+ h3. Images
21
+
22
+ Images can be included by absolute url on your hard drive or a absolute url on the Internet. You can also refer to an image relative from the markup file. Example in textile.
23
+
24
+ <pre>
25
+ !/tmp/test.jpg!
26
+ !http://upload.wikimedia.org/wikipedia/en/b/bc/Wiki.png!
27
+ !../images/test.jpg!
28
+ </pre>
29
+
20
30
  h2. Installation
21
31
 
22
32
  The best way to install Gimli is with RubyGems:
data/bin/gimli CHANGED
@@ -1,7 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'bundler/setup'
4
-
5
3
  $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__)) + '/../lib/')
6
4
 
7
5
  require 'gimli'
@@ -12,7 +12,7 @@ module Gimli
12
12
  class Converter
13
13
 
14
14
  # Initialize the converter with a File
15
- # @param [Array] files The list of Gimli::File to convert (passing a single file will still work)
15
+ # @param [Array] files The list of Gimli::MarkupFile to convert (passing a single file will still work)
16
16
  def initialize(files)
17
17
  @files = files
18
18
  end
@@ -23,7 +23,7 @@ module Gimli
23
23
  merged_contents = []
24
24
  @files.each do |file|
25
25
  markup = Markup.new file
26
- html = convert_image_urls markup.render
26
+ html = convert_image_urls markup.render, file.filename
27
27
  if merge
28
28
  html = "<div class=\"page-break\"></div>#{html}" unless merged_contents.empty?
29
29
  merged_contents << html
@@ -41,9 +41,10 @@ module Gimli
41
41
  # Rewrite relative image urls to absolute
42
42
  # @param [String] html some html to parse
43
43
  # @return [String] the html with all image urls replaced to absolute
44
- def convert_image_urls(html)
44
+ def convert_image_urls(html, filename)
45
+ dir_string = ::File.dirname(::File.expand_path(filename))
45
46
  html.scan(/<img[^>]+src="([^"]+)"/).each do |url|
46
- html.gsub!(url[0], ::File.expand_path(url[0])) unless url[0] =~ /^https?/
47
+ html.gsub!(url[0], ::File.expand_path(url[0], dir_string)) unless url[0] =~ /^https?/
47
48
  end
48
49
 
49
50
  html
data/lib/gimli/version.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Gimli
4
4
 
5
- Version = "0.1.8"
5
+ Version = "0.1.9"
6
6
 
7
7
  end
8
8
 
@@ -84,31 +84,37 @@ describe Gimli::Converter do
84
84
 
85
85
  it 'should convert relative image urls to absolute' do
86
86
  file = Gimli::MarkupFile.new 'fake'
87
+ filename = 'fixtures/fake.textile'
88
+ dir_string = ::File.dirname(::File.expand_path(filename))
87
89
  converter = Gimli::Converter.new file
88
90
 
89
91
  html = '<p>foo</p><img src="test.jpg" alt="" /><p>bar</p><img src="test2.jpg" alt="" />'
90
- valid_html = "<p>foo</p><img src=\"#{File.expand_path('test.jpg')}\" alt=\"\" /><p>bar</p><img src=\"#{File.expand_path('test2.jpg')}\" alt=\"\" />"
92
+ valid_html = "<p>foo</p><img src=\"#{File.expand_path('test.jpg', dir_string)}\" alt=\"\" /><p>bar</p><img src=\"#{File.expand_path('test2.jpg', dir_string)}\" alt=\"\" />"
91
93
 
92
- converter.convert_image_urls(html).should == valid_html
94
+ converter.convert_image_urls(html, filename).should == valid_html
93
95
  end
94
96
 
95
97
  it 'should not rewrite non relative urls' do
96
98
  file = Gimli::MarkupFile.new 'fake'
99
+ filename = '../../fixtures/fake.textile'
100
+ dir_string = ::File.dirname(::File.expand_path(filename))
97
101
  converter = Gimli::Converter.new file
98
102
 
99
103
  html = '<p>foo</p><img src="https://d3nwyuy0nl342s.cloudfront.net/images/modules/header/logov3-hover.png" alt="" /><p>bar</p>'
100
104
 
101
- converter.convert_image_urls(html).should == html
105
+ converter.convert_image_urls(html, filename).should == html
102
106
  end
103
107
 
104
108
  it 'should work on both absolute and relative images' do
105
109
  file = Gimli::MarkupFile.new 'fake'
110
+ filename = '../../fixtures/fake.textile'
111
+ dir_string = ::File.dirname(::File.expand_path(filename))
106
112
  converter = Gimli::Converter.new file
107
113
 
108
114
  html = '<p>foo</p><img src="test.jpg" alt="" /><p>bar</p><img src="/tmp/test2.jpg" alt="" /> <img src="https://d3nwyuy0nl342s.cloudfront.net/images/modules/header/logov3-hover.png" alt="" />'
109
- valid_html = "<p>foo</p><img src=\"#{File.expand_path('test.jpg')}\" alt=\"\" /><p>bar</p><img src=\"/tmp/test2.jpg\" alt=\"\" /> <img src=\"https://d3nwyuy0nl342s.cloudfront.net/images/modules/header/logov3-hover.png\" alt=\"\" />"
115
+ valid_html = "<p>foo</p><img src=\"#{File.expand_path('test.jpg', dir_string)}\" alt=\"\" /><p>bar</p><img src=\"/tmp/test2.jpg\" alt=\"\" /> <img src=\"https://d3nwyuy0nl342s.cloudfront.net/images/modules/header/logov3-hover.png\" alt=\"\" />"
110
116
 
111
- converter.convert_image_urls(html).should == valid_html
117
+ converter.convert_image_urls(html, filename).should == valid_html
112
118
  end
113
119
  end
114
120
 
metadata CHANGED
@@ -1,229 +1,181 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: gimli
3
- version: !ruby/object:Gem::Version
4
- hash: 11
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.9
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 1
9
- - 8
10
- version: 0.1.8
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Fredrik Wallgren
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-06-26 00:00:00 +02:00
12
+ date: 2011-07-11 00:00:00.000000000 +02:00
19
13
  default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
22
- name: bundler
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 3
30
- segments:
31
- - 0
32
- version: "0"
33
- type: :runtime
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
36
16
  name: github-markup
37
- prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
17
+ requirement: &10022600 !ruby/object:Gem::Requirement
39
18
  none: false
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- hash: 3
44
- segments:
45
- - 0
46
- version: "0"
19
+ requirements:
20
+ - - ~>
21
+ - !ruby/object:Gem::Version
22
+ version: 0.5.3
47
23
  type: :runtime
48
- version_requirements: *id002
49
- - !ruby/object:Gem::Dependency
50
- name: redcarpet
51
24
  prerelease: false
52
- requirement: &id003 !ruby/object:Gem::Requirement
25
+ version_requirements: *10022600
26
+ - !ruby/object:Gem::Dependency
27
+ name: redcarpet
28
+ requirement: &10022120 !ruby/object:Gem::Requirement
53
29
  none: false
54
- requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
57
- hash: 3
58
- segments:
59
- - 0
60
- version: "0"
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 1.17.2
61
34
  type: :runtime
62
- version_requirements: *id003
63
- - !ruby/object:Gem::Dependency
64
- name: RedCloth
65
35
  prerelease: false
66
- requirement: &id004 !ruby/object:Gem::Requirement
36
+ version_requirements: *10022120
37
+ - !ruby/object:Gem::Dependency
38
+ name: RedCloth
39
+ requirement: &10021660 !ruby/object:Gem::Requirement
67
40
  none: false
68
- requirements:
69
- - - ">="
70
- - !ruby/object:Gem::Version
71
- hash: 3
72
- segments:
73
- - 0
74
- version: "0"
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
44
+ version: 4.2.7
75
45
  type: :runtime
76
- version_requirements: *id004
77
- - !ruby/object:Gem::Dependency
78
- name: org-ruby
79
46
  prerelease: false
80
- requirement: &id005 !ruby/object:Gem::Requirement
47
+ version_requirements: *10021660
48
+ - !ruby/object:Gem::Dependency
49
+ name: org-ruby
50
+ requirement: &10021200 !ruby/object:Gem::Requirement
81
51
  none: false
82
- requirements:
83
- - - ">="
84
- - !ruby/object:Gem::Version
85
- hash: 3
86
- segments:
87
- - 0
88
- version: "0"
52
+ requirements:
53
+ - - ~>
54
+ - !ruby/object:Gem::Version
55
+ version: 0.5.3
89
56
  type: :runtime
90
- version_requirements: *id005
91
- - !ruby/object:Gem::Dependency
92
- name: creole
93
57
  prerelease: false
94
- requirement: &id006 !ruby/object:Gem::Requirement
58
+ version_requirements: *10021200
59
+ - !ruby/object:Gem::Dependency
60
+ name: creole
61
+ requirement: &10020740 !ruby/object:Gem::Requirement
95
62
  none: false
96
- requirements:
97
- - - ">="
98
- - !ruby/object:Gem::Version
99
- hash: 3
100
- segments:
101
- - 0
102
- version: "0"
63
+ requirements:
64
+ - - ~>
65
+ - !ruby/object:Gem::Version
66
+ version: 0.4.2
103
67
  type: :runtime
104
- version_requirements: *id006
105
- - !ruby/object:Gem::Dependency
106
- name: wikicloth
107
68
  prerelease: false
108
- requirement: &id007 !ruby/object:Gem::Requirement
69
+ version_requirements: *10020740
70
+ - !ruby/object:Gem::Dependency
71
+ name: wikicloth
72
+ requirement: &10020280 !ruby/object:Gem::Requirement
109
73
  none: false
110
- requirements:
111
- - - ">="
112
- - !ruby/object:Gem::Version
113
- hash: 3
114
- segments:
115
- - 0
116
- version: "0"
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 0.6.3
117
78
  type: :runtime
118
- version_requirements: *id007
119
- - !ruby/object:Gem::Dependency
120
- name: albino
121
79
  prerelease: false
122
- requirement: &id008 !ruby/object:Gem::Requirement
80
+ version_requirements: *10020280
81
+ - !ruby/object:Gem::Dependency
82
+ name: albino
83
+ requirement: &10019820 !ruby/object:Gem::Requirement
123
84
  none: false
124
- requirements:
125
- - - ">="
126
- - !ruby/object:Gem::Version
127
- hash: 3
128
- segments:
129
- - 0
130
- version: "0"
85
+ requirements:
86
+ - - ~>
87
+ - !ruby/object:Gem::Version
88
+ version: 1.3.3
131
89
  type: :runtime
132
- version_requirements: *id008
133
- - !ruby/object:Gem::Dependency
134
- name: nokogiri
135
90
  prerelease: false
136
- requirement: &id009 !ruby/object:Gem::Requirement
91
+ version_requirements: *10019820
92
+ - !ruby/object:Gem::Dependency
93
+ name: nokogiri
94
+ requirement: &10019360 !ruby/object:Gem::Requirement
137
95
  none: false
138
- requirements:
139
- - - ">="
140
- - !ruby/object:Gem::Version
141
- hash: 3
142
- segments:
143
- - 0
144
- version: "0"
96
+ requirements:
97
+ - - ~>
98
+ - !ruby/object:Gem::Version
99
+ version: 1.4.4
145
100
  type: :runtime
146
- version_requirements: *id009
147
- - !ruby/object:Gem::Dependency
148
- name: wkhtmltopdf-binary
149
101
  prerelease: false
150
- requirement: &id010 !ruby/object:Gem::Requirement
102
+ version_requirements: *10019360
103
+ - !ruby/object:Gem::Dependency
104
+ name: wkhtmltopdf-binary
105
+ requirement: &10018900 !ruby/object:Gem::Requirement
151
106
  none: false
152
- requirements:
153
- - - ">="
154
- - !ruby/object:Gem::Version
155
- hash: 3
156
- segments:
157
- - 0
158
- version: "0"
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: 0.9.5.3
159
111
  type: :runtime
160
- version_requirements: *id010
161
- - !ruby/object:Gem::Dependency
162
- name: pdfkit
163
112
  prerelease: false
164
- requirement: &id011 !ruby/object:Gem::Requirement
113
+ version_requirements: *10018900
114
+ - !ruby/object:Gem::Dependency
115
+ name: pdfkit
116
+ requirement: &10018440 !ruby/object:Gem::Requirement
165
117
  none: false
166
- requirements:
167
- - - ">="
168
- - !ruby/object:Gem::Version
169
- hash: 3
170
- segments:
171
- - 0
172
- version: "0"
118
+ requirements:
119
+ - - ~>
120
+ - !ruby/object:Gem::Version
121
+ version: 0.5.2
173
122
  type: :runtime
174
- version_requirements: *id011
175
- - !ruby/object:Gem::Dependency
176
- name: optiflag
177
123
  prerelease: false
178
- requirement: &id012 !ruby/object:Gem::Requirement
124
+ version_requirements: *10018440
125
+ - !ruby/object:Gem::Dependency
126
+ name: optiflag
127
+ requirement: &10017980 !ruby/object:Gem::Requirement
179
128
  none: false
180
- requirements:
181
- - - ">="
182
- - !ruby/object:Gem::Version
183
- hash: 3
184
- segments:
185
- - 0
186
- version: "0"
129
+ requirements:
130
+ - - ~>
131
+ - !ruby/object:Gem::Version
132
+ version: '0.7'
187
133
  type: :runtime
188
- version_requirements: *id012
189
- - !ruby/object:Gem::Dependency
190
- name: rspec
191
134
  prerelease: false
192
- requirement: &id013 !ruby/object:Gem::Requirement
135
+ version_requirements: *10017980
136
+ - !ruby/object:Gem::Dependency
137
+ name: rspec
138
+ requirement: &10017600 !ruby/object:Gem::Requirement
193
139
  none: false
194
- requirements:
195
- - - ">="
196
- - !ruby/object:Gem::Version
197
- hash: 3
198
- segments:
199
- - 0
200
- version: "0"
140
+ requirements:
141
+ - - ! '>='
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
201
144
  type: :development
202
- version_requirements: *id013
203
- - !ruby/object:Gem::Dependency
145
+ prerelease: false
146
+ version_requirements: *10017600
147
+ - !ruby/object:Gem::Dependency
204
148
  name: rr
149
+ requirement: &10017140 !ruby/object:Gem::Requirement
150
+ none: false
151
+ requirements:
152
+ - - ! '>='
153
+ - !ruby/object:Gem::Version
154
+ version: '0'
155
+ type: :development
205
156
  prerelease: false
206
- requirement: &id014 !ruby/object:Gem::Requirement
157
+ version_requirements: *10017140
158
+ - !ruby/object:Gem::Dependency
159
+ name: bundler
160
+ requirement: &10016720 !ruby/object:Gem::Requirement
207
161
  none: false
208
- requirements:
209
- - - ">="
210
- - !ruby/object:Gem::Version
211
- hash: 3
212
- segments:
213
- - 0
214
- version: "0"
162
+ requirements:
163
+ - - ! '>='
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
215
166
  type: :development
216
- version_requirements: *id014
217
- description: Utility for converting markup files to pdf files. Useful for reports etc.
167
+ prerelease: false
168
+ version_requirements: *10016720
169
+ description: Utility for converting markup files to pdf files. Useful for reports
170
+ etc.
218
171
  email: fredrik.wallgren@gmail.com
219
- executables:
172
+ executables:
220
173
  - gimli
221
174
  extensions: []
222
-
223
- extra_rdoc_files:
175
+ extra_rdoc_files:
224
176
  - README.textile
225
177
  - LICENSE
226
- files:
178
+ files:
227
179
  - bin/gimli
228
180
  - lib/gimli/version.rb
229
181
  - lib/gimli/path.rb
@@ -249,36 +201,27 @@ files:
249
201
  has_rdoc: true
250
202
  homepage: https://github.com/walle/gimli
251
203
  licenses: []
252
-
253
204
  post_install_message:
254
- rdoc_options:
205
+ rdoc_options:
255
206
  - --charset=UTF-8
256
- require_paths:
207
+ require_paths:
257
208
  - - lib
258
- required_ruby_version: !ruby/object:Gem::Requirement
209
+ required_ruby_version: !ruby/object:Gem::Requirement
259
210
  none: false
260
- requirements:
261
- - - ">="
262
- - !ruby/object:Gem::Version
263
- hash: 3
264
- segments:
265
- - 0
266
- version: "0"
267
- required_rubygems_version: !ruby/object:Gem::Requirement
211
+ requirements:
212
+ - - ! '>='
213
+ - !ruby/object:Gem::Version
214
+ version: '0'
215
+ required_rubygems_version: !ruby/object:Gem::Requirement
268
216
  none: false
269
- requirements:
270
- - - ">="
271
- - !ruby/object:Gem::Version
272
- hash: 3
273
- segments:
274
- - 0
275
- version: "0"
217
+ requirements:
218
+ - - ! '>='
219
+ - !ruby/object:Gem::Version
220
+ version: '0'
276
221
  requirements: []
277
-
278
222
  rubyforge_project: gimli
279
223
  rubygems_version: 1.6.2
280
224
  signing_key:
281
225
  specification_version: 3
282
226
  summary: Utility for converting markup files to pdf files.
283
227
  test_files: []
284
-