owrb 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/Gemfile +4 -0
- data/README.md +34 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/owrb.rb +86 -0
- data/lib/owrb/version.rb +3 -0
- data/owrb.gemspec +26 -0
- metadata +108 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9834fce5f78693d6ddb3fdfe464165d070f61d34
|
4
|
+
data.tar.gz: fafe54fac8ff7158e14f6da51e486994621680fa
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b7cfa99522c9dfcf91d31394c857751bda461fb634b59837607bf95859da0e4794f821ceb86820d8668674ed3bcd7cdf634c1a63abfb17039c0995590dd01e74
|
7
|
+
data.tar.gz: 4a4822c76eb03229cb3b7a3ceb67e89dbfb151f8b27dc877c35b53af1189043c4d718771ac9b0a9044c3cc3404ac69c431c85106dfd60bfc89abfe454e18a0aa
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# Owrb
|
2
|
+
|
3
|
+
Web scripts.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'owrb'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install owrb
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Thinking...
|
24
|
+
|
25
|
+
## Development
|
26
|
+
|
27
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
28
|
+
|
29
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
30
|
+
|
31
|
+
## Contributing
|
32
|
+
|
33
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/liveralmask/owrb.
|
34
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "owrb"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/lib/owrb.rb
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
require "owrb/version"
|
2
|
+
|
3
|
+
require "uri"
|
4
|
+
require "json"
|
5
|
+
require "nokogiri"
|
6
|
+
require "watir-webdriver"
|
7
|
+
|
8
|
+
module Owrb
|
9
|
+
module URL
|
10
|
+
def self.parse( url )
|
11
|
+
URI.parse( url )
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
module JSON
|
16
|
+
def self.encode( value )
|
17
|
+
::JSON.generate( value )
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.decode( value )
|
21
|
+
::JSON.parse( value )
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
module HTML
|
26
|
+
class Element
|
27
|
+
attr_reader :name, :attributes
|
28
|
+
|
29
|
+
def initialize( element )
|
30
|
+
@name = element.name
|
31
|
+
@attributes = {}
|
32
|
+
element.attributes.each{|name, attribute|
|
33
|
+
@attributes[ attribute.name ] = attribute.value
|
34
|
+
}
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
class Document
|
39
|
+
def initialize( document )
|
40
|
+
@document = document
|
41
|
+
end
|
42
|
+
|
43
|
+
def xpath( expression )
|
44
|
+
elements = []
|
45
|
+
@document.xpath( expression ).each{|element|
|
46
|
+
elements.push Element.new( element )
|
47
|
+
}
|
48
|
+
elements
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.parse( code )
|
53
|
+
Document.new( Nokogiri::HTML.parse( code ) )
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
class Browser
|
58
|
+
def initialize( type = :phantomjs )
|
59
|
+
@browser = Watir::Browser.new( type )
|
60
|
+
end
|
61
|
+
|
62
|
+
def html
|
63
|
+
@browser.html
|
64
|
+
end
|
65
|
+
|
66
|
+
def go( url )
|
67
|
+
@browser.goto( url )
|
68
|
+
end
|
69
|
+
|
70
|
+
def click( expression )
|
71
|
+
@browser.element( :xpath, expression ).click
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
=begin
|
76
|
+
class Cipher
|
77
|
+
def encode
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
def decode
|
82
|
+
|
83
|
+
end
|
84
|
+
end
|
85
|
+
=end
|
86
|
+
end
|
data/lib/owrb/version.rb
ADDED
data/owrb.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'owrb/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "owrb"
|
8
|
+
spec.version = Owrb::VERSION
|
9
|
+
spec.authors = ["liveralmask"]
|
10
|
+
spec.email = ["liveralmask.lisk@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Web scripts.}
|
13
|
+
spec.description = %q{Web scripts.}
|
14
|
+
spec.homepage = "https://github.com/liveralmask/owrb"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
|
24
|
+
spec.add_dependency "nokogiri"
|
25
|
+
spec.add_dependency "watir"
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: owrb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- liveralmask
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-04-28 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.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: nokogiri
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
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: watir
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Web scripts.
|
70
|
+
email:
|
71
|
+
- liveralmask.lisk@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- Gemfile
|
78
|
+
- README.md
|
79
|
+
- Rakefile
|
80
|
+
- bin/console
|
81
|
+
- bin/setup
|
82
|
+
- lib/owrb.rb
|
83
|
+
- lib/owrb/version.rb
|
84
|
+
- owrb.gemspec
|
85
|
+
homepage: https://github.com/liveralmask/owrb
|
86
|
+
licenses: []
|
87
|
+
metadata: {}
|
88
|
+
post_install_message:
|
89
|
+
rdoc_options: []
|
90
|
+
require_paths:
|
91
|
+
- lib
|
92
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
requirements: []
|
103
|
+
rubyforge_project:
|
104
|
+
rubygems_version: 2.4.5.1
|
105
|
+
signing_key:
|
106
|
+
specification_version: 4
|
107
|
+
summary: Web scripts.
|
108
|
+
test_files: []
|