htmls_to_pdf 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/README.markdown +23 -10
- data/examples/get_backbone_fundamentals.rb +24 -0
- data/examples/get_coffeescript.rb +4 -4
- data/examples/get_coffeescript_cookbook.rb +23 -14
- data/examples/get_jasmine_wiki.rb +61 -0
- data/examples/get_ror_guides.rb +6 -2
- data/examples/get_rspec.rb +97 -95
- data/lib/htmls_to_pdf/htmls_to_pdf.rb +130 -52
- data/lib/htmls_to_pdf/version.rb +1 -1
- data/spec/htmls_to_pdf_spec.rb +116 -27
- metadata +4 -2
data/.gitignore
CHANGED
data/README.markdown
CHANGED
@@ -4,15 +4,17 @@
|
|
4
4
|
|
5
5
|
HtmlsToPdf enables you to package one or more (ordered) HTML pages as a PDF.
|
6
6
|
|
7
|
-
##
|
7
|
+
## WHY?
|
8
8
|
|
9
|
-
I
|
9
|
+
I often see multi-page websites with content I would rather have in a single PDF file for searching and offline viewing. Examples include: *The Ruby on Rails Guides* and *RSpec documentation*.
|
10
|
+
|
11
|
+
Viewing docs offline also reduces browser "tab-itis," browser crashes, and unnecessary re-downloading of server content.
|
10
12
|
|
11
13
|
## REQUIREMENTS
|
12
14
|
|
13
15
|
I have run this only on Linux. It likely works on OS X. It may not work on Windows.
|
14
16
|
|
15
|
-
HtmlsToPdf uses the PDFKit gem, which itself uses the
|
17
|
+
HtmlsToPdf uses [the PDFKit gem](https://github.com/pdfkit/PDFKit/), which itself uses [the wkhtmltopdf program](http://madalgo.au.dk/~jakobt/wkhtmltoxdoc/wkhtmltopdf-0.9.9-doc.html), which uses qtwebkit.
|
16
18
|
|
17
19
|
Dependence chain summary: HtmlsToPdf -> PDFKit -> wkhtmltopdf -> qtwebkit -> webkit
|
18
20
|
|
@@ -38,21 +40,27 @@ For information on PDFKit:
|
|
38
40
|
|
39
41
|
## BASIC USAGE
|
40
42
|
|
41
|
-
|
43
|
+
Create a new HtmlsToPdf object, passing in all your configuration options. Then tell the new object to .create_pdf:
|
42
44
|
|
43
45
|
require 'rubygems'
|
44
46
|
require 'htmls_to_pdf'
|
45
47
|
|
46
48
|
config = {}
|
47
|
-
config[:urls]
|
48
|
-
config[:savedir]
|
49
|
+
config[:urls] = ['http://.../url1.htm', 'https://.../url2.html']
|
50
|
+
config[:savedir] = '~/my/savedir'
|
49
51
|
config[:savename] = 'Name_to_save_file_as.pdf'
|
52
|
+
config[:css] = ['http://www.example.com/css_file.css',
|
53
|
+
'h1 {color: red; margin: 10px 5px;} p {color: blue; border: 1px solid green; font-size: 80%;}']
|
50
54
|
|
51
55
|
HtmlsToPdf.new(config).create_pdf
|
52
56
|
|
57
|
+
(Alternatively, you can set configuration options by calling setters on an HtmlsToPdf instance, e.g.: h2p = HtmlsToPdf.new({}); h2p.savedir = '~/my/savedir')
|
58
|
+
|
53
59
|
## OPTIONS
|
54
60
|
|
55
|
-
`config[:css]` takes an array of CSS
|
61
|
+
`config[:css]` takes an array of CSS file URLs and/or valid CSS strings (you can mix URLs and CSS strings within an array) to apply during PDF rendering. (If you have just one CSS URL/string, you can pass it without an array.)
|
62
|
+
|
63
|
+
`config[:debug]` (default: false) determines whether the program outputs verbose information while processing create_pdf()
|
56
64
|
|
57
65
|
`config[:overwrite_existing_pdf]` (default: false) determines whether the program can overwrite a previously generated PDF file
|
58
66
|
|
@@ -68,15 +76,17 @@ To use HtmlsToPdf, you create a new HtmlsToPdf object and pass in all your confi
|
|
68
76
|
|
69
77
|
## EXAMPLES
|
70
78
|
|
71
|
-
You will find
|
79
|
+
You will find 20 example scripts in the /examples directory. Each creates a PDF from a website:
|
72
80
|
|
73
81
|
- [The 12 Factor App](http://www.12factor.net) (Adam Wiggins)
|
82
|
+
- [Advanced Rails - Five-Day](http://tutorials.jumpstartlab.com/paths/advanced_rails_five_day.html) (Jumpstart Labs)
|
83
|
+
- [Backbone Fundamentals](https://github.com/addyosmani/backbone-fundamentals/blob/master/book.md) (Addy Osmani)
|
74
84
|
- [Bash Guide](http://mywiki.wooledge.org/BashGuide) (Greg Wooledge)
|
75
85
|
- [Coffeescript Meet Backbone.js](http://adamjspooner.github.com/coffeescript-meet-backbonejs/) (Adam J. Spooner)
|
76
86
|
- [Coffeescript Cookbook](http://coffeescriptcookbook.com) ([Various authors](http://coffeescriptcookbook.com/authors))
|
77
87
|
- [Coffeescript official documentation](http://coffeescript.org/)
|
78
88
|
- [Exploring Coffeescript](http://elegantcode.com/2011/08/09/exploring-coffeescript-part-6-show-me-the-goodies/) (ElegantCode.com)
|
79
|
-
- [
|
89
|
+
- [Jasmine Wiki](https://github.com/pivotal/jasmine/wiki/) (Pivotal Labs)
|
80
90
|
- [The Little Book on Coffeescript](http://arcturo.github.com/library/coffeescript/) (Alex MacCaw)
|
81
91
|
- [Natural Language Processing for the Working Programmer](nlpwp.org/book/) (Daniël de Kok)
|
82
92
|
- [Learn Python the Hard Way](http://learnpythonthehardway.org) (Zed A. Shaw)
|
@@ -91,7 +101,7 @@ You will find 18 example scripts in the /examples directory. Each creates a PDF
|
|
91
101
|
|
92
102
|
After you install HtmlsToPdf and its dependencies, you can write an ordinary Ruby script to save multiple ordered HTML pages as a single PDF.
|
93
103
|
|
94
|
-
### EXAMPLE 1: Single HTML page without CSS
|
104
|
+
### EXAMPLE 1: Single HTML page without CSS, with debugging
|
95
105
|
|
96
106
|
Annotated version of /examples/get\_rails\_3\_1\_release\_notes.rb:
|
97
107
|
|
@@ -106,6 +116,9 @@ Annotated version of /examples/get\_rails\_3\_1\_release\_notes.rb:
|
|
106
116
|
config = {}
|
107
117
|
config[:urls] = ['http://guides.rubyonrails.org/3_1_release_notes.html']
|
108
118
|
|
119
|
+
# enable verbose messages during PDF creation process
|
120
|
+
config[:debug] = true
|
121
|
+
|
109
122
|
# set a :savedir key with a string value indicating the directory to create
|
110
123
|
# your PDF file in. If the directory does not exist, it will be created
|
111
124
|
config[:savedir] = '~/Tech/Rails/3.1'
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'htmls_to_pdf'
|
3
|
+
|
4
|
+
# Get "addyosmani's Developing Backbone.js Applications" as pdf file
|
5
|
+
# Source: 'https://github.com/addyosmani/backbone-fundamentals/blob/master/book.md'
|
6
|
+
#
|
7
|
+
# I used only the first Github stylesheet and added the following
|
8
|
+
# at the bottom:
|
9
|
+
#
|
10
|
+
# header, .header, #header, #userbox, .title-actions-bar, .subnav, .meta, .scope, .repostats, .breadcrumb, .file-history-tease, ul.tabs, .topsearch, #footer, #footer-push {
|
11
|
+
# display: none;
|
12
|
+
# }
|
13
|
+
|
14
|
+
config = {}
|
15
|
+
config[:urls] = ['https://github.com/addyosmani/backbone-fundamentals/blob/master/book.md']
|
16
|
+
|
17
|
+
config[:savedir] = '~/Tech/Javascript/BACKBONE.JS'
|
18
|
+
config[:css] = ['https://a248.e.akamai.net/assets.github.com/stylesheets/bundles/github-e2fb92c4dcb5e5b1ce2ffd0e84d6bf80937d9197.css'] #,
|
19
|
+
#'https://a248.e.akamai.net/assets.github.com/stylesheets/bundles/github2-98a6177ed18ac7b415e311fdb34652f17ad0038c.css']
|
20
|
+
config[:savename] = 'Developing_Backbone.js_Applications.pdf'
|
21
|
+
config[:remove_css_files] = false
|
22
|
+
config[:overwrite_existing_pdf] = true
|
23
|
+
|
24
|
+
HtmlsToPdf.new(config).create_pdf
|
@@ -2,13 +2,13 @@ require 'rubygems'
|
|
2
2
|
require 'htmls_to_pdf'
|
3
3
|
|
4
4
|
# Get 'CoffeeScript_documentation' as pdf file
|
5
|
-
# Source: 'http://
|
5
|
+
# Source: 'http://coffeescript.org/'
|
6
6
|
|
7
7
|
config = {}
|
8
|
-
config[:urls] = ['http://
|
8
|
+
config[:urls] = ['http://coffeescript.org/']
|
9
9
|
config[:savedir] = '~/Tech/Javascript/COFFEESCRIPT/DOCUMENTATION'
|
10
10
|
config[:savename] = 'CoffeeScript_documentation.pdf'
|
11
|
-
config[:css] = ['http://
|
12
|
-
'http://
|
11
|
+
config[:css] = ['http://coffeescript.org/documentation/css/docs.css',
|
12
|
+
'http://coffeescript.org/documentation/css/idle.css']
|
13
13
|
|
14
14
|
HtmlsToPdf.new(config).create_pdf
|
@@ -7,18 +7,19 @@ require 'htmls_to_pdf'
|
|
7
7
|
config = {}
|
8
8
|
config[:urls] = [
|
9
9
|
'http://coffeescriptcookbook.com/',
|
10
|
-
'http://coffeescriptcookbook.com/chapters/syntax',
|
10
|
+
'http://coffeescriptcookbook.com/chapters/syntax/',
|
11
11
|
'http://coffeescriptcookbook.com/chapters/syntax/embedding_javascript',
|
12
12
|
'http://coffeescriptcookbook.com/chapters/syntax/comparing_ranges',
|
13
|
+
'http://coffeescriptcookbook.com/chapters/syntax/code_reuse_on_client_and_server',
|
13
14
|
'http://coffeescriptcookbook.com/chapters/syntax/for_loops',
|
14
|
-
'http://coffeescriptcookbook.com/chapters/classes_and_objects',
|
15
|
+
'http://coffeescriptcookbook.com/chapters/classes_and_objects/',
|
15
16
|
'http://coffeescriptcookbook.com/chapters/classes_and_objects/class-methods-and-instance-methods',
|
16
17
|
'http://coffeescriptcookbook.com/chapters/classes_and_objects/cloning',
|
17
18
|
'http://coffeescriptcookbook.com/chapters/classes_and_objects/object-literal',
|
18
19
|
'http://coffeescriptcookbook.com/chapters/classes_and_objects/type-function',
|
19
20
|
'http://coffeescriptcookbook.com/chapters/classes_and_objects/class-variables',
|
20
21
|
'http://coffeescriptcookbook.com/chapters/classes_and_objects/chaining',
|
21
|
-
'http://coffeescriptcookbook.com/chapters/strings',
|
22
|
+
'http://coffeescriptcookbook.com/chapters/strings/',
|
22
23
|
'http://coffeescriptcookbook.com/chapters/strings/repeating',
|
23
24
|
'http://coffeescriptcookbook.com/chapters/strings/lowercasing-a-string',
|
24
25
|
'http://coffeescriptcookbook.com/chapters/strings/uppercasing-a-string',
|
@@ -29,13 +30,14 @@ config[:urls] = [
|
|
29
30
|
'http://coffeescriptcookbook.com/chapters/strings/interpolation',
|
30
31
|
'http://coffeescriptcookbook.com/chapters/strings/matching-strings',
|
31
32
|
'http://coffeescriptcookbook.com/chapters/strings/generating-a-unique-id',
|
32
|
-
'http://coffeescriptcookbook.com/chapters/arrays',
|
33
|
+
'http://coffeescriptcookbook.com/chapters/arrays/',
|
33
34
|
'http://coffeescriptcookbook.com/chapters/arrays/creating-a-string-from-an-array',
|
34
35
|
'http://coffeescriptcookbook.com/chapters/arrays/zip-function',
|
35
36
|
'http://coffeescriptcookbook.com/chapters/arrays/max-array-value',
|
36
37
|
'http://coffeescriptcookbook.com/chapters/arrays/using-arrays-to-swap-variables',
|
37
38
|
'http://coffeescriptcookbook.com/chapters/arrays/define-ranges',
|
38
39
|
'http://coffeescriptcookbook.com/chapters/arrays/shuffling-array-elements',
|
40
|
+
'http://coffeescriptcookbook.com/chapters/arrays/creating-a-dictionary-object-from-an-array',
|
39
41
|
'http://coffeescriptcookbook.com/chapters/arrays/mapping-arrays',
|
40
42
|
'http://coffeescriptcookbook.com/chapters/arrays/reducing-arrays',
|
41
43
|
'http://coffeescriptcookbook.com/chapters/arrays/filtering-arrays',
|
@@ -44,13 +46,14 @@ config[:urls] = [
|
|
44
46
|
'http://coffeescriptcookbook.com/chapters/arrays/testing-every-element',
|
45
47
|
'http://coffeescriptcookbook.com/chapters/arrays/list-comprehensions',
|
46
48
|
'http://coffeescriptcookbook.com/chapters/arrays/removing-duplicate-elements-from-arrays',
|
47
|
-
'http://coffeescriptcookbook.com/chapters/dates_and_times',
|
49
|
+
'http://coffeescriptcookbook.com/chapters/dates_and_times/',
|
48
50
|
'http://coffeescriptcookbook.com/chapters/dates_and_times/date-of-easter',
|
49
51
|
'http://coffeescriptcookbook.com/chapters/dates_and_times/date-of-thanksgiving',
|
50
52
|
'http://coffeescriptcookbook.com/chapters/dates_and_times/finding-last-day-of-the-month',
|
51
53
|
'http://coffeescriptcookbook.com/chapters/dates_and_times/days-between-two-dates',
|
54
|
+
'http://coffeescriptcookbook.com/chapters/dates_and_times/moon-phase-for-date',
|
52
55
|
'http://coffeescriptcookbook.com/chapters/dates_and_times/finding-last-or-next-month',
|
53
|
-
'http://coffeescriptcookbook.com/chapters/math',
|
56
|
+
'http://coffeescriptcookbook.com/chapters/math/',
|
54
57
|
'http://coffeescriptcookbook.com/chapters/math/fast-fibonacci',
|
55
58
|
'http://coffeescriptcookbook.com/chapters/math/random-integer',
|
56
59
|
'http://coffeescriptcookbook.com/chapters/math/generating-random-numbers',
|
@@ -58,30 +61,32 @@ config[:urls] = [
|
|
58
61
|
'http://coffeescriptcookbook.com/chapters/math/generating-predictable-random-numbers',
|
59
62
|
'http://coffeescriptcookbook.com/chapters/math/fast-inv-square',
|
60
63
|
'http://coffeescriptcookbook.com/chapters/math/radians-degrees',
|
61
|
-
'http://coffeescriptcookbook.com/chapters/functions',
|
64
|
+
'http://coffeescriptcookbook.com/chapters/functions/',
|
62
65
|
'http://coffeescriptcookbook.com/chapters/functions/recursion',
|
63
66
|
'http://coffeescriptcookbook.com/chapters/functions/parentheses',
|
64
67
|
'http://coffeescriptcookbook.com/chapters/functions/splat_arguments',
|
65
|
-
'http://coffeescriptcookbook.com/chapters/metaprogramming',
|
68
|
+
'http://coffeescriptcookbook.com/chapters/metaprogramming/',
|
66
69
|
'http://coffeescriptcookbook.com/chapters/metaprogramming/detecting-and-replacing-functions',
|
67
70
|
'http://coffeescriptcookbook.com/chapters/metaprogramming/extending-built-in-objects',
|
68
|
-
'http://coffeescriptcookbook.com/chapters/jquery',
|
71
|
+
'http://coffeescriptcookbook.com/chapters/jquery/',
|
69
72
|
'http://coffeescriptcookbook.com/chapters/jquery/ajax',
|
70
73
|
'http://coffeescriptcookbook.com/chapters/jquery/plugin',
|
71
74
|
'http://coffeescriptcookbook.com/chapters/jquery/callback-bindings-jquery',
|
72
|
-
'http://coffeescriptcookbook.com/chapters/
|
75
|
+
'http://coffeescriptcookbook.com/chapters/ajax/',
|
76
|
+
'http://coffeescriptcookbook.com/chapters/ajax/ajax_request_without_jquery',
|
77
|
+
'http://coffeescriptcookbook.com/chapters/regular_expressions/',
|
73
78
|
'http://coffeescriptcookbook.com/chapters/regular_expressions/replacing-substrings',
|
74
79
|
'http://coffeescriptcookbook.com/chapters/regular_expressions/replacing-html-tags-with-html-named-entities',
|
75
80
|
'http://coffeescriptcookbook.com/chapters/regular_expressions/heregexes',
|
76
81
|
'http://coffeescriptcookbook.com/chapters/regular_expressions/searching-for-substrings',
|
77
|
-
'http://coffeescriptcookbook.com/chapters/networking',
|
82
|
+
'http://coffeescriptcookbook.com/chapters/networking/',
|
78
83
|
'http://coffeescriptcookbook.com/chapters/networking/bi-directional-server',
|
79
84
|
'http://coffeescriptcookbook.com/chapters/networking/bi-directional-client',
|
80
85
|
'http://coffeescriptcookbook.com/chapters/networking/basic-client',
|
81
86
|
'http://coffeescriptcookbook.com/chapters/networking/basic-http-client',
|
82
87
|
'http://coffeescriptcookbook.com/chapters/networking/basic-server',
|
83
88
|
'http://coffeescriptcookbook.com/chapters/networking/basic-http-server',
|
84
|
-
'http://coffeescriptcookbook.com/chapters/design_patterns',
|
89
|
+
'http://coffeescriptcookbook.com/chapters/design_patterns/',
|
85
90
|
'http://coffeescriptcookbook.com/chapters/design_patterns/builder',
|
86
91
|
'http://coffeescriptcookbook.com/chapters/design_patterns/bridge',
|
87
92
|
'http://coffeescriptcookbook.com/chapters/design_patterns/decorator',
|
@@ -91,11 +96,15 @@ config[:urls] = [
|
|
91
96
|
'http://coffeescriptcookbook.com/chapters/design_patterns/strategy',
|
92
97
|
'http://coffeescriptcookbook.com/chapters/design_patterns/memento',
|
93
98
|
'http://coffeescriptcookbook.com/chapters/design_patterns/singleton',
|
94
|
-
'http://coffeescriptcookbook.com/chapters/databases',
|
99
|
+
'http://coffeescriptcookbook.com/chapters/databases/',
|
95
100
|
'http://coffeescriptcookbook.com/chapters/databases/mongodb',
|
96
|
-
'http://coffeescriptcookbook.com/chapters/databases/sqlite'
|
101
|
+
'http://coffeescriptcookbook.com/chapters/databases/sqlite',
|
102
|
+
'http://coffeescriptcookbook.com/chapters/testing/',
|
103
|
+
'http://coffeescriptcookbook.com/chapters/testing/testing_with_jasmine']
|
97
104
|
config[:savedir] = '~/Tech/Javascript/COFFEESCRIPT/DOCUMENTATION'
|
98
105
|
config[:savename] = 'CoffeeScript_Cookbook.pdf'
|
99
106
|
config[:css] = ['http://coffeescriptcookbook.com/css/default.css']
|
107
|
+
config[:debug] = true
|
108
|
+
config[:overwrite_existing_pdf] = true
|
100
109
|
|
101
110
|
HtmlsToPdf.new(config).create_pdf
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'htmls_to_pdf'
|
3
|
+
|
4
|
+
# Get Pivotal Labs' "Jasmine Wiki" as pdf file
|
5
|
+
# Source: 'https://github.com/pivotal/jasmine/wiki/'
|
6
|
+
#
|
7
|
+
|
8
|
+
config = {}
|
9
|
+
config[:urls] = ['https://github.com/pivotal/jasmine/wiki/Background',
|
10
|
+
'https://github.com/pivotal/jasmine/wiki/Suites-and-specs',
|
11
|
+
'https://github.com/pivotal/jasmine/wiki/Matchers',
|
12
|
+
'https://github.com/pivotal/jasmine/wiki/Before-and-After',
|
13
|
+
'https://github.com/pivotal/jasmine/wiki/Spies',
|
14
|
+
'https://github.com/pivotal/jasmine/wiki/Asynchronous-specs',
|
15
|
+
'https://github.com/pivotal/jasmine/wiki/A-simple-project',
|
16
|
+
'https://github.com/pivotal/jasmine/wiki/A-ruby-project-%28with-or-without-rails%29',
|
17
|
+
'https://github.com/pivotal/jasmine/wiki/Spider-monkey',
|
18
|
+
'http://pivotal.github.com/jasmine/jsdoc/symbols/jasmine.html',
|
19
|
+
'http://pivotal.github.com/jasmine/jsdoc/symbols/jasmine.Spy.html',
|
20
|
+
'http://pivotal.github.com/jasmine/jsdoc/symbols/src/src_core_base.js.html',
|
21
|
+
'http://pivotal.github.com/jasmine/jsdoc/symbols/jasmine.Block.html',
|
22
|
+
'http://pivotal.github.com/jasmine/jsdoc/symbols/src/src_core_Block.js.html',
|
23
|
+
'http://pivotal.github.com/jasmine/jsdoc/symbols/jasmine.Clock.html',
|
24
|
+
'http://pivotal.github.com/jasmine/jsdoc/symbols/src/src_core_mock-timeout.js.html',
|
25
|
+
'http://pivotal.github.com/jasmine/jsdoc/symbols/jasmine.Env.html',
|
26
|
+
'http://pivotal.github.com/jasmine/jsdoc/symbols/src/src_core_Env.js.html',
|
27
|
+
'http://pivotal.github.com/jasmine/jsdoc/symbols/jasmine.JsApiReporter.html',
|
28
|
+
'http://pivotal.github.com/jasmine/jsdoc/symbols/src/src_core_JsApiReporter.js.html',
|
29
|
+
'http://pivotal.github.com/jasmine/jsdoc/symbols/jasmine.Matchers.html',
|
30
|
+
'http://pivotal.github.com/jasmine/jsdoc/symbols/src/src_core_Matchers.js.html',
|
31
|
+
'http://pivotal.github.com/jasmine/jsdoc/symbols/jasmine.NestedResults.html',
|
32
|
+
'http://pivotal.github.com/jasmine/jsdoc/symbols/src/src_core_NestedResults.js.html',
|
33
|
+
'http://pivotal.github.com/jasmine/jsdoc/symbols/src/src_core_PrettyPrinter.js.html',
|
34
|
+
'http://pivotal.github.com/jasmine/jsdoc/symbols/jasmine.Reporter.html',
|
35
|
+
'http://pivotal.github.com/jasmine/jsdoc/symbols/jasmine.MultiReporter.html',
|
36
|
+
'http://pivotal.github.com/jasmine/jsdoc/symbols/src/src_html_TrivialReporter.js.html',
|
37
|
+
'http://pivotal.github.com/jasmine/jsdoc/symbols/src/src_core_Reporter.js.html',
|
38
|
+
'http://pivotal.github.com/jasmine/jsdoc/symbols/src/src_core_MultiReporter.js.html',
|
39
|
+
'http://pivotal.github.com/jasmine/jsdoc/symbols/jasmine.Runner.html',
|
40
|
+
'http://pivotal.github.com/jasmine/jsdoc/symbols/src/src_core_Runner.js.html',
|
41
|
+
'http://pivotal.github.com/jasmine/jsdoc/symbols/src/src_core_Queue.js.html',
|
42
|
+
'http://pivotal.github.com/jasmine/jsdoc/symbols/jasmine.Spec.html',
|
43
|
+
'http://pivotal.github.com/jasmine/jsdoc/symbols/src/src_core_Spec.js.html',
|
44
|
+
'http://pivotal.github.com/jasmine/jsdoc/symbols/jasmine.Suite.html',
|
45
|
+
'http://pivotal.github.com/jasmine/jsdoc/symbols/src/src_core_Suite.js.html',
|
46
|
+
'http://pivotal.github.com/jasmine/jsdoc/symbols/jasmine.util.html',
|
47
|
+
'http://pivotal.github.com/jasmine/jsdoc/symbols/src/src_core_util.js.html',
|
48
|
+
'http://pivotal.github.com/jasmine/jsdoc/symbols/jasmine.WaitsForBlock.html',
|
49
|
+
'http://pivotal.github.com/jasmine/jsdoc/symbols/src/src_core_WaitsBlock.js.html',
|
50
|
+
'http://pivotal.github.com/jasmine/jsdoc/symbols/src/src_core_WaitsForBlock.js.html']
|
51
|
+
|
52
|
+
config[:savedir] = '~/Tech/Javascript/JASMINE'
|
53
|
+
#config[:css] = ['https://a248.e.akamai.net/assets.github.com/assets/github-d32e243bf8eb8ccb9713860d2989f567c74780f5.css',
|
54
|
+
# 'https://a248.e.akamai.net/assets.github.com/assets/github2-9618739f589609d8af1547d00def64a14f3f4410.css']
|
55
|
+
config[:css] = 'div#header{display:none;} ul.tabs{display:none;} div#logo-popup{display:none;} div#footer{display:none;} div#markdown-help{display:none;} div.pagehead{display:none;} ul.wiki-actions{display:none;} div#keyboard_shortcuts_pane{display:none;} div.js-hidden-pane{display:none;} div#ajax-error-message{display:none;}'
|
56
|
+
config[:savename] = 'Jasmine_wiki.pdf'
|
57
|
+
config[:remove_css_files] = true
|
58
|
+
config[:remove_html_files] = false
|
59
|
+
config[:overwrite_existing_pdf] = true
|
60
|
+
|
61
|
+
HtmlsToPdf.new(config).create_pdf
|
data/examples/get_ror_guides.rb
CHANGED
@@ -41,8 +41,12 @@ config[:urls] = [
|
|
41
41
|
]
|
42
42
|
config[:savedir] = '~/Tech/Rails/RAILS_GUIDES'
|
43
43
|
config[:savename] = 'Ruby_on_Rails_Guides.pdf'
|
44
|
-
config[:css] = [
|
45
|
-
'http://guides.rubyonrails.org/stylesheets/print.css'
|
44
|
+
config[:css] = ['http://guides.rubyonrails.org/stylesheets/style.css',
|
45
|
+
'http://guides.rubyonrails.org/stylesheets/print.css',
|
46
|
+
'http://guides.rubyonrails.org/stylesheets/syntaxhighlighter/shCore.css',
|
47
|
+
'http://guides.rubyonrails.org/stylesheets/syntaxhighlighter/shThemeRailsGuides.css',
|
48
|
+
'http://guides.rubyonrails.org/stylesheets/fixes.css']
|
46
49
|
config[:remove_temp_files] = true
|
50
|
+
config[:overwrite_existing_pdf] = true
|
47
51
|
|
48
52
|
HtmlsToPdf.new(config).create_pdf
|
data/examples/get_rspec.rb
CHANGED
@@ -7,109 +7,111 @@ require 'htmls_to_pdf'
|
|
7
7
|
config = {}
|
8
8
|
config[:urls] = [
|
9
9
|
'https://www.relishapp.com/rspec/rspec-core/docs',
|
10
|
-
'https://www.relishapp.com/rspec/rspec-core/v/2-
|
11
|
-
'https://www.relishapp.com/rspec/rspec-core/v/2-
|
12
|
-
'https://www.relishapp.com/rspec/rspec-core/v/2-
|
13
|
-
'https://www.relishapp.com/rspec/rspec-core/v/2-
|
14
|
-
'https://www.relishapp.com/rspec/rspec-core/v/2-
|
15
|
-
'https://www.relishapp.com/rspec/rspec-core/v/2-
|
16
|
-
'https://www.relishapp.com/rspec/rspec-core/v/2-
|
17
|
-
'https://www.relishapp.com/rspec/rspec-core/v/2-
|
18
|
-
'https://www.relishapp.com/rspec/rspec-core/v/2-
|
19
|
-
'https://www.relishapp.com/rspec/rspec-core/v/2-
|
20
|
-
'https://www.relishapp.com/rspec/rspec-core/v/2-
|
21
|
-
'https://www.relishapp.com/rspec/rspec-core/v/2-
|
22
|
-
'https://www.relishapp.com/rspec/rspec-core/v/2-
|
23
|
-
'https://www.relishapp.com/rspec/rspec-core/v/2-
|
24
|
-
'https://www.relishapp.com/rspec/rspec-core/v/2-
|
25
|
-
'https://www.relishapp.com/rspec/rspec-core/v/2-
|
26
|
-
'https://www.relishapp.com/rspec/rspec-core/v/2-
|
27
|
-
'https://www.relishapp.com/rspec/rspec-core/v/2-
|
28
|
-
'https://www.relishapp.com/rspec/rspec-core/v/2-
|
29
|
-
'https://www.relishapp.com/rspec/rspec-core/v/2-
|
30
|
-
'https://www.relishapp.com/rspec/rspec-core/v/2-
|
31
|
-
'https://www.relishapp.com/rspec/rspec-core/v/2-
|
32
|
-
'https://www.relishapp.com/rspec/rspec-core/v/2-
|
33
|
-
'https://www.relishapp.com/rspec/rspec-core/v/2-
|
34
|
-
'https://www.relishapp.com/rspec/rspec-core/v/2-
|
35
|
-
'https://www.relishapp.com/rspec/rspec-core/v/2-
|
36
|
-
'https://www.relishapp.com/rspec/rspec-core/v/2-
|
37
|
-
'https://www.relishapp.com/rspec/rspec-core/v/2-
|
38
|
-
'https://www.relishapp.com/rspec/rspec-core/v/2-
|
39
|
-
'https://www.relishapp.com/rspec/rspec-core/v/2-
|
40
|
-
'https://www.relishapp.com/rspec/rspec-core/v/2-
|
41
|
-
'https://www.relishapp.com/rspec/rspec-core/v/2-
|
42
|
-
'https://www.relishapp.com/rspec/rspec-core/v/2-
|
43
|
-
'https://www.relishapp.com/rspec/rspec-core/v/2-
|
44
|
-
'https://www.relishapp.com/rspec/rspec-core/v/2-
|
45
|
-
'https://www.relishapp.com/rspec/rspec-core/v/2-
|
46
|
-
'https://www.relishapp.com/rspec/rspec-core/v/2-
|
47
|
-
'https://www.relishapp.com/rspec/rspec-core/v/2-
|
48
|
-
'https://www.relishapp.com/rspec/rspec-core/v/2-
|
49
|
-
'https://www.relishapp.com/rspec/rspec-core/v/2-
|
50
|
-
'https://www.relishapp.com/rspec/rspec-core/v/2-
|
51
|
-
'https://www.relishapp.com/rspec/rspec-core/v/2-
|
52
|
-
'https://www.relishapp.com/rspec/rspec-core/v/2-
|
53
|
-
'https://www.relishapp.com/rspec/rspec-core/v/2-
|
54
|
-
'https://www.relishapp.com/rspec/rspec-core/v/2-
|
55
|
-
'https://www.relishapp.com/rspec/rspec-core/v/2-
|
56
|
-
'https://www.relishapp.com/rspec/rspec-core/v/2-
|
57
|
-
'https://www.relishapp.com/rspec/rspec-core/v/2-
|
58
|
-
'https://www.relishapp.com/rspec/rspec-core/v/2-
|
10
|
+
'https://www.relishapp.com/rspec/rspec-core/v/2-11/docs/upgrade',
|
11
|
+
'https://www.relishapp.com/rspec/rspec-core/v/2-11/docs/autotest',
|
12
|
+
'https://www.relishapp.com/rspec/rspec-core/v/2-11/docs/example-groups',
|
13
|
+
'https://www.relishapp.com/rspec/rspec-core/v/2-11/docs/example-groups/basic-structure-describe-it',
|
14
|
+
'https://www.relishapp.com/rspec/rspec-core/v/2-11/docs/example-groups/shared-examples',
|
15
|
+
'https://www.relishapp.com/rspec/rspec-core/v/2-11/docs/example-groups/shared-context',
|
16
|
+
'https://www.relishapp.com/rspec/rspec-core/v/2-11/docs/command-line',
|
17
|
+
'https://www.relishapp.com/rspec/rspec-core/v/2-11/docs/command-line/example-option',
|
18
|
+
'https://www.relishapp.com/rspec/rspec-core/v/2-11/docs/command-line/format-option',
|
19
|
+
'https://www.relishapp.com/rspec/rspec-core/v/2-11/docs/command-line/line-number-option',
|
20
|
+
'https://www.relishapp.com/rspec/rspec-core/v/2-11/docs/command-line/tag-option',
|
21
|
+
'https://www.relishapp.com/rspec/rspec-core/v/2-11/docs/command-line/line-number-appended-to-file-path',
|
22
|
+
'https://www.relishapp.com/rspec/rspec-core/v/2-11/docs/command-line/exit-status',
|
23
|
+
'https://www.relishapp.com/rspec/rspec-core/v/2-11/docs/command-line/rake-task',
|
24
|
+
'https://www.relishapp.com/rspec/rspec-core/v/2-11/docs/command-line/init-option',
|
25
|
+
'https://www.relishapp.com/rspec/rspec-core/v/2-11/docs/command-line/order-new-in-rspec-core-2-8',
|
26
|
+
'https://www.relishapp.com/rspec/rspec-core/v/2-11/docs/command-line/pattern-option',
|
27
|
+
'https://www.relishapp.com/rspec/rspec-core/v/2-11/docs/command-line/run-with-ruby-command',
|
28
|
+
'https://www.relishapp.com/rspec/rspec-core/v/2-11/docs/pending/pending-examples',
|
29
|
+
'https://www.relishapp.com/rspec/rspec-core/v/2-11/docs/hooks/before-and-after-hooks',
|
30
|
+
'https://www.relishapp.com/rspec/rspec-core/v/2-11/docs/hooks/around-hooks',
|
31
|
+
'https://www.relishapp.com/rspec/rspec-core/v/2-11/docs/hooks/filters',
|
32
|
+
'https://www.relishapp.com/rspec/rspec-core/v/2-11/docs/subject/implicitly-defined-subject',
|
33
|
+
'https://www.relishapp.com/rspec/rspec-core/v/2-11/docs/subject/explicit-subject',
|
34
|
+
'https://www.relishapp.com/rspec/rspec-core/v/2-11/docs/subject/attribute-of-subject',
|
35
|
+
'https://www.relishapp.com/rspec/rspec-core/v/2-11/docs/subject/implicit-receiver',
|
36
|
+
'https://www.relishapp.com/rspec/rspec-core/v/2-11/docs/helper-methods/let-and-let',
|
37
|
+
'https://www.relishapp.com/rspec/rspec-core/v/2-11/docs/helper-methods/arbitrary-helper-methods',
|
38
|
+
'https://www.relishapp.com/rspec/rspec-core/v/2-11/docs/helper-methods/define-helper-methods-in-a-module',
|
39
|
+
'https://www.relishapp.com/rspec/rspec-core/v/2-11/docs/metadata/current-example',
|
40
|
+
'https://www.relishapp.com/rspec/rspec-core/v/2-11/docs/metadata/described-class',
|
41
|
+
'https://www.relishapp.com/rspec/rspec-core/v/2-11/docs/metadata/user-defined-metadata',
|
42
|
+
'https://www.relishapp.com/rspec/rspec-core/v/2-11/docs/filtering/inclusion-filters',
|
43
|
+
'https://www.relishapp.com/rspec/rspec-core/v/2-11/docs/filtering/exclusion-filters',
|
44
|
+
'https://www.relishapp.com/rspec/rspec-core/v/2-11/docs/filtering/if-and-unless',
|
45
|
+
'https://www.relishapp.com/rspec/rspec-core/v/2-11/docs/filtering/run-all-when-everything-filtered',
|
46
|
+
'https://www.relishapp.com/rspec/rspec-core/v/2-11/docs/configuration/read-command-line-configuration-options-from-files',
|
47
|
+
'https://www.relishapp.com/rspec/rspec-core/v/2-11/docs/configuration/fail-fast',
|
48
|
+
'https://www.relishapp.com/rspec/rspec-core/v/2-11/docs/configuration/custom-settings',
|
49
|
+
'https://www.relishapp.com/rspec/rspec-core/v/2-11/docs/configuration/alias-example-to',
|
50
|
+
'https://www.relishapp.com/rspec/rspec-core/v/2-11/docs/configuration/default-path',
|
51
|
+
'https://www.relishapp.com/rspec/rspec-core/v/2-11/docs/expectation-framework-integration/configure-expectation-framework',
|
52
|
+
'https://www.relishapp.com/rspec/rspec-core/v/2-11/docs/mock-framework-integration/mock-with-rspec',
|
53
|
+
'https://www.relishapp.com/rspec/rspec-core/v/2-11/docs/mock-framework-integration/mock-with-flexmock',
|
54
|
+
'https://www.relishapp.com/rspec/rspec-core/v/2-11/docs/mock-framework-integration/mock-with-mocha',
|
55
|
+
'https://www.relishapp.com/rspec/rspec-core/v/2-11/docs/mock-framework-integration/mock-with-rr',
|
56
|
+
'https://www.relishapp.com/rspec/rspec-core/v/2-11/docs/mock-framework-integration/mock-with-an-alternative-framework',
|
57
|
+
'https://www.relishapp.com/rspec/rspec-core/v/2-11/docs/formatters/custom-formatters',
|
58
|
+
'https://www.relishapp.com/rspec/rspec-core/v/2-11/docs/formatters/text-formatter',
|
59
|
+
'https://www.relishapp.com/rspec/rspec-core/v/2-11/docs/spec-files/arbitrary-file-suffix',
|
59
60
|
'https://www.relishapp.com/rspec/rspec-expectations/docs',
|
60
|
-
'https://www.relishapp.com/rspec/rspec-expectations/v/2-
|
61
|
-
'https://www.relishapp.com/rspec/rspec-expectations/v/2-
|
62
|
-
'https://www.relishapp.com/rspec/rspec-expectations/v/2-
|
63
|
-
'https://www.relishapp.com/rspec/rspec-expectations/v/2-
|
64
|
-
'https://www.relishapp.com/rspec/rspec-expectations/v/2-
|
65
|
-
'https://www.relishapp.com/rspec/rspec-expectations/v/2-
|
66
|
-
'https://www.relishapp.com/rspec/rspec-expectations/v/2-
|
67
|
-
'https://www.relishapp.com/rspec/rspec-expectations/v/2-
|
68
|
-
'https://www.relishapp.com/rspec/rspec-expectations/v/2-
|
69
|
-
'https://www.relishapp.com/rspec/rspec-expectations/v/2-
|
70
|
-
'https://www.relishapp.com/rspec/rspec-expectations/v/2-
|
71
|
-
'https://www.relishapp.com/rspec/rspec-expectations/v/2-
|
72
|
-
'https://www.relishapp.com/rspec/rspec-expectations/v/2-
|
73
|
-
'https://www.relishapp.com/rspec/rspec-expectations/v/2-
|
74
|
-
'https://www.relishapp.com/rspec/rspec-expectations/v/2-
|
75
|
-
'https://www.relishapp.com/rspec/rspec-expectations/v/2-
|
76
|
-
'https://www.relishapp.com/rspec/rspec-expectations/v/2-
|
77
|
-
'https://www.relishapp.com/rspec/rspec-expectations/v/2-
|
78
|
-
'https://www.relishapp.com/rspec/rspec-expectations/v/2-
|
79
|
-
'https://www.relishapp.com/rspec/rspec-expectations/v/2-
|
80
|
-
'https://www.relishapp.com/rspec/rspec-expectations/v/2-
|
81
|
-
'https://www.relishapp.com/rspec/rspec-expectations/v/2-
|
82
|
-
'https://www.relishapp.com/rspec/rspec-expectations/v/2-
|
83
|
-
'https://www.relishapp.com/rspec/rspec-expectations/v/2-
|
84
|
-
'https://www.relishapp.com/rspec/rspec-expectations/v/2-
|
85
|
-
'https://www.relishapp.com/rspec/rspec-expectations/v/2-
|
86
|
-
'https://www.relishapp.com/rspec/rspec-expectations/v/2-
|
61
|
+
'https://www.relishapp.com/rspec/rspec-expectations/v/2-11/docs/customized-message',
|
62
|
+
'https://www.relishapp.com/rspec/rspec-expectations/v/2-11/docs/diffing',
|
63
|
+
'https://www.relishapp.com/rspec/rspec-expectations/v/2-11/docs/implicit-docstrings',
|
64
|
+
'https://www.relishapp.com/rspec/rspec-expectations/v/2-11/docs/built-in-matchers',
|
65
|
+
'https://www.relishapp.com/rspec/rspec-expectations/v/2-11/docs/built-in-matchers/be-matchers',
|
66
|
+
'https://www.relishapp.com/rspec/rspec-expectations/v/2-11/docs/built-in-matchers/be-within-matcher',
|
67
|
+
'https://www.relishapp.com/rspec/rspec-expectations/v/2-11/docs/built-in-matchers/equality-matchers',
|
68
|
+
'https://www.relishapp.com/rspec/rspec-expectations/v/2-11/docs/built-in-matchers/exist-matcher',
|
69
|
+
'https://www.relishapp.com/rspec/rspec-expectations/v/2-11/docs/built-in-matchers/expect-change',
|
70
|
+
'https://www.relishapp.com/rspec/rspec-expectations/v/2-11/docs/built-in-matchers/raise-error-matcher',
|
71
|
+
'https://www.relishapp.com/rspec/rspec-expectations/v/2-11/docs/built-in-matchers/have-n-items-matcher',
|
72
|
+
'https://www.relishapp.com/rspec/rspec-expectations/v/2-11/docs/built-in-matchers/include-matcher',
|
73
|
+
'https://www.relishapp.com/rspec/rspec-expectations/v/2-11/docs/built-in-matchers/match-matcher',
|
74
|
+
'https://www.relishapp.com/rspec/rspec-expectations/v/2-11/docs/built-in-matchers/operator-matchers',
|
75
|
+
'https://www.relishapp.com/rspec/rspec-expectations/v/2-11/docs/built-in-matchers/predicate-matchers',
|
76
|
+
'https://www.relishapp.com/rspec/rspec-expectations/v/2-11/docs/built-in-matchers/respond-to-matcher',
|
77
|
+
'https://www.relishapp.com/rspec/rspec-expectations/v/2-11/docs/built-in-matchers/satisfy-matcher',
|
78
|
+
'https://www.relishapp.com/rspec/rspec-expectations/v/2-11/docs/built-in-matchers/throw-symbol-matcher',
|
79
|
+
'https://www.relishapp.com/rspec/rspec-expectations/v/2-11/docs/built-in-matchers/specify-types-of-objects',
|
80
|
+
'https://www.relishapp.com/rspec/rspec-expectations/v/2-11/docs/built-in-matchers/cover-matcher',
|
81
|
+
'https://www.relishapp.com/rspec/rspec-expectations/v/2-11/docs/custom-matchers',
|
82
|
+
'https://www.relishapp.com/rspec/rspec-expectations/v/2-11/docs/custom-matchers/define-matcher',
|
83
|
+
'https://www.relishapp.com/rspec/rspec-expectations/v/2-11/docs/custom-matchers/define-diffable-matcher',
|
84
|
+
'https://www.relishapp.com/rspec/rspec-expectations/v/2-11/docs/custom-matchers/define-matcher-with-fluent-interface',
|
85
|
+
'https://www.relishapp.com/rspec/rspec-expectations/v/2-11/docs/custom-matchers/access-running-example',
|
86
|
+
'https://www.relishapp.com/rspec/rspec-expectations/v/2-11/docs/custom-matchers/define-matcher-outside-rspec',
|
87
|
+
'https://www.relishapp.com/rspec/rspec-expectations/v/2-11/docs/test-frameworks/test-unit-integration',
|
87
88
|
'https://www.relishapp.com/rspec/rspec-mocks/docs',
|
88
|
-
'https://www.relishapp.com/rspec/rspec-mocks/v/2-
|
89
|
-
'https://www.relishapp.com/rspec/rspec-mocks/v/2-
|
90
|
-
'https://www.relishapp.com/rspec/rspec-mocks/v/2-
|
91
|
-
'https://www.relishapp.com/rspec/rspec-mocks/v/2-
|
92
|
-
'https://www.relishapp.com/rspec/rspec-mocks/v/2-
|
93
|
-
'https://www.relishapp.com/rspec/rspec-mocks/v/2-
|
94
|
-
'https://www.relishapp.com/rspec/rspec-mocks/v/2-
|
95
|
-
'https://www.relishapp.com/rspec/rspec-mocks/v/2-
|
96
|
-
'https://www.relishapp.com/rspec/rspec-mocks/v/2-
|
97
|
-
'https://www.relishapp.com/rspec/rspec-mocks/v/2-
|
98
|
-
'https://www.relishapp.com/rspec/rspec-mocks/v/2-
|
99
|
-
'https://www.relishapp.com/rspec/rspec-mocks/v/2-
|
100
|
-
'https://www.relishapp.com/rspec/rspec-mocks/v/2-
|
101
|
-
'https://www.relishapp.com/rspec/rspec-mocks/v/2-
|
102
|
-
'https://www.relishapp.com/rspec/rspec-mocks/v/2-
|
103
|
-
'https://www.relishapp.com/rspec/rspec-mocks/v/2-
|
104
|
-
'https://www.relishapp.com/rspec/rspec-mocks/v/2-
|
105
|
-
'https://www.relishapp.com/rspec/rspec-mocks/v/2-
|
89
|
+
'https://www.relishapp.com/rspec/rspec-mocks/v/2-11/docs/method-stubs',
|
90
|
+
'https://www.relishapp.com/rspec/rspec-mocks/v/2-11/docs/method-stubs/stub-with-a-simple-return-value',
|
91
|
+
'https://www.relishapp.com/rspec/rspec-mocks/v/2-11/docs/method-stubs/stub-with-substitute-implementation',
|
92
|
+
'https://www.relishapp.com/rspec/rspec-mocks/v/2-11/docs/method-stubs/stub-a-chain-of-methods',
|
93
|
+
'https://www.relishapp.com/rspec/rspec-mocks/v/2-11/docs/method-stubs/stub-on-any-instance-of-a-class',
|
94
|
+
'https://www.relishapp.com/rspec/rspec-mocks/v/2-11/docs/method-stubs/as-null-object',
|
95
|
+
'https://www.relishapp.com/rspec/rspec-mocks/v/2-11/docs/method-stubs/double-handling-to-ary',
|
96
|
+
'https://www.relishapp.com/rspec/rspec-mocks/v/2-11/docs/message-expectations',
|
97
|
+
'https://www.relishapp.com/rspec/rspec-mocks/v/2-11/docs/message-expectations/expect-a-message',
|
98
|
+
'https://www.relishapp.com/rspec/rspec-mocks/v/2-11/docs/message-expectations/expect-a-message-on-any-instance-of-a-class',
|
99
|
+
'https://www.relishapp.com/rspec/rspec-mocks/v/2-11/docs/message-expectations/warn-when-expectation-is-set-on-nil',
|
100
|
+
'https://www.relishapp.com/rspec/rspec-mocks/v/2-11/docs/message-expectations/receive-counts',
|
101
|
+
'https://www.relishapp.com/rspec/rspec-mocks/v/2-11/docs/argument-matchers',
|
102
|
+
'https://www.relishapp.com/rspec/rspec-mocks/v/2-11/docs/argument-matchers/explicit-arguments',
|
103
|
+
'https://www.relishapp.com/rspec/rspec-mocks/v/2-11/docs/argument-matchers/general-matchers',
|
104
|
+
'https://www.relishapp.com/rspec/rspec-mocks/v/2-11/docs/argument-matchers/stub-with-argument-constraints',
|
105
|
+
'https://www.relishapp.com/rspec/rspec-mocks/v/2-11/docs/outside-rspec/configure-any-test-framework-to-use-rspec-mocks',
|
106
|
+
'https://www.relishapp.com/rspec/rspec-mocks/v/2-11/docs/outside-rspec/standalone'
|
106
107
|
]
|
107
108
|
config[:savedir] = '~/Tech/Ruby/TESTING/RSPEC'
|
108
109
|
config[:savename] = 'RSpec_documentation.pdf'
|
109
110
|
config[:css] = [
|
110
|
-
'https://www.relishapp.com/stylesheets/global.css',
|
111
|
+
#'https://www.relishapp.com/stylesheets/global.css',
|
111
112
|
#'https://www.relishapp.com/stylesheets/application.css',
|
112
113
|
'https://www.relishapp.com/stylesheets/print.css']
|
113
114
|
config[:remove_temp_files] = true
|
115
|
+
config[:debug] = true
|
114
116
|
|
115
117
|
HtmlsToPdf.new(config).create_pdf
|
@@ -4,42 +4,44 @@ require 'pdfkit'
|
|
4
4
|
require 'uri'
|
5
5
|
#include URI
|
6
6
|
require 'net/http'
|
7
|
+
require 'net/https'
|
7
8
|
|
9
|
+
# HtmlsToPdf.new takes a configuration hash and returns an object with a create_pdf() method
|
10
|
+
# Calling create_pdf() on the HtmlsToPdf object generates a PDF file configured according to
|
11
|
+
# the configuration hash settings
|
12
|
+
#
|
13
|
+
# Usage:
|
14
|
+
# HtmlsToPdf.new(options_hash).create_pdf
|
8
15
|
class HtmlsToPdf
|
9
16
|
|
10
|
-
|
17
|
+
attr_accessor :debug, :htmlarray, :pdfarray, :cssarray, :urls, :savedir, :savename, :remove_temp_files, :remove_html_files, :remove_css_files, :remove_tmp_pdf_files, :options, :overwrite_existing_pdf
|
11
18
|
|
12
19
|
TMP_HTML_PREFIX = 'tmp_html_file_'
|
13
20
|
TMP_PDF_PREFIX = 'tmp_pdf_file_'
|
14
21
|
|
15
|
-
def initialize(
|
16
|
-
|
17
|
-
:
|
18
|
-
:
|
19
|
-
:
|
20
|
-
:
|
21
|
-
:
|
22
|
-
:
|
23
|
-
:
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
22
|
+
def initialize(config = {})
|
23
|
+
defaults = {
|
24
|
+
remove_css_files: true,
|
25
|
+
remove_html_files: true,
|
26
|
+
remove_tmp_pdf_files: true,
|
27
|
+
overwrite_existing_pdf: false,
|
28
|
+
savedir: "~",
|
29
|
+
savename: 'htmls_to_pdf.pdf',
|
30
|
+
debug: false
|
31
|
+
}
|
32
|
+
config = defaults.merge!(config)
|
33
|
+
|
34
|
+
set_instance_vars(config)
|
35
|
+
|
36
|
+
set_dir(@savedir)
|
37
|
+
|
29
38
|
exit_if_pdf_exists unless @overwrite_existing_pdf
|
30
|
-
@urls = clean_urls(config[:urls])
|
31
|
-
@pdfarray = create_pdfarray
|
32
|
-
@cssarray = config[:css].kind_of?(Array) ? config[:css] : Array[ config[:css] ]
|
33
|
-
@remove_css_files = config[:remove_css_files]
|
34
|
-
@remove_html_files = config[:remove_html_files]
|
35
|
-
@remove_tmp_pdf_files = config[:remove_tmp_pdf_files]
|
36
|
-
@remove_css_files = @remove_html_files = @remove_tmp_pdf_files = true if in_config[:remove_temp_files]
|
37
|
-
@options = config[:options]
|
38
39
|
end
|
39
40
|
|
40
41
|
def create_pdf
|
41
42
|
clean_temp_files
|
42
|
-
|
43
|
+
get_temp_files
|
44
|
+
# update_asset_urls
|
43
45
|
generate_pdfs
|
44
46
|
join_pdfs
|
45
47
|
clean_temp_files
|
@@ -47,6 +49,21 @@ class HtmlsToPdf
|
|
47
49
|
|
48
50
|
private
|
49
51
|
|
52
|
+
def set_instance_vars(config)
|
53
|
+
@savedir = File.expand_path(config[:savedir])
|
54
|
+
@savename = config[:savename]
|
55
|
+
@overwrite_existing_pdf = config[:overwrite_existing_pdf]
|
56
|
+
@urls = clean_urls(config[:urls])
|
57
|
+
@pdfarray = create_pdfarray
|
58
|
+
@cssarray = Array(config[:css])
|
59
|
+
@remove_css_files = config[:remove_css_files]
|
60
|
+
@remove_html_files = config[:remove_html_files]
|
61
|
+
@remove_tmp_pdf_files = config[:remove_tmp_pdf_files]
|
62
|
+
@remove_css_files = @remove_html_files = @remove_tmp_pdf_files = true if config[:remove_temp_files]
|
63
|
+
@debug = config[:debug]
|
64
|
+
@options = config[:options] || {}
|
65
|
+
end
|
66
|
+
|
50
67
|
def clean_temp_files
|
51
68
|
delete_html_files if @remove_html_files
|
52
69
|
delete_css_files if @remove_css_files
|
@@ -78,6 +95,16 @@ class HtmlsToPdf
|
|
78
95
|
urls.map { |url| url.match(/\.s?html?$/) ? url : url + '.html' }
|
79
96
|
end
|
80
97
|
|
98
|
+
def update_asset_urls
|
99
|
+
img_urls = []
|
100
|
+
html_array.each do |html_file|
|
101
|
+
File.open(html_file) do |f|
|
102
|
+
img_urls
|
103
|
+
end
|
104
|
+
end
|
105
|
+
exit
|
106
|
+
end
|
107
|
+
|
81
108
|
def create_pdfarray
|
82
109
|
outarray = []
|
83
110
|
(0...@urls.length).each do |idx|
|
@@ -87,63 +114,109 @@ class HtmlsToPdf
|
|
87
114
|
end
|
88
115
|
|
89
116
|
def exit_if_pdf_exists
|
90
|
-
if File.exists?(
|
91
|
-
|
117
|
+
if File.exists?(savename)
|
118
|
+
message = "File #{savename} already exists in #{savedir}. Please rename or delete and re-run this program."
|
119
|
+
puts message
|
92
120
|
exit
|
93
121
|
end
|
94
122
|
end
|
95
123
|
|
96
124
|
def set_dir(savedir)
|
97
|
-
|
98
|
-
|
99
|
-
FileUtils.mkdir_p(save_to)
|
100
|
-
Dir.chdir(save_to)
|
125
|
+
FileUtils.mkdir_p(savedir)
|
126
|
+
Dir.chdir(savedir)
|
101
127
|
end
|
102
128
|
|
103
129
|
#def add_css(css_file)
|
104
130
|
# @cssarray << css_file
|
105
131
|
#end
|
106
132
|
|
107
|
-
def
|
108
|
-
|
109
|
-
|
133
|
+
def get_temp_files
|
134
|
+
get_html_files
|
135
|
+
get_css_files
|
110
136
|
end
|
111
137
|
|
112
|
-
def
|
138
|
+
def get_http_https(url)
|
113
139
|
uri = URI.parse(url)
|
114
|
-
|
115
|
-
|
140
|
+
if /^https:\/\//.match(url)
|
141
|
+
https = Net::HTTP.new(uri.host, uri.port)
|
142
|
+
https.use_ssl = true
|
143
|
+
https.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
144
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
145
|
+
puts "Downloading #{url}" if debug
|
146
|
+
response = https.request(request)
|
147
|
+
return response.body
|
148
|
+
elsif /^http:\/\//.match(url)
|
149
|
+
puts "Downloading #{url}" if debug
|
150
|
+
return Net::HTTP.get_response(uri).body
|
151
|
+
else
|
152
|
+
raise "Cannot parse URI: #{uri}"
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
def save_url_to_filename(url, filename)
|
157
|
+
file_content = get_http_https(url)
|
158
|
+
puts "Saving #{url} to #{filename}" if debug
|
159
|
+
File.open(filename, 'w') { |f| f.write(file_content) }
|
160
|
+
end
|
161
|
+
|
162
|
+
def save_string_to_filename(string, filename)
|
163
|
+
puts "Saving to #{filename}" if debug
|
164
|
+
File.open(filename, 'w') { |f| f.write(string) }
|
116
165
|
end
|
117
166
|
|
118
|
-
def
|
167
|
+
def get_html_files
|
119
168
|
existing_files = Dir.entries(".")
|
120
169
|
@htmlarray = []
|
121
170
|
@urls.each_with_index do |url,idx|
|
122
|
-
|
123
|
-
unless existing_files.include?(
|
124
|
-
|
125
|
-
|
171
|
+
filename = TMP_HTML_PREFIX + idx.to_s
|
172
|
+
unless existing_files.include?(filename)
|
173
|
+
puts "Saving #{url} to #{filename}" if debug
|
174
|
+
save_url_to_filename(url, filename)
|
175
|
+
#`wget #{url} -O #{filename}`
|
126
176
|
end
|
127
|
-
@htmlarray <<
|
177
|
+
@htmlarray << filename
|
128
178
|
end
|
129
179
|
end
|
130
180
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
181
|
+
# accepts css files as URLs or as text strings
|
182
|
+
def process_css_input(css_input)
|
183
|
+
begin
|
184
|
+
URI::regexp.match(css_input)
|
185
|
+
process_css_url(css_input)
|
186
|
+
rescue URI::InvalidURIError
|
187
|
+
process_css_string(css_input)
|
138
188
|
end
|
139
189
|
end
|
140
190
|
|
191
|
+
def process_css_url(css_url)
|
192
|
+
filename = File.basename(css_url)
|
193
|
+
existing_files = Dir.entries(".")
|
194
|
+
return filename if existing_files.include?(filename)
|
195
|
+
puts "Saving #{css_url} to #{filename}" if debug
|
196
|
+
save_url_to_filename(css_url, filename)
|
197
|
+
return filename
|
198
|
+
end
|
199
|
+
|
200
|
+
def process_css_string(css_string)
|
201
|
+
#filename = rand(36**7).to_s(36) + '.css'
|
202
|
+
filename = Digest::SHA1.hexdigest(css_string) + '.css'
|
203
|
+
existing_files = Dir.entries(".")
|
204
|
+
return filename if existing_files.include?(filename)
|
205
|
+
puts "Saving #{css_string} to #{filename}" if debug
|
206
|
+
save_string_to_filename(css_string, filename)
|
207
|
+
return filename
|
208
|
+
end
|
209
|
+
|
210
|
+
def get_css_files
|
211
|
+
@cssarray.map! { |css_input| process_css_input(css_input) }
|
212
|
+
end
|
213
|
+
|
141
214
|
def generate_pdfs
|
142
215
|
@urls.each_with_index { |url,i| html_to_pdf(TMP_HTML_PREFIX + i.to_s,@pdfarray[i]) }
|
143
216
|
end
|
144
217
|
|
145
218
|
def html_to_pdf(html_file,pdf_file)
|
146
|
-
puts "
|
219
|
+
puts "Creating #{pdf_file} from #{html_file}" if debug
|
147
220
|
html = nil
|
148
221
|
unless Dir.entries(".").include?(pdf_file)
|
149
222
|
File.open(html_file, 'r') { |inf| html = inf.read }
|
@@ -155,22 +228,27 @@ class HtmlsToPdf
|
|
155
228
|
end
|
156
229
|
|
157
230
|
def join_pdfs
|
158
|
-
unless File.exists?(
|
231
|
+
unless File.exists?(savename) && !overwrite_existing_pdf
|
232
|
+
puts "Merging PDF files into single PDF #{savename}" if debug
|
159
233
|
pdfs_string = @pdfarray.join(" ")
|
160
|
-
`pdftk #{pdfs_string} output #{
|
234
|
+
`pdftk #{pdfs_string} output #{savename}`
|
235
|
+
puts "Saved PDF file as #{savedir}/#{savename}"
|
161
236
|
end
|
162
237
|
end
|
163
238
|
|
164
239
|
def delete_tmp_pdf_files
|
240
|
+
puts "Deleting temporary PDF files" if debug
|
165
241
|
@pdfarray.each { |pdffile| File.delete(pdffile) if File.exist?(File.basename(pdffile)) } unless @pdfarray.empty?
|
166
242
|
end
|
167
243
|
|
168
244
|
def delete_html_files
|
245
|
+
puts "Deleting HTML files" if debug
|
169
246
|
to_delete = Dir.glob("#{TMP_HTML_PREFIX}*")
|
170
247
|
to_delete.each { |f| File.delete(f) }
|
171
248
|
end
|
172
249
|
|
173
250
|
def delete_css_files
|
251
|
+
puts "Deleting CSS files" if debug
|
174
252
|
@cssarray.each { |cssfile| File.delete(File.basename(cssfile)) if File.exist?(File.basename(cssfile)) } unless @cssarray.empty?
|
175
253
|
end
|
176
254
|
|
data/lib/htmls_to_pdf/version.rb
CHANGED
data/spec/htmls_to_pdf_spec.rb
CHANGED
@@ -1,13 +1,17 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
require 'htmls_to_pdf'
|
3
3
|
|
4
|
-
describe
|
4
|
+
describe HtmlsToPdf do
|
5
|
+
|
6
|
+
let(:url_arr) { %w(http://www.fakeurl.com/adfsdafds.html https://fakesshurl.com/blog/posts/143.htm) }
|
7
|
+
|
8
|
+
subject { HtmlsToPdf.new(in_config) }
|
9
|
+
|
5
10
|
context "without argument" do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
end
|
11
|
+
|
12
|
+
let(:in_config) { {} }
|
13
|
+
|
14
|
+
it { should be_true }
|
11
15
|
its(:overwrite_existing_pdf) { should be_false }
|
12
16
|
its(:remove_temp_files) { should be_false }
|
13
17
|
its(:remove_css_files) { should be_true }
|
@@ -17,20 +21,21 @@ describe "initialization" do
|
|
17
21
|
its(:urls) { should be_empty }
|
18
22
|
its(:savedir) { should == File.expand_path("~") }
|
19
23
|
its(:savename) { should == 'htmls_to_pdf.pdf' }
|
24
|
+
its(:debug) { should be_false }
|
20
25
|
its(:options) { should be_kind_of Hash }
|
21
26
|
its(:options) { should be_empty }
|
27
|
+
|
22
28
|
end
|
29
|
+
|
23
30
|
context "with basic config" do
|
24
|
-
|
31
|
+
|
32
|
+
|
25
33
|
let(:in_config) { {savedir: '~/my/savedir',
|
26
34
|
savename: 'Name_to_save_file_as.pdf',
|
27
35
|
urls: url_arr }
|
28
36
|
}
|
29
|
-
|
30
|
-
|
31
|
-
it "should initialize" do
|
32
|
-
subject.should be_true
|
33
|
-
end
|
37
|
+
|
38
|
+
it { should be_true }
|
34
39
|
its(:overwrite_existing_pdf) { should be_false }
|
35
40
|
its(:remove_temp_files) { should be_false }
|
36
41
|
its(:remove_css_files) { should be_true }
|
@@ -44,15 +49,95 @@ describe "initialization" do
|
|
44
49
|
its(:options) { should be_empty }
|
45
50
|
it "should call all subfunctions of create_pdf" do
|
46
51
|
subject.should_receive(:clean_temp_files).twice.and_return('Temp files cleaned')
|
47
|
-
subject.should_receive(:
|
52
|
+
subject.should_receive(:get_temp_files).once.and_return('HTML files downloaded')
|
48
53
|
subject.should_receive(:generate_pdfs).once.and_return('PDF files generated')
|
49
54
|
subject.should_receive(:join_pdfs).once.and_return('PDF files joined')
|
55
|
+
stub_request(:get, "http://www.fakeurl.com/adfsdafds.html").
|
56
|
+
with(:headers => {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}).
|
57
|
+
to_return(:status => 200, :body => "", :headers => {})
|
58
|
+
stub_request(:get, "https://fakesshurl.com/blog/posts/143.htm").
|
59
|
+
with(:headers => {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}).
|
60
|
+
to_return(:status => 200, :body => "", :headers => {})
|
50
61
|
subject.create_pdf
|
51
62
|
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
context "with debug" do
|
67
|
+
|
68
|
+
let(:in_config) { {savedir: '~/my/savedir',
|
69
|
+
savename: 'Name_to_save_file_as.pdf',
|
70
|
+
urls: url_arr,
|
71
|
+
debug: true } }
|
72
|
+
|
73
|
+
its(:debug) { should be_true }
|
74
|
+
|
75
|
+
it "should output the correct debugging information" do
|
76
|
+
subject.should_receive(:clean_temp_files).twice.and_return('Temp files cleaned')
|
77
|
+
# let subject.get_temp_files play out
|
78
|
+
STDOUT.should_receive(:write).at_least(:once).with("Downloading #{url_arr[0]}")
|
79
|
+
STDOUT.should_receive(:write).at_least(:once).with("Saving #{url_arr[0]} to tmp_html_file_0")
|
80
|
+
STDOUT.should_receive(:write).at_least(:once).with("\n") # I have no idea why this is necessary, but test fails without it
|
81
|
+
STDOUT.should_receive(:write).at_least(:once).with("Downloading #{url_arr[1]}")
|
82
|
+
STDOUT.should_receive(:write).at_least(:once).with("Saving #{url_arr[1]} to tmp_html_file_1")
|
83
|
+
subject.should_receive(:generate_pdfs).once.and_return('PDF files generated')
|
84
|
+
subject.should_receive(:join_pdfs).once.and_return('PDF files joined')
|
85
|
+
stub_request(:get, "http://www.fakeurl.com/adfsdafds.html").
|
86
|
+
with(:headers => {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}).
|
87
|
+
to_return(:status => 200, :body => "", :headers => {})
|
88
|
+
stub_request(:get, "https://fakesshurl.com/blog/posts/143.htm").
|
89
|
+
with(:headers => {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}).
|
90
|
+
to_return(:status => 200, :body => "", :headers => {})
|
91
|
+
subject.create_pdf
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
|
96
|
+
context "if savename already exists" do
|
97
|
+
|
98
|
+
let(:in_config) { {savedir: '~/my/savedir',
|
99
|
+
savename: 'Name_to_save_file_as.pdf',
|
100
|
+
urls: url_arr } }
|
101
|
+
before do
|
102
|
+
@dirname = File.expand_path('~/my/savedir')
|
103
|
+
FileUtils.mkdir_p(@dirname)
|
104
|
+
FileUtils.touch(@dirname + '/Name_to_save_file_as.pdf')
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should generate an informative error message" do
|
108
|
+
# I really want to test message, but the test fails
|
109
|
+
# message = "File Name_to_save_file_as.pdf already exists in #{@dirname}. Please rename or delete and re-run this program."
|
110
|
+
# $stdout.should_receive(:write).at_least(:once).with(message)
|
111
|
+
$stdout.should_receive(:write).at_least(:once)
|
112
|
+
begin
|
113
|
+
subject
|
114
|
+
rescue SystemExit
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
it "should terminate" do
|
119
|
+
expect { subject }.to raise_error SystemExit
|
120
|
+
end
|
121
|
+
|
52
122
|
end
|
123
|
+
|
124
|
+
context "if savedir does not already exist" do
|
125
|
+
|
126
|
+
let(:in_config) { {savedir: '~/my/savedir',
|
127
|
+
savename: 'Name_to_save_file_as.pdf',
|
128
|
+
urls: url_arr } }
|
129
|
+
|
130
|
+
it "should create savedir" do
|
131
|
+
subject
|
132
|
+
File.directory?(File.expand_path('~/my/savedir')).should be_true
|
133
|
+
end
|
134
|
+
|
135
|
+
end
|
136
|
+
|
53
137
|
context "with more complicated config" do
|
54
|
-
|
55
|
-
let(:css_arr) { %w(http://fakeurl.com/assets/cssfile.css https://www.
|
138
|
+
|
139
|
+
let(:css_arr) { %w(http://fakeurl.com/assets/cssfile.css https://www.fakesshurl.com/public/css/CSS-file.css) }
|
140
|
+
|
56
141
|
let(:in_config) { {savedir: '~/my/savedir',
|
57
142
|
savename: 'Name_to_save_file_as.pdf',
|
58
143
|
urls: url_arr,
|
@@ -61,11 +146,8 @@ describe "initialization" do
|
|
61
146
|
remove_html_files: false,
|
62
147
|
overwrite_existing_pdf: true }
|
63
148
|
}
|
64
|
-
|
65
|
-
|
66
|
-
it "should initialize" do
|
67
|
-
subject.should be_true
|
68
|
-
end
|
149
|
+
|
150
|
+
it { should be_true }
|
69
151
|
its(:overwrite_existing_pdf) { should be_true }
|
70
152
|
its(:remove_temp_files) { should be_false }
|
71
153
|
its(:remove_css_files) { should be_false }
|
@@ -77,24 +159,29 @@ describe "initialization" do
|
|
77
159
|
its(:savename) { should == 'Name_to_save_file_as.pdf' }
|
78
160
|
its(:options) { should be_kind_of Hash }
|
79
161
|
its(:options) { should be_empty }
|
162
|
+
|
80
163
|
it "should call all subfunctions of create_pdf" do
|
81
164
|
subject.should_receive(:clean_temp_files).twice.and_return('Temp files cleaned')
|
82
|
-
subject.should_receive(:
|
165
|
+
subject.should_receive(:get_temp_files).once.and_return('HTML files downloaded')
|
83
166
|
subject.should_receive(:generate_pdfs).once.and_return('PDF files generated')
|
84
167
|
subject.should_receive(:join_pdfs).once.and_return('PDF files joined')
|
168
|
+
stub_request(:get, "http://www.fakeurl.com/adfsdafds.html").
|
169
|
+
with(:headers => {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}).
|
170
|
+
to_return(:status => 200, :body => "", :headers => {})
|
85
171
|
subject.create_pdf
|
86
172
|
end
|
173
|
+
|
87
174
|
it "should not delete html or css files" do
|
88
175
|
stub_request(:get, "http://www.fakeurl.com/adfsdafds.html").
|
89
176
|
with(:headers => {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}).
|
90
177
|
to_return(:status => 200, :body => "", :headers => {})
|
91
|
-
stub_request(:get, "
|
178
|
+
stub_request(:get, "https://fakesshurl.com/blog/posts/143.htm").
|
92
179
|
with(:headers => {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}).
|
93
180
|
to_return(:status => 200, :body => "", :headers => {})
|
94
181
|
stub_request(:get, "http://fakeurl.com/assets/cssfile.css").
|
95
182
|
with(:headers => {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}).
|
96
183
|
to_return(:status => 200, :body => "", :headers => {})
|
97
|
-
stub_request(:get, "
|
184
|
+
stub_request(:get, "https://www.fakesshurl.com/public/css/CSS-file.css").
|
98
185
|
with(:headers => {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}).
|
99
186
|
to_return(:status => 200, :body => "", :headers => {})
|
100
187
|
subject.should_receive(:generate_pdfs).once.and_return('PDF files generated')
|
@@ -103,27 +190,29 @@ describe "initialization" do
|
|
103
190
|
subject.should_not_receive(:delete_css_files)
|
104
191
|
subject.create_pdf
|
105
192
|
end
|
193
|
+
|
106
194
|
it "should request the HTML files" do
|
107
195
|
stub_request(:get, "http://www.fakeurl.com/adfsdafds.html").
|
108
196
|
with(:headers => {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}).
|
109
197
|
to_return(:status => 200, :body => "", :headers => {})
|
110
|
-
stub_request(:get, "
|
198
|
+
stub_request(:get, "https://fakesshurl.com/blog/posts/143.htm").
|
111
199
|
with(:headers => {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}).
|
112
200
|
to_return(:status => 200, :body => "", :headers => {})
|
113
201
|
stub_request(:get, "http://fakeurl.com/assets/cssfile.css").
|
114
202
|
with(:headers => {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}).
|
115
203
|
to_return(:status => 200, :body => "", :headers => {})
|
116
|
-
stub_request(:get, "
|
204
|
+
stub_request(:get, "https://www.fakesshurl.com/public/css/CSS-file.css").
|
117
205
|
with(:headers => {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}).
|
118
206
|
to_return(:status => 200, :body => "", :headers => {})
|
119
207
|
subject.should_receive(:generate_pdfs).once.and_return('PDF files generated')
|
120
208
|
subject.should_receive(:join_pdfs).once.and_return('PDF files joined')
|
121
209
|
subject.create_pdf
|
122
210
|
a_request(:get, "www.fakeurl.com/adfsdafds.html").should have_been_made
|
123
|
-
a_request(:get, "
|
211
|
+
a_request(:get, "https://fakesshurl.com/blog/posts/143.htm").should have_been_made
|
124
212
|
a_request(:get, "fakeurl.com/assets/cssfile.css").should have_been_made
|
125
|
-
a_request(:get, "www.
|
213
|
+
a_request(:get, "https://www.fakesshurl.com/public/css/CSS-file.css").should have_been_made
|
126
214
|
end
|
127
215
|
|
128
216
|
end
|
217
|
+
|
129
218
|
end
|
metadata
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
name: htmls_to_pdf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.9
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- James Lavin
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-08-24 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: pdfkit
|
@@ -68,11 +68,13 @@ files:
|
|
68
68
|
- .gitignore
|
69
69
|
- README.markdown
|
70
70
|
- examples/get_12factor.rb
|
71
|
+
- examples/get_backbone_fundamentals.rb
|
71
72
|
- examples/get_bash_guide.rb
|
72
73
|
- examples/get_coffeescript.rb
|
73
74
|
- examples/get_coffeescript_cookbook.rb
|
74
75
|
- examples/get_coffeescript_meet_backbone.rb
|
75
76
|
- examples/get_exploring_coffeescript.rb
|
77
|
+
- examples/get_jasmine_wiki.rb
|
76
78
|
- examples/get_jumpstartlabs_advanced_rails.rb
|
77
79
|
- examples/get_little_book_on_coffeescript.rb
|
78
80
|
- examples/get_nlp_for_working_programmer.rb
|