phantompdf 1.2.2 → 2.0.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 441f0c5b99c19b04255b8c58e444a29d2b24baa9
4
- data.tar.gz: 5f1407eba70476e146f2f306778c0ea87b638994
3
+ metadata.gz: feb06fd2577e409810280e38654637e1417baa0d
4
+ data.tar.gz: df8f6b3e792e063b273ad6a6aa9c61505cec3131
5
5
  SHA512:
6
- metadata.gz: 3eef559de00397dea76002a6974fab90dcfa1bdcedbc4979d9b07974afdb9fcfd0bbbe3ab151fd6a541c6c7dcec72ec2e33bb000b9bf7a7672e450ba121f331b
7
- data.tar.gz: bc16f070cadb564da24b6a32ad44b6c7dba3c2e65de4884119ec5635c16cd042f8b9ceb63bd7886a4719b05fa4625e4934d8ad6f0527d183cf93218d4b756789
6
+ metadata.gz: 3ca72578625edf9232c761e3f662230477cd63f33914536bd2c3ef1a6ef061861d7f514c0e4c8ab2ea9d3010766d2bd7eb11a9453cc2b42439d2186890e2faa5
7
+ data.tar.gz: 2ea7e5983be73004bc851c07b6694248008481af43e4fbe31457b9024dc30f732a6fb619baf8b3898311e78af3a347e766ba6be04efc1cd37c31ee65b1e66396
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.4
4
+ before_script:
5
+ - sudo apt-get install phantomjs
6
+ - mkdir -p /home/travis/.phantomjs/$(phantomjs -v)/x86_64-linux/bin/
7
+ - ln -s $(which phantomjs) /home/travis/.phantomjs/$(phantomjs -v)/x86_64-linux/bin/
8
+ script: bundle exec rspec
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- phantompdf (1.2.0)
4
+ phantompdf (1.2.2)
5
5
  json
6
6
  phantomjs
7
7
  rack
@@ -10,35 +10,36 @@ GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
12
  Ascii85 (1.0.2)
13
- afm (0.2.0)
14
- byebug (2.5.0)
15
- columnize (~> 0.3.6)
16
- debugger-linecache (~> 1.2.0)
17
- columnize (0.3.6)
18
- debugger-linecache (1.2.0)
19
- diff-lcs (1.2.5)
20
- hashery (2.1.1)
21
- json (1.8.1)
22
- pdf-reader (1.3.3)
13
+ afm (0.2.2)
14
+ byebug (9.1.0)
15
+ diff-lcs (1.3)
16
+ hashery (2.1.2)
17
+ json (2.1.0)
18
+ pdf-reader (2.0.0)
23
19
  Ascii85 (~> 1.0.0)
24
- afm (~> 0.2.0)
20
+ afm (~> 0.2.1)
25
21
  hashery (~> 2.0)
26
22
  ruby-rc4
27
23
  ttfunk
28
- phantomjs (1.9.2.1)
29
- rack (1.5.2)
30
- rack-test (0.6.2)
31
- rack (>= 1.0)
32
- rspec (2.14.1)
33
- rspec-core (~> 2.14.0)
34
- rspec-expectations (~> 2.14.0)
35
- rspec-mocks (~> 2.14.0)
36
- rspec-core (2.14.7)
37
- rspec-expectations (2.14.4)
38
- diff-lcs (>= 1.1.3, < 2.0)
39
- rspec-mocks (2.14.4)
24
+ phantomjs (2.1.1.0)
25
+ rack (2.0.3)
26
+ rack-test (0.7.0)
27
+ rack (>= 1.0, < 3)
28
+ rspec (3.6.0)
29
+ rspec-core (~> 3.6.0)
30
+ rspec-expectations (~> 3.6.0)
31
+ rspec-mocks (~> 3.6.0)
32
+ rspec-core (3.6.0)
33
+ rspec-support (~> 3.6.0)
34
+ rspec-expectations (3.6.0)
35
+ diff-lcs (>= 1.2.0, < 2.0)
36
+ rspec-support (~> 3.6.0)
37
+ rspec-mocks (3.6.0)
38
+ diff-lcs (>= 1.2.0, < 2.0)
39
+ rspec-support (~> 3.6.0)
40
+ rspec-support (3.6.0)
40
41
  ruby-rc4 (0.1.5)
41
- ttfunk (1.0.3)
42
+ ttfunk (1.5.1)
42
43
 
43
44
  PLATFORMS
44
45
  ruby
@@ -50,3 +51,6 @@ DEPENDENCIES
50
51
  phantompdf!
51
52
  rack-test
52
53
  rspec
54
+
55
+ BUNDLED WITH
56
+ 1.15.4
@@ -1,3 +1,3 @@
1
1
  module PhantomPDF
2
- VERSION = "1.2.2"
2
+ VERSION = "2.0.0"
3
3
  end
@@ -18,11 +18,12 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = %w(lib)
20
20
 
21
- spec.add_runtime_dependency 'phantomjs'
22
- spec.add_runtime_dependency 'rack'
23
- spec.add_runtime_dependency 'json'
21
+ spec.add_runtime_dependency 'phantomjs', '~> 1.9'
22
+ spec.add_runtime_dependency 'rack', '~> 2.0'
23
+ spec.add_runtime_dependency 'json', '~> 2.1'
24
24
 
25
- spec.add_development_dependency 'rack-test'
26
- spec.add_development_dependency 'rspec'
27
- spec.add_development_dependency 'byebug'
25
+ spec.add_development_dependency 'rack-test', '~> 0.7'
26
+ spec.add_development_dependency 'rspec', '~> 3.6'
27
+ spec.add_development_dependency 'byebug', '~> 9.1'
28
+ spec.add_development_dependency 'pdf-reader', '~> 2.0'
28
29
  end
@@ -4,17 +4,17 @@ module PhantomPDF
4
4
  describe Assets do
5
5
  context ".root" do
6
6
  it "should return vendor folder" do
7
- File.directory?(Assets.root).should be_true
7
+ expect(File.directory?(Assets.root)).to be true
8
8
  end
9
9
  end
10
10
 
11
11
  context ".javascripts" do
12
12
  it "should return rasterize.js abs path" do
13
- File.exist?(Assets.javascripts('rasterize')).should be_true
13
+ expect(File.exist?(Assets.javascripts('rasterize'))).to be true
14
14
  end
15
15
 
16
16
  it "should return nil for un-existed file" do
17
- Assets.javascripts('un-exist-javascript').should be_nil
17
+ expect(Assets.javascripts('un-exist-javascript')).to be nil
18
18
  end
19
19
  end
20
20
  end
@@ -8,11 +8,11 @@ module PhantomPDF
8
8
 
9
9
  context "#phantomjs" do
10
10
  it "should respond to :phantomjs" do
11
- @config.should respond_to(:phantomjs)
11
+ expect(@config).to respond_to(:phantomjs)
12
12
  end
13
13
 
14
14
  it "should return phantomjs bin path" do
15
- @config.phantomjs.should == Phantomjs.path
15
+ expect(@config.phantomjs).to eq Phantomjs.path
16
16
  end
17
17
  end
18
18
 
@@ -20,7 +20,7 @@ module PhantomPDF
20
20
  method = :"#{method}="
21
21
 
22
22
  it "should respond to #{method}" do
23
- @config.should respond_to(method)
23
+ expect(@config).to respond_to(method)
24
24
  end
25
25
  end
26
26
  end
@@ -26,7 +26,7 @@ module PhantomPDF
26
26
 
27
27
  context "#generate" do
28
28
  it "should works" do
29
- Generator.new(resource).generate.should be_pdf_file
29
+ expect(Generator.new(resource).generate).to be_pdf_file
30
30
  end
31
31
 
32
32
  context "with output" do
@@ -41,11 +41,11 @@ module PhantomPDF
41
41
  end
42
42
 
43
43
  it "should generate pdf file following output" do
44
- File.exist?(@destination).should be_false
44
+ expect(File.exist?(@destination)).to be false
45
45
  Generator.new(resource, @destination).generate
46
- File.exist?(@destination).should be_true
46
+ expect(File.exist?(@destination)).to be true
47
47
 
48
- @destination.should be_pdf_file
48
+ expect(@destination).to be_pdf_file
49
49
  end
50
50
 
51
51
  it "should raise PhantomPDF::DestinationTypeError when output is not a string" do
@@ -54,12 +54,13 @@ module PhantomPDF
54
54
  }.to raise_error(PhantomPDF::DestinationTypeError)
55
55
  end
56
56
 
57
- pending "should raise PhantomPDF::DestinationPermitError when output is not writable" do
58
- File.stub(:writable?, '/tmp') { false }
57
+ it "should raise PhantomPDF::DestinationPermitError when output is not writable" do
58
+ allow(File).to receive(:writable?).with('/tmp').and_return(false)
59
59
 
60
60
  expect{
61
61
  Generator.new(resource, @destination)
62
62
  }.to raise_error(PhantomPDF::DestinationPermitError)
63
+ expect(File).to have_received(:writable?)
63
64
  end
64
65
  end
65
66
 
@@ -78,7 +79,7 @@ module PhantomPDF
78
79
  it "should support custom header" do
79
80
  header = 'Hello, PhantomPDF header!'
80
81
 
81
- Generator.new(resource, @destination, {:header => header}).generate.should be_pdf_file
82
+ expect(Generator.new(resource, @destination, {:header => header}).generate).to be_pdf_file
82
83
 
83
84
  # we CANNOT reader the file as PDF
84
85
  # pdf_content = PDF::Reader.new(@destination).page(1).text
@@ -88,7 +89,7 @@ module PhantomPDF
88
89
  it "should support images in custom header" do
89
90
  header = "1.8cm*PhantomPDF header!<img src=\"#{@custom_image}\" style=\"float:right;\"/>"
90
91
 
91
- Generator.new(resource, @destination, {:header => header}).generate.should be_pdf_file
92
+ expect(Generator.new(resource, @destination, {:header => header}).generate).to be_pdf_file
92
93
 
93
94
  # we CANNOT reader the file as PDF
94
95
  # pdf_content = PDF::Reader.new(@destination).page(1).text
@@ -97,8 +98,8 @@ module PhantomPDF
97
98
 
98
99
  it "should support custom footer" do
99
100
  footer = 'Hello, PhantomPDF footer!'
100
-
101
- Generator.new(resource, @destination, {:footer => footer}).generate.should be_pdf_file
101
+
102
+ expect(Generator.new(resource, @destination, {:footer => footer}).generate).to be_pdf_file
102
103
 
103
104
  # we CANNOT reader the file as PDF
104
105
  # pdf_content = PDF::Reader.new(@destination).page(1).text
@@ -108,7 +109,7 @@ module PhantomPDF
108
109
  it "should support images in custom footer" do
109
110
  footer = "1.8cm*PhantomPDF footer!<img src=\"#{@custom_image}\" style=\"float:right;\"/>"
110
111
 
111
- Generator.new(resource, @destination, {:footer => footer}).generate.should be_pdf_file
112
+ expect(Generator.new(resource, @destination, {:footer => footer}).generate).to be_pdf_file
112
113
 
113
114
  # we CANNOT reader the file as PDF
114
115
  # pdf_content = PDF::Reader.new(@destination).page(1).text
@@ -119,10 +120,10 @@ module PhantomPDF
119
120
 
120
121
  context "#generate!" do
121
122
  it "should raise PhantomPDF::RenderingError when failed to generate" do
122
- $?.stub(:exitstatus) { 1 }
123
+ allow($?).to receive(:exitstatus).and_return(1)
123
124
 
124
125
  generator = Generator.new(resource)
125
- generator.stub(:run) { 'rendering error' }
126
+ allow(generator).to receive(:run).and_return('rendering error')
126
127
 
127
128
  expect{
128
129
  generator.generate!
@@ -132,7 +133,7 @@ module PhantomPDF
132
133
 
133
134
  context "#to_string" do
134
135
  it "should return string of PDF file" do
135
- Generator.new(resource).to_string.should be_pdf_string
136
+ expect(Generator.new(resource).to_string).to be_pdf_string
136
137
  end
137
138
  end
138
139
  end
@@ -13,15 +13,15 @@ module PhantomPDF
13
13
  it "should works" do
14
14
  get '/index.pdf'
15
15
 
16
- last_response.status.should == 200
17
- last_response.body.should be_pdf_string
16
+ expect(last_response).to be_ok
17
+ expect(last_response.body).to be_pdf_string
18
18
  end
19
19
 
20
20
  it "should respond with original data without PDF request" do
21
21
  get '/'
22
22
 
23
- last_response.status.should == 200
24
- last_response.body.should_not be_pdf_string
23
+ expect(last_response).to be_ok
24
+ expect(last_response.body).not_to be_pdf_string
25
25
  end
26
26
  end
27
27
  end
@@ -14,75 +14,77 @@ module PhantomPDF
14
14
 
15
15
  context "#url?" do
16
16
  it "should return true for url" do
17
- @url_source.url?.should be_true
17
+ expect(@url_source).to be_url
18
18
  end
19
19
 
20
20
  it "should return false for file" do
21
- @file_source.url?.should be_false
21
+ expect(@file_source).not_to be_url
22
22
  end
23
23
 
24
24
  it "should return false for html" do
25
- @html_source.url?.should be_false
25
+ expect(@html_source).not_to be_url
26
26
  end
27
27
  end
28
28
 
29
29
  context "#file?" do
30
30
  it "should return false for url" do
31
- @url_source.file?.should be_false
31
+ expect(@url_source).not_to be_file
32
32
  end
33
33
 
34
34
  it "should return true for file" do
35
- @file_source.file?.should be_true
35
+ expect(@file_source).to be_file
36
36
  end
37
37
 
38
38
  it "should return false for html" do
39
- @html_source.file?.should be_false
39
+ expect(@html_source).not_to be_file
40
40
  end
41
41
 
42
- it "should return false if file does not exist" do
43
- Source.new('path/to/unexisted/file').file?.should be_false
42
+ context 'when the file does not exist' do
43
+ subject { Source.new('path/to/unexisted/file') }
44
+
45
+ it { is_expected.not_to be_file }
44
46
  end
45
47
  end
46
48
 
47
49
  context "#html?" do
48
50
  it "should return false for url" do
49
- @url_source.html?.should be_false
51
+ expect(@url_source).not_to be_html
50
52
  end
51
53
 
52
54
  it "should return false for file" do
53
- @file_source.html?.should be_false
55
+ expect(@file_source).not_to be_html
54
56
  end
55
57
 
56
58
  it "should return true for html" do
57
- @html_source.html?.should be_true
59
+ expect(@html_source).to be_html
58
60
  end
59
61
  end
60
62
 
61
63
  context "#valid?" do
62
64
  it "should return true for url" do
63
- @url_source.valid?.should be_true
65
+ expect(@url_source).to be_valid
64
66
  end
65
67
 
66
68
  it "should return true for file" do
67
- @file_source.valid?.should be_true
69
+ expect(@file_source).to be_valid
68
70
  end
69
71
 
70
72
  it "should return true for html" do
71
- @html_source.valid?.should be_true
73
+ expect(@html_source).to be_valid
72
74
  end
73
75
  end
74
76
 
75
77
  context "#to_s" do
76
78
  it "should return url for url source" do
77
- @url_source.to_s.should == @url
79
+ expect(@url_source.to_s).to eq @url
78
80
  end
79
81
 
80
82
  it "should return file path for file source" do
81
- @file_source.to_s.should == @file
83
+ expect(@file_source.to_s).to eq @file
82
84
  end
83
85
 
84
86
  it "should return html string for html source" do
85
- @html_source.to_s.should == @html
87
+ expect(@html_source.to_s).to eq @html
86
88
  end
87
89
  end
88
90
  end
@@ -18,7 +18,7 @@ var page = require('webpage').create(),
18
18
 
19
19
  phantom.exit(code || 0);
20
20
  };
21
- if (phantom.version.major < 1 || phantom.version.minor < 7) {
21
+ if (phantom.version.major < 1 && phantom.version.minor < 7) {
22
22
  phantom_exit(1, "PhantomJS version must greater than 1.7!");
23
23
  }
24
24
  if (system_args_len < 3 || system_args_len > 12) {
metadata CHANGED
@@ -1,99 +1,113 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phantompdf
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Spring MC
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-07 00:00:00.000000000 Z
11
+ date: 2017-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: phantomjs
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '1.9'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '1.9'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rack
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '2.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '2.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: json
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '2.1'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '2.1'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rack-test
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: '0.7'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: '0.7'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
75
+ version: '3.6'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0'
82
+ version: '3.6'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: byebug
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '>='
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0'
89
+ version: '9.1'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '>='
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '0'
96
+ version: '9.1'
97
+ - !ruby/object:Gem::Dependency
98
+ name: pdf-reader
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '2.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '2.0'
97
111
  description: Generate PDF from HTML using PhantomJS
98
112
  email:
99
113
  - Heresy.Mc@gmail.com
@@ -101,7 +115,8 @@ executables: []
101
115
  extensions: []
102
116
  extra_rdoc_files: []
103
117
  files:
104
- - .gitignore
118
+ - ".gitignore"
119
+ - ".travis.yml"
105
120
  - Gemfile
106
121
  - Gemfile.lock
107
122
  - LICENSE
@@ -136,17 +151,17 @@ require_paths:
136
151
  - lib
137
152
  required_ruby_version: !ruby/object:Gem::Requirement
138
153
  requirements:
139
- - - '>='
154
+ - - ">="
140
155
  - !ruby/object:Gem::Version
141
156
  version: '0'
142
157
  required_rubygems_version: !ruby/object:Gem::Requirement
143
158
  requirements:
144
- - - '>='
159
+ - - ">="
145
160
  - !ruby/object:Gem::Version
146
161
  version: '0'
147
162
  requirements: []
148
163
  rubyforge_project:
149
- rubygems_version: 2.1.11
164
+ rubygems_version: 2.5.2
150
165
  signing_key:
151
166
  specification_version: 4
152
167
  summary: A PhantomJS based PDF generator