glue 0.0.1 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +19 -0
- data/INSTALL +56 -0
- data/README +3 -0
- data/Rakefile +73 -10
- data/doc/AUTHORS +16 -0
- data/doc/LICENSE +33 -0
- data/doc/RELEASES +5 -0
- data/install.rb +47 -0
- data/lib/glue.rb +57 -59
- data/lib/glue/array.rb +61 -0
- data/lib/glue/attribute.rb +83 -0
- data/lib/glue/cache.rb +138 -0
- data/lib/glue/flexob.rb +12 -0
- data/lib/glue/hash.rb +122 -0
- data/lib/glue/inflector.rb +91 -0
- data/lib/glue/logger.rb +147 -0
- data/lib/glue/misc.rb +14 -0
- data/lib/glue/mixins.rb +36 -0
- data/lib/glue/number.rb +24 -0
- data/lib/glue/object.rb +32 -0
- data/lib/glue/pool.rb +60 -0
- data/lib/glue/property.rb +408 -0
- data/lib/glue/string.rb +162 -0
- data/lib/glue/time.rb +85 -0
- data/lib/glue/validation.rb +461 -0
- data/test/glue/tc_attribute.rb +22 -0
- data/test/glue/tc_cache.rb +45 -0
- data/test/glue/tc_hash.rb +38 -0
- data/test/glue/tc_logger.rb +39 -0
- data/test/glue/tc_numbers.rb +20 -0
- data/test/glue/tc_property.rb +91 -0
- data/test/glue/tc_property_mixins.rb +93 -0
- data/test/glue/tc_property_type_checking.rb +35 -0
- data/test/glue/tc_strings.rb +103 -0
- data/test/glue/tc_validation.rb +214 -0
- metadata +95 -89
- data/History.txt +0 -6
- data/Manifest.txt +0 -7
- data/README.txt +0 -127
- data/bin/glue +0 -1
- data/test/test_glue.rb +0 -218
data/bin/glue
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
data/test/test_glue.rb
DELETED
@@ -1,218 +0,0 @@
|
|
1
|
-
require "test/unit"
|
2
|
-
require "#{File.dirname(__FILE__)}/../lib/glue.rb"
|
3
|
-
require "mocha"
|
4
|
-
|
5
|
-
class TestGlue < Test::Unit::TestCase
|
6
|
-
|
7
|
-
def setup
|
8
|
-
@subdomain = 'AccountSubDomain'
|
9
|
-
@username = 'Username'
|
10
|
-
@password = 'Password'
|
11
|
-
@client = Glue::API.new( @subdomain, @username, @password )
|
12
|
-
@title = "My Title"
|
13
|
-
@title2 = "Your Title"
|
14
|
-
@body = "Body Text"
|
15
|
-
@body2 = "Hello World"
|
16
|
-
@url = "http://bit.ly/sakIM"
|
17
|
-
@id = "14415"
|
18
|
-
@id2 = "14416"
|
19
|
-
@lurl = "http://jordandobson.com"
|
20
|
-
@guid = "#{@lurl}##{@id}"
|
21
|
-
@guid2 = "#{@lurl}##{@id2}"
|
22
|
-
@author = "Jordan"
|
23
|
-
|
24
|
-
@resp_fail = {}
|
25
|
-
|
26
|
-
@resp_ok = { "rsp" => {
|
27
|
-
"user" => {
|
28
|
-
"author" => @author,
|
29
|
-
"admin" => "true" ,
|
30
|
-
"email" => nil },
|
31
|
-
"stat" => "ok" }}
|
32
|
-
|
33
|
-
@post_ok = { "rsp" => {
|
34
|
-
"post" => {
|
35
|
-
"title" => @title ,
|
36
|
-
"url" => @url ,
|
37
|
-
"id" => @id ,
|
38
|
-
"longurl" => @lurl },
|
39
|
-
"stat" => "ok" }}
|
40
|
-
|
41
|
-
@rss = { "rss" => {
|
42
|
-
"channel" => {
|
43
|
-
"item" => {
|
44
|
-
"pubDate" => "Fri, 12 Sep 2008 00:00:00 +0000",
|
45
|
-
"title" => @title ,
|
46
|
-
"guid" => @guid ,
|
47
|
-
"dc:creator" => @author ,
|
48
|
-
"description" => "<p>#{@body}</p>" ,
|
49
|
-
"link" => @lurl ,
|
50
|
-
"source" => "Glue" }}}}
|
51
|
-
|
52
|
-
@rss_many = { "rss" => {
|
53
|
-
"channel" => {
|
54
|
-
"item" => [{
|
55
|
-
"pubDate" => "Fri, 12 Sep 2008 00:00:00 +0000",
|
56
|
-
"title" => @title ,
|
57
|
-
"guid" => @guid ,
|
58
|
-
"dc:creator" => @author ,
|
59
|
-
"description" => "<p>#{@body}</p>" ,
|
60
|
-
"link" => @lurl ,
|
61
|
-
"source" => "Glue" },{
|
62
|
-
"pubDate" => "Fri, 12 Sep 2009 00:00:00 +0000",
|
63
|
-
"title" => @title2 ,
|
64
|
-
"guid" => @guid2 ,
|
65
|
-
"dc:creator" => nil ,
|
66
|
-
"description" => "<p>#{@body2}</p>" ,
|
67
|
-
"link" => @lurl ,
|
68
|
-
"source" => "Glue" }]}}}
|
69
|
-
|
70
|
-
@rss_empty = { "rss" => {
|
71
|
-
"channel" => {
|
72
|
-
"pubDate" => "Tue, 18 Aug 2009 10:48:28 +0000" ,
|
73
|
-
"webMaster" => "glue@jordan.gluenow.com (Glue)" ,
|
74
|
-
"link" => "http://jordandobson.com" }}}
|
75
|
-
|
76
|
-
@html_page = { "html" => {
|
77
|
-
"head" => {
|
78
|
-
"title" => "GLUE | Web + Mobile Content Publishing" },
|
79
|
-
"body" => "<p>Webpage Body</p>" }}
|
80
|
-
end
|
81
|
-
|
82
|
-
def test_raises_without_account_url
|
83
|
-
assert_raise Glue::AuthError do
|
84
|
-
Glue::API.new( '' , @username, @password )
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
def test_raises_without_user
|
89
|
-
assert_raise Glue::AuthError do
|
90
|
-
Glue::API.new( @subdomain, '', @password )
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
def test_raises_without_password
|
95
|
-
assert_raise Glue::AuthError do
|
96
|
-
Glue::API.new( @subdomain, @username, '' )
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
def test_raises_with_number_account_url
|
101
|
-
assert_raise NoMethodError do
|
102
|
-
Glue::API.new( 00 , @username, @password )
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
def test_raises_with_number_user
|
107
|
-
assert_raise NoMethodError do
|
108
|
-
Glue::API.new( @subdomain, 00, @password )
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
def test_raises_with_number_password
|
113
|
-
assert_raise NoMethodError do
|
114
|
-
Glue::API.new( @subdomain, @username, 00 )
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
def test_site_is_valid
|
119
|
-
OpenURI.stubs(:open_uri).returns('<body id="login"></body>')
|
120
|
-
assert @client.valid_site?
|
121
|
-
end
|
122
|
-
|
123
|
-
def test_site_is_invalid
|
124
|
-
OpenURI.stubs(:open_uri).returns('<body></body>')
|
125
|
-
assert !@client.valid_site?
|
126
|
-
end
|
127
|
-
|
128
|
-
def test_user_info_valid
|
129
|
-
Glue::API.stubs(:post).returns(@resp_ok)
|
130
|
-
actual = @client.user_info
|
131
|
-
assert_equal "ok", actual["rsp"]["stat"]
|
132
|
-
assert actual["rsp"]["user"]
|
133
|
-
assert_equal "Jordan", actual["rsp"]["user"]["author"]
|
134
|
-
assert_equal "true", actual["rsp"]["user"]["admin"]
|
135
|
-
assert_equal nil, actual["rsp"]["user"]["email"]
|
136
|
-
end
|
137
|
-
|
138
|
-
def test_user_info_invalid
|
139
|
-
Glue::API.stubs(:post).returns(@resp_fail)
|
140
|
-
actual = @client.user_info
|
141
|
-
assert_equal @resp_fail, actual
|
142
|
-
end
|
143
|
-
|
144
|
-
def test_bad_post_response
|
145
|
-
Glue::API.stubs(:post).returns(@resp_fail)
|
146
|
-
actual = @client.post(@title, @body)
|
147
|
-
assert_equal @resp_fail, actual
|
148
|
-
end
|
149
|
-
|
150
|
-
def test_good_post_response
|
151
|
-
Glue::API.stubs(:post).returns(@post_ok)
|
152
|
-
actual = @client.post(@title, @body)
|
153
|
-
assert_equal "ok", actual["rsp"]["stat"]
|
154
|
-
assert actual["rsp"]["post"]
|
155
|
-
assert_equal @title, actual["rsp"]["post"]["title"]
|
156
|
-
assert_equal @url, actual["rsp"]["post"]["url"]
|
157
|
-
assert_equal @id, actual["rsp"]["post"]["id"]
|
158
|
-
assert_equal @lurl, actual["rsp"]["post"]["longurl"]
|
159
|
-
end
|
160
|
-
|
161
|
-
# Need to test pusting with the options
|
162
|
-
|
163
|
-
def test_reading_single_post
|
164
|
-
Glue::RSS.stubs(:get).returns(@rss)
|
165
|
-
actual = Glue::RSS.new('jordan').feed(1,1)['rss']['channel']["item"]
|
166
|
-
assert_equal @title, actual["title"]
|
167
|
-
assert_match @body, actual["description"]
|
168
|
-
assert_equal @lurl, actual["link"]
|
169
|
-
assert_equal @guid, actual["guid"]
|
170
|
-
assert_equal @author, actual["dc:creator"]
|
171
|
-
end
|
172
|
-
|
173
|
-
def test_reading_multiple_posts
|
174
|
-
Glue::RSS.stubs(:get).returns(@rss_many)
|
175
|
-
actual = Glue::RSS.new('jordan').feed['rss']['channel']["item"]
|
176
|
-
assert_equal 2, actual.length
|
177
|
-
|
178
|
-
# First Article
|
179
|
-
assert_equal @title, actual.first["title"]
|
180
|
-
assert_match @body, actual.first["description"]
|
181
|
-
assert_equal @lurl, actual.first["link"]
|
182
|
-
assert_equal @guid, actual.first["guid"]
|
183
|
-
assert_equal @author, actual.first["dc:creator"]
|
184
|
-
|
185
|
-
# Last Article
|
186
|
-
assert_equal @title2, actual.last["title"]
|
187
|
-
assert_match @body2, actual.last["description"]
|
188
|
-
assert_equal nil, actual.last["dc:creator"]
|
189
|
-
assert_equal @lurl, actual.last["link"]
|
190
|
-
assert_equal @guid2, actual.last["guid"]
|
191
|
-
|
192
|
-
assert_not_equal actual.first["title"], actual.last["title"]
|
193
|
-
assert_not_equal actual.first["description"], actual.last["description"]
|
194
|
-
assert_not_equal actual.first["dc:creator"], actual.last["dc:creator"]
|
195
|
-
assert_not_equal actual.first["guid"], actual.last["guid"]
|
196
|
-
assert_equal actual.first["link"], actual.last["link"]
|
197
|
-
end
|
198
|
-
|
199
|
-
def test_no_public_posts_available
|
200
|
-
Glue::RSS.stubs(:get).returns(@rss_empty)
|
201
|
-
subdomain = 'jordan'
|
202
|
-
actual = Glue::RSS.new(subdomain).feed
|
203
|
-
assert actual["rss"]["channel"]
|
204
|
-
assert_nil actual["rss"]["channel"]["item"]
|
205
|
-
assert_match subdomain, actual["rss"]["channel"]["webMaster"]
|
206
|
-
end
|
207
|
-
|
208
|
-
def test_bad_url
|
209
|
-
Glue::RSS.stubs(:get).returns(@html_page)
|
210
|
-
actual = Glue::RSS.new('666-DIE-666').feed
|
211
|
-
assert actual["html"]
|
212
|
-
assert_nil actual["rss"]
|
213
|
-
assert_raise NoMethodError do
|
214
|
-
actual["rss"]["channel"]
|
215
|
-
end
|
216
|
-
end
|
217
|
-
|
218
|
-
end
|