ubiquitously 0.0.1.6 → 0.1.0

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.
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
@@ -1,56 +0,0 @@
1
- module Ubiquitously
2
- module Base
3
- class User
4
- include ActiveModel::Validations
5
- include ActiveModel::Serialization
6
- include Ubiquitously::Resourceful
7
-
8
- attr_accessor :agent, :username, :password
9
-
10
- validates_presence_of :username, :password
11
-
12
- def initialize(attributes = {})
13
- attributes = attributes.symbolize_keys
14
-
15
- attributes[:username] ||= Ubiquitously.key("#{service_name}.key")
16
- attributes[:password] ||= Ubiquitously.key("#{service_name}.secret")
17
-
18
- @logged_in = false
19
-
20
- super(attributes)
21
-
22
- self.agent = Mechanize.new
23
- # self.agent.log = Logger.new(STDOUT)
24
- self.agent.user_agent = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_2; ru-ru) AppleWebKit/533.2+ (KHTML, like Gecko) Version/4.0.4 Safari/531.21.10"
25
- end
26
-
27
- def logged_in?
28
- @logged_in == true
29
- end
30
- end
31
-
32
- class Post
33
- include ActiveModel::Validations
34
- include ActiveModel::Serialization
35
- include Ubiquitously::Resourceful
36
-
37
- attr_accessor :title, :url, :description, :tags, :categories, :service_url, :user
38
-
39
- def user
40
- @user ||= "Ubiquitously::#{service_name.titleize}::User".constantize.new
41
- end
42
-
43
- def agent
44
- user.agent
45
- end
46
-
47
- class << self
48
- def create(options = {})
49
- record = new(options)
50
- record.save
51
- record
52
- end
53
- end
54
- end
55
- end
56
- end
@@ -1,111 +0,0 @@
1
- module Ubiquitously
2
- module Dzone
3
- class User < Ubiquitously::Base::User
4
- def login
5
- return true if logged_in?
6
-
7
- page = agent.get("http://www.dzone.com/links/loginLightbox.html")
8
- form = page.form_with(:action => "/links/j_acegi_security_check")
9
- form["j_username"] = username
10
- form["j_password"] = password
11
- page = form.submit
12
-
13
- @logged_in = (page.body !~ /Invalid username or password/i).nil?
14
-
15
- unless @logged_in
16
- raise AuthenticationError.new("Invalid username or password for #{service_name.titleize}")
17
- end
18
-
19
- @logged_in
20
- end
21
-
22
- def create
23
-
24
- end
25
- end
26
-
27
- class Post < Ubiquitously::Base::Post
28
- validates_presence_of :url, :title, :description, :service_url
29
-
30
- class << self
31
-
32
- def first(url)
33
- find(url).first
34
- end
35
-
36
- def last(url)
37
- find(url).last
38
- end
39
-
40
- def find(url)
41
- query = CGI.escape(url.gsub(/http(s)?\:\/\//, ""))
42
- search = "http://www.dzone.com/links/search.html?query=#{query}"
43
- html = Nokogiri::HTML(open(search).read)
44
- records = []
45
-
46
- html.css(".linkblock").each do |node|
47
- link = node.css(".thumb a").first["href"]
48
- header = node.css(".details h3 a").first
49
- title = header.text
50
- service_url = header["href"]
51
- records << Ubiquitously::Dzone::Post.new(
52
- :url => link,
53
- :title => title,
54
- :service_url => service_url
55
- )
56
- end
57
-
58
- records
59
- end
60
-
61
- # http://www.dzone.com/links/feed/user/<user_id>/rss.xml
62
- # check to see if dzone already has the url
63
- def new_record?(url, throw_error = false)
64
- exists = !find(url).blank?
65
- raise DuplicateError.new("DZone already links to #{url}") if throw_error && exists
66
- exists
67
- end
68
- end
69
-
70
- def save(options = {})
71
- return false unless valid? && new_record?
72
-
73
- user.login
74
-
75
- # url
76
- page = agent.get("http://www.dzone.com/links/add.html")
77
- form = page.form_with(:action => "/links/add.html")
78
-
79
- accepted_tags = []
80
-
81
- form.checkboxes_with(:name => "tags").each do |tag|
82
- accepted_tags << tag.value.to_s
83
- end
84
-
85
- unaccepted_tags = tags.select { |tag| !accepted_tags.include?(tag) }
86
-
87
- if unaccepted_tags.length > 0
88
- raise ArgumentError.new("DZone doesn't accept these tags: #{unaccepted_tags.inspect}, they want these:\n#{accepted_tags.inspect}")
89
- end
90
-
91
- form["title"] = title
92
- form["url"] = url
93
- form["description"] = description
94
-
95
- form.checkboxes_with(:name => "tags").each do |checkbox|
96
- checkbox.check if tags.include?(checkbox.value)
97
- end
98
-
99
- unless options[:debug] == true
100
- page = form.submit
101
- end
102
-
103
- true
104
- end
105
-
106
- def new_record?
107
- self.class.new_record?(url)
108
- end
109
- end
110
- end
111
- end
@@ -1,43 +0,0 @@
1
- module Ubiquitously
2
- module Faves
3
- class User < Ubiquitously::Base::User
4
- def login
5
- page = agent.get("https://secure.faves.com/signIn")
6
- form = page.forms.detect {|form| form.form_node["id"] == "signInBox"}
7
- form["rUsername"] = username
8
- form["rPassword"] = password
9
- page = form.submit
10
-
11
- @logged_in = (page.title =~ /Sign In/i).nil?
12
-
13
- unless @logged_in
14
- raise AuthenticationError.new("Invalid username or password for #{service_name.titleize}")
15
- end
16
-
17
- @logged_in
18
- end
19
- end
20
-
21
- class Post < Ubiquitously::Base::Post
22
- validates_presence_of :url, :title, :description, :tags
23
-
24
- def save
25
- return false unless valid?
26
-
27
- user.login
28
-
29
- page = agent.get("http://faves.com/createdot.aspx")
30
- form = page.form_with(:name => "createDotForm")
31
- form["noteText"] = description
32
- form["urlText"] = url
33
- form["subjectText"] = title
34
- form["tagsText"] = tags.join(", ")
35
- #form["rateSelect"]
36
-
37
- unless options[:debug] == true
38
- page = form.submit
39
- end
40
- end
41
- end
42
- end
43
- end
@@ -1,11 +0,0 @@
1
- module Ubiquitously
2
- module MisterWong
3
- class User
4
-
5
- end
6
-
7
- class Post
8
-
9
- end
10
- end
11
- end
@@ -1,50 +0,0 @@
1
- module Ubiquitously
2
- module Resourceful
3
- def self.included(base)
4
- base.extend ClassMethods
5
- base.send :include, InstanceMethods
6
- end
7
-
8
- module ClassMethods
9
- def service_name
10
- self.to_s.split("::")[1].underscore.downcase
11
- end
12
-
13
- def required_arguments(*args)
14
- @required_arguments = args unless args.blank?
15
- @required_arguments ||= []
16
- @required_arguments
17
- end
18
- alias requires required_arguments
19
-
20
- def assert_required_arguments(options)
21
- missing = []
22
- required_arguments.each do |arg|
23
- missing << arg unless options.has_key?(arg)
24
- end
25
- unless missing.blank?
26
- raise ArgumentError.new("#{service_name.titleize} requires #{missing.join(", and")}")
27
- end
28
-
29
- missing.blank?
30
- end
31
- end
32
-
33
- module InstanceMethods
34
-
35
- def initialize(attributes = {})
36
- attributes.each do |key, value|
37
- self.send("#{key.to_s}=", value) if self.respond_to?(key)
38
- end
39
- end
40
-
41
- def service_name
42
- self.class.service_name
43
- end
44
-
45
- def assert_required_arguments(options)
46
- self.class.assert_required_arguments(options)
47
- end
48
- end
49
- end
50
- end
@@ -1,66 +0,0 @@
1
- module Ubiquitously
2
- module Mixx
3
- class User < Ubiquitously::Base::User
4
- def login
5
- return true if logged_in?
6
-
7
- page = agent.get("https://www.mixx.com/")
8
- form = page.form_with(:action => "https://www.mixx.com/save_login")
9
- form["user[loginid]"] = username
10
- form["user[password]"] = password
11
- page = form.submit
12
-
13
- @logged_in = (page.body =~ /login was unsuccessful/i).nil?
14
-
15
- unless @logged_in
16
- raise AuthenticationError.new("Invalid username or password for #{service_name.titleize}")
17
- end
18
-
19
- @logged_in
20
- end
21
- end
22
-
23
- class Post < Ubiquitously::Base::Post
24
- def save
25
- return false unless valid?
26
-
27
- user.login
28
-
29
- page = agent.get("http://www.mixx.com/submit")
30
- form = page.form_with(:action => "http://www.mixx.com/submit/step2")
31
- form["thingy[page_url]"] = url
32
- page = form.submit
33
-
34
- # last page
35
- form = page.form_with(:action => "http://www.mixx.com/submit/save")
36
-
37
- # captcha
38
- iframe_url = page.parser.css("li.captcha iframe").first["src"]
39
- params = iframe_url.split("?").last
40
- captcha_iframe = agent.click(page.iframes.first)
41
- captcha_form = captcha_iframe.forms.first
42
- captcha_image = captcha_iframe.parser.css("img").first["src"]
43
- # open browser with captcha image
44
- system("open", "http://api.recaptcha.net/#{captcha_image}")
45
- # enter captcha response in terminal
46
- captcha_says = ask("Enter Captcha from Browser Image: ") { |q| q.echo = true }
47
- captcha_form["recaptcha_response_field"] = captcha_says
48
- # submit captcha
49
- captcha_form.action = "http://www.google.com/recaptcha/api/noscript?#{params}"
50
- captcha_response = captcha_form.submit
51
- # grab secret
52
- captcha_response = captcha_response.parser.css("textarea").first.text
53
-
54
- # submit post
55
- form = page.form_with(:action => "http://www.mixx.com/submit/save")
56
- form["thingy[title]"] = title
57
- form["thingy[description]"] = description if description
58
- form["thingy[new_tags]"] = tags if tags
59
- form["recaptcha_challenge_field"] = captcha_response
60
- form["recaptcha_response_field"] = captcha_says
61
-
62
- form.submit
63
- end
64
- end
65
- end
66
- end
@@ -1,54 +0,0 @@
1
- module Ubiquitously
2
- module Newsvine
3
- class User < Ubiquitously::Base::User
4
- def login
5
- return true if logged_in?
6
-
7
- page = agent.get("https://www.newsvine.com/_nv/accounts/login")
8
- form = page.form_with(:action => "https://www.newsvine.com/_nv/api/accounts/login")
9
- form["email"] = username
10
- form["password"] = password
11
- page = form.submit
12
-
13
- # No match. Please try again
14
- @logged_in = (page.title =~ /Log in/i).nil?
15
-
16
- unless @logged_in
17
- raise AuthenticationError.new("Invalid username or password for #{service_name.titleize}")
18
- end
19
-
20
- @logged_in
21
- end
22
- end
23
-
24
- class Post < Ubiquitously::Base::Post
25
- validates_presence_of :url, :title
26
-
27
- def save(options = {})
28
- return false unless valid?
29
-
30
- user.login
31
-
32
- page = agent.get("http://www.newsvine.com/_tools/seed")
33
- form = page.form_with(:action => "http://www.newsvine.com/_action/tools/saveLink")
34
-
35
- form["url"] = url
36
- form["headline"] = title
37
- form.radiobuttons_with(:name => "newsType").each do |button|
38
- button.check if button.value == "x"
39
- end
40
- form.field_with(:name => "categoryTag").options.each do |option|
41
- option.select if option.value == "technology"
42
- end
43
- form["blurb"] = description
44
- form["tags"] = tags.join(", ")
45
-
46
- unless options[:debug] == true
47
- page = form.submit
48
- end
49
-
50
- true
51
- end
52
- end
53
- end
54
- end
@@ -1,46 +0,0 @@
1
- module Ubiquitously
2
- module Reddit
3
- class User < Ubiquitously::Base::User
4
- def login
5
- return true if logged_in?
6
-
7
- page = agent.get("http://www.reddit.com/")
8
- form = page.form_with(:action => "http://www.reddit.com/post/login")
9
- form["user"] = username
10
- form["passwd"] = password
11
- page = form.submit
12
-
13
- @logged_in = (page.title =~ /login or register/i).nil?
14
-
15
- unless @logged_in
16
- raise AuthenticationError.new("Invalid username or password for #{service_name.titleize}")
17
- end
18
-
19
- @logged_in
20
- end
21
- end
22
-
23
- class Post < Ubiquitously::Base::Post
24
- validates_presence_of :url, :title
25
-
26
- def save(options = {})
27
- return false unless valid?
28
-
29
- user.login
30
-
31
- page = agent.get("http://www.reddit.com/submit")
32
- form = page.forms.detect {|form| form.form_node["id"] == "newlink"}
33
- form["title"] = title
34
- form["url"] = url
35
- form["id"] = "#newlink"
36
- form.action = "http://www.reddit.com/api/submit"
37
- headers = {
38
- "Content-Type" => "application/json"
39
- }
40
- unless options[:debug] == true
41
- page = form.submit(nil, headers)
42
- end
43
- end
44
- end
45
- end
46
- end
@@ -1,11 +0,0 @@
1
- module Ubiquitously
2
- module Sphinn
3
- class User
4
-
5
- end
6
-
7
- class Post
8
-
9
- end
10
- end
11
- end