pdf-my-url 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile ADDED
@@ -0,0 +1 @@
1
+ source 'http://rubygems.org'
File without changes
@@ -1,17 +1,29 @@
1
1
  = PDFmyURL
2
2
 
3
- A basic ruby-on-rails interface to http://pdfmyurl.com/
3
+ PDFmyURL is a basic ruby-on-rails view helper for the online web service http://pdfmyurl.com/. It allows for easy PDF creation from URLs without having to install any conversion tools.
4
+
5
+ == Requirements
6
+
7
+ The gem has only been tested with Ruby 1.9.2 and Rails 3.0.3 but may well work with other versions of Ruby or Rails.
8
+
9
+ == Installation
10
+
11
+ gem install pdf-my-url
4
12
 
5
13
  == Example
6
14
 
7
15
  <%= pdf_my_url 'CBC', 'http://www.cbc.ca/' %>
8
-
9
- <%= pdf_my_url 'BBC', 'http://www.bbc.co.uk/', :filename => 'BBC.pdf' %>
10
-
11
- <%= pdf_my_url 'NY Times', 'http://www.nytimes.com/', :filename => 'NY-Times.pdf',
12
- :page_height => 200, :page_width => 100,
13
- :margin_top => 10, :margin_left => 5, :margin_right => 5, :margin_bottom => 10 %>
16
+
17
+ <%= pdf_my_url 'CBC', 'http://www.cbc.ca/', :filename => 'CBC.pdf' %>
18
+
19
+ <%= pdf_my_url 'CBC', 'http://www.cbc.ca/', :orientation => :portrait %>
20
+
21
+ <%= pdf_my_url 'CBC', 'http://www.cbc.ca/', :orientation => :landscape %>
22
+
23
+ <%= pdf_my_url 'CBC', 'http://www.cbc.ca/', :page => { :height => 200, :width => 200 } %>
24
+
25
+ <%= pdf_my_url 'CBC', 'http://www.cbc.ca/', :margin => { :top => 10, :left => 5, :right => 5, :bottom => 10 } %>
14
26
 
15
27
  == Copyright
16
28
 
17
- Copyright (c) 2010 Kevin Sylvestre, released under the MIT license
29
+ Copyright (c) 2010 Kevin Sylvestre. See LICENSE for details.
@@ -1,32 +1,59 @@
1
- module ActionView
2
- module Helpers
3
-
4
- def pdf_my_url(name, url, options = {})
5
-
6
- parameters = ""
7
-
8
- parameters += "&--filename=#{options[:filename]}" if options[:filename]
9
-
10
- parameters += "&--orientation=Portrait" if options[:orientation] == :portrait
11
- parameters += "&--orientation=Landscape" if options[:orientation] == :landscape
12
-
13
- parameters += "&--page-size=#{options[:page_size]}" if options[:page_size]
14
-
15
- parameters += "&--proxy=#{options[:proxy]}" if options[:proxy]
16
- parameters += "&--username=#{options[:username]}" if options[:username]
17
- parameters += "&--password=#{options[:password]}" if options[:password]
18
-
19
- parameters += "&--page-width=#{options[:page_width]}" if options[:page_width]
20
- parameters += "&--page-height=#{options[:page_height]}" if options[:page_height]
21
-
22
- parameters += "&--margin-top=#{options[:margin_top]}" if options[:margin_top]
23
- parameters += "&--margin-left=#{options[:margin_left]}" if options[:margin_left]
24
- parameters += "&--margin-right=#{options[:margin_right]}" if options[:margin_right]
25
- parameters += "&--margin-bottom=#{options[:margin_bottom]}" if options[:margin_bottom]
26
-
27
- link_to name, "http://pdfmyurl.com/?url=#{url}#{parameters}"
28
-
29
- end
30
-
1
+ require 'pdf-my-url/railtie'
2
+
3
+ module PdfMyUrl
4
+
5
+
6
+ # Create a link with the approriate parameters to the service.
7
+ #
8
+ # Options:
9
+ #
10
+ # * :protocol - set a custom protocol (the default is 'http' and 'https' is supported)
11
+ # * :filename - set a custom name to download (the default is the filename made from the url)
12
+ # * :orientation - set a document orientation to landscape (:landscape) or portrait (:portrait)
13
+ # * :proxy - set a custom proxy to access the url
14
+ # * :username - set a http authentication username used when accessing the url
15
+ # * :password - set a http authentication password used when accessing the url
16
+ # * :page
17
+ # * :size - set a page size (for example: 'A4' or 'Letter')
18
+ # * :width - set a page width (for example: '200mm') with a default unit of millimeters
19
+ # * :height - set a page height (for example: '300mm') with a default unit of millimeters
20
+ # * :margin
21
+ # * :top - set a margin (for example: '10mm') or use the default 10mm
22
+ # * :left - set a margin (for example: '10mm') or use the default 10mm
23
+ # * :right - set a margin (for example: '10mm') or use the default 10mm
24
+ # * :bottom - set a margin (for example: '10mm') or use the default 10mm
25
+
26
+ def pdf_my_url(name, url, options = {})
27
+
28
+ protocol = options[:protocol] || 'http'
29
+
30
+ options[:page ] ||= {}
31
+ options[:margin] ||= {}
32
+
33
+ parameters = "?url=#{url}"
34
+
35
+ parameters += "&--filename=#{options[:filename]}" if options[:filename]
36
+
37
+ parameters += "&--orientation=Portrait" if options[:orientation] == :portrait
38
+ parameters += "&--orientation=Landscape" if options[:orientation] == :landscape
39
+
40
+ parameters += "&--proxy=#{options[:proxy]}" if options[:proxy]
41
+
42
+ parameters += "&--username=#{options[:username]}" if options[:username]
43
+ parameters += "&--password=#{options[:password]}" if options[:password]
44
+
45
+ parameters += "&--page-size=#{options[:page][:size]}" if options[:page][:size ]
46
+ parameters += "&--page-width=#{options[:page][:width]}" if options[:page][:width ]
47
+ parameters += "&--page-height=#{options[:page][:height]}" if options[:page][:height]
48
+
49
+ parameters += "&--margin-top=#{options[:margin][:top]}" if options[:margin][:top ]
50
+ parameters += "&--margin-left=#{options[:margin][:left]}" if options[:margin][:left ]
51
+ parameters += "&--margin-right=#{options[:margin][:right]}" if options[:margin][:right ]
52
+ parameters += "&--margin-bottom=#{options[:margin][:bottom]}" if options[:margin][:bottom]
53
+
54
+ link_to name, "#{protocol}://pdfmyurl.com#{parameters}"
55
+
31
56
  end
57
+
58
+
32
59
  end
@@ -0,0 +1,10 @@
1
+ require 'pdf-my-url'
2
+ require 'rails'
3
+
4
+ module PdfMyUrl
5
+ class Railtie < Rails::Railtie
6
+ initializer 'pdf-my-url.initialize' do
7
+ ActionView::Helpers.send :include, PdfMyUrl
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,3 @@
1
+ module PdfMyUrl
2
+ VERSION = "1.0.1"
3
+ end
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pdf-my-url
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
5
4
  prerelease: false
6
5
  segments:
7
6
  - 1
8
7
  - 0
9
- - 0
10
- version: 1.0.0
8
+ - 1
9
+ version: 1.0.1
11
10
  platform: ruby
12
11
  authors:
13
12
  - Kevin Sylvestre
@@ -15,33 +14,33 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2010-07-19 00:00:00 -04:00
17
+ date: 2010-12-29 00:00:00 -05:00
19
18
  default_executable:
20
19
  dependencies: []
21
20
 
22
- description:
21
+ description: PDF my URL is a Ruby on Rails view helper for easily creating attachments from the online web service with the same name.
23
22
  email:
23
+ - kevin@ksylvest.com
24
24
  executables: []
25
25
 
26
26
  extensions: []
27
27
 
28
- extra_rdoc_files:
29
- - README.rdoc
28
+ extra_rdoc_files: []
29
+
30
30
  files:
31
- - MIT-LICENSE
32
- - README.rdoc
33
- - Rakefile
34
- - VERSION
35
- - init.rb
31
+ - lib/pdf-my-url/railtie.rb
32
+ - lib/pdf-my-url/version.rb
36
33
  - lib/pdf-my-url.rb
37
- - pdf-my-url.gemspec
34
+ - README.rdoc
35
+ - LICENSE
36
+ - Gemfile
38
37
  has_rdoc: true
39
38
  homepage: http://github.com/ksylvest/pdf-my-url
40
39
  licenses: []
41
40
 
42
41
  post_install_message:
43
- rdoc_options:
44
- - --charset=UTF-8
42
+ rdoc_options: []
43
+
45
44
  require_paths:
46
45
  - lib
47
46
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -49,7 +48,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
49
48
  requirements:
50
49
  - - ">="
51
50
  - !ruby/object:Gem::Version
52
- hash: 3
53
51
  segments:
54
52
  - 0
55
53
  version: "0"
@@ -58,7 +56,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
58
56
  requirements:
59
57
  - - ">="
60
58
  - !ruby/object:Gem::Version
61
- hash: 3
62
59
  segments:
63
60
  - 0
64
61
  version: "0"
data/Rakefile DELETED
@@ -1,14 +0,0 @@
1
- require 'rubygems'
2
- require 'rake'
3
-
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gemspec|
7
- gemspec.name = "pdf-my-url"
8
- gemspec.summary = "A basic ruby-on-rails interface to http://pdfmyurl.com/"
9
- gemspec.homepage = "http://github.com/ksylvest/pdf-my-url"
10
- gemspec.author = "Kevin Sylvestre"
11
- end
12
- rescue LoadError
13
- puts "Jeweler not available. Install it with: gem install jeweler"
14
- end
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 1.0.0
data/init.rb DELETED
@@ -1 +0,0 @@
1
- require 'pdf-my-url'
@@ -1,41 +0,0 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
- # -*- encoding: utf-8 -*-
5
-
6
- Gem::Specification.new do |s|
7
- s.name = %q{pdf-my-url}
8
- s.version = "1.0.0"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Kevin Sylvestre"]
12
- s.date = %q{2010-07-19}
13
- s.extra_rdoc_files = [
14
- "README.rdoc"
15
- ]
16
- s.files = [
17
- "MIT-LICENSE",
18
- "README.rdoc",
19
- "Rakefile",
20
- "VERSION",
21
- "init.rb",
22
- "lib/pdf-my-url.rb",
23
- "pdf-my-url.gemspec"
24
- ]
25
- s.homepage = %q{http://github.com/ksylvest/pdf-my-url}
26
- s.rdoc_options = ["--charset=UTF-8"]
27
- s.require_paths = ["lib"]
28
- s.rubygems_version = %q{1.3.7}
29
- s.summary = %q{A basic ruby-on-rails interface to http://pdfmyurl.com/}
30
-
31
- if s.respond_to? :specification_version then
32
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
33
- s.specification_version = 3
34
-
35
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
36
- else
37
- end
38
- else
39
- end
40
- end
41
-