cpsn 0.4.1 → 0.4.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/VERSION +1 -1
- data/bin/cpsn +22 -11
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.2
|
data/bin/cpsn
CHANGED
@@ -25,8 +25,8 @@ end
|
|
25
25
|
def load_groups(settings)
|
26
26
|
$log.debug("Loading groups")
|
27
27
|
groups = {}
|
28
|
-
|
29
|
-
if not settings
|
28
|
+
|
29
|
+
if not settings[:groups]
|
30
30
|
return groups
|
31
31
|
end
|
32
32
|
|
@@ -65,13 +65,13 @@ def get_cookie(agent, username, password)
|
|
65
65
|
agent.cookie_jar.save_as File.expand_path("~/.cpsn/cookies.yml")
|
66
66
|
end
|
67
67
|
|
68
|
-
def get_agent(username, password)
|
68
|
+
def get_agent(username, password, force_cookie)
|
69
69
|
$log.debug("Creating new user agent")
|
70
70
|
agent = WWW::Mechanize.new
|
71
71
|
agent.user_agent_alias = 'Mac FireFox'
|
72
72
|
agent.redirect_ok = true
|
73
73
|
|
74
|
-
if File.exist? File.expand_path("~/.cpsn/cookies.yml")
|
74
|
+
if File.exist? File.expand_path("~/.cpsn/cookies.yml") and not force_cookie
|
75
75
|
agent.cookie_jar.load File.expand_path("~/.cpsn/cookies.yml")
|
76
76
|
return agent
|
77
77
|
end
|
@@ -132,6 +132,10 @@ optparse = OptionParser.new do |opts|
|
|
132
132
|
$log.level = Logger::DEBUG
|
133
133
|
end
|
134
134
|
|
135
|
+
options[:cookie] = false
|
136
|
+
opts.on('-c', '--cookie', 'Force cookie expiration') do
|
137
|
+
options[:cookie] = true
|
138
|
+
end
|
135
139
|
|
136
140
|
opts.on(nil, '--version', 'Display version information') do
|
137
141
|
gem_dir = File.join(File.dirname(__FILE__), '..')
|
@@ -151,7 +155,8 @@ optparse.parse!
|
|
151
155
|
|
152
156
|
settings = load_settings()
|
153
157
|
groups = load_groups(settings)
|
154
|
-
agent = get_agent(settings[:username].value, settings[:password].value
|
158
|
+
agent = get_agent(settings[:username].value, settings[:password].value,
|
159
|
+
options[:cookie])
|
155
160
|
|
156
161
|
if ARGV.length >= 1
|
157
162
|
friend_names = Set.new []
|
@@ -166,18 +171,24 @@ if ARGV.length >= 1
|
|
166
171
|
else
|
167
172
|
begin
|
168
173
|
friend_names = get_friends(agent)
|
169
|
-
rescue WWW::Mechanize::ResponseCodeError
|
170
|
-
|
171
|
-
|
174
|
+
rescue WWW::Mechanize::ResponseCodeError => response
|
175
|
+
if response.response_code == 404
|
176
|
+
get_cookie(agent, settings[:username].value,
|
177
|
+
settings[:password].value)
|
178
|
+
retry
|
179
|
+
end
|
172
180
|
end
|
173
181
|
end
|
174
182
|
|
175
183
|
for friend_name in friend_names
|
176
184
|
begin
|
177
185
|
friend = get_friend_status(agent, friend_name)
|
178
|
-
rescue WWW::Mechanize::ResponseCodeError
|
179
|
-
|
180
|
-
|
186
|
+
rescue WWW::Mechanize::ResponseCodeError => response
|
187
|
+
if response.response_code == 404
|
188
|
+
get_cookie(agent, settings[:username].value,
|
189
|
+
settings[:password].value)
|
190
|
+
retry
|
191
|
+
end
|
181
192
|
end
|
182
193
|
|
183
194
|
if friend
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cpsn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Bowes
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-11-
|
12
|
+
date: 2009-11-19 00:00:00 -05:00
|
13
13
|
default_executable: cpsn
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|