phantomjs.rb 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (195) hide show
  1. data/.autotest +7 -0
  2. data/.gitignore +4 -0
  3. data/Gemfile +4 -0
  4. data/README.md +16 -0
  5. data/Rakefile +1 -0
  6. data/lib/phantomjs.rb +53 -0
  7. data/lib/phantomjs/version.rb +3 -0
  8. data/phantomjs.rb.gemspec +24 -0
  9. data/spec/phantomjs_spec.rb +13 -0
  10. data/spec/runner.js +2 -0
  11. data/vendor/phantomjs-1.4.1_OSX/ChangeLog +145 -0
  12. data/vendor/phantomjs-1.4.1_OSX/LICENSE.BSD +22 -0
  13. data/vendor/phantomjs-1.4.1_OSX/README.md +33 -0
  14. data/vendor/phantomjs-1.4.1_OSX/bin/Info.plist +12 -0
  15. data/vendor/phantomjs-1.4.1_OSX/bin/phantomjs +0 -0
  16. data/vendor/phantomjs-1.4.1_OSX/examples/arguments.coffee +6 -0
  17. data/vendor/phantomjs-1.4.1_OSX/examples/arguments.js +8 -0
  18. data/vendor/phantomjs-1.4.1_OSX/examples/colorwheel.coffee +46 -0
  19. data/vendor/phantomjs-1.4.1_OSX/examples/colorwheel.js +51 -0
  20. data/vendor/phantomjs-1.4.1_OSX/examples/countdown.coffee +8 -0
  21. data/vendor/phantomjs-1.4.1_OSX/examples/countdown.js +9 -0
  22. data/vendor/phantomjs-1.4.1_OSX/examples/detectsniff.coffee +40 -0
  23. data/vendor/phantomjs-1.4.1_OSX/examples/detectsniff.js +57 -0
  24. data/vendor/phantomjs-1.4.1_OSX/examples/direction.coffee +29 -0
  25. data/vendor/phantomjs-1.4.1_OSX/examples/direction.js +34 -0
  26. data/vendor/phantomjs-1.4.1_OSX/examples/echoToFile.coffee +19 -0
  27. data/vendor/phantomjs-1.4.1_OSX/examples/echoToFile.js +22 -0
  28. data/vendor/phantomjs-1.4.1_OSX/examples/features.js +30 -0
  29. data/vendor/phantomjs-1.4.1_OSX/examples/fibo.coffee +8 -0
  30. data/vendor/phantomjs-1.4.1_OSX/examples/fibo.js +9 -0
  31. data/vendor/phantomjs-1.4.1_OSX/examples/follow.coffee +54 -0
  32. data/vendor/phantomjs-1.4.1_OSX/examples/follow.js +59 -0
  33. data/vendor/phantomjs-1.4.1_OSX/examples/hello.coffee +2 -0
  34. data/vendor/phantomjs-1.4.1_OSX/examples/hello.js +2 -0
  35. data/vendor/phantomjs-1.4.1_OSX/examples/imagebin.coffee +19 -0
  36. data/vendor/phantomjs-1.4.1_OSX/examples/imagebin.js +22 -0
  37. data/vendor/phantomjs-1.4.1_OSX/examples/injectme.coffee +23 -0
  38. data/vendor/phantomjs-1.4.1_OSX/examples/injectme.js +25 -0
  39. data/vendor/phantomjs-1.4.1_OSX/examples/ipgeocode.coffee +13 -0
  40. data/vendor/phantomjs-1.4.1_OSX/examples/ipgeocode.js +14 -0
  41. data/vendor/phantomjs-1.4.1_OSX/examples/loadspeed.coffee +17 -0
  42. data/vendor/phantomjs-1.4.1_OSX/examples/loadspeed.js +22 -0
  43. data/vendor/phantomjs-1.4.1_OSX/examples/modernizr.js +1116 -0
  44. data/vendor/phantomjs-1.4.1_OSX/examples/movies.coffee +13 -0
  45. data/vendor/phantomjs-1.4.1_OSX/examples/movies.js +14 -0
  46. data/vendor/phantomjs-1.4.1_OSX/examples/netlog.coffee +17 -0
  47. data/vendor/phantomjs-1.4.1_OSX/examples/netlog.js +23 -0
  48. data/vendor/phantomjs-1.4.1_OSX/examples/netsniff.coffee +109 -0
  49. data/vendor/phantomjs-1.4.1_OSX/examples/netsniff.js +131 -0
  50. data/vendor/phantomjs-1.4.1_OSX/examples/outputEncoding.coffee +12 -0
  51. data/vendor/phantomjs-1.4.1_OSX/examples/outputEncoding.js +16 -0
  52. data/vendor/phantomjs-1.4.1_OSX/examples/phantomwebintro.coffee +13 -0
  53. data/vendor/phantomjs-1.4.1_OSX/examples/phantomwebintro.js +19 -0
  54. data/vendor/phantomjs-1.4.1_OSX/examples/pizza.coffee +18 -0
  55. data/vendor/phantomjs-1.4.1_OSX/examples/pizza.js +20 -0
  56. data/vendor/phantomjs-1.4.1_OSX/examples/post.coffee +12 -0
  57. data/vendor/phantomjs-1.4.1_OSX/examples/post.js +14 -0
  58. data/vendor/phantomjs-1.4.1_OSX/examples/rasterize.coffee +22 -0
  59. data/vendor/phantomjs-1.4.1_OSX/examples/rasterize.js +27 -0
  60. data/vendor/phantomjs-1.4.1_OSX/examples/render_multi_url.coffee +48 -0
  61. data/vendor/phantomjs-1.4.1_OSX/examples/render_multi_url.js +60 -0
  62. data/vendor/phantomjs-1.4.1_OSX/examples/run-jasmine.coffee +59 -0
  63. data/vendor/phantomjs-1.4.1_OSX/examples/run-jasmine.js +77 -0
  64. data/vendor/phantomjs-1.4.1_OSX/examples/run-qunit.coffee +62 -0
  65. data/vendor/phantomjs-1.4.1_OSX/examples/run-qunit.js +74 -0
  66. data/vendor/phantomjs-1.4.1_OSX/examples/scandir.coffee +15 -0
  67. data/vendor/phantomjs-1.4.1_OSX/examples/scandir.js +21 -0
  68. data/vendor/phantomjs-1.4.1_OSX/examples/seasonfood.coffee +17 -0
  69. data/vendor/phantomjs-1.4.1_OSX/examples/seasonfood.js +19 -0
  70. data/vendor/phantomjs-1.4.1_OSX/examples/simpleserver.coffee +35 -0
  71. data/vendor/phantomjs-1.4.1_OSX/examples/simpleserver.js +40 -0
  72. data/vendor/phantomjs-1.4.1_OSX/examples/sleepsort.coffee +17 -0
  73. data/vendor/phantomjs-1.4.1_OSX/examples/sleepsort.js +24 -0
  74. data/vendor/phantomjs-1.4.1_OSX/examples/technews.coffee +17 -0
  75. data/vendor/phantomjs-1.4.1_OSX/examples/technews.js +16 -0
  76. data/vendor/phantomjs-1.4.1_OSX/examples/tweets.coffee +30 -0
  77. data/vendor/phantomjs-1.4.1_OSX/examples/tweets.js +36 -0
  78. data/vendor/phantomjs-1.4.1_OSX/examples/unrandomize.coffee +18 -0
  79. data/vendor/phantomjs-1.4.1_OSX/examples/unrandomize.js +24 -0
  80. data/vendor/phantomjs-1.4.1_OSX/examples/useragent.coffee +11 -0
  81. data/vendor/phantomjs-1.4.1_OSX/examples/useragent.js +14 -0
  82. data/vendor/phantomjs-1.4.1_OSX/examples/version.coffee +5 -0
  83. data/vendor/phantomjs-1.4.1_OSX/examples/version.js +5 -0
  84. data/vendor/phantomjs-1.4.1_OSX/examples/waitfor.coffee +48 -0
  85. data/vendor/phantomjs-1.4.1_OSX/examples/waitfor.js +57 -0
  86. data/vendor/phantomjs-1.4.1_OSX/examples/weather.coffee +48 -0
  87. data/vendor/phantomjs-1.4.1_OSX/examples/weather.js +57 -0
  88. data/vendor/phantomjs-1.4.1_OSX/lib/jquery.js +8374 -0
  89. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/ChangeLog +177 -0
  90. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/LICENSE.BSD +22 -0
  91. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/README.md +33 -0
  92. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/bin/Info.plist +12 -0
  93. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/bin/phantomjs +0 -0
  94. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/arguments.coffee +7 -0
  95. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/arguments.js +9 -0
  96. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/colorwheel.coffee +46 -0
  97. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/colorwheel.js +51 -0
  98. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/countdown.coffee +8 -0
  99. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/countdown.js +9 -0
  100. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/detectsniff.coffee +41 -0
  101. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/detectsniff.js +58 -0
  102. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/direction.coffee +30 -0
  103. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/direction.js +35 -0
  104. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/echoToFile.coffee +20 -0
  105. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/echoToFile.js +24 -0
  106. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/features.js +30 -0
  107. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/fibo.coffee +8 -0
  108. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/fibo.js +9 -0
  109. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/follow.coffee +29 -0
  110. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/follow.js +34 -0
  111. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/hello.coffee +2 -0
  112. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/hello.js +2 -0
  113. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/imagebin.coffee +20 -0
  114. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/imagebin.js +23 -0
  115. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/injectme.coffee +23 -0
  116. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/injectme.js +25 -0
  117. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/ipgeocode.coffee +13 -0
  118. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/ipgeocode.js +14 -0
  119. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/loadspeed.coffee +18 -0
  120. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/loadspeed.js +23 -0
  121. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/modernizr.js +1116 -0
  122. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/movies.coffee +13 -0
  123. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/movies.js +14 -0
  124. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/netlog.coffee +18 -0
  125. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/netlog.js +25 -0
  126. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/netsniff.coffee +110 -0
  127. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/netsniff.js +132 -0
  128. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/outputEncoding.coffee +12 -0
  129. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/outputEncoding.js +16 -0
  130. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/phantomwebintro.coffee +13 -0
  131. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/phantomwebintro.js +19 -0
  132. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/pizza.coffee +18 -0
  133. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/pizza.js +20 -0
  134. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/post.coffee +12 -0
  135. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/post.js +14 -0
  136. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/postserver.js +34 -0
  137. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/printenv.js +10 -0
  138. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/printmargins.js +35 -0
  139. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/rasterize.coffee +23 -0
  140. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/rasterize.js +28 -0
  141. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/render_multi_url.coffee +50 -0
  142. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/render_multi_url.js +62 -0
  143. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/run-jasmine.coffee +61 -0
  144. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/run-jasmine.js +79 -0
  145. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/run-qunit.coffee +64 -0
  146. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/run-qunit.js +76 -0
  147. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/scandir.coffee +16 -0
  148. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/scandir.js +22 -0
  149. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/seasonfood.coffee +17 -0
  150. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/seasonfood.js +19 -0
  151. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/server.js +43 -0
  152. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/serverkeepalive.js +34 -0
  153. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/simpleserver.coffee +38 -0
  154. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/simpleserver.js +42 -0
  155. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/sleepsort.coffee +20 -0
  156. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/sleepsort.js +25 -0
  157. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/technews.coffee +17 -0
  158. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/technews.js +16 -0
  159. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/tweets.coffee +31 -0
  160. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/tweets.js +37 -0
  161. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/unrandomize.coffee +18 -0
  162. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/unrandomize.js +24 -0
  163. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/useragent.coffee +11 -0
  164. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/useragent.js +14 -0
  165. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/version.coffee +5 -0
  166. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/version.js +5 -0
  167. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/waitfor.coffee +48 -0
  168. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/waitfor.js +57 -0
  169. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/weather.coffee +49 -0
  170. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/weather.js +58 -0
  171. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtCore.la +28 -0
  172. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtCore.prl +7 -0
  173. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtCore.so +0 -0
  174. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtCore.so.4 +0 -0
  175. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtCore.so.4.8 +0 -0
  176. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtCore.so.4.8.0 +0 -0
  177. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtGui.la +28 -0
  178. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtGui.prl +7 -0
  179. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtGui.so +0 -0
  180. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtGui.so.4 +0 -0
  181. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtGui.so.4.8 +0 -0
  182. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtGui.so.4.8.0 +0 -0
  183. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtNetwork.la +28 -0
  184. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtNetwork.prl +7 -0
  185. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtNetwork.so +0 -0
  186. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtNetwork.so.4 +0 -0
  187. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtNetwork.so.4.8 +0 -0
  188. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtNetwork.so.4.8.0 +0 -0
  189. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtWebKit.la +28 -0
  190. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtWebKit.prl +6 -0
  191. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtWebKit.so +0 -0
  192. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtWebKit.so.4 +0 -0
  193. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtWebKit.so.4.9 +0 -0
  194. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtWebKit.so.4.9.0 +0 -0
  195. metadata +252 -0
data/.autotest ADDED
@@ -0,0 +1,7 @@
1
+ require 'autotest/restart'
2
+
3
+ Autotest.add_hook :initialize do |at|
4
+ at.add_mapping(/.*/) do |f, _|
5
+ at.files_matching(/.*.rb$/)
6
+ end
7
+ end
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in phantomjs.rb.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,16 @@
1
+ # phantomjs.rb
2
+
3
+ A ruby wrapper for phantomjs
4
+
5
+ ## Install
6
+
7
+ ```sh
8
+ gem install phantomjs.rb
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```rb
14
+ output = Phantomjs.run(script_name, arg1, arg2)
15
+ p output # Whatever it outputs from stdout
16
+ ```
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/lib/phantomjs.rb ADDED
@@ -0,0 +1,53 @@
1
+ require "phantomjs/version"
2
+
3
+ module Phantomjs
4
+ # Fight the power
5
+ extend self
6
+
7
+ # Public: Runs the phantomjs binary
8
+ #
9
+ # script - The absolute path to the script
10
+ # *args - The arguments to pass to the script
11
+ #
12
+ # Returns the stdout output of phantomjs
13
+ def run(script, *args)
14
+ string_args = args.join(" ")
15
+ @executable ||= get_executable
16
+ `#{@executable} #{script} #{string_args}`
17
+ end
18
+
19
+ private
20
+
21
+ def get_executable
22
+ if Os.is_mac?
23
+ File.expand_path("./vendor/phantomjs-1.4.1_OSX/bin/phantomjs")
24
+ elsif Os.is_linux?
25
+ File.expand_path("./vendor/phantomjs-1.5.0-liunx-x86-dynamic/bin/phantomjs")
26
+ else
27
+ # Sorry windows guy
28
+ # Nothing here
29
+ end
30
+ end
31
+ end
32
+
33
+ module Os
34
+ # Again, Fight the power
35
+ extend self
36
+
37
+ # universal-darwin9.0 shows up for RUBY_PLATFORM on os X leopard with the bundled ruby.
38
+ # Installing ruby in different manners may give a different result, so beware.
39
+ # Examine the ruby platform yourself. If you see other values please comment
40
+ # in the snippet on dzone and I will add them.
41
+
42
+ def is_mac?
43
+ RUBY_PLATFORM.downcase.include?("darwin")
44
+ end
45
+
46
+ def is_windows?
47
+ RUBY_PLATFORM.downcase.include?("mswin")
48
+ end
49
+
50
+ def is_linux?
51
+ RUBY_PLATFORM.downcase.include?("linux")
52
+ end
53
+ end
@@ -0,0 +1,3 @@
1
+ module Phantomjs
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "phantomjs/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "phantomjs.rb"
7
+ s.version = Phantomjs::VERSION
8
+ s.authors = ["William Estoque"]
9
+ s.email = ["william.estoque@gmail.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{Ruby wrapper for phantomjs}
12
+ s.description = %q{Ruby wrapper for phantomjs}
13
+
14
+ s.rubyforge_project = "phantomjs.rb"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ # specify any dependencies here; for example:
22
+ s.add_development_dependency "ZenTest"
23
+ # s.add_runtime_dependency "rest-client"
24
+ end
@@ -0,0 +1,13 @@
1
+ require 'minitest/spec'
2
+ require 'minitest/autorun'
3
+ require 'phantomjs'
4
+
5
+ describe Phantomjs do
6
+ describe ".run" do
7
+ it "runs phantomjs binary with the correct arguments" do
8
+ script = File.expand_path('./spec/runner.js')
9
+ result = Phantomjs.run(script, 'foo1', 'foo2')
10
+ result.must_equal "bar foo1 foo2\n"
11
+ end
12
+ end
13
+ end
data/spec/runner.js ADDED
@@ -0,0 +1,2 @@
1
+ console.log('bar ' + phantom.args[0] + ' ' + phantom.args[1]);
2
+ phantom.exit();
@@ -0,0 +1,145 @@
1
+ Please see also http://code.google.com/p/phantomjs/wiki/ReleaseNotes.
2
+
3
+ 2011-12-31: Version 1.4.1
4
+
5
+ Bug fixes
6
+
7
+ * Fix setting the proxy type (issue 266)
8
+ * Workaround for file upload regression (issue 307)
9
+ * Fix extraneous messsages in non-debug mode (issue 323)
10
+
11
+ 2011-12-22: Version 1.4.0 "Glory of the Snow"
12
+
13
+ New features
14
+
15
+ * Added embedded HTTP server (issue 115)
16
+ * Added convenient build script for Linux (issue 197)
17
+ * Added support for SOCKS5 proxy (issue 266)
18
+ * Updated CoffeeScript compiler to version 1.2 (issue 312)
19
+
20
+ Bug fixes
21
+
22
+ * Fix potential crash in QUrl with Qt 4.8 (issue 304)
23
+ * Fix bug in CookieJar with QSettings and string (PyPhantomJS issue 10)
24
+ * Prevent showing the icon on Mac OS X Dock (issue 281)
25
+
26
+ Examples
27
+
28
+ * Added a new example to detect browsers sniffing (issue 263)
29
+ * Added HTTP server example (issue 115)
30
+
31
+ 2011-09-23: Version 1.3.0 "Water Lily"
32
+
33
+ Bug fixes
34
+
35
+ * Fixed open() and POST method, without specifying the finished handler
36
+ * Fixed script execution warning dialog (issue 165)
37
+ * Added WebPage.release() to free the web page from memory (issue 154)
38
+ * Added special handling of about:blank (issue 235)
39
+ * Made a separate network access manager for each page (issue 190)
40
+
41
+ New features
42
+
43
+ * Introduced file system API based on CommonJS Filesystem proposal (issue 129)
44
+ * Added support for persistent cookies (issue 91)
45
+ * Added event handling, currently only for mouse events (issue 234)
46
+ * Added page scroll position (issue 162)
47
+ * Added HTTP authentication support (issue 45)
48
+ * Added callback for page initialization (issue 143)
49
+ * Added support to specify script and output encoding (issue 186)
50
+ * Added option to allow local content to do cross-domain access (issue 28)
51
+ * Added support to apply configurations from a JSON file (issue 180)
52
+ * Added a convenient WebPage initialization construction (issue 206)
53
+ * Added option to limit the size of disk cache (issue 220)
54
+
55
+ Examples
56
+
57
+ * Added a new example on using Modernizr to detect features (issue 144)
58
+ * Fixed pizza.js example to use Mobile Yelp (issue 200)
59
+ * Fixed netsniff.coffee example due to wrong indentation (issue 225)
60
+ * Added an example to show live network traffic (issue 227)
61
+ * Added an example demonstrating different output encodings (issue 186)
62
+
63
+ 2011-06-21: Version 1.2.0 "Birds of Paradise"
64
+
65
+ Version 1.2.0 is a major update. It introduces a whole set of new API.
66
+
67
+ Bug fixes
68
+
69
+ * Fixed rendering a very large web page (issue 54)
70
+ * Fixed reporting of CoffeeScript compile error (issue 125)
71
+
72
+ New features
73
+
74
+ * Added callback for console message (issue 12)
75
+ * Improved security model via WebPage object (issue 41)
76
+ * Added support for POST, HEAD, PUT, and DELETE (issue 88)
77
+ * Scripts filename is now passed as phantom.scriptName
78
+ * Added callback to capture resource requests and responses (issue 2)
79
+ * Added the ability to load external JavaScript (issue 32)
80
+
81
+ Examples
82
+
83
+ * Ported examples to use WebPage object
84
+ * Added a new example to upload an image to imagebin.org
85
+ * Added a new example to show HTTP POST feature
86
+ * Added a new example to sniff network traffic and save it in HAR format
87
+
88
+
89
+ 2011-04-27: Version 1.1.0 "Cherry Blossom"
90
+
91
+ Fixed the script loading to use UTF-8 encoding (Yasuhiro Matsumoto).
92
+
93
+ Added check for system proxy setting (Yasuhiro Matsumoto).
94
+
95
+ Fixed building with Cygwin and Qt 4.5 (John Dalton).
96
+
97
+ Added a new example: driver for QUnit tests (Łukasz Korecki).
98
+
99
+ Fixed issue #20: problem with JPG transparent color (Alessandro Portale).
100
+
101
+ Fixed issue #9: ignore first line starting with #! (Matthias, aka fourplusone).
102
+
103
+ Fixed issue #7: support for file upload for form submission (Matthias, aka fourplusone).
104
+
105
+ Fixed issue #35: support for disabling images loading (Ariya Hidayat).
106
+
107
+ Fixed issue #14: enable or disable plugins (Ariya Hidayat).
108
+
109
+ Added a new example: using Canvas to produce the color wheel (Ariya Hidayat).
110
+
111
+ Added support for rasterizing as GIF image (Ariya Hidayat).
112
+
113
+ Added support for CoffeeScript (Ariya Hidayat).
114
+
115
+ Fixed issue #19: option for setting the proxy (Clint Berry, Ariya Hidayat).
116
+
117
+ Python implementation using PyQt (James Roe).
118
+
119
+ Fixed issue #17: Specify paper size for PDF export (Alessandro Portale).
120
+
121
+ Fixed issue #60: Win32 and OS/2 icon files (Salvador Parra Camacho).
122
+
123
+ Added clipping rectangle to the render function (Wouter de Bie).
124
+
125
+ Added an example on sychronous waiting (Gabor Torok).
126
+
127
+ Added command line option to use disk cache (Jon Turner).
128
+
129
+ Added text extracting example (Weston Ruter).
130
+
131
+ Fixed issue #93: Build with Qt < 4.7 (Ariya Hidayat).
132
+
133
+ Ported all examples to CoffeeScript (Robert Gieseke).
134
+
135
+ 2011-01-17: Version 1.0.0
136
+
137
+ Initial launch.
138
+
139
+ The API is centralized at the 'phantom' object (as child of
140
+ window object) which has the properties: args, content,
141
+ loadStatus, state, userAgent, version, viewportSize, and
142
+ the following functions: exit, open, render, sleep.
143
+
144
+ Several examples are included, among others: web page rasterizer,
145
+ weather service, headless test framework driver, and many others.
@@ -0,0 +1,22 @@
1
+ Redistribution and use in source and binary forms, with or without
2
+ modification, are permitted provided that the following conditions are met:
3
+
4
+ * Redistributions of source code must retain the above copyright
5
+ notice, this list of conditions and the following disclaimer.
6
+ * Redistributions in binary form must reproduce the above copyright
7
+ notice, this list of conditions and the following disclaimer in the
8
+ documentation and/or other materials provided with the distribution.
9
+ * Neither the name of the <organization> nor the
10
+ names of its contributors may be used to endorse or promote products
11
+ derived from this software without specific prior written permission.
12
+
13
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16
+ ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
17
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,33 @@
1
+ PhantomJS ([www.phantomjs.org](http://phantomjs.org)) is a headless WebKit with JavaScript API.
2
+
3
+ It has **fast** and **native** support for DOM handling, CSS selector, JSON, Canvas, and SVG.
4
+
5
+ PhantomJS is cross-platform, it can be compiled for Linux, Windows, FreeBSD, and Mac OS X.
6
+ Refer to the [build instructions](http://code.google.com/p/phantomjs/wiki/BuildInstructions)
7
+ for details.
8
+
9
+ **Note**: If you are on Mac OS X, [read the notice](http://code.google.com/p/phantomjs/wiki/BuildInstructions#Mac_OS_X)
10
+ before you start using `brew` or `port` to install Qt and/or PhantomJS.
11
+
12
+ PhantomJS scripts can be written in JavaScript or [CoffeeScript](http://jashkenas.github.com/coffee-script/).
13
+
14
+ See also [quick start guide](http://code.google.com/p/phantomjs/wiki/QuickStart)
15
+ and more [advanced examples](http://code.google.com/p/phantomjs/wiki/ServiceIntegration)
16
+ which show various PhantomJS scripts, covering:
17
+
18
+ * getting driving direction
19
+ * showing weather forecast conditions
20
+ * finding pizza in New York
21
+ * looking up approximate location based on IP address
22
+ * pulling the list of seasonal food
23
+ * running regression tests from command line
24
+ * producing PDF version of a Wikipedia article
25
+ * rasterizing SVG to image
26
+
27
+ Do not forget to consult the concise [API Reference](http://code.google.com/p/phantomjs/wiki/Interface).
28
+
29
+ PhantomJS is based on [Qt](http://qt.nokia.com). There are two implementations, using C++ and Python.
30
+
31
+ The latest [stable release](http://code.google.com/p/phantomjs/wiki/ReleaseNotes) is version 1.4 ("Glory of the Snow").
32
+
33
+ If you want to contribute, please read the [Contribution Guide](http://code.google.com/p/phantomjs/wiki/ContributionGuide).
@@ -0,0 +1,12 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
3
+ <plist version="0.9">
4
+ <dict>
5
+ <key>CFBundleExecutable</key>
6
+ <string>phantomjs</string>
7
+ <key>CFBundleIdentifier</key>
8
+ <string>org.phantomjs</string>
9
+ <key>LSUIElement</key>
10
+ <string>1</string>
11
+ </dict>
12
+ </plist>
@@ -0,0 +1,6 @@
1
+ if phantom.args.length is 0
2
+ console.log 'Try to pass some args when invoking this script!'
3
+ else
4
+ for arg, i in phantom.args
5
+ console.log i + ': ' + arg
6
+ phantom.exit()
@@ -0,0 +1,8 @@
1
+ if (phantom.args.length === 0) {
2
+ console.log('Try to pass some args when invoking this script!');
3
+ } else {
4
+ phantom.args.forEach(function (arg, i) {
5
+ console.log(i + ': ' + arg);
6
+ });
7
+ }
8
+ phantom.exit();
@@ -0,0 +1,46 @@
1
+ page = require('webpage').create()
2
+
3
+ page.viewportSize = { width: 400, height : 400 }
4
+ page.content = '<html><body><canvas id="surface"></canvas></body></html>'
5
+
6
+ page.evaluate ->
7
+ el = document.getElementById 'surface'
8
+ context = el.getContext '2d'
9
+ width = window.innerWidth
10
+ height = window.innerHeight
11
+ cx = width / 2
12
+ cy = height / 2
13
+ radius = width / 2.3
14
+ i = 0
15
+
16
+ el.width = width
17
+ el.height = height
18
+ imageData = context.createImageData(width, height)
19
+ pixels = imageData.data
20
+
21
+ for y in [0...height]
22
+ for x in [0...width]
23
+ i = i + 4
24
+ rx = x - cx
25
+ ry = y - cy
26
+ d = rx * rx + ry * ry
27
+ if d < radius * radius
28
+ hue = 6 * (Math.atan2(ry, rx) + Math.PI) / (2 * Math.PI)
29
+ sat = Math.sqrt(d) / radius
30
+ g = Math.floor(hue)
31
+ f = hue - g
32
+ u = 255 * (1 - sat)
33
+ v = 255 * (1 - sat * f)
34
+ w = 255 * (1 - sat * (1 - f))
35
+ pixels[i] = [255, v, u, u, w, 255, 255][g]
36
+ pixels[i + 1] = [w, 255, 255, v, u, u, w][g]
37
+ pixels[i + 2] = [u, u, w, 255, 255, v, u][g]
38
+ pixels[i + 3] = 255
39
+
40
+ context.putImageData imageData, 0, 0
41
+ document.body.style.backgroundColor = 'white'
42
+ document.body.style.margin = '0px'
43
+
44
+ page.render('colorwheel.png')
45
+
46
+ phantom.exit()
@@ -0,0 +1,51 @@
1
+ var page = require('webpage').create();
2
+ page.viewportSize = { width: 400, height : 400 };
3
+ page.content = '<html><body><canvas id="surface"></canvas></body></html>';
4
+ page.evaluate(function() {
5
+ var el = document.getElementById('surface'),
6
+ context = el.getContext('2d'),
7
+ width = window.innerWidth,
8
+ height = window.innerHeight,
9
+ cx = width / 2,
10
+ cy = height / 2,
11
+ radius = width / 2.3,
12
+ imageData,
13
+ pixels,
14
+ hue, sat, value,
15
+ i = 0, x, y, rx, ry, d,
16
+ f, g, p, u, v, w, rgb;
17
+
18
+ el.width = width;
19
+ el.height = height;
20
+ imageData = context.createImageData(width, height);
21
+ pixels = imageData.data;
22
+
23
+ for (y = 0; y < height; y = y + 1) {
24
+ for (x = 0; x < width; x = x + 1, i = i + 4) {
25
+ rx = x - cx;
26
+ ry = y - cy;
27
+ d = rx * rx + ry * ry;
28
+ if (d < radius * radius) {
29
+ hue = 6 * (Math.atan2(ry, rx) + Math.PI) / (2 * Math.PI);
30
+ sat = Math.sqrt(d) / radius;
31
+ g = Math.floor(hue);
32
+ f = hue - g;
33
+ u = 255 * (1 - sat);
34
+ v = 255 * (1 - sat * f);
35
+ w = 255 * (1 - sat * (1 - f));
36
+ pixels[i] = [255, v, u, u, w, 255, 255][g];
37
+ pixels[i + 1] = [w, 255, 255, v, u, u, w][g];
38
+ pixels[i + 2] = [u, u, w, 255, 255, v, u][g];
39
+ pixels[i + 3] = 255;
40
+ }
41
+ }
42
+ }
43
+
44
+ context.putImageData(imageData, 0, 0);
45
+ document.body.style.backgroundColor = 'white';
46
+ document.body.style.margin = '0px';
47
+ });
48
+
49
+ page.render('colorwheel.png');
50
+
51
+ phantom.exit();