phantomjs 1.6.0.0 → 1.8.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,11 @@
1
+ script:
2
+ - bundle
3
+ - bundle exec rspec
4
+ rvm:
5
+ - 1.9.3
6
+ - 2.0.0
7
+ - rbx-19mode
8
+ notifications:
9
+ email:
10
+ on_success: always
11
+ on_failure: always
data/README.md CHANGED
@@ -9,7 +9,7 @@ It keeps installations of phantomjs in `$HOME/.phantomjs/VERSION/PLATFORM`. When
9
9
  will return the path to the phantomjs executable in there. If that is not present, it will first fetch and
10
10
  install the prebuilt packages suitable for the current plattform (currently Linux 32/64 or OS X supported).
11
11
 
12
- You will need `wget` on your system. For extraction, `bunzip2` and `tar` are required on Linux, and `unzip`
12
+ You will need `cURL` or `wget` on your system. For extraction, `bunzip2` and `tar` are required on Linux, and `unzip`
13
13
  on OS X. They should be installed already.
14
14
 
15
15
  **TL;DR:** Instead of manually installing phantomjs on your machines, use this gem. It will take care of it.
@@ -40,6 +40,8 @@ the Poltergeist capybara driver to use the phantomjs package from this gem:
40
40
  Capybara::Poltergeist::Driver.new(app, :phantomjs => Phantomjs.path)
41
41
  end
42
42
 
43
+ Check out [the poltergeist docs](https://www.ruby-toolbox.com/gems/phantomjs) for all the options you can pass in there.
44
+
43
45
  ## A note about versions.
44
46
 
45
47
  The gem version consists of 4 digits: The first 3 indicate the phantomjs release installed via this gem,
@@ -10,11 +10,29 @@ module Phantomjs
10
10
  end
11
11
 
12
12
  def phantomjs_path
13
- File.expand_path File.join(Phantomjs.base_dir, platform, 'bin/phantomjs')
13
+ if system_phantomjs_installed?
14
+ system_phantomjs_path
15
+ else
16
+ File.expand_path File.join(Phantomjs.base_dir, platform, 'bin/phantomjs')
17
+ end
18
+ end
19
+
20
+ def system_phantomjs_path
21
+ `which phantomjs`.delete("\n")
22
+ rescue
23
+ end
24
+
25
+ def system_phantomjs_version
26
+ `phantomjs --version`.delete("\n")
27
+ rescue
28
+ end
29
+
30
+ def system_phantomjs_installed?
31
+ system_phantomjs_version == Phantomjs.version
14
32
  end
15
33
 
16
34
  def installed?
17
- File.exist? phantomjs_path
35
+ File.exist?(phantomjs_path) || system_phantomjs_installed?
18
36
  end
19
37
 
20
38
  # TODO: Clean this up, it looks like a pile of...
@@ -29,8 +47,8 @@ module Phantomjs
29
47
  FileUtils.mkdir_p temp_dir
30
48
 
31
49
  Dir.chdir temp_dir do
32
- unless system "wget #{package_url}"
33
- raise "Failed to load phantomjs from #{package_url} :("
50
+ unless system "curl -O #{package_url}" or system "wget #{package_url}"
51
+ raise "\n\nFailed to load phantomjs! :(\nYou need to have cURL or wget installed on your system.\nIf you have, the source of phantomjs might be unavailable: #{package_url}\n\n"
34
52
  end
35
53
 
36
54
  case package_url.split('.').last
@@ -47,10 +65,14 @@ module Phantomjs
47
65
  extracted_dir = Dir['phantomjs*'].find { |path| File.directory?(path) }
48
66
 
49
67
  # Move the extracted phantomjs build to $HOME/.phantomjs/version/platform
50
- FileUtils.mv extracted_dir, File.join(Phantomjs.base_dir, platform)
68
+ if FileUtils.mv extracted_dir, File.join(Phantomjs.base_dir, platform)
69
+ STDOUT.puts "\nSuccessfully installed phantomjs. Yay!"
70
+ end
51
71
 
52
72
  # Clean up remaining files in tmp
53
- FileUtils.rm_rf temp_dir
73
+ if FileUtils.rm_rf temp_dir
74
+ STDOUT.puts "Removed temporarily downloaded files."
75
+ end
54
76
  end
55
77
 
56
78
  raise "Failed to install phantomjs. Sorry :(" unless File.exist?(phantomjs_path)
@@ -72,7 +94,7 @@ module Phantomjs
72
94
  end
73
95
 
74
96
  def package_url
75
- 'http://phantomjs.googlecode.com/files/phantomjs-1.6.0-linux-x86_64-dynamic.tar.bz2'
97
+ 'http://phantomjs.googlecode.com/files/phantomjs-1.8.1-linux-x86_64.tar.bz2'
76
98
  end
77
99
  end
78
100
  end
@@ -88,7 +110,7 @@ module Phantomjs
88
110
  end
89
111
 
90
112
  def package_url
91
- 'http://phantomjs.googlecode.com/files/phantomjs-1.6.0-linux-i686-dynamic.tar.bz2'
113
+ 'http://phantomjs.googlecode.com/files/phantomjs-1.8.1-linux-i686.tar.bz2'
92
114
  end
93
115
  end
94
116
  end
@@ -104,7 +126,7 @@ module Phantomjs
104
126
  end
105
127
 
106
128
  def package_url
107
- 'http://phantomjs.googlecode.com/files/phantomjs-1.6.0-macosx-static.zip'
129
+ 'http://phantomjs.googlecode.com/files/phantomjs-1.8.1-macosx.zip'
108
130
  end
109
131
  end
110
132
  end
@@ -1,3 +1,3 @@
1
1
  module Phantomjs
2
- VERSION = "1.6.0.0"
2
+ VERSION = "1.8.1.0"
3
3
  end
@@ -8,9 +8,11 @@ Gem::Specification.new do |gem|
8
8
  gem.summary = %q{Auto-install phantomjs on demand for current platform. Comes with poltergeist integration.}
9
9
  gem.homepage = "https://github.com/colszowka/phantomjs-gem"
10
10
 
11
- gem.add_development_dependency 'rspec', "~> 2.10.0"
12
- gem.add_development_dependency 'poltergeist'
11
+ gem.add_runtime_dependency 'poltergeist'
12
+
13
+ gem.add_development_dependency 'rspec', ">= 2.11.0"
13
14
  gem.add_development_dependency 'simplecov'
15
+ gem.add_development_dependency 'rake'
14
16
 
15
17
  gem.files = `git ls-files`.split($\)
16
18
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
@@ -2,6 +2,25 @@ require 'spec_helper'
2
2
 
3
3
  describe Phantomjs::Platform do
4
4
  before(:each) { Phantomjs.reset! }
5
+ describe "with a system install present" do
6
+ describe "#system_phantomjs_installed?" do
7
+ it "is true when the system version matches Phantomjs.version" do
8
+ Phantomjs::Platform.should_receive(:system_phantomjs_version).and_return(Phantomjs.version)
9
+ expect(Phantomjs::Platform.system_phantomjs_installed?).to be_true
10
+ end
11
+
12
+ it "is false when the system version does not match Phantomjs.version" do
13
+ Phantomjs::Platform.should_receive(:system_phantomjs_version).and_return('1.2.3')
14
+ expect(Phantomjs::Platform.system_phantomjs_installed?).to be_false
15
+ end
16
+
17
+ it "is false when there's no system version" do
18
+ Phantomjs::Platform.should_receive(:system_phantomjs_version).and_return(nil)
19
+ expect(Phantomjs::Platform.system_phantomjs_installed?).to be_false
20
+ end
21
+ end
22
+ end
23
+
5
24
  describe "on a 64 bit linux" do
6
25
  before do
7
26
  Phantomjs::Platform.stub(:host_os).and_return('linux-gnu')
@@ -12,8 +31,23 @@ describe Phantomjs::Platform do
12
31
  Phantomjs::Platform::Linux64.should be_useable
13
32
  end
14
33
 
15
- it "returns the correct phantom js executable path for the platform" do
16
- Phantomjs.path.should =~ /x86_64-linux\/bin\/phantomjs$/
34
+ describe "without system install" do
35
+ before(:each) { Phantomjs::Platform.stub(:system_phantomjs_version).and_return(nil) }
36
+
37
+ it "returns the correct phantom js executable path for the platform" do
38
+ Phantomjs.path.should =~ /x86_64-linux\/bin\/phantomjs$/
39
+ end
40
+ end
41
+
42
+ describe "with system install" do
43
+ before(:each) do
44
+ Phantomjs::Platform.stub(:system_phantomjs_version).and_return(Phantomjs.version)
45
+ Phantomjs::Platform.stub(:system_phantomjs_path).and_return('/tmp/path')
46
+ end
47
+
48
+ it "returns the correct phantom js executable path for the platform" do
49
+ expect(Phantomjs.path).to be == '/tmp/path'
50
+ end
17
51
  end
18
52
 
19
53
  it "reports the Linux32 platform as unuseable" do
@@ -41,8 +75,23 @@ describe Phantomjs::Platform do
41
75
  Phantomjs::Platform::Linux32.should be_useable
42
76
  end
43
77
 
44
- it "returns the correct phantom js executable path for the platform" do
45
- Phantomjs.path.should =~ /x86_32-linux\/bin\/phantomjs$/
78
+ describe "without system install" do
79
+ before(:each) { Phantomjs::Platform.stub(:system_phantomjs_version).and_return(nil) }
80
+
81
+ it "returns the correct phantom js executable path for the platform" do
82
+ Phantomjs.path.should =~ /x86_32-linux\/bin\/phantomjs$/
83
+ end
84
+ end
85
+
86
+ describe "with system install" do
87
+ before(:each) do
88
+ Phantomjs::Platform.stub(:system_phantomjs_version).and_return(Phantomjs.version)
89
+ Phantomjs::Platform.stub(:system_phantomjs_path).and_return('/tmp/path')
90
+ end
91
+
92
+ it "returns the correct phantom js executable path for the platform" do
93
+ expect(Phantomjs.path).to be == '/tmp/path'
94
+ end
46
95
  end
47
96
 
48
97
  it "reports the Linux64 platform as unuseable" do
@@ -64,8 +113,23 @@ describe Phantomjs::Platform do
64
113
  Phantomjs::Platform::OsX.should be_useable
65
114
  end
66
115
 
67
- it "returns the correct phantom js executable path for the platform" do
68
- Phantomjs.path.should =~ /darwin\/bin\/phantomjs$/
116
+ describe "without system install" do
117
+ before(:each) { Phantomjs::Platform.stub(:system_phantomjs_version).and_return(nil) }
118
+
119
+ it "returns the correct phantom js executable path for the platform" do
120
+ Phantomjs.path.should =~ /darwin\/bin\/phantomjs$/
121
+ end
122
+ end
123
+
124
+ describe "with system install" do
125
+ before(:each) do
126
+ Phantomjs::Platform.stub(:system_phantomjs_version).and_return(Phantomjs.version)
127
+ Phantomjs::Platform.stub(:system_phantomjs_path).and_return('/tmp/path')
128
+ end
129
+
130
+ it "returns the correct phantom js executable path for the platform" do
131
+ expect(Phantomjs.path).to be == '/tmp/path'
132
+ end
69
133
  end
70
134
 
71
135
  it "reports the Linux32 Platform as unuseable" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phantomjs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0.0
4
+ version: 1.8.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,26 +9,42 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-20 00:00:00.000000000 Z
12
+ date: 2013-02-28 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: poltergeist
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
14
30
  - !ruby/object:Gem::Dependency
15
31
  name: rspec
16
32
  requirement: !ruby/object:Gem::Requirement
17
33
  none: false
18
34
  requirements:
19
- - - ~>
35
+ - - ! '>='
20
36
  - !ruby/object:Gem::Version
21
- version: 2.10.0
37
+ version: 2.11.0
22
38
  type: :development
23
39
  prerelease: false
24
40
  version_requirements: !ruby/object:Gem::Requirement
25
41
  none: false
26
42
  requirements:
27
- - - ~>
43
+ - - ! '>='
28
44
  - !ruby/object:Gem::Version
29
- version: 2.10.0
45
+ version: 2.11.0
30
46
  - !ruby/object:Gem::Dependency
31
- name: poltergeist
47
+ name: simplecov
32
48
  requirement: !ruby/object:Gem::Requirement
33
49
  none: false
34
50
  requirements:
@@ -44,7 +60,7 @@ dependencies:
44
60
  - !ruby/object:Gem::Version
45
61
  version: '0'
46
62
  - !ruby/object:Gem::Dependency
47
- name: simplecov
63
+ name: rake
48
64
  requirement: !ruby/object:Gem::Requirement
49
65
  none: false
50
66
  requirements:
@@ -70,6 +86,7 @@ files:
70
86
  - .gitignore
71
87
  - .rspec
72
88
  - .simplecov
89
+ - .travis.yml
73
90
  - Gemfile
74
91
  - LICENSE
75
92
  - README.md
@@ -94,15 +111,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
94
111
  - - ! '>='
95
112
  - !ruby/object:Gem::Version
96
113
  version: '0'
114
+ segments:
115
+ - 0
116
+ hash: 3414073590874210701
97
117
  required_rubygems_version: !ruby/object:Gem::Requirement
98
118
  none: false
99
119
  requirements:
100
120
  - - ! '>='
101
121
  - !ruby/object:Gem::Version
102
122
  version: '0'
123
+ segments:
124
+ - 0
125
+ hash: 3414073590874210701
103
126
  requirements: []
104
127
  rubyforge_project:
105
- rubygems_version: 1.8.24
128
+ rubygems_version: 1.8.25
106
129
  signing_key:
107
130
  specification_version: 3
108
131
  summary: Auto-install phantomjs on demand for current platform. Comes with poltergeist
@@ -111,4 +134,3 @@ test_files:
111
134
  - spec/phantomjs_spec.rb
112
135
  - spec/platform_spec.rb
113
136
  - spec/spec_helper.rb
114
- has_rdoc: