glue 1.1.0 → 1.1.1
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/History.txt +5 -0
- data/README.txt +42 -58
- data/Rakefile +1 -0
- data/lib/glue.rb +11 -13
- data/test/test_glue.rb +14 -12
- metadata +6 -9
data/History.txt
CHANGED
data/README.txt
CHANGED
@@ -1,108 +1,92 @@
|
|
1
1
|
= glue
|
2
2
|
|
3
|
-
http://Glue.RubyForge.org
|
4
|
-
|
5
3
|
http://GlueNow.com
|
6
4
|
|
7
5
|
== DESCRIPTION:
|
8
6
|
|
9
|
-
The Glue gem enables posting to GlueNow.com API service using an account subdomain, username, password. In this version you can add a post by providing a title
|
10
|
-
|
11
|
-
You can also request public posts from an account using the same RSS that powers the many Glue feeds.
|
7
|
+
The Glue gem enables posting to GlueNow.com API service using an account subdomain, username, password. In this version you can add a post by providing a title and body. You can access some basic info about a users account and check if their account info is valid and request public posts from an account using the same RSS that powers many of the Glue feeds.
|
12
8
|
|
13
9
|
== FEATURES/PROBLEMS:
|
14
10
|
|
15
|
-
* To Add a new post Title & Body text must be included
|
16
|
-
* Access info about an account with successful login:
|
17
|
-
* Email Address
|
18
|
-
* If they are an admin
|
19
|
-
* Thier Author Name
|
20
|
-
* Can check if a subdomain is valid and belongs to an account
|
21
|
-
* Read all public posts
|
22
|
-
* This Gem is throughly tested
|
23
|
-
* Adding & Reading posts Only at this time
|
24
|
-
* You can't editor delete a posts yet
|
25
|
-
* No way to verify if a post has accepted the author name yet
|
26
11
|
|
12
|
+
Adding new posts requires Title & Body text
|
13
|
+
Access info about an account with successful login:
|
14
|
+
* Email Address
|
15
|
+
* If they are an admin
|
16
|
+
* Their Author Name
|
17
|
+
Check a subdomain is valid and belongs to an account
|
18
|
+
Read all public posts
|
19
|
+
Gem is thoroughly tested
|
20
|
+
Only allows Adding & Reading posts at this time
|
21
|
+
You can't edit or delete posts
|
27
22
|
|
28
|
-
== SYNOPSIS:
|
29
23
|
|
30
|
-
|
24
|
+
== SYNOPSIS:
|
31
25
|
|
32
|
-
|
26
|
+
TO ADD A POST USING THE GLUENOW.COM API
|
33
27
|
|
34
|
-
|
28
|
+
1. Instantiate your account - Provide subdomain, username and password of http://Your-Subdomain.GlueNow.com Account
|
35
29
|
|
36
|
-
account = Glue::API.new(
|
30
|
+
account = Glue::API.new("your-subdomain", "your-username", "your-password")
|
37
31
|
|
38
|
-
2. Check if the account subdomain is valid
|
32
|
+
2. Check if the account subdomain is valid
|
39
33
|
|
40
34
|
account.valid_site?
|
41
35
|
|
42
|
-
3. Get more info about the user's account
|
36
|
+
3. Get more info about the user's account
|
43
37
|
|
44
|
-
|
38
|
+
user = account.user_info
|
45
39
|
|
46
|
-
|
40
|
+
user #=> {"rsp"=>{"user"=>{"author"=>"Jordan Dobson","admin"=>"true","email"=>"jordandobson@gmail.com"},"stat"=>"ok"}}
|
47
41
|
|
48
|
-
4. Post
|
49
|
-
|
50
|
-
* Both Title and Body are required - Set to a variable to check the response
|
51
|
-
|
52
|
-
response = account.post("My Title", "My Body")
|
53
|
-
|
54
|
-
* You can also choose to set the post as private and/or use the optional Author Name
|
55
|
-
* In this example we set false for not private and true to use the author name
|
42
|
+
4. Post Your Content - Title & Body are required
|
56
43
|
|
57
|
-
response = account.post("My Title", "
|
44
|
+
response = account.post("My Title", "Body Text")
|
58
45
|
|
46
|
+
5. Receive a Success or Error Hash
|
59
47
|
|
60
|
-
|
61
|
-
|
62
|
-
* A Successful response would look like this
|
48
|
+
SUCCESS
|
63
49
|
|
64
50
|
response #=> {"rsp"=>{"post"=>{"title"=>"My Title","url"=>"http://bit.ly/sakIM","id"=>"14415","longurl"=>"http://jordandobson.com"},"stat"=>"ok"}}
|
65
51
|
|
66
|
-
|
52
|
+
ERROR
|
67
53
|
|
68
54
|
response #=> {}
|
69
|
-
|
70
|
-
---- Reading Posts ----
|
71
55
|
|
72
|
-
|
73
|
-
|
74
|
-
|
56
|
+
|
57
|
+
TO READ POSTS USING GLUENOW.COM RSS
|
58
|
+
|
59
|
+
1. Instantiate your Reader with your account info - Provide subdomain for http://Your-Subdomain.GlueNow.com Account
|
75
60
|
|
76
|
-
account = Glue::RSS.new(
|
61
|
+
account = Glue::RSS.new("your-account")
|
77
62
|
|
78
|
-
2. Request posts from the RSS feed
|
79
|
-
|
80
|
-
* If you want all of them don't include any limiting or range. Defaults to up to 999 posts on one page
|
63
|
+
2. Request posts from the RSS feed - Include an optional limit & page view for paging
|
81
64
|
|
82
|
-
|
65
|
+
all_the_posts = account.feed
|
83
66
|
|
84
|
-
|
67
|
+
OR
|
85
68
|
|
86
|
-
|
69
|
+
limited_posts = account.feed(10, 3)
|
87
70
|
|
88
|
-
3.
|
71
|
+
3. Receive a Success or Error Hash - Example is simplified to include important nodes
|
89
72
|
|
90
|
-
|
73
|
+
SUCCESS
|
91
74
|
|
92
|
-
|
75
|
+
all_the_posts #=> {"rss"=>{"channel"=>{"item"=>{"pubDate"=>"Fri, 12 Sep 2008 00:00:00 +0000","title"=>"My Title","guid"=>"http://jordandobson.com#14415","dc:creator"=>"Jordan","description"=>"<p>Body Text</p>","link"=>"http://jordandobson.com","source"=>"Glue"}}}}
|
93
76
|
|
94
|
-
|
77
|
+
ERROR
|
95
78
|
|
96
|
-
|
79
|
+
all_the_posts #=> {}
|
80
|
+
|
81
|
+
|
97
82
|
|
98
83
|
== REQUIREMENTS:
|
99
84
|
|
100
|
-
|
101
|
-
* Mocha (for tests)
|
85
|
+
HTTParty
|
102
86
|
|
103
87
|
== INSTALL:
|
104
88
|
|
105
|
-
|
89
|
+
sudo gem install glue
|
106
90
|
|
107
91
|
== LICENSE:
|
108
92
|
|
data/Rakefile
CHANGED
@@ -7,6 +7,7 @@ require './lib/glue.rb'
|
|
7
7
|
Hoe.new('glue', Glue::VERSION) do |p|
|
8
8
|
# p.rubyforge_name = 'gluex' # if different than lowercase project name
|
9
9
|
p.developer('Jordan Dobson', 'jordan.dobson@madebysquad.com')
|
10
|
+
p.extra_deps = ['nokogiri']
|
10
11
|
p.extra_deps = ['httparty']
|
11
12
|
p.extra_dev_deps = ['mocha']
|
12
13
|
p.remote_rdoc_dir = '' # Release to root
|
data/lib/glue.rb
CHANGED
@@ -4,7 +4,7 @@ require 'open-uri'
|
|
4
4
|
|
5
5
|
module Glue
|
6
6
|
|
7
|
-
VERSION = '1.1.
|
7
|
+
VERSION = '1.1.1'
|
8
8
|
DOMAIN = 'gluenow.com'
|
9
9
|
|
10
10
|
class AuthError < StandardError; end
|
@@ -30,27 +30,25 @@ module Glue
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def user_info
|
33
|
-
response = self.class.
|
33
|
+
response = self.class.get(
|
34
34
|
USER,
|
35
|
-
:
|
36
|
-
:basic_auth => @auth
|
35
|
+
{ :basic_auth => @auth }
|
37
36
|
)
|
38
37
|
response['rsp'] ? response : {}
|
39
|
-
|
40
38
|
end
|
41
39
|
|
42
40
|
def post title, body, *opts
|
43
|
-
response = self.class.
|
41
|
+
response = self.class.get(
|
44
42
|
POST,
|
45
|
-
:query
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
43
|
+
{ :query => {
|
44
|
+
:title => title,
|
45
|
+
:body => body,
|
46
|
+
:draft => opts.include?( :draft ) ,
|
47
|
+
:author => opts.include?( :author ) },
|
48
|
+
:basic_auth => @auth
|
49
|
+
}
|
51
50
|
)
|
52
51
|
response['rsp'] ? response : {}
|
53
|
-
|
54
52
|
end
|
55
53
|
|
56
54
|
private
|
data/test/test_glue.rb
CHANGED
@@ -5,6 +5,7 @@ require "mocha"
|
|
5
5
|
class TestGlue < Test::Unit::TestCase
|
6
6
|
|
7
7
|
def setup
|
8
|
+
@badClient = Glue::API.new( "notavalidurl", "fail", "fail" )
|
8
9
|
@subdomain = 'AccountSubDomain'
|
9
10
|
@username = 'Username'
|
10
11
|
@password = 'Password'
|
@@ -19,7 +20,8 @@ class TestGlue < Test::Unit::TestCase
|
|
19
20
|
@lurl = "http://jordandobson.com"
|
20
21
|
@guid = "#{@lurl}##{@id}"
|
21
22
|
@guid2 = "#{@lurl}##{@id2}"
|
22
|
-
@author = "Jordan"
|
23
|
+
@author = "Jordan Dobson"
|
24
|
+
@email = "jordan.dobson@madebysquad.com"
|
23
25
|
|
24
26
|
@resp_fail = {}
|
25
27
|
@resp_html = {"html"=>{"head"=>{"title" => "GLUE | Web + Mobile Publishing"}}}
|
@@ -28,7 +30,7 @@ class TestGlue < Test::Unit::TestCase
|
|
28
30
|
"user" => {
|
29
31
|
"author" => @author,
|
30
32
|
"admin" => "true" ,
|
31
|
-
"email" =>
|
33
|
+
"email" => @email },
|
32
34
|
"stat" => "ok" }}
|
33
35
|
|
34
36
|
@post_ok = { "rsp" => {
|
@@ -118,38 +120,38 @@ class TestGlue < Test::Unit::TestCase
|
|
118
120
|
|
119
121
|
def test_site_is_valid
|
120
122
|
@client.stubs(:login_page).returns('<html><body id="login"></body></html>')
|
121
|
-
assert
|
123
|
+
assert @client.valid_site?
|
122
124
|
end
|
123
125
|
|
124
126
|
def test_site_is_invalid
|
125
127
|
@client.stubs(:login_page).returns('<html><body></body></html>')
|
126
|
-
assert
|
128
|
+
assert !@badClient.valid_site?
|
127
129
|
end
|
128
130
|
|
129
131
|
def test_user_info_valid
|
130
|
-
Glue::API.stubs(:
|
132
|
+
Glue::API.stubs(:get).returns(@resp_ok)
|
131
133
|
actual = @client.user_info
|
132
134
|
assert_equal "ok", actual["rsp"]["stat"]
|
133
135
|
assert actual["rsp"]["user"]
|
134
|
-
assert_equal
|
136
|
+
assert_equal @author, actual["rsp"]["user"]["author"]
|
135
137
|
assert_equal "true", actual["rsp"]["user"]["admin"]
|
136
|
-
assert_equal
|
138
|
+
assert_equal @email, actual["rsp"]["user"]["email"]
|
137
139
|
end
|
138
140
|
|
139
141
|
def test_user_info_invalid
|
140
|
-
Glue::API.stubs(:
|
141
|
-
actual = @
|
142
|
+
Glue::API.stubs(:get).returns(@resp_html)
|
143
|
+
actual = @badClient.user_info
|
142
144
|
assert_equal @resp_fail, actual
|
143
145
|
end
|
144
146
|
|
145
147
|
def test_bad_post_response
|
146
|
-
|
147
|
-
actual = @
|
148
|
+
Glue::API.stubs(:get).returns(@resp_html)
|
149
|
+
actual = @badClient.post(@title, @body)
|
148
150
|
assert_equal @resp_fail, actual
|
149
151
|
end
|
150
152
|
|
151
153
|
def test_good_post_response
|
152
|
-
Glue::API.stubs(:
|
154
|
+
Glue::API.stubs(:get).returns(@post_ok)
|
153
155
|
actual = @client.post(@title, @body)
|
154
156
|
assert_equal "ok", actual["rsp"]["stat"]
|
155
157
|
assert actual["rsp"]["post"]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glue
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jordan Dobson
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2010-01-29 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -40,12 +40,9 @@ dependencies:
|
|
40
40
|
requirements:
|
41
41
|
- - ">="
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version:
|
43
|
+
version: 2.3.3
|
44
44
|
version:
|
45
|
-
description:
|
46
|
-
The Glue gem enables posting to GlueNow.com API service using an account subdomain, username, password. In this version you can add a post by providing a title, body, optional author name and optional private settings. You can also access some basic info about a users account and check if their account info is valid.
|
47
|
-
|
48
|
-
You can also request public posts from an account using the same RSS that powers the many Glue feeds.
|
45
|
+
description: The Glue gem enables posting to GlueNow.com API service using an account subdomain, username, password. In this version you can add a post by providing a title and body. You can access some basic info about a users account and check if their account info is valid and request public posts from an account using the same RSS that powers many of the Glue feeds.
|
49
46
|
email:
|
50
47
|
- jordan.dobson@madebysquad.com
|
51
48
|
executables: []
|
@@ -64,7 +61,7 @@ files:
|
|
64
61
|
- lib/glue.rb
|
65
62
|
- test/test_glue.rb
|
66
63
|
has_rdoc: true
|
67
|
-
homepage: http://
|
64
|
+
homepage: http://GlueNow.com
|
68
65
|
licenses: []
|
69
66
|
|
70
67
|
post_install_message:
|
@@ -88,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
85
|
requirements: []
|
89
86
|
|
90
87
|
rubyforge_project: glue
|
91
|
-
rubygems_version: 1.3.
|
88
|
+
rubygems_version: 1.3.5
|
92
89
|
signing_key:
|
93
90
|
specification_version: 3
|
94
91
|
summary: The Glue gem enables posting to GlueNow.com API service using an account subdomain, username, password
|