Commit bf562cb92819cb57c797e4701042af0f24f0cf1e

  • Tree SHA1: 909c009
  • Parent SHA1: 8663d62 (Fix a CSS syntax bug and adjust some div heights that were wrong as a result of fixing the aforementioned bug.)
  • raw diff | raw patch
Add more tests, refactor, add Rakefile with test and rcov targets, update gitignore.
.gitignore
(1 / 0)
  
11*~
22*.yml
33untracked/
4coverage/
Rakefile
(22 / 0)
  
1# -*- ruby -*-
2require 'rake'
3require 'rake/testtask'
4require 'rcov/rcovtask'
5task :default => ["test"]
6
7task :test do
8 Rake::TestTask.new do |t|
9 t.libs << "tests"
10 t.test_files = FileList['tests/*.rb']
11 t.verbose = true
12 end
13end
14
15task :rcov do
16 Rcov::RcovTask.new do |t|
17 t.test_files = FileList['tests/*.rb']
18 t.verbose = true
19 t.rcov_opts << "--test-unit-only"
20 t.rcov_opts << "-x \"/site_ruby/\""
21 end
22end
  
5050end
5151
5252def html(text)
53 return text.gsub(/&(?!(amp|lt|gt|#39|quot);)/, "&amp;").
53 return escape_amp(text).
5454 gsub("<", "&lt;").
5555 gsub(">", "&gt;").
5656 gsub("'", "&#39;").
9494end
9595
9696def convert_time_to_est(time)
97 date_time = DateTime.parse(time)
98 new_time = date_time.new_offset(Rational(-1,6))
97 new_time = DateTime.parse(time).new_offset(Rational(-1,6))
9998 return new_time.strftime("%A, %B %e %Y at %l:%M %P")
10099end
101100
181181 metadata[site]['new_since'] = metadata[site]['last_id']
182182 next
183183 end
184 metadata[site]['last_update'] = DateTime.parse(first['created_at']).new_offset(Rational(-1,6)).strftime("%A, %B %e %Y at %l:%M %P")
185 metadata[site]['last_request'] = Time.now.strftime("%A, %B %e %Y at %l:%M %P")
184 metadata[site]['last_update'] = convert_time_to_est(first['created_at'])
185 metadata[site]['last_request'] = convert_time_to_est(Time.now.to_s)
186186 metadata[site]['new_since'] = metadata[site]['last_id']
187187 metadata[site]['last_id'] = first['id']
188188 end
  
133133 identicaify("Conan\'s #Tonight_Show: \"In the year 3000 #Facebook, #Twitter, and #YouTube merge to form the largest time-wasting site ever: #YouTwitFace.\"")
134134 end
135135 end
136
137 context "html" do
138 should "correctly encode <, >, ', \", and &" do
139 assert_equal "&lt;", html("<")
140 assert_equal "&gt;", html(">")
141 assert_equal "&quot;", html("\"")
142 assert_equal "&amp;", html("&")
143 assert_equal "&#39;", html("'")
144
145 assert_equal "&lt;;&gt;", html("<;>")
146 assert_equal "&gt;;&lt;", html(">;<")
147
148 assert_equal "&amp;", html("&amp;")
149 assert_equal "&lt;", html("&lt;")
150 assert_equal "&gt;", html("&gt;")
151 assert_equal "&#39;", html("'")
152 assert_equal "&quot;", html("\"")
153
154 assert_equal "&amp;", html("&")
155 assert_equal "&amp;foo", html("&foo")
156 assert_equal "&amp;foo;", html("&foo;")
157 assert_equal "foo&amp;", html("foo&")
158 end
159 end
160
161 context "parse_text" do
162 should "not linkify hashtags from twitter" do
163 assert_equal "I like #pie", parse_text("twitter", "I like #pie")
164 end
165 should "linkify hashtags from identica" do
166 assert_equal "I like #<a href=\"http://identi.ca/tag/pie\">pie</a>",
167 parse_text("identica", "I like #pie")
168 end
169 end
170
171 context "handling time" do
172 should "be in the right time zone" do
173 assert_equal "Tuesday, June 9 2009 at 5:39 pm",
174 convert_time_to_est("Tue Jun 09 21:39:31 +0000 2009")
175 end
176 end
136177end