fluttrly 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/fluttrly-gem/version.rb +1 -1
- data/lib/fluttrly-gem.rb +25 -2
- metadata +4 -4
data/lib/fluttrly-gem/version.rb
CHANGED
data/lib/fluttrly-gem.rb
CHANGED
@@ -35,8 +35,31 @@ module Fluttrly
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
|
39
|
-
|
38
|
+
#Posting requires getting COOKIE om nom nom and a csrf token..
|
39
|
+
def post(list, message)
|
40
|
+
uri = URI.parse("http://fluttrly.com/#{list}")
|
41
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
42
|
+
response = http.request(Net::HTTP::Get.new(uri.request_uri))
|
43
|
+
|
44
|
+
#get the csrf-token, really wanna use hpricot here but...
|
45
|
+
auth_token = $1 if response.body =~ /"authenticity_token".*value="(.+)"/ or nil
|
46
|
+
raise "No authenticity token found :(" if auth_token.nil?
|
47
|
+
|
48
|
+
#COOKIE COOKIE COOKIE COOKIE COOKIE COOKIE
|
49
|
+
cookie = response['set-cookie'].split('; ')[0]
|
50
|
+
|
51
|
+
#ok ok, now send that post data
|
52
|
+
uri = URI.parse('http://fluttrly.com/tasks.js')
|
53
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
54
|
+
params = {
|
55
|
+
'authenticity_token' => auth_token,
|
56
|
+
'task[name]' => "#{list}",
|
57
|
+
'task[content]' => "#{message}"
|
58
|
+
}
|
59
|
+
request["Cookie"] = cookie
|
60
|
+
request.set_form_data(params)
|
61
|
+
response = http.request(request)
|
62
|
+
|
40
63
|
end
|
41
64
|
|
42
65
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluttrly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Brent Beer
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-02-
|
18
|
+
date: 2011-02-10 00:00:00 -06:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|