prawn-format 0.1.1 → 0.2.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -6,7 +6,7 @@ rescue LoadError
6
6
  abort "You'll need to have `echoe' installed to use Prawn::Format's Rakefile"
7
7
  end
8
8
 
9
- version = Prawn::Format::Version::STRING.dup
9
+ version = Prawn::Format::VERSION.dup
10
10
  if ENV['SNAPSHOT'].to_i == 1
11
11
  version << "." << Time.now.utc.strftime("%Y%m%d%H%M%S")
12
12
  end
@@ -20,7 +20,7 @@ Echoe.new('prawn-format', version) do |p|
20
20
  p.url = "http://rubyforge.org/projects/prawn"
21
21
  p.project = "prawn"
22
22
 
23
- p.runtime_dependencies += ["prawn >=0.4", "prawn <0.5"]
23
+ p.runtime_dependencies << "prawn-core"
24
24
 
25
25
  p.need_zip = true
26
26
  p.include_rakefile = true
@@ -9,6 +9,9 @@ module Prawn
9
9
  mod.send :alias_method, :text_without_formatting, :text
10
10
  mod.send :alias_method, :text, :text_with_formatting
11
11
 
12
+ mod.send :alias_method, :width_of_without_formatting, :width_of
13
+ mod.send :alias_method, :width_of, :width_of_with_formatting
14
+
12
15
  mod.send :alias_method, :height_of_without_formatting, :height_of
13
16
  mod.send :alias_method, :height_of, :height_of_with_formatting
14
17
  end
@@ -33,6 +36,16 @@ module Prawn
33
36
  end
34
37
  end
35
38
 
39
+ # Overloaded version of #width_of. Call via #width_of, rather than
40
+ # #width_of_with_formatting (see above, where it aliased to #width_of).
41
+ def width_of_with_formatting(string, options={}) #:nodoc:
42
+ if unformatted?(string, options)
43
+ width_of_without_formatting(string, options)
44
+ else
45
+ formatted_width(string, options)
46
+ end
47
+ end
48
+
36
49
  DEFAULT_TAGS = {
37
50
  :a => { :meta => { :name => :anchor, :href => :target }, :color => "0000ff", :text_decoration => :underline },
38
51
  :b => { :font_weight => :bold },
@@ -200,10 +213,15 @@ module Prawn
200
213
  end
201
214
 
202
215
  def formatted_height(string, line_width, size=font_size, options={})
203
- helper = layout(string, options.merge(:size => font_size))
216
+ helper = layout(string, options.merge(:size => size))
204
217
  lines = helper.word_wrap(line_width)
205
218
  return lines.inject(0) { |s, line| s + line.height }
206
219
  end
220
+
221
+ def formatted_width(string, options={})
222
+ helper = layout(string, options)
223
+ helper.next.width
224
+ end
207
225
  end
208
226
  end
209
227
 
@@ -6,7 +6,7 @@ module Prawn
6
6
 
7
7
  class Link
8
8
  def initialize(target, x)
9
- @target = target.sub(/^#/, "")
9
+ @target = target
10
10
  @x = x
11
11
  end
12
12
 
@@ -16,7 +16,11 @@ module Prawn
16
16
  y = draw_state[:real_y] + draw_state[:dy]
17
17
 
18
18
  rect = [x1, y + draw_state[:line].descent, x2, y + draw_state[:line].ascent]
19
- document.link_annotation(rect, :Dest => @target, :Border => [0,0,0])
19
+ if @target.match(/^#/)
20
+ document.link_annotation(rect, :Dest => @target.sub(/^#/,""), :Border => [0,0,0])
21
+ else
22
+ document.link_annotation(rect, :Border => [0,0,0], :A => { :Type => :Action, :S => :URI, :URI => Prawn::LiteralString.new(@target) } )
23
+ end #new
20
24
  end
21
25
 
22
26
  def wrap(document, draw_state)
@@ -57,7 +57,7 @@ module Prawn
57
57
  end
58
58
 
59
59
  def width(type=:all)
60
- @width ||= @state.font.width_of(@text, :size => @state.font_size, :kerning => @state.kerning?)
60
+ @width ||= @state.font.compute_width_of(@text, :size => @state.font_size, :kerning => @state.kerning?)
61
61
 
62
62
  case type
63
63
  when :discardable then discardable? ? @width : 0
@@ -1,11 +1,5 @@
1
1
  module Prawn
2
2
  module Format
3
- module Version
4
- MAJOR = 0
5
- MINOR = 1
6
- TINY = 1
7
-
8
- STRING = [MAJOR, MINOR, TINY].join(".")
9
- end
3
+ VERSION = "0.2.0.1"
10
4
  end
11
5
  end
@@ -1,39 +1,37 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  Gem::Specification.new do |s|
2
4
  s.name = %q{prawn-format}
3
- s.version = "0.1.1"
5
+ s.version = "0.2.0.1"
4
6
 
5
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
6
8
  s.authors = ["Jamis Buck"]
7
- s.date = %q{2009-01-27}
9
+ s.date = %q{2009-06-15}
8
10
  s.description = %q{an extension of Prawn that allows inline formatting}
9
11
  s.email = %q{jamis@jamisbuck.org}
10
12
  s.extra_rdoc_files = ["lib/prawn/format/effects/link.rb", "lib/prawn/format/effects/underline.rb", "lib/prawn/format/instructions/base.rb", "lib/prawn/format/instructions/tag_close.rb", "lib/prawn/format/instructions/tag_open.rb", "lib/prawn/format/instructions/text.rb", "lib/prawn/format/layout_builder.rb", "lib/prawn/format/lexer.rb", "lib/prawn/format/line.rb", "lib/prawn/format/parser.rb", "lib/prawn/format/state.rb", "lib/prawn/format/text_object.rb", "lib/prawn/format/version.rb", "lib/prawn/format.rb"]
11
13
  s.files = ["examples/basic-formatting.rb", "examples/christmas-carol.txt", "examples/document.rb", "examples/flowing.rb", "examples/style-classes.rb", "examples/syntax-highlighting.rb", "examples/tags.rb", "lib/prawn/format/effects/link.rb", "lib/prawn/format/effects/underline.rb", "lib/prawn/format/instructions/base.rb", "lib/prawn/format/instructions/tag_close.rb", "lib/prawn/format/instructions/tag_open.rb", "lib/prawn/format/instructions/text.rb", "lib/prawn/format/layout_builder.rb", "lib/prawn/format/lexer.rb", "lib/prawn/format/line.rb", "lib/prawn/format/parser.rb", "lib/prawn/format/state.rb", "lib/prawn/format/text_object.rb", "lib/prawn/format/version.rb", "lib/prawn/format.rb", "manual/html.rb", "manual/include/basics.rb", "manual/include/breaks.rb", "manual/include/custom-tags.rb", "manual/include/custom-tags2.rb", "manual/include/indent.rb", "manual/include/options.rb", "manual/include/style-classes.rb", "manual/manual.txt", "manual/pdf.rb", "Rakefile", "spec/layout_builder_spec.rb", "spec/lexer_spec.rb", "spec/parser_spec.rb", "spec/spec_helper.rb", "Manifest", "prawn-format.gemspec"]
12
- s.has_rdoc = true
13
14
  s.homepage = %q{http://rubyforge.org/projects/prawn}
14
15
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Prawn-format"]
15
16
  s.require_paths = ["lib"]
16
17
  s.rubyforge_project = %q{prawn}
17
- s.rubygems_version = %q{1.2.0}
18
+ s.rubygems_version = %q{1.3.4}
18
19
  s.summary = %q{an extension of Prawn that allows inline formatting}
19
20
  s.test_files = ["spec/layout_builder_spec.rb", "spec/lexer_spec.rb", "spec/parser_spec.rb"]
20
21
 
21
22
  if s.respond_to? :specification_version then
22
23
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
23
- s.specification_version = 2
24
+ s.specification_version = 3
24
25
 
25
- if current_version >= 3 then
26
- s.add_runtime_dependency(%q<prawn>, [">= 0.4"])
27
- s.add_runtime_dependency(%q<prawn>, ["< 0.5"])
26
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
27
+ s.add_runtime_dependency(%q<prawn-core>, [">= 0"])
28
28
  s.add_development_dependency(%q<echoe>, [">= 0"])
29
29
  else
30
- s.add_dependency(%q<prawn>, [">= 0.4"])
31
- s.add_dependency(%q<prawn>, ["< 0.5"])
30
+ s.add_dependency(%q<prawn-core>, [">= 0"])
32
31
  s.add_dependency(%q<echoe>, [">= 0"])
33
32
  end
34
33
  else
35
- s.add_dependency(%q<prawn>, [">= 0.4"])
36
- s.add_dependency(%q<prawn>, ["< 0.5"])
34
+ s.add_dependency(%q<prawn-core>, [">= 0"])
37
35
  s.add_dependency(%q<echoe>, [">= 0"])
38
36
  end
39
37
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prawn-format
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamis Buck
@@ -9,28 +9,18 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-01-27 00:00:00 -07:00
12
+ date: 2009-06-15 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: prawn
16
+ name: prawn-core
17
17
  type: :runtime
18
18
  version_requirement:
19
19
  version_requirements: !ruby/object:Gem::Requirement
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: "0.4"
24
- version:
25
- - !ruby/object:Gem::Dependency
26
- name: prawn
27
- type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - <
32
- - !ruby/object:Gem::Version
33
- version: "0.5"
23
+ version: "0"
34
24
  version:
35
25
  - !ruby/object:Gem::Dependency
36
26
  name: echoe
@@ -104,6 +94,8 @@ files:
104
94
  - prawn-format.gemspec
105
95
  has_rdoc: true
106
96
  homepage: http://rubyforge.org/projects/prawn
97
+ licenses: []
98
+
107
99
  post_install_message:
108
100
  rdoc_options:
109
101
  - --line-numbers
@@ -127,9 +119,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
119
  requirements: []
128
120
 
129
121
  rubyforge_project: prawn
130
- rubygems_version: 1.2.0
122
+ rubygems_version: 1.3.4
131
123
  signing_key:
132
- specification_version: 2
124
+ specification_version: 3
133
125
  summary: an extension of Prawn that allows inline formatting
134
126
  test_files:
135
127
  - spec/layout_builder_spec.rb