ubiquitously 0.0.1.6 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. data/README.markdown +224 -19
  2. data/Rakefile +12 -4
  3. data/bin/u.me +4 -0
  4. data/lib/ubiquitously.rb +56 -7
  5. data/lib/ubiquitously/commands/base.rb +118 -0
  6. data/lib/ubiquitously/commands/post.rb +108 -0
  7. data/lib/ubiquitously/commands/user.rb +111 -0
  8. data/lib/ubiquitously/extensions/callbacks.rb +62 -0
  9. data/lib/ubiquitously/extensions/core.rb +88 -0
  10. data/lib/ubiquitously/extensions/mechanize.rb +35 -0
  11. data/lib/ubiquitously/models/base.rb +18 -0
  12. data/lib/ubiquitously/models/page.rb +28 -0
  13. data/lib/ubiquitously/models/post.rb +66 -0
  14. data/lib/ubiquitously/models/service.rb +1 -0
  15. data/lib/ubiquitously/models/service/account.rb +57 -0
  16. data/lib/ubiquitously/models/service/account/authorizable.rb +58 -0
  17. data/lib/ubiquitously/models/service/account/loggable.rb +50 -0
  18. data/lib/ubiquitously/models/service/account/restful.rb +21 -0
  19. data/lib/ubiquitously/models/service/post.rb +59 -0
  20. data/lib/ubiquitously/models/service/post/loggable.rb +64 -0
  21. data/lib/ubiquitously/models/service/post/ownable.rb +31 -0
  22. data/lib/ubiquitously/models/service/post/postable.rb +73 -0
  23. data/lib/ubiquitously/models/service/post/restful.rb +52 -0
  24. data/lib/ubiquitously/models/user.rb +128 -0
  25. data/lib/ubiquitously/services/blogger_den.rb +68 -0
  26. data/lib/ubiquitously/services/chetzit.rb +37 -0
  27. data/lib/ubiquitously/services/code_project.rb +21 -0
  28. data/lib/ubiquitously/services/delicious.rb +54 -0
  29. data/lib/ubiquitously/services/design_bump.rb +41 -0
  30. data/lib/ubiquitously/services/designgizer.rb +21 -0
  31. data/lib/ubiquitously/services/designr_fix.rb +21 -0
  32. data/lib/ubiquitously/services/digg.rb +151 -0
  33. data/lib/ubiquitously/services/digzign.rb +25 -0
  34. data/lib/ubiquitously/services/diigo.rb +68 -0
  35. data/lib/ubiquitously/services/dzone.rb +132 -0
  36. data/lib/ubiquitously/services/dzone_snippets.rb +39 -0
  37. data/lib/ubiquitously/services/facebook.rb +42 -0
  38. data/lib/ubiquitously/services/faves.rb +81 -0
  39. data/lib/ubiquitously/services/favshare.rb +78 -0
  40. data/lib/ubiquitously/services/flikode.rb +38 -0
  41. data/lib/ubiquitously/services/friendfeed.rb +21 -0
  42. data/lib/ubiquitously/services/gist.rb +52 -0
  43. data/lib/ubiquitously/services/google_buzz.rb +15 -0
  44. data/lib/ubiquitously/services/identica.rb +15 -0
  45. data/lib/ubiquitously/services/jump_tags.rb +21 -0
  46. data/lib/ubiquitously/services/kailoon.rb +27 -0
  47. data/lib/ubiquitously/services/meta_filter.rb +26 -0
  48. data/lib/ubiquitously/services/mixx.rb +94 -0
  49. data/lib/ubiquitously/services/mmo.rb +22 -0
  50. data/lib/ubiquitously/services/mvc_forge.rb +37 -0
  51. data/lib/ubiquitously/services/my_space.rb +25 -0
  52. data/lib/ubiquitously/services/nestdev.rb +36 -0
  53. data/lib/ubiquitously/services/newsvine.rb +76 -0
  54. data/lib/ubiquitously/services/pixel_groovy.rb +22 -0
  55. data/lib/ubiquitously/services/posterous.rb +24 -0
  56. data/lib/ubiquitously/services/programmers_heaven.rb +21 -0
  57. data/lib/ubiquitously/{propeller.rb → services/propeller.rb} +17 -26
  58. data/lib/ubiquitously/services/queness.rb +38 -0
  59. data/lib/ubiquitously/services/reddit.rb +62 -0
  60. data/lib/ubiquitously/services/scribd.rb +21 -0
  61. data/lib/ubiquitously/services/script_and_style.rb +23 -0
  62. data/lib/ubiquitously/services/sharebrain.rb +19 -0
  63. data/lib/ubiquitously/services/shoutwire.rb +34 -0
  64. data/lib/ubiquitously/services/slideshare.rb +70 -0
  65. data/lib/ubiquitously/services/smipple.rb +21 -0
  66. data/lib/ubiquitously/services/snipplr.rb +67 -0
  67. data/lib/ubiquitously/services/snipt.rb +49 -0
  68. data/lib/ubiquitously/services/sphinn.rb +24 -0
  69. data/lib/ubiquitously/services/stumble_upon.rb +67 -0
  70. data/lib/ubiquitously/services/stumpedia.rb +13 -0
  71. data/lib/ubiquitously/services/tumblr.rb +28 -0
  72. data/lib/ubiquitously/services/tweako.rb +53 -0
  73. data/lib/ubiquitously/services/twitter.rb +60 -0
  74. data/lib/ubiquitously/services/web_blend.rb +25 -0
  75. data/lib/ubiquitously/services/webdev5.rb +32 -0
  76. data/lib/ubiquitously/services/who_freelance.rb +21 -0
  77. data/lib/ubiquitously/services/wordtaps.rb +36 -0
  78. data/lib/ubiquitously/services/yahoo_buzz.rb +64 -0
  79. data/lib/ubiquitously/services/youblr.rb +15 -0
  80. data/lib/ubiquitously/services/zabox.rb +22 -0
  81. data/lib/ubiquitously/support/active_record.rb +25 -0
  82. data/lib/ubiquitously/support/storage.rb +71 -0
  83. data/test/config/cookies.yml +111 -0
  84. data/test/config/credentials.yml +7 -0
  85. data/test/config/secrets.yml +33 -0
  86. data/test/config/tokens.yml +30 -0
  87. data/test/meta.html +19 -0
  88. data/test/test_delicious.rb +37 -0
  89. data/test/test_digg.rb +57 -0
  90. data/test/test_dzone.rb +23 -18
  91. data/test/test_facebook.rb +40 -0
  92. data/test/test_faves.rb +18 -20
  93. data/test/test_helper.rb +8 -1
  94. data/test/test_newsvine.rb +3 -3
  95. data/test/test_page.rb +21 -0
  96. data/test/test_post.rb +55 -0
  97. data/test/test_propeller.rb +2 -2
  98. data/test/test_reddit.rb +26 -4
  99. data/test/test_stumble_upon.rb +23 -3
  100. data/test/test_twitter.rb +33 -0
  101. data/test/test_user.rb +22 -0
  102. metadata +199 -24
  103. data/lib/ext.rb +0 -37
  104. data/lib/ubiquitously/base.rb +0 -56
  105. data/lib/ubiquitously/dzone.rb +0 -111
  106. data/lib/ubiquitously/faves.rb +0 -43
  107. data/lib/ubiquitously/mister_wong.rb +0 -11
  108. data/lib/ubiquitously/mixins/resourceful.rb +0 -50
  109. data/lib/ubiquitously/mixx.rb +0 -66
  110. data/lib/ubiquitously/newsvine.rb +0 -54
  111. data/lib/ubiquitously/reddit.rb +0 -46
  112. data/lib/ubiquitously/sphinn.rb +0 -11
  113. data/lib/ubiquitously/stumble_upon.rb +0 -61
  114. data/test/config.yml +0 -18
@@ -0,0 +1,22 @@
1
+ # http://www.mmosocialnetwork.com/
2
+ module Ubiquitously
3
+ module Mmo
4
+ class Account < Ubiquitously::Service::Account
5
+ def login
6
+ page = agent.get("http://service.com/login")
7
+ form = page.form_with(:name => "loginform")
8
+ form["username"] = username
9
+ form["password"] = password
10
+ page = form.submit
11
+
12
+ authorized?(page.title =~ /Some title/i)
13
+ end
14
+ end
15
+
16
+ class Post < Ubiquitously::Service::Post
17
+ def create
18
+ page = agent.get("")
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,37 @@
1
+ module Ubiquitously
2
+ module MvcForge
3
+ class Account < Ubiquitously::Service::Account
4
+ # raises Net::HTTPForbidden 403 if already logged in
5
+ def login
6
+ page = agent.get("http://mvcforge.com/user/login")
7
+ form = page.forms.detect { |form| form.form_node["id"] == "user-login" }
8
+ form["name"] = username
9
+ form["pass"] = password
10
+
11
+ page = form.submit
12
+
13
+ authorize!(page.parser.css(".messages.error").text.to_s !~ /unrecognized username or password/i)
14
+ end
15
+ end
16
+
17
+ class Post < Ubiquitously::Service::Post
18
+ def create
19
+ page = agent.get("http://mvcforge.com/submit")
20
+ form = page.form_with(:action => "/submit")
21
+
22
+ form["url"] = token[:url]
23
+ form["title"] = token[:title]
24
+ form["body"] = token[:description]
25
+ form["taxonomy[tags][3]"]
26
+ form.field_with(:name => "taxonomy[1]").options.each do |option|
27
+ option.select if option.value.to_s == "90"
28
+ end
29
+ form["op"] = "Submit"
30
+
31
+ page = form.submit(form.button_with(:value => "Submit"))
32
+
33
+ true
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,25 @@
1
+ module Ubiquitously
2
+ module MySpace
3
+ class Account < Ubiquitously::Service::Account
4
+ def login
5
+ referer = "http://localhost:4567/"
6
+ url = MyspaceToken.authorize_url(referer)
7
+ page = agent.get(url, [], referer)
8
+ form = page.forms.detect { |form| form.form_node["id"] == "login_form" }
9
+ form["email"] = username
10
+ form["pass"] = password
11
+ page = form.submit
12
+
13
+ # do something with the oauth token, save it in the cookie?
14
+
15
+ authorized?(page.uri !~ /http:\/\/login\.facebook\.com\/login\.php/i)
16
+ end
17
+ end
18
+
19
+ class Post < Ubiquitously::Service::Post
20
+ def create
21
+ page = agent.get("")
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,36 @@
1
+ module Ubiquitously
2
+ module Nestdev
3
+ class Account < Ubiquitously::Service::Account
4
+ def login
5
+ page = agent.get("http://nestdev.com/wp-login.php")
6
+ form = page.form_with(:name => "loginform")
7
+ form["log"] = username
8
+ form["pwd"] = password
9
+ form.checkboxes.first.check
10
+ page = form.submit
11
+
12
+ authorize!(page.parser.css("#login_error").first.nil?)
13
+ end
14
+ end
15
+
16
+ class Post < Ubiquitously::Service::Post
17
+ def create
18
+ page = agent.get("http://nestdev.com/")
19
+ form = page.form_with(:name => "new_post")
20
+
21
+ form["posttitle"] = token[:title]
22
+ form["posturl"] = token[:url]
23
+ form.field_with(:name => "post_category").options.each do |option|
24
+ option.select if option.value.to_s == "158"
25
+ end
26
+ # max length == 800
27
+ form["tags"] = token[:tags]
28
+ form["posttext"] = description
29
+
30
+ page = form.submit
31
+
32
+ true
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,76 @@
1
+ module Ubiquitously
2
+ module Newsvine
3
+ class Account < Ubiquitously::Service::Account
4
+ def login
5
+ page = agent.get("https://www.newsvine.com/_nv/accounts/login")
6
+ form = page.form_with(:action => "https://www.newsvine.com/_nv/api/accounts/login")
7
+ form["email"] = username
8
+ form["password"] = password
9
+ page = form.submit
10
+
11
+ authorize!(page.title !~ /Log in/i)
12
+ end
13
+ end
14
+
15
+ class Post < Ubiquitously::Service::Post
16
+ def tokenize
17
+ super.merge(:tags => tags.taggify(" ", ", "))
18
+ end
19
+
20
+ def create
21
+ page = agent.get("http://www.newsvine.com/_tools/seed")
22
+ form = page.form_with(:action => "http://www.newsvine.com/_action/tools/saveLink")
23
+
24
+ form["url"] = token[:url]
25
+ form["headline"] = token[:title]
26
+ form.radiobuttons_with(:name => "newsType").each do |button|
27
+ button.check if button.value == "x"
28
+ end
29
+ form.field_with(:name => "categoryTag").options.each do |option|
30
+ option.select if option.value == "technology"
31
+ end
32
+ form["blurb"] = token[:description]
33
+ form["tags"] = token[:tags]
34
+
35
+ unless debug?
36
+ page = form.submit
37
+ end
38
+
39
+ true
40
+ end
41
+
42
+ class << self
43
+ def find(options = {})
44
+ records = []
45
+ user = options[:user]
46
+ user_url = "http://#{user.username_for(self)}.newsvine.com"
47
+ html = Nokogiri::HTML(open(user_url).read)
48
+ urls = url_permutations(options[:url])
49
+
50
+ html.css(".quickpost").each do |node|
51
+ title = node.css("h1").first.text rescue nil
52
+ url = node.css("a.external").first["href"] rescue nil
53
+ description = node.xpath("p").first.text rescue nil
54
+ service_url = node.css("h1 a").first["href"] rescue nil
55
+ tags = []
56
+ node.css(".tags a").each do |tag|
57
+ tags << tag.text
58
+ end
59
+ record = new(
60
+ :title => title,
61
+ :url => url,
62
+ :description => description,
63
+ :tags => tags,
64
+ :service_url => service_url,
65
+ :user => user
66
+ )
67
+ return record if urls.include?(record.url)
68
+ records << record
69
+ end
70
+
71
+ options[:url] ? nil : records
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,22 @@
1
+ # http://www.pixelgroovy.com/
2
+ module Ubiquitously
3
+ module PixelGroovy
4
+ class Account < Ubiquitously::Service::Account
5
+ def login
6
+ page = agent.get("http://service.com/login")
7
+ form = page.form_with(:name => "loginform")
8
+ form["username"] = username
9
+ form["password"] = password
10
+ page = form.submit
11
+
12
+ authorized?(page.title =~ /Some title/i)
13
+ end
14
+ end
15
+
16
+ class Post < Ubiquitously::Service::Post
17
+ def create
18
+ page = agent.get("")
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,24 @@
1
+ module Ubiquitously
2
+ module Posterous
3
+ class Account < Ubiquitously::Service::Account
4
+ end
5
+
6
+ class Post < Ubiquitously::Service::Post
7
+ include HTTParty
8
+ base_uri 'http://posterous.com/api'
9
+
10
+ def create
11
+ self.class.post("/newpost", {
12
+ :query => {
13
+ :title => token[:title],
14
+ :body => token[:description],
15
+ :tags => token[:tags]
16
+ },
17
+ :basic_auth => @auth
18
+ })
19
+
20
+ true
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,21 @@
1
+ module Ubiquitously
2
+ module ProgrammersHeaven
3
+ class Account < Ubiquitously::Service::Account
4
+ def login
5
+ page = agent.get("http://digzign.com/login")
6
+ form = page.form_with(:name => "loginform")
7
+ form["username"] = username
8
+ form["password"] = password
9
+ page = form.submit
10
+
11
+ authorize!(page.title =~ /Like Digg/i)
12
+ end
13
+ end
14
+
15
+ class Post < Ubiquitously::Service::Post
16
+ def create
17
+ page = agent.get("")
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,52 +1,43 @@
1
1
  module Ubiquitously
2
2
  module Propeller
3
- class User < Ubiquitously::Base::User
3
+ class Account < Ubiquitously::Service::Account
4
4
  def login
5
- puts "LOGGING IN"
6
5
  page = agent.get("http://www.propeller.com/signin/")
7
6
  form = page.forms.detect {|form| form.form_node["class"] == "ajax-form"}
8
7
  form["member_name"] = username
9
8
  form["password"] = password
10
9
  form["submit"] = "sign in" # require to get around the ajax
11
10
  page = form.submit
12
- puts "DONE"
13
- @logged_in = (page.body =~ /Invalid member name or password/i).nil? && (page.body =~ /ajax-form/).nil?
14
-
15
- unless @logged_in
16
- raise AuthenticationError.new("Invalid username or password for #{service_name.titleize}")
17
- end
18
-
19
- @logged_in
11
+
12
+ authorize!((page.body !~ /Invalid member name or password/i) && (page.body !~ /ajax-form/))
20
13
  end
21
14
  end
22
15
 
23
- class Post < Ubiquitously::Base::Post
16
+ class Post < Ubiquitously::Service::Post
24
17
  # title max == 150
25
- validates_presence_of :url, :title, :tags, :description
18
+ def tokenize
19
+ super.merge(:tags => tags.taggify("_", " "))
20
+ end
26
21
 
27
- def save
28
- return false unless valid?
29
-
30
- user.login
31
-
22
+ def create
32
23
  # url
33
24
  page = agent.get("http://www.propeller.com/story/submit/")
34
25
  form = page.forms.detect {|form| form.form_node["method"].downcase == "post"}
35
- form["url"] = url
36
- puts "SUBMIT FORM"
26
+ form["url"] = token[:url]
27
+
37
28
  # details
38
29
  # http://www.propeller.com/story/submit/content/
39
30
  page = form.submit
40
31
  form = page.forms.detect {|form| form.form_node["method"].downcase == "post"}
41
- puts "DETAILS"
32
+
42
33
  form.radiobuttons_with(:name => "title_multi").each do |button|
43
34
  button.check if button.value == "-1"
44
35
  end
45
36
 
46
- form["title_multi_text"] = title
47
- form["description"] = description
37
+ form["title_multi_text"] = token[:title]
38
+ form["description"] = token[:description]
48
39
  # separate by space, multi words are underscored
49
- form["user_tags"] = tags.map {|tag| tag.underscore.gsub(/[\s|-]+/, "_")}.join(" ")
40
+ form["user_tags"] = token[:tags]
50
41
 
51
42
  form.radiobuttons_with(:name => "category").each do |button|
52
43
  button.check if button.value.to_s == "18"
@@ -54,14 +45,14 @@ module Ubiquitously
54
45
 
55
46
  # http://www.propeller.com/story/submit/preview/
56
47
  page = form.submit
57
- puts "SUBMIT DETAILS"
48
+
58
49
  # approve
59
50
  page.forms[1].submit
60
51
 
61
- unless options[:debug] == true
52
+ unless debug?
62
53
  page = form.submit
63
54
  end
64
-
55
+
65
56
  true
66
57
  end
67
58
  end
@@ -0,0 +1,38 @@
1
+ module Ubiquitously
2
+ module Queness
3
+ class Account < Ubiquitously::Service::Account
4
+ def login
5
+ page = agent.get("http://www.queness.com/")
6
+ form = page.form_with(:action => "http://www.queness.com/login.php")
7
+ form["login[username]"] = username
8
+ form["login[password]"] = password
9
+ form.checkboxes.first.check
10
+ page = form.submit
11
+
12
+ authorize!(page.parser.css(".error").text !~ /Incorrect/i)
13
+ end
14
+ end
15
+
16
+ class Post < Ubiquitously::Service::Post
17
+ def create
18
+ page = agent.get("http://www.queness.com/post")
19
+ form = page.forms.detect { |form| !form.form_node.css(".postform").first.nil? }
20
+
21
+ form["form[title]"] = token[:title]
22
+ form["form[description]"] = token[:description]
23
+ form["form[url]"] = token[:url]
24
+ # 1-4 tags
25
+ form.checkboxes_with(:name => "tags[]").each do |box|
26
+ case box.value.to_s
27
+ when "1", "12", "11", "3"
28
+ box.check
29
+ end
30
+ end
31
+
32
+ page = form.submit
33
+
34
+ true
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,62 @@
1
+ module Ubiquitously
2
+ module Reddit
3
+ class Account < Ubiquitously::Service::Account
4
+ def login
5
+ page = agent.get("http://www.reddit.com/")
6
+ form = page.form_with(:action => "http://www.reddit.com/post/login")
7
+ form["user"] = username
8
+ form["passwd"] = password
9
+ page = form.submit
10
+
11
+ authorize!(page.title !~ /login or register/i)
12
+ end
13
+ end
14
+
15
+ class Post < Ubiquitously::Service::Post
16
+ def create
17
+ page = agent.get("http://www.reddit.com/submit?url=#{url}")
18
+ key = page.body.match(/modhash\:\s+'([^']+)'/)[1]
19
+
20
+ if page.parser.css(".infobar a").first.text =~ /submit it again/i
21
+ post = page.parser.css(".thing").first
22
+ id = post["class"].match(/id-(\w+)/)[1]
23
+ vh = post.css(".arrow.up").first["onclick"].match(/\((?:\s+)?['"](\w+)['"]/)[1]
24
+ post_site = page.body.match(/post_site:\s+['"]([^'"]+)['"]/)[1] rescue "javascript"
25
+ params = {
26
+ "id" => id,
27
+ "vh" => vh,
28
+ "dir" => 1,
29
+ "uh" => key,
30
+ "renderstyle" => "html",
31
+ "r" => post_site
32
+ }
33
+
34
+ # dir = 1, 0, or -1. “direction” of vote.
35
+ headers = {
36
+ "X-Requested-With" => "XMLHttpRequest",
37
+ "Accept" => "application/json, text/javascript, */*"
38
+ }
39
+ unless debug?
40
+ page = agent.post("http://www.reddit.com/api/vote", params, headers)
41
+ end
42
+ else
43
+ form = page.forms.detect {|form| form.form_node["id"] == "newlink"}
44
+ form["title"] = title
45
+ form["url"] = url
46
+ form["id"] = "#newlink"
47
+ form["uh"] = key
48
+ form["renderstyle"] = "html"
49
+ form["kind"] = "link"
50
+
51
+ form.action = "http://www.reddit.com/api/submit"
52
+ headers = {
53
+ "X-Requested-With" => "XMLHttpRequest"
54
+ }
55
+ unless debug?
56
+ page = form.submit(nil, headers)
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end