userscripts_org 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +9 -0
- data/Rakefile +2 -7
- data/bin/userjs +0 -0
- data/lib/userscripts_org.rb +13 -9
- metadata +6 -4
data/ChangeLog
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
2009-01-07 SATOH Hiroh <cho45@lowreal.net>
|
2
|
+
|
3
|
+
* [release]:
|
4
|
+
Release 0.0.3
|
5
|
+
|
6
|
+
* [bug]:
|
7
|
+
follow new design of userscripts.org.
|
8
|
+
follow mechanize 0.9.0.
|
9
|
+
|
1
10
|
ChangeLog of http://svn.coderepos.org/share/lang/ruby/userscripts_org/trunk
|
2
11
|
|
3
12
|
2008-01-11 cho45
|
data/Rakefile
CHANGED
@@ -63,7 +63,7 @@ spec = Gem::Specification.new do |s|
|
|
63
63
|
s.test_files = Dir["test/test_*.rb"]
|
64
64
|
|
65
65
|
s.add_dependency('pit')
|
66
|
-
s.add_dependency('mechanize')
|
66
|
+
s.add_dependency('mechanize', '>=0.9.0')
|
67
67
|
#s.add_dependency('activesupport', '>=1.3.1')
|
68
68
|
#s.required_ruby_version = '>= 1.8.2'
|
69
69
|
|
@@ -119,16 +119,11 @@ Rake::ShipitTask.new do |s|
|
|
119
119
|
s.Step.new {
|
120
120
|
system("svn", "up")
|
121
121
|
}.and {}
|
122
|
-
s.Step.new {
|
123
|
-
raise "changelog-with-hatenastar.rb is not found" unless system("which", "changelog-with-hatenastar.rb")
|
124
|
-
}.and {
|
125
|
-
system("changelog-with-hatenastar.rb > ChangeLog")
|
126
|
-
}
|
127
122
|
s.ChangeVersion "lib/userscripts_org.rb", "VERSION"
|
128
123
|
s.Commit
|
129
124
|
s.Task :clean, :package
|
130
125
|
s.RubyForge
|
131
|
-
s.Tag
|
126
|
+
s.Tag "release-%s"
|
132
127
|
s.Twitter
|
133
128
|
s.Task :rubyforge
|
134
129
|
end
|
data/bin/userjs
CHANGED
File without changes
|
data/lib/userscripts_org.rb
CHANGED
@@ -8,7 +8,7 @@ require "ostruct"
|
|
8
8
|
require "uri"
|
9
9
|
|
10
10
|
class UserscriptsOrg
|
11
|
-
VERSION = "0.0.
|
11
|
+
VERSION = "0.0.3"
|
12
12
|
|
13
13
|
class UserscriptsOrgError < StandardError; end
|
14
14
|
class NotLoggedinError < UserscriptsOrgError; end
|
@@ -28,13 +28,13 @@ class UserscriptsOrg
|
|
28
28
|
def login
|
29
29
|
# Login
|
30
30
|
@agent.get(BASE + "/login")
|
31
|
-
form = @agent.page.forms.
|
31
|
+
form = @agent.page.forms.find {|i| i.action == "/sessions" }
|
32
32
|
form.login = @config.username
|
33
33
|
form.password = @config.password
|
34
|
-
@agent.submit(form, form.buttons.name
|
34
|
+
@agent.submit(form, form.buttons.find {|i| i.name == "commit"})
|
35
35
|
|
36
36
|
# Retreive user id
|
37
|
-
@uid = @agent.page.links.text
|
37
|
+
@uid = @agent.page.links.find {|i| i.text == "public profile" }.href[%r|/users/(\d+)|, 1].to_i
|
38
38
|
self
|
39
39
|
end
|
40
40
|
|
@@ -57,12 +57,14 @@ class UserscriptsOrg
|
|
57
57
|
raise UserscriptsOrgError, "Script named #{name} is not found." if script.nil?
|
58
58
|
@agent.get BASE + "/scripts/edit_src/#{script.uid}"
|
59
59
|
|
60
|
-
form = @agent.page.forms.
|
60
|
+
form = @agent.page.forms.find {|i| i.action =~ %r|^/scripts/update_src/| }
|
61
61
|
form["which_source"] = "textarea"
|
62
62
|
form["script[src]"] = content
|
63
63
|
|
64
|
-
@agent.submit(form, form.buttons.name
|
65
|
-
|
64
|
+
@agent.submit(form, form.buttons.find {|i| i.name == "commit"})
|
65
|
+
|
66
|
+
date = (@agent.page.root/"//span[@class = 'date']").text.gsub(/^\s+|\s+$/, "")
|
67
|
+
unless date == "Last update a few seconds ago"
|
66
68
|
raise UserscriptsOrgError, "Update may failed"
|
67
69
|
end
|
68
70
|
script
|
@@ -81,10 +83,12 @@ class UserscriptsOrg
|
|
81
83
|
|
82
84
|
def create(content)
|
83
85
|
@agent.get BASE + "/scripts/new"
|
84
|
-
form = @agent.page.forms.
|
86
|
+
form = @agent.page.forms.find {|i| i.action == "/scripts/create" }
|
85
87
|
form["which_source"] = "textarea"
|
86
88
|
form["script[src]"] = content
|
87
|
-
@agent.submit(form, form.buttons.name
|
89
|
+
@agent.submit(form, form.buttons.find {|i| i.name == "commit" })
|
90
|
+
p @agent.page
|
91
|
+
p @agent.page.uri
|
88
92
|
|
89
93
|
get(@agent.page.uri.to_s[%r|/scripts/show/(\d+)|, 1])
|
90
94
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: userscripts_org
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- cho45
|
@@ -9,11 +9,12 @@ autorequire: ""
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2009-01-07 00:00:00 +09:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: pit
|
17
|
+
type: :runtime
|
17
18
|
version_requirement:
|
18
19
|
version_requirements: !ruby/object:Gem::Requirement
|
19
20
|
requirements:
|
@@ -23,12 +24,13 @@ dependencies:
|
|
23
24
|
version:
|
24
25
|
- !ruby/object:Gem::Dependency
|
25
26
|
name: mechanize
|
27
|
+
type: :runtime
|
26
28
|
version_requirement:
|
27
29
|
version_requirements: !ruby/object:Gem::Requirement
|
28
30
|
requirements:
|
29
31
|
- - ">="
|
30
32
|
- !ruby/object:Gem::Version
|
31
|
-
version:
|
33
|
+
version: 0.9.0
|
32
34
|
version:
|
33
35
|
description: Manipulate userscripts.org
|
34
36
|
email: cho45@lowreal.net
|
@@ -80,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
80
82
|
requirements: []
|
81
83
|
|
82
84
|
rubyforge_project: lowreal
|
83
|
-
rubygems_version: 1.0
|
85
|
+
rubygems_version: 1.2.0
|
84
86
|
signing_key:
|
85
87
|
specification_version: 2
|
86
88
|
summary: Manipulate userscripts.org
|