mech-js 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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c6c76a75bd8aa52743ded234081a27694b8f7b96
4
+ data.tar.gz: 393666521af2bf5a06279a188a25d39de79d6439
5
+ SHA512:
6
+ metadata.gz: 953d9d05094769f608a82cf3023edb9963d5a041beca5183b54363962b7d01de8ef5bbd64e6153e15c412bdf238c58bcf2cadaf0579216c553c7f6c609621880
7
+ data.tar.gz: 33a2bf710ff56da43ce21eaa08d84f6ecc472552f0602793f9be4b4b2778e7ac9bfa29428584cbfcb2e3430303495418ee97f41575225172f983a8d7d37f89fb
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in mech-js.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Sam Treweek
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.
@@ -0,0 +1,33 @@
1
+ # MechJs
2
+
3
+ Mechanize has no support for Javascript,
4
+ this library allows the user to apply standard browser
5
+ type events, which will trigger a get request
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'mech-js'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install mech-js
22
+
23
+ ## Usage
24
+
25
+ require 'mech_js'
26
+
27
+ ## Contributing
28
+
29
+ 1. Fork it ( https://github.com/[my-github-username]/mech-js/fork )
30
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
31
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
32
+ 4. Push to the branch (`git push origin my-new-feature`)
33
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,10 @@
1
+ require "mech_js/version"
2
+ require 'mech_js/page'
3
+ require 'mech_js/page/button'
4
+
5
+ module MechJS
6
+ def self.mech_js
7
+ 'Javascript Gem addon for Mechanize'
8
+ end
9
+
10
+ end
@@ -0,0 +1,12 @@
1
+ class Mechanize::Page < Mechanize::File
2
+ elements_with :button
3
+
4
+ ##
5
+ # Return a list of all buttons
6
+ def buttons
7
+ @buttons ||=
8
+ search('button').map { |node| Button.new(node, self) }
9
+ end
10
+
11
+ end
12
+
@@ -0,0 +1,48 @@
1
+ ##
2
+ # The button class has been designed around usign javascripts
3
+ # events to figure out where mech should be sent
4
+
5
+ class Mechanize::Page::Button
6
+
7
+ attr_reader :node
8
+ attr_accessor :page
9
+ attr_accessor :mech
10
+
11
+ ##
12
+ # Creates a new Mechanize::Page::Button from an button +node+ and source
13
+ # +page+.
14
+
15
+ def initialize node, page
16
+ @node = node
17
+ @page = page
18
+ @mech = page.mech
19
+ end
20
+
21
+ # This method is a shortcut to get form's DOM id.
22
+ # Common usage:
23
+ # page.button_with(:dom_id => "submit-btn")
24
+ # Note that you can also use +:id+ to get to this method:
25
+ # page.button_with(:id => "submit-btn")
26
+
27
+ def dom_id
28
+ node['id']
29
+ end
30
+
31
+ # This method uses the text of the button.
32
+ # Common usage:
33
+ # page.button_with(:text => "Cancel")
34
+
35
+ def text
36
+ @node.inner_text.strip
37
+ end
38
+
39
+ # This method will use use the location.href from the onclick attribute
40
+ # to construct a get method on the agent.
41
+
42
+ def js_click
43
+ href = node.attributes['onclick'].to_s.match(/location.href='(.*)'/)[1]
44
+ full_uri = URI::HTTP.build({scheme: page.uri.scheme, host: page.uri.host, path: href})
45
+ mech.get(full_uri)
46
+ end
47
+
48
+ end
@@ -0,0 +1,3 @@
1
+ module MechJS
2
+ VERSION = "0.0.1"
3
+ 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 'mech_js/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "mech-js"
8
+ spec.version = MechJS::VERSION
9
+ spec.authors = ["Sam Treweek"]
10
+ spec.email = ["info@uksa.eu"]
11
+ spec.summary = %q{Addon library for mechanize for Javascript.}
12
+ spec.description = %q{Mechanize has no support for Javascript,
13
+ this library allows the user to apply standard browser
14
+ type events, which will trigger a get request}
15
+ spec.homepage = "https://www.uksa.eu"
16
+ spec.license = "MIT"
17
+ spec.files = `git ls-files -z`.split("\x0")
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.7"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ end
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mech-js
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Sam Treweek
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDeDCCAmCgAwIBAgIBATANBgkqhkiG9w0BAQUFADBBMRMwEQYDVQQDDApzYW10
14
+ cmV3ZWVrMRUwEwYKCZImiZPyLGQBGRYFZ21haWwxEzARBgoJkiaJk/IsZAEZFgNj
15
+ b20wHhcNMTMxMDEzMjAxMjE5WhcNMTQxMDEzMjAxMjE5WjBBMRMwEQYDVQQDDApz
16
+ YW10cmV3ZWVrMRUwEwYKCZImiZPyLGQBGRYFZ21haWwxEzARBgoJkiaJk/IsZAEZ
17
+ FgNjb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDt5a6qQLOOsPv7
18
+ cdGaWtu8g622mMvgLpP5DPDc3D6BMOib9wwSXhZJJBcddtO+QN52lRb0tBR8klBE
19
+ uqAbBkv2UuBCKu2cKFldCVMQ5KKwTxj25My8cG3UVX60o7uT7HmWOmsGXqojGw9f
20
+ DFdBzURwFwI5ZtKl3sblwl25AH4qmn+DbENMgrvlYDDGs+JRBGBeMU6fN30C0PvP
21
+ YVUAdt3GAOG4KxPvA/8e5FMwohiAV6OfVjdIz7XV3c95omrZtafVVj8jQsaPOCO4
22
+ YsBd9zrZAqglVp2yo5fEzAozKS6B6FE5n+wpBR9dhjXMhfCmKKuGPjD9zvnnaE6Y
23
+ KnCyK0j9AgMBAAGjezB5MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQW
24
+ BBSoLCC1wDQu43FFE55O778Ox77OmjAfBgNVHREEGDAWgRRzYW10cmV3ZWVrQGdt
25
+ YWlsLmNvbTAfBgNVHRIEGDAWgRRzYW10cmV3ZWVrQGdtYWlsLmNvbTANBgkqhkiG
26
+ 9w0BAQUFAAOCAQEAJ3swCy1wmG6tQ9oer7PpxUhZzXPYZ8JBMFaZWbkirFeoI9Yn
27
+ c4qh0FyHnaM2pqde0pqOfbKxESUHSLtb8x2vhwpTvvsjRRixdMpIBP/Vtxp6p9Oa
28
+ Ayq5ITS201gMgktPhDO8MkaSpaxMXSCcMQSWuJmdY4uDv+mAY2ansK6mpwYLLi60
29
+ ovWjYMUykCDhWQH8l8SsWRkIKcVlnjgs73ZAKCSlehzPWCFBmMgpAZeMNFHw3a5k
30
+ qzoH/QN65IPJvffqtIusKUZBsHUKy9n60vrCEgK4ZTj+VZAjvxmPRB5UYDeP6xeh
31
+ SC+V9I2l+qX545yXG4raXDZqTyh9bsMrlE+5+A==
32
+ -----END CERTIFICATE-----
33
+ date: 2015-09-28 00:00:00.000000000 Z
34
+ dependencies:
35
+ - !ruby/object:Gem::Dependency
36
+ name: bundler
37
+ requirement: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '1.7'
42
+ type: :development
43
+ prerelease: false
44
+ version_requirements: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '1.7'
49
+ - !ruby/object:Gem::Dependency
50
+ name: rake
51
+ requirement: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '10.0'
56
+ type: :development
57
+ prerelease: false
58
+ version_requirements: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '10.0'
63
+ description: |-
64
+ Mechanize has no support for Javascript,
65
+ this library allows the user to apply standard browser
66
+ type events, which will trigger a get request
67
+ email:
68
+ - info@uksa.eu
69
+ executables: []
70
+ extensions: []
71
+ extra_rdoc_files: []
72
+ files:
73
+ - ".gitignore"
74
+ - Gemfile
75
+ - LICENSE.txt
76
+ - README.md
77
+ - Rakefile
78
+ - lib/mech_js.rb
79
+ - lib/mech_js/page.rb
80
+ - lib/mech_js/page/button.rb
81
+ - lib/mech_js/version.rb
82
+ - mech-js.gemspec
83
+ homepage: https://www.uksa.eu
84
+ licenses:
85
+ - MIT
86
+ metadata: {}
87
+ post_install_message:
88
+ rdoc_options: []
89
+ require_paths:
90
+ - lib
91
+ required_ruby_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ requirements: []
102
+ rubyforge_project:
103
+ rubygems_version: 2.2.2
104
+ signing_key:
105
+ specification_version: 4
106
+ summary: Addon library for mechanize for Javascript.
107
+ test_files: []