haml-edge 3.1.70 → 3.1.71

Sign up to get free protection for your applications and to get access to all the features.
data/EDGE_GEM_VERSION CHANGED
@@ -1 +1 @@
1
- 3.1.70
1
+ 3.1.71
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.1.70
1
+ 3.1.71
data/lib/haml/util.rb CHANGED
@@ -231,6 +231,44 @@ module Haml
231
231
  info
232
232
  end
233
233
 
234
+ # Returns whether one version string represents a more recent version than another.
235
+ #
236
+ # @param v1 [String] A version string.
237
+ # @param v2 [String] Another version string.
238
+ # @return [Boolean]
239
+ def version_gt(v1, v2)
240
+ # Construct an array to make sure the shorter version is padded with nil
241
+ Array.new([v1.length, v2.length].max).zip(v1.split("."), v2.split(".")) do |_, p1, p2|
242
+ p1 ||= "0"
243
+ p2 ||= "0"
244
+ release1 = p1 =~ /^[0-9]+$/
245
+ release2 = p2 =~ /^[0-9]+$/
246
+ if release1 && release2
247
+ # Integer comparison if both are full releases
248
+ p1, p2 = p1.to_i, p2.to_i
249
+ next if p1 == p2
250
+ return p1 > p2
251
+ elsif !release1 && !release2
252
+ # String comparison if both are prereleases
253
+ next if p1 == p2
254
+ return p1 > p2
255
+ else
256
+ # If only one is a release, that one is newer
257
+ return release1
258
+ end
259
+ end
260
+ end
261
+
262
+ # Returns whether one version string represents the same or a more
263
+ # recent version than another.
264
+ #
265
+ # @param v1 [String] A version string.
266
+ # @param v2 [String] Another version string.
267
+ # @return [Boolean]
268
+ def version_geq(v1, v2)
269
+ version_gt(v1, v2) || !version_gt(v2, v1)
270
+ end
271
+
234
272
  # Silence all output to STDERR within a block.
235
273
  #
236
274
  # @yield A block in which no output will be printed to STDERR
@@ -308,7 +346,7 @@ module Haml
308
346
  return false unless defined?(ActionPack) && defined?(ActionPack::VERSION) &&
309
347
  defined?(ActionPack::VERSION::STRING)
310
348
 
311
- ActionPack::VERSION::STRING >= version
349
+ version_geq(ActionPack::VERSION::STRING, version)
312
350
  end
313
351
 
314
352
  # Returns an ActionView::Template* class.
@@ -217,6 +217,29 @@ class UtilTest < Test::Unit::TestCase
217
217
  assert_equal(["/tmp/foo.rb", 12, "fizzle"], caller_info("/tmp/foo.rb:12: in `fizzle {}'"))
218
218
  end
219
219
 
220
+ def test_version_gt
221
+ assert_version_gt("2.0.0", "1.0.0")
222
+ assert_version_gt("1.1.0", "1.0.0")
223
+ assert_version_gt("1.0.1", "1.0.0")
224
+ assert_version_gt("1.0.0", "1.0.0.rc")
225
+ assert_version_gt("1.0.0.1", "1.0.0.rc")
226
+ assert_version_gt("1.0.0.rc", "0.9.9")
227
+ assert_version_gt("1.0.0.beta", "1.0.0.alpha")
228
+
229
+ assert_version_eq("1.0.0", "1.0.0")
230
+ assert_version_eq("1.0.0", "1.0.0.0")
231
+ end
232
+
233
+ def assert_version_gt(v1, v2)
234
+ #assert(version_gt(v1, v2), "Expected #{v1} > #{v2}")
235
+ assert(!version_gt(v2, v1), "Expected #{v2} < #{v1}")
236
+ end
237
+
238
+ def assert_version_eq(v1, v2)
239
+ assert(!version_gt(v1, v2), "Expected #{v1} = #{v2}")
240
+ assert(!version_gt(v2, v1), "Expected #{v2} = #{v1}")
241
+ end
242
+
220
243
  def test_def_static_method
221
244
  klass = Class.new
222
245
  def_static_method(klass, :static_method, [:arg1, :arg2],
data/test/test_helper.rb CHANGED
@@ -76,7 +76,15 @@ class Test::Unit::TestCase
76
76
 
77
77
  def rails_form_opener
78
78
  return '' unless Haml::Util.ap_geq?("3.0.0.rc")
79
- return '<div style="margin:0;padding:0;display:inline"><input name="_snowman" type="hidden" value="&#9731;" /></div>'
79
+ if Haml::Util.ap_geq?("3.0.0.rc2")
80
+ encoding = 'utf8'
81
+ char = '&#x2713;'
82
+ else
83
+ encoding = '_snowman'
84
+ char = '&#9731;'
85
+ end
86
+ return '<div style="margin:0;padding:0;display:inline"><input name="' + encoding +
87
+ '" type="hidden" value="' + char + '" /></div>'
80
88
  end
81
89
 
82
90
  def assert_raise_message(klass, message)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: haml-edge
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.70
4
+ version: 3.1.71
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Weizenbaum
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2010-08-28 00:00:00 -04:00
14
+ date: 2010-08-30 00:00:00 -04:00
15
15
  default_executable:
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency