utopia 0.9.56 → 0.9.57

Sign up to get free protection for your applications and to get access to all the features.
data/lib/utopia.rb CHANGED
@@ -14,3 +14,8 @@
14
14
  #
15
15
  # You should have received a copy of the GNU Affero General Public License along with this
16
16
  # program. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ require 'utopia/version'
19
+
20
+ module Utopia
21
+ end
@@ -2,19 +2,66 @@
2
2
  # Copyright 2010 Samuel Williams. All rights reserved.
3
3
  # See <utopia.rb> for licensing details.
4
4
 
5
+ # These amendments allow for Date <=> DateTime <=> Time, and so on.
6
+ # Use only if required. This implementation works for Ruby 1.9.2.
7
+
5
8
  require 'date'
6
9
 
7
10
  class Date
8
- alias_method :old_cmp, :<=>
11
+ alias_method :old_compare, :<=>
12
+
13
+ def <=>(other)
14
+ if other.class == Date
15
+ old_compare(other)
16
+ else
17
+ if Time === other
18
+ other = other.to_datetime
19
+ end
20
+
21
+ if DateTime === other
22
+ result = old_compare(other.to_date)
23
+ if result == 0 && other.day_fraction > 0
24
+ -1
25
+ else
26
+ result
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+
33
+ class Time
34
+ alias_method :old_compare, :<=>
9
35
 
10
- def <=> (other)
11
- # Comparing a Date with something that has a time component truncates the time
12
- # component, thus we need to check if the other object has a more exact comparison
13
- # function.
14
- if other.respond_to?(:hour)
15
- return (other <=> self) * -1
36
+ def <=>(other)
37
+ if other.class == Date
38
+ (other <=> self) * -1
39
+ elsif Time === other
40
+ old_compare(other)
16
41
  else
17
- old_cmp(other)
42
+ if DateTime === other
43
+ other = other.to_time
44
+ end
45
+
46
+ old_compare(other)
18
47
  end
19
- end
48
+ end
20
49
  end
50
+
51
+ class DateTime
52
+ alias_method :old_compare, :<=>
53
+
54
+ def <=>(other)
55
+ if other.class == Date
56
+ (other <=> self) * -1
57
+ elsif DateTime === other
58
+ old_compare(other)
59
+ else
60
+ if Time === other
61
+ other = other.to_datetime
62
+ end
63
+
64
+ old_compare(other)
65
+ end
66
+ end
67
+ end
data/lib/utopia/link.rb CHANGED
@@ -4,7 +4,6 @@
4
4
 
5
5
  require 'yaml'
6
6
 
7
- require 'utopia/extensions/date'
8
7
  require 'utopia/extensions/string'
9
8
  require 'utopia/extensions/hash'
10
9
  require 'utopia/extensions/array'
@@ -4,7 +4,9 @@
4
4
 
5
5
  require 'pathname'
6
6
 
7
- Pathname.new(__FILE__).dirname.entries.grep(/\.rb$/).each do |path|
7
+ Pathname.new(__FILE__).dirname.entries.each do |path|
8
+ next unless /\.rb$/ === path.to_s
9
+
8
10
  name = File.basename(path.to_s, ".rb")
9
11
 
10
12
  if name != "all"
@@ -98,6 +98,11 @@ module Utopia
98
98
  }
99
99
  request(env.merge(path_env))
100
100
  end
101
+
102
+ # Avoid a huge amount of junk being printed when inspecting +env+.
103
+ def inspect
104
+ to_s
105
+ end
101
106
  end
102
107
 
103
108
  end
@@ -175,6 +175,7 @@ module Utopia
175
175
 
176
176
  # Fix a problem if the browser request has multiple @rel@
177
177
  # This normally indicates a browser bug.. :(
178
+ name = name.dup
178
179
  name.delete("@rel@")
179
180
  else
180
181
  path = path.dirname
data/lib/utopia/tags.rb CHANGED
@@ -11,7 +11,7 @@ module Utopia
11
11
  end
12
12
 
13
13
  def self.create(name, &block)
14
- @@all[name] = Proc.new(&block)
14
+ @@all[name] = block
15
15
  end
16
16
 
17
17
  def self.all
@@ -4,7 +4,9 @@
4
4
 
5
5
  require 'pathname'
6
6
 
7
- Pathname.new(__FILE__).dirname.entries.grep(/\.rb$/).each do |path|
7
+ Pathname.new(__FILE__).dirname.entries.each do |path|
8
+ next unless /\.rb$/ === path.to_s
9
+
8
10
  name = File.basename(path.to_s, ".rb")
9
11
 
10
12
  if name != "all"
@@ -6,19 +6,14 @@ require 'utopia/tags'
6
6
 
7
7
  Utopia::Tags.create("google_analytics") do |transaction, state|
8
8
  html = <<EOF
9
- <!-- Google Analytics -->
10
-
11
9
  <script type="text/javascript">
12
- var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
13
- document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
10
+ var _gaq = _gaq || []; _gaq.push(['_setAccount', #{state[:id].to_quoted_string}]); _gaq.push(['_trackPageview']);
11
+ (function() {
12
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
13
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
14
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
15
+ })();
14
16
  </script>
15
- <script type="text/javascript">
16
- try {
17
- var pageTracker = _gat._getTracker(#{state[:id].dump});
18
- pageTracker._trackPageview();
19
- } catch(err) {}</script>
20
-
21
- <!-- Google Analytics -->
22
17
  EOF
23
18
 
24
19
 
@@ -35,7 +35,7 @@ module Utopia
35
35
  @header = []
36
36
  end
37
37
 
38
- diff = (Set.new(header) + "time") - @header
38
+ diff = (Set.new(header) + ["time"]) - @header
39
39
 
40
40
  if diff.size
41
41
  @header += diff.to_a.sort
@@ -3,11 +3,11 @@
3
3
  # See <utopia.rb> for licensing details.
4
4
 
5
5
  module Utopia
6
- module VERSION
7
- MAJOR = 0
8
- MINOR = 9
9
- TINY = 56
6
+ module VERSION
7
+ MAJOR = 0
8
+ MINOR = 9
9
+ TINY = 57
10
10
 
11
- STRING = [MAJOR, MINOR, TINY].join('.')
12
- end
11
+ STRING = [MAJOR, MINOR, TINY].join('.')
12
+ end
13
13
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: utopia
3
3
  version: !ruby/object:Gem::Version
4
- hash: 75
4
+ hash: 73
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
- - 56
10
- version: 0.9.56
9
+ - 57
10
+ version: 0.9.57
11
11
  platform: ruby
12
12
  authors:
13
13
  - Samuel Williams
@@ -15,8 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-07-01 00:00:00 +12:00
19
- default_executable: utopia
18
+ date: 2011-08-30 00:00:00 Z
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
21
  name: mime-types
@@ -156,7 +155,6 @@ files:
156
155
  - lib/utopia/xnode.rb
157
156
  - lib/utopia.rb
158
157
  - bin/utopia
159
- has_rdoc: true
160
158
  homepage: http://www.oriontransfer.co.nz/software/utopia
161
159
  licenses: []
162
160
 
@@ -186,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
186
184
  requirements: []
187
185
 
188
186
  rubyforge_project:
189
- rubygems_version: 1.6.2
187
+ rubygems_version: 1.8.7
190
188
  signing_key:
191
189
  specification_version: 3
192
190
  summary: Utopia is a framework for building websites.