slimerjs-gem 0.9.1.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 +7 -0
- data/.gitignore +22 -0
- data/.travis.yml +16 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +50 -0
- data/Rakefile +2 -0
- data/lib/slimerjs.rb +61 -0
- data/lib/slimerjs/platform.rb +184 -0
- data/lib/slimerjs/version.rb +3 -0
- data/slimerjs-gem.gemspec +24 -0
- data/spec/platform_spec.rb +203 -0
- data/spec/runner.js +7 -0
- data/spec/slimerjs_spec.rb +18 -0
- data/spec/spec_helper.rb +10 -0
- metadata +118 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d37db1a63e4e344572d7e74dc3eaf145da815f4b
|
4
|
+
data.tar.gz: 0674efc530ef9ccb8ea99af92cf6bdfae66f34e0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 95b449da1cd8d86ba2546b856132b442b8b88f41dcda43c61a710697ae7ade20b16706d3ba539734b7e1f22a059eaa916884e0d8b319ca94a02335629eb7dc85
|
7
|
+
data.tar.gz: e8bf3c37815be089dbad82dfddcdb78f432ee4a6b79dffa923305e8e8f6684da8980ffa34de27ab73df190a68b381003986142abad8269d974b4565397f2166c
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/.travis.yml
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
before_install:
|
2
|
+
- "export DISPLAY=:99.0"
|
3
|
+
- "sh -e /etc/init.d/xvfb start"
|
4
|
+
script:
|
5
|
+
- bundle
|
6
|
+
- bundle exec rspec
|
7
|
+
rvm:
|
8
|
+
- 1.9
|
9
|
+
- 2.0
|
10
|
+
- 2.1
|
11
|
+
- jruby-19mode
|
12
|
+
- rbx-2.2.7
|
13
|
+
notifications:
|
14
|
+
email:
|
15
|
+
on_success: always
|
16
|
+
on_failure: always
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Mark Tareshawty
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# Slimerjs-Gem
|
2
|
+
[](https://travis-ci.org/tarebyte/slimerjs-gem)
|
3
|
+
|
4
|
+
## Work in progress
|
5
|
+
|
6
|
+
This is basically a knock off of the [PhantomJS Gem](https://github.com/colszowka/phantomjs-gem) for [SlimerJS](http://slimerjs.org/)
|
7
|
+
|
8
|
+
For now this supports the [standalone edition](http://slimerjs.org/download.html#standalone) only
|
9
|
+
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Add this line to your application's Gemfile:
|
14
|
+
|
15
|
+
gem 'slimerjs'
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install slimerjs
|
24
|
+
|
25
|
+
## Example
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
# Standalone
|
29
|
+
require 'slimerjs'
|
30
|
+
```
|
31
|
+
|
32
|
+
## Contributing
|
33
|
+
|
34
|
+
1. Fork it ( https://github.com/tarebyte/slimerjs-gem/fork )
|
35
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
36
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
37
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
38
|
+
5. Create a new Pull Request
|
39
|
+
|
40
|
+
## Thanks
|
41
|
+
|
42
|
+
To [Chris Olszowka](https://github.com/colszowka) for the [PhantomJS Gem](https://github.com/colszowka/phantomjs-gem) which
|
43
|
+
has had a heavy influence on this project.
|
44
|
+
|
45
|
+
## Copyright
|
46
|
+
|
47
|
+
(c) 2014 Mark Tareshawty
|
48
|
+
|
49
|
+
Note that this project merely simplifies the installation of the entirely separate SlimerJS project via a Ruby gem.
|
50
|
+
You can find the license information for SlimerJS at [http://slimerjs.org/](http://slimerjs.org/)
|
data/Rakefile
ADDED
data/lib/slimerjs.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
require "slimerjs/version"
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
module Slimerjs
|
5
|
+
class UnknownPlatform < StandardError; end;
|
6
|
+
|
7
|
+
class << self
|
8
|
+
def available_platforms
|
9
|
+
@available_platforms ||= []
|
10
|
+
end
|
11
|
+
|
12
|
+
def base_dir
|
13
|
+
@base_dir ||= File.join(File.expand_path('~'), '.slimerjs', version)
|
14
|
+
end
|
15
|
+
|
16
|
+
def base_dir=(dir)
|
17
|
+
@base_dir = dir
|
18
|
+
end
|
19
|
+
|
20
|
+
def version
|
21
|
+
Slimerjs::VERSION.split('.')[0..-2].join('.')
|
22
|
+
end
|
23
|
+
|
24
|
+
def path
|
25
|
+
@path ||= platform.slimerjs_path
|
26
|
+
end
|
27
|
+
|
28
|
+
def platform
|
29
|
+
if platform = available_platforms.find {|p| p.useable? }
|
30
|
+
platform.ensure_installed!
|
31
|
+
platform
|
32
|
+
else
|
33
|
+
raise UnknownPlatform, "Could not find an appropriate SlimerJS library for your platform (#{RUBY_PLATFORM} :( Please install manually."
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# Removes the local slimerjs copy
|
38
|
+
def implode!
|
39
|
+
FileUtils.rm_rf File.join(File.expand_path('~'), '.slimerjs')
|
40
|
+
end
|
41
|
+
|
42
|
+
# Clears cached state. Primarily useful for testing.
|
43
|
+
def reset!
|
44
|
+
@base_dir = @path = nil
|
45
|
+
end
|
46
|
+
|
47
|
+
# Run slimerjs with the given arguments, and either
|
48
|
+
# return the stdout or yield each line to the passed block.
|
49
|
+
def run(*args, &block)
|
50
|
+
IO.popen([path, *args]) do |io|
|
51
|
+
block ? io.each(&block) : io.read
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
require 'slimerjs/platform'
|
58
|
+
Slimerjs.available_platforms << Slimerjs::Platform::Linux32
|
59
|
+
Slimerjs.available_platforms << Slimerjs::Platform::Linux64
|
60
|
+
Slimerjs.available_platforms << Slimerjs::Platform::OsX
|
61
|
+
Slimerjs.available_platforms << Slimerjs::Platform::Win32
|
@@ -0,0 +1,184 @@
|
|
1
|
+
module Slimerjs
|
2
|
+
class Platform
|
3
|
+
class << self
|
4
|
+
def host_os
|
5
|
+
RbConfig::CONFIG['host_os']
|
6
|
+
end
|
7
|
+
|
8
|
+
def architecture
|
9
|
+
RbConfig::CONFIG['host_cpu']
|
10
|
+
end
|
11
|
+
|
12
|
+
def temp_path
|
13
|
+
ENV['TMPDIR'] || ENV['TEMP'] || '/tmp'
|
14
|
+
end
|
15
|
+
|
16
|
+
def slimerjs_path
|
17
|
+
if system_slimerjs_installed?
|
18
|
+
system_slimerjs_path
|
19
|
+
else
|
20
|
+
File.expand_path File.join(Slimerjs.base_dir, platform, 'slimerjs')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def system_slimerjs_path
|
25
|
+
`which slimerjs`.delete("\n")
|
26
|
+
rescue
|
27
|
+
end
|
28
|
+
|
29
|
+
def system_slimerjs_version
|
30
|
+
`slimerjs --version`.delete("\n") if system_slimerjs_path.length > 4.2
|
31
|
+
rescue
|
32
|
+
end
|
33
|
+
|
34
|
+
def system_slimerjs_installed?
|
35
|
+
system_slimerjs_version == Slimerjs.version
|
36
|
+
end
|
37
|
+
|
38
|
+
def installed?
|
39
|
+
File.exist?(slimerjs_path) || system_slimerjs_installed?
|
40
|
+
end
|
41
|
+
|
42
|
+
# TODO: Clean this up, it looks like a pile of...
|
43
|
+
def install!
|
44
|
+
STDERR.puts "Slimerjs does not appear to be installed in #{slimerjs_path}, installing!"
|
45
|
+
FileUtils.mkdir_p Slimerjs.base_dir
|
46
|
+
|
47
|
+
# Purge temporary directory if it is still hanging around from previous installs,
|
48
|
+
# then re-create it.
|
49
|
+
temp_dir = File.join(temp_path, 'slimerjs_install')
|
50
|
+
FileUtils.rm_rf temp_dir
|
51
|
+
FileUtils.mkdir_p temp_dir
|
52
|
+
|
53
|
+
Dir.chdir temp_dir do
|
54
|
+
unless system "curl -O #{package_url}" or system "wget #{package_url}"
|
55
|
+
raise "\n\nFailed to load slimerjs! :(\nYou need to have cURL or wget installed on your system.\nIf you have, the source of slimerjs might be unavailable: #{package_url}\n\n"
|
56
|
+
end
|
57
|
+
|
58
|
+
case package_url.split('.').last
|
59
|
+
when 'bz2'
|
60
|
+
system "bunzip2 #{File.basename(package_url)}"
|
61
|
+
system "tar xf #{File.basename(package_url).sub(/\.bz2$/, '')}"
|
62
|
+
when 'zip'
|
63
|
+
system "unzip #{File.basename(package_url)}"
|
64
|
+
else
|
65
|
+
raise "Unknown compression format for #{File.basename(package_url)}"
|
66
|
+
end
|
67
|
+
|
68
|
+
# Find the slimerjs build we just extracted
|
69
|
+
extracted_dir = Dir['slimerjs*'].find { |path| File.directory?(path) }
|
70
|
+
|
71
|
+
# Move the extracted slimerjs build to $HOME/.slimerjs/version/platform
|
72
|
+
if FileUtils.mv extracted_dir, File.join(Slimerjs.base_dir, platform)
|
73
|
+
STDOUT.puts "\nSuccessfully installed slimerjs. Yay!"
|
74
|
+
end
|
75
|
+
|
76
|
+
# Clean up remaining files in tmp
|
77
|
+
if FileUtils.rm_rf temp_dir
|
78
|
+
STDOUT.puts "Removed temporarily downloaded files."
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
raise "Failed to install slimerjs. Sorry :(" unless File.exist?(slimerjs_path)
|
83
|
+
end
|
84
|
+
|
85
|
+
def ensure_installed!
|
86
|
+
install! unless installed?
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
class Lightweight < Platform
|
91
|
+
class << self
|
92
|
+
def useable
|
93
|
+
# WIP come back and fix this
|
94
|
+
(
|
95
|
+
Slimerjs::Platform::Linux32.useable? ||
|
96
|
+
Slimerjs::Platform::Linux32.useable? ||
|
97
|
+
Slimerjs::Platform::OsX.useable? ||
|
98
|
+
Slimerjs::Platform::Win32.useable?
|
99
|
+
)
|
100
|
+
end
|
101
|
+
|
102
|
+
def platform
|
103
|
+
'lightweight'
|
104
|
+
end
|
105
|
+
|
106
|
+
def package_url
|
107
|
+
'http://download.slimerjs.org/v0.9/0.9.1/slimerjs-0.9.1.zip'
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
class Linux64 < Platform
|
113
|
+
class << self
|
114
|
+
def useable?
|
115
|
+
host_os.include?('linux') and architecture.include?('x86_64')
|
116
|
+
end
|
117
|
+
|
118
|
+
def platform
|
119
|
+
'x86_64-linux'
|
120
|
+
end
|
121
|
+
|
122
|
+
def package_url
|
123
|
+
'http://download.slimerjs.org/v0.9/0.9.1/slimerjs-0.9.1-linux-x86_64.tar.bz2'
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
class Linux32 < Platform
|
129
|
+
class << self
|
130
|
+
def useable?
|
131
|
+
host_os.include?('linux') and (architecture.include?('x86_32') or architecture.include?('i686'))
|
132
|
+
end
|
133
|
+
|
134
|
+
def platform
|
135
|
+
'x86_32-linux'
|
136
|
+
end
|
137
|
+
|
138
|
+
def package_url
|
139
|
+
'http://download.slimerjs.org/v0.9/0.9.1/slimerjs-0.9.1-linux-i686.tar.bz2'
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
class OsX < Platform
|
145
|
+
class << self
|
146
|
+
def useable?
|
147
|
+
host_os.include?('darwin')
|
148
|
+
end
|
149
|
+
|
150
|
+
def platform
|
151
|
+
'darwin'
|
152
|
+
end
|
153
|
+
|
154
|
+
def package_url
|
155
|
+
'http://download.slimerjs.org/v0.9/0.9.1/slimerjs-0.9.1-mac.tar.bz2'
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
class Win32 < Platform
|
161
|
+
class << self
|
162
|
+
def useable?
|
163
|
+
host_os.include?('mingw32') and architecture.include?('i686')
|
164
|
+
end
|
165
|
+
|
166
|
+
def platform
|
167
|
+
'win32'
|
168
|
+
end
|
169
|
+
|
170
|
+
def slimerjs_path
|
171
|
+
if system_slimerjs_installed?
|
172
|
+
system_slimerjs_path
|
173
|
+
else
|
174
|
+
File.expand_path File.join(Slimerjs.base_dir, platform, 'slimerjs.bat')
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
def package_url
|
179
|
+
'http://download.slimerjs.org/v0.9/0.9.1/slimerjs-0.9.1-win32.zip'
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'slimerjs/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "slimerjs-gem"
|
8
|
+
spec.version = Slimerjs::VERSION
|
9
|
+
spec.authors = ["Mark Tareshawty"]
|
10
|
+
spec.email = ["tarebyte@gmail.com"]
|
11
|
+
spec.summary = %q{Auto-install slimerjs on demand for current platform.}
|
12
|
+
spec.description = %q{Auto-install slimerjs on demand for current platform.}
|
13
|
+
spec.homepage = "https://github.com/tarebyte/slimerjs-gem"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
21
|
+
spec.add_development_dependency "rake"
|
22
|
+
spec.add_development_dependency "rspec"
|
23
|
+
spec.add_development_dependency "simplecov"
|
24
|
+
end
|
@@ -0,0 +1,203 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Slimerjs::Platform do
|
4
|
+
before(:each) { Slimerjs.reset! }
|
5
|
+
describe "with a system install present" do
|
6
|
+
describe "#system_slimerjs_installed?" do
|
7
|
+
it "is true when the system version matches Slimerjs.version" do
|
8
|
+
Slimerjs::Platform.should_receive(:system_slimerjs_version).and_return(Slimerjs.version)
|
9
|
+
expect(Slimerjs::Platform.system_slimerjs_installed?).to be_true
|
10
|
+
end
|
11
|
+
|
12
|
+
it "is false when the system version does not match Slimerjs.version" do
|
13
|
+
Slimerjs::Platform.should_receive(:system_slimerjs_version).and_return('0.9.1')
|
14
|
+
expect(Slimerjs::Platform.system_slimerjs_installed?).to be_false
|
15
|
+
end
|
16
|
+
|
17
|
+
it "is false when there's no system version" do
|
18
|
+
Slimerjs::Platform.should_receive(:system_slimerjs_version).and_return(nil)
|
19
|
+
expect(Slimerjs::Platform.system_slimerjs_installed?).to be_false
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "on a 64 bit linux" do
|
25
|
+
before do
|
26
|
+
Slimerjs::Platform.stub(:host_os).and_return('linux-gnu')
|
27
|
+
Slimerjs::Platform.stub(:architecture).and_return('x86_64')
|
28
|
+
end
|
29
|
+
|
30
|
+
it "reports the Linux64 Platform as useable" do
|
31
|
+
Slimerjs::Platform::Linux64.should be_useable
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "without system install" do
|
35
|
+
before(:each) { Slimerjs::Platform.stub(:system_slimerjs_version).and_return(nil) }
|
36
|
+
|
37
|
+
it "returns the correct slimer js executable path for the platform" do
|
38
|
+
Slimerjs.path.should =~ /x86_64-linux\/slimerjs$/
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "with system install" do
|
43
|
+
before(:each) do
|
44
|
+
Slimerjs::Platform.stub(:system_slimerjs_version).and_return(Slimerjs.version)
|
45
|
+
Slimerjs::Platform.stub(:system_slimerjs_path).and_return('/tmp/path')
|
46
|
+
end
|
47
|
+
|
48
|
+
it "returns the correct slimer js executable path for the platform" do
|
49
|
+
expect(Slimerjs.path).to be == '/tmp/path'
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
it "reports the Linux32 platform as unuseable" do
|
54
|
+
Slimerjs::Platform::Linux32.should_not be_useable
|
55
|
+
end
|
56
|
+
|
57
|
+
it "reports the Darwin platform as unuseable" do
|
58
|
+
Slimerjs::Platform::OsX.should_not be_useable
|
59
|
+
end
|
60
|
+
|
61
|
+
it "reports the Win32 Platform as unuseable" do
|
62
|
+
Slimerjs::Platform::Win32.should_not be_useable
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe "on a 32 bit linux" do
|
67
|
+
before do
|
68
|
+
Slimerjs::Platform.stub(:host_os).and_return('linux-gnu')
|
69
|
+
Slimerjs::Platform.stub(:architecture).and_return('x86_32')
|
70
|
+
end
|
71
|
+
|
72
|
+
it "reports the Linux32 Platform as useable" do
|
73
|
+
Slimerjs::Platform::Linux32.should be_useable
|
74
|
+
end
|
75
|
+
|
76
|
+
it "reports another Linux32 Platform as useable" do
|
77
|
+
Slimerjs::Platform.stub(:host_os).and_return('linux-gnu')
|
78
|
+
Slimerjs::Platform.stub(:architecture).and_return('i686')
|
79
|
+
Slimerjs::Platform::Linux32.should be_useable
|
80
|
+
end
|
81
|
+
|
82
|
+
describe "without system install" do
|
83
|
+
before(:each) { Slimerjs::Platform.stub(:system_slimerjs_version).and_return(nil) }
|
84
|
+
|
85
|
+
it "returns the correct slimer js executable path for the platform" do
|
86
|
+
Slimerjs.path.should =~ /x86_32-linux\/slimerjs$/
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe "with system install" do
|
91
|
+
before(:each) do
|
92
|
+
Slimerjs::Platform.stub(:system_slimerjs_version).and_return(Slimerjs.version)
|
93
|
+
Slimerjs::Platform.stub(:system_slimerjs_path).and_return('/tmp/path')
|
94
|
+
end
|
95
|
+
|
96
|
+
it "returns the correct slimer js executable path for the platform" do
|
97
|
+
expect(Slimerjs.path).to be == '/tmp/path'
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
it "reports the Linux64 platform as unuseable" do
|
102
|
+
Slimerjs::Platform::Linux64.should_not be_useable
|
103
|
+
end
|
104
|
+
|
105
|
+
it "reports the Darwin platform as unuseable" do
|
106
|
+
Slimerjs::Platform::OsX.should_not be_useable
|
107
|
+
end
|
108
|
+
|
109
|
+
it "reports the Win32 Platform as unuseable" do
|
110
|
+
Slimerjs::Platform::Win32.should_not be_useable
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
describe "on OS X" do
|
115
|
+
before do
|
116
|
+
Slimerjs::Platform.stub(:host_os).and_return('darwin')
|
117
|
+
Slimerjs::Platform.stub(:architecture).and_return('x86_64')
|
118
|
+
end
|
119
|
+
|
120
|
+
it "reports the Darwin platform as useable" do
|
121
|
+
Slimerjs::Platform::OsX.should be_useable
|
122
|
+
end
|
123
|
+
|
124
|
+
describe "without system install" do
|
125
|
+
before(:each) { Slimerjs::Platform.stub(:system_slimerjs_version).and_return(nil) }
|
126
|
+
|
127
|
+
it "returns the correct slimer js executable path for the platform" do
|
128
|
+
Slimerjs.path.should =~ /darwin\/slimerjs$/
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
describe "with system install" do
|
133
|
+
before(:each) do
|
134
|
+
Slimerjs::Platform.stub(:system_slimerjs_version).and_return(Slimerjs.version)
|
135
|
+
Slimerjs::Platform.stub(:system_slimerjs_path).and_return('/tmp/path')
|
136
|
+
end
|
137
|
+
|
138
|
+
it "returns the correct slimer js executable path for the platform" do
|
139
|
+
expect(Slimerjs.path).to be == '/tmp/path'
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
it "reports the Linux32 Platform as unuseable" do
|
144
|
+
Slimerjs::Platform::Linux32.should_not be_useable
|
145
|
+
end
|
146
|
+
|
147
|
+
it "reports the Linux64 platform as unuseable" do
|
148
|
+
Slimerjs::Platform::Linux64.should_not be_useable
|
149
|
+
end
|
150
|
+
|
151
|
+
it "reports the Win32 Platform as unuseable" do
|
152
|
+
Slimerjs::Platform::Win32.should_not be_useable
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
describe "on Windows" do
|
157
|
+
before do
|
158
|
+
Slimerjs::Platform.stub(:host_os).and_return('mingw32')
|
159
|
+
Slimerjs::Platform.stub(:architecture).and_return('i686')
|
160
|
+
end
|
161
|
+
|
162
|
+
describe "without system install" do
|
163
|
+
before(:each) { Slimerjs::Platform.stub(:system_slimerjs_version).and_return(nil) }
|
164
|
+
|
165
|
+
it "returns the correct slimer js executable path for the platform" do
|
166
|
+
Slimerjs.path.should =~ /win32\/slimerjs.bat$/
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
describe "with system install" do
|
171
|
+
before(:each) do
|
172
|
+
Slimerjs::Platform.stub(:system_slimerjs_version).and_return(Slimerjs.version)
|
173
|
+
Slimerjs::Platform.stub(:system_slimerjs_path).and_return("#{ENV['TEMP']}/path")
|
174
|
+
end
|
175
|
+
|
176
|
+
it "returns the correct slimer js executable path for the platform" do
|
177
|
+
expect(Slimerjs.path).to be == "#{ENV['TEMP']}/path"
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
it "reports the Darwin platform as unuseable" do
|
182
|
+
Slimerjs::Platform::OsX.should_not be_useable
|
183
|
+
end
|
184
|
+
|
185
|
+
it "reports the Linux32 Platform as unuseable" do
|
186
|
+
Slimerjs::Platform::Linux32.should_not be_useable
|
187
|
+
end
|
188
|
+
|
189
|
+
it "reports the Linux64 platform as unuseable" do
|
190
|
+
Slimerjs::Platform::Linux64.should_not be_useable
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
describe 'on an unknown platform' do
|
195
|
+
before do
|
196
|
+
Slimerjs::Platform.stub(:host_os).and_return('foobar')
|
197
|
+
end
|
198
|
+
|
199
|
+
it "raises an UnknownPlatform error" do
|
200
|
+
-> { Slimerjs.platform }.should raise_error(Slimerjs::UnknownPlatform)
|
201
|
+
end
|
202
|
+
end
|
203
|
+
end
|
data/spec/runner.js
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Slimerjs do
|
4
|
+
describe ".run" do
|
5
|
+
it "runs slimerjs binary with the correct arguments" do
|
6
|
+
script = File.expand_path('./spec/runner.js')
|
7
|
+
result = Slimerjs.run(script, 'foo1', 'foo2')
|
8
|
+
result.should eq("bar foo1\nbar foo2\n")
|
9
|
+
end
|
10
|
+
|
11
|
+
it "accepts a block that will get called for each line of output" do
|
12
|
+
lines = []
|
13
|
+
script = File.expand_path('./spec/runner.js')
|
14
|
+
Slimerjs.run(script, 'foo1', 'foo2') { |line| lines << line }
|
15
|
+
lines.should eq(["bar foo1\n", "bar foo2\n"])
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: slimerjs-gem
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mark Tareshawty
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-06-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: simplecov
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Auto-install slimerjs on demand for current platform.
|
70
|
+
email:
|
71
|
+
- tarebyte@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".travis.yml"
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- lib/slimerjs.rb
|
83
|
+
- lib/slimerjs/platform.rb
|
84
|
+
- lib/slimerjs/version.rb
|
85
|
+
- slimerjs-gem.gemspec
|
86
|
+
- spec/platform_spec.rb
|
87
|
+
- spec/runner.js
|
88
|
+
- spec/slimerjs_spec.rb
|
89
|
+
- spec/spec_helper.rb
|
90
|
+
homepage: https://github.com/tarebyte/slimerjs-gem
|
91
|
+
licenses: []
|
92
|
+
metadata: {}
|
93
|
+
post_install_message:
|
94
|
+
rdoc_options: []
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
requirements: []
|
108
|
+
rubyforge_project:
|
109
|
+
rubygems_version: 2.2.2
|
110
|
+
signing_key:
|
111
|
+
specification_version: 4
|
112
|
+
summary: Auto-install slimerjs on demand for current platform.
|
113
|
+
test_files:
|
114
|
+
- spec/platform_spec.rb
|
115
|
+
- spec/runner.js
|
116
|
+
- spec/slimerjs_spec.rb
|
117
|
+
- spec/spec_helper.rb
|
118
|
+
has_rdoc:
|