tagen 2.0.1 → 2.0.2
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.
- data/CHANGELOG.md +10 -8
- data/CONTRIBUTING.md +17 -0
- data/Gemfile.lock +1 -1
- data/README.md +3 -10
- data/benchmark/{a.rb → require.rb} +3 -4
- data/lib/tagen/core/kernel/shell.rb +13 -2
- data/lib/tagen/selenium-webdriver/webdriver/firefox.rb +15 -0
- data/lib/tagen/version.rb +1 -1
- data/lib/tagen/watir.rb +111 -0
- data/spec/tagen/core/kernel/shell_spec.rb +10 -0
- metadata +6 -4
data/CHANGELOG.md
CHANGED
@@ -1,21 +1,23 @@
|
|
1
|
+
## 2.0.2 (Nov 4, 2012)
|
2
|
+
|
3
|
+
**Improvements**
|
4
|
+
|
5
|
+
- add `tagen/watir`: a hacker to keep cookies for firefox.
|
6
|
+
|
1
7
|
## 2.0.1 (Sep 9, 2012)
|
2
8
|
|
3
|
-
Bugfixes
|
9
|
+
**Bugfixes**
|
4
10
|
|
5
11
|
- Fix 'activesupport' dependency error in gemspec
|
6
12
|
|
7
13
|
## 2.0.0 (Aug 29, 2012)
|
8
14
|
|
9
|
-
Improvements
|
15
|
+
**Improvements**
|
10
16
|
|
11
|
-
- Based on `active_support`
|
17
|
+
- Based on `active_support` *GutenYe*
|
12
18
|
- Support `rubinius` version
|
13
19
|
|
14
|
-
Changes
|
20
|
+
**Changes**
|
15
21
|
|
16
22
|
- Remove `PyFormat`, `Array#extract_extend_options[!]`
|
17
23
|
- Change `Time::Detal` to `Numberic#time_humanize`
|
18
|
-
|
19
|
-
|
20
|
-
<!--- The following link definition list is generated by PimpMyChangelog --->
|
21
|
-
[@gutenye]: https://github.com/gutenye
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
We love pull requests. Here's a quick guide:
|
2
|
+
|
3
|
+
1. Fork the repo.
|
4
|
+
|
5
|
+
2. Create a topic branch from where you want to base your work.
|
6
|
+
|
7
|
+
3. Add a test for your change. Only refactoring and documentation changes
|
8
|
+
require no new tests. If you are adding functionality or fixing a bug, we need
|
9
|
+
a test!
|
10
|
+
|
11
|
+
4. Make the test pass with `rake test`.
|
12
|
+
|
13
|
+
5. Push to your fork and submit a pull request.
|
14
|
+
|
15
|
+
6. Coding Style Guide: https://gist.github.com/1105334
|
16
|
+
|
17
|
+
And in case we didn't emphasize it enough: we love tests!
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -35,21 +35,14 @@ Install
|
|
35
35
|
Development [](https://gemnasium.com/GutenYe/tagen) [](https://codeclimate.com/github/GutenYe/tagen)
|
36
36
|
===========
|
37
37
|
|
38
|
-
Contributing
|
38
|
+
Contributing
|
39
39
|
-------------
|
40
40
|
|
41
41
|
* Submit any bugs/features/ideas to github issue tracker.
|
42
42
|
|
43
|
-
|
43
|
+
Please see [Contibution Documentation](https://github.com/GutenYe/tagen/blob/master/CONTRIBUTING.md).
|
44
44
|
|
45
|
-
|
46
|
-
* Make sure your patches are well tested. All specs run with `rake test:portability` must pass.
|
47
|
-
* Coding Style Guide: https://gist.github.com/1105334
|
48
|
-
|
49
|
-
Contributors
|
50
|
-
------------
|
51
|
-
|
52
|
-
[https://github.com/GutenYe/tagen/contributors](https://github.com/GutenYe/tagen/contributors)
|
45
|
+
A list of [Contributors](https://github.com/GutenYe/tagen/contributors).
|
53
46
|
|
54
47
|
Resources
|
55
48
|
---------
|
@@ -4,11 +4,10 @@ dir = File.expand_path("../..", __FILE__)
|
|
4
4
|
$:.unshift File.join(dir, "lib")
|
5
5
|
ENV["BUNDLE_GEMFILE"] = File.join(dir, "Gemfile")
|
6
6
|
|
7
|
-
require "bundler/setup"
|
7
|
+
#require "bundler/setup"
|
8
8
|
require "benchmark"
|
9
9
|
|
10
10
|
Benchmark.bm do |b|
|
11
|
-
b.report
|
12
|
-
|
13
|
-
end
|
11
|
+
b.report('require "tagen/some"'){ require "tagen/core/io"; require "tagen/core/array" }
|
12
|
+
#b.report('require "tagen/core"') { require "tagen/core" }
|
14
13
|
end
|
@@ -12,7 +12,7 @@ private
|
|
12
12
|
# @see Kernel#`
|
13
13
|
def sh(cmd, *args)
|
14
14
|
o = args.last.instance_of?(Hash) ? args.pop : {}
|
15
|
-
|
15
|
+
puts _tagen_wrap_cmd(cmd, o[:show_cmd]) if o[:show_cmd]
|
16
16
|
`#{cmd}`
|
17
17
|
end
|
18
18
|
|
@@ -31,7 +31,7 @@ private
|
|
31
31
|
end
|
32
32
|
|
33
33
|
if o[:show_cmd]
|
34
|
-
puts cmds.join(" ")
|
34
|
+
puts _tagen_wrap_cmd(cmds.join(" "), o[:show_cmd])
|
35
35
|
o.delete(:show_cmd)
|
36
36
|
end
|
37
37
|
|
@@ -40,6 +40,17 @@ private
|
|
40
40
|
|
41
41
|
alias system_without_tagen system
|
42
42
|
alias system system_with_tagen
|
43
|
+
|
44
|
+
|
45
|
+
# @private
|
46
|
+
def _tagen_wrap_cmd(cmd, pretty)
|
47
|
+
case pretty
|
48
|
+
when "$", "#"
|
49
|
+
"#{pretty} #{cmd}"
|
50
|
+
else
|
51
|
+
cmd
|
52
|
+
end
|
53
|
+
end
|
43
54
|
end
|
44
55
|
|
45
56
|
$sudo = Process.pid != 0 && system("which sudo &>/dev/null") ? "sudo" : ""
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# keep_cookies!
|
2
|
+
module Selenium
|
3
|
+
module WebDriver
|
4
|
+
module Firefox
|
5
|
+
class Launcher
|
6
|
+
def keep_cookies!
|
7
|
+
origin_profile_dir = @profile.instance_variable_get("@model")
|
8
|
+
|
9
|
+
File.delete "#{@profile_dir}/cookies.sqlite"
|
10
|
+
File.symlink "#{origin_profile_dir}/cookies.sqlite", "#{@profile_dir}/cookies.sqlite"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/tagen/version.rb
CHANGED
data/lib/tagen/watir.rb
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
require "watir"
|
2
|
+
|
3
|
+
# Cookies
|
4
|
+
module Watir
|
5
|
+
class Browser
|
6
|
+
# TODO: support windows.
|
7
|
+
#
|
8
|
+
# firefox only.
|
9
|
+
def keep_cookies!
|
10
|
+
require "tagen/selenium-webdriver/webdriver/firefox"
|
11
|
+
|
12
|
+
launcher = driver.instance_variable_get("@bridge").instance_variable_get("@launcher")
|
13
|
+
launcher.keep_cookies!
|
14
|
+
end
|
15
|
+
|
16
|
+
# Read cookies from Mozilla cookies.txt-style IO stream
|
17
|
+
#
|
18
|
+
# @param file [IO,String]
|
19
|
+
#
|
20
|
+
def load_cookies(file)
|
21
|
+
now = ::Time.now
|
22
|
+
|
23
|
+
io = case file
|
24
|
+
when String
|
25
|
+
open(file)
|
26
|
+
else
|
27
|
+
file
|
28
|
+
end
|
29
|
+
|
30
|
+
io.each_line do |line|
|
31
|
+
line.chomp!
|
32
|
+
line.gsub!(/#.+/, '')
|
33
|
+
fields = line.split("\t")
|
34
|
+
|
35
|
+
next if fields.length != 7
|
36
|
+
|
37
|
+
name, value, domain, for_domain, path, secure, version = fields[5], fields[6],
|
38
|
+
fields[0], (fields[1] == "TRUE"), fields[2], (fields[3] == "TRUE"), 0
|
39
|
+
|
40
|
+
expires_seconds = fields[4].to_i
|
41
|
+
expires = (expires_seconds == 0) ? nil : ::Time.at(expires_seconds)
|
42
|
+
next if expires and (expires < now)
|
43
|
+
|
44
|
+
cookies.add(name, value, domain: domain, path: path, expires: expires, secure: secure)
|
45
|
+
end
|
46
|
+
|
47
|
+
io.close if String === file
|
48
|
+
|
49
|
+
self
|
50
|
+
end
|
51
|
+
|
52
|
+
# Write cookies to Mozilla cookies.txt-style IO stream
|
53
|
+
#
|
54
|
+
# @param file [IO,String]
|
55
|
+
def dump_cookies(file)
|
56
|
+
io = case file
|
57
|
+
when String
|
58
|
+
open(file, "w")
|
59
|
+
else
|
60
|
+
file
|
61
|
+
end
|
62
|
+
|
63
|
+
cookies.to_a.each do |cookie|
|
64
|
+
io.puts([
|
65
|
+
cookie[:domain],
|
66
|
+
"FALSE", # for_domain
|
67
|
+
cookie[:path],
|
68
|
+
cookie[:secure] ? "TRUE" : "FALSE",
|
69
|
+
cookie[:expires].to_i.to_s,
|
70
|
+
cookie[:name],
|
71
|
+
cookie[:value]
|
72
|
+
].join("\t"))
|
73
|
+
end
|
74
|
+
|
75
|
+
io.close if String === file
|
76
|
+
|
77
|
+
self
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
module Watir
|
83
|
+
class Element
|
84
|
+
# quick set value.
|
85
|
+
#
|
86
|
+
# @example
|
87
|
+
#
|
88
|
+
# form = browser.form(id: "foo")
|
89
|
+
# form.set("//input[@name='value']", "hello")
|
90
|
+
# form.set("//input[@name='check']", true)
|
91
|
+
# form.set("//select[@name='foo']", "Bar")
|
92
|
+
# form.set("//textarea[@name='foo']", "bar")
|
93
|
+
#
|
94
|
+
def set2(selector, value=nil)
|
95
|
+
elem = element(xpath: selector).to_subtype
|
96
|
+
|
97
|
+
case elem
|
98
|
+
when Watir::Radio
|
99
|
+
elem.set
|
100
|
+
when Watir::Select
|
101
|
+
elem.select value
|
102
|
+
when Watir::Input
|
103
|
+
elem.set value
|
104
|
+
when Watir::TextArea
|
105
|
+
elem.set value
|
106
|
+
else
|
107
|
+
elem.click
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
@@ -1,6 +1,14 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Kernel do
|
4
|
+
describe "#_tagen_wrap_cmd" do
|
5
|
+
it do
|
6
|
+
expect(_tagen_wrap_cmd("ls -l", true)).to eq("ls -l")
|
7
|
+
expect(_tagen_wrap_cmd("ls -l", "$")).to eq("$ ls -l")
|
8
|
+
expect(_tagen_wrap_cmd("ls -l", "#")).to eq("# ls -l")
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
4
12
|
describe "#system" do
|
5
13
|
it "" do
|
6
14
|
should_receive(:system_without_tagen).with("foo -l", {})
|
@@ -24,4 +32,6 @@ describe Kernel do
|
|
24
32
|
expect(output).to eq("foo -l\n")
|
25
33
|
end
|
26
34
|
end
|
35
|
+
|
36
|
+
|
27
37
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tagen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-11-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: pd
|
@@ -54,12 +54,13 @@ files:
|
|
54
54
|
- .travis.yml
|
55
55
|
- .yardopts
|
56
56
|
- CHANGELOG.md
|
57
|
+
- CONTRIBUTING.md
|
57
58
|
- Gemfile
|
58
59
|
- Gemfile.lock
|
59
60
|
- Guardfile
|
60
61
|
- README.md
|
61
62
|
- Rakefile
|
62
|
-
- benchmark/
|
63
|
+
- benchmark/require.rb
|
63
64
|
- lib/tagen/core.rb
|
64
65
|
- lib/tagen/core/array.rb
|
65
66
|
- lib/tagen/core/array/append.rb
|
@@ -88,10 +89,12 @@ files:
|
|
88
89
|
- lib/tagen/net/http.rb
|
89
90
|
- lib/tagen/pathname.rb
|
90
91
|
- lib/tagen/rbconfig.rb
|
92
|
+
- lib/tagen/selenium-webdriver/webdriver/firefox.rb
|
91
93
|
- lib/tagen/socket.rb
|
92
94
|
- lib/tagen/uri.rb
|
93
95
|
- lib/tagen/version.rb
|
94
96
|
- lib/tagen/vim.rb
|
97
|
+
- lib/tagen/watir.rb
|
95
98
|
- lib/tagen/xmpp4r.rb
|
96
99
|
- spec/spec_helper.rb
|
97
100
|
- spec/tagen/core/array/delete_values_spec.rb
|
@@ -138,4 +141,3 @@ signing_key:
|
|
138
141
|
specification_version: 3
|
139
142
|
summary: a lightweight core and extra extensions for Ruby.
|
140
143
|
test_files: []
|
141
|
-
has_rdoc:
|