utopia 0.9.22 → 0.9.23

Sign up to get free protection for your applications and to get access to all the features.
@@ -21,6 +21,8 @@ module Utopia
21
21
  XNODE_EXT = ".xnode"
22
22
 
23
23
  def initialize(kind, path, info = nil)
24
+ path = Path.create(path)
25
+
24
26
  @kind = kind
25
27
 
26
28
  case @kind
@@ -36,7 +38,8 @@ module Utopia
36
38
  end
37
39
 
38
40
  @components = @name.split(".")
39
- @locale = components[1..-1].join(".")
41
+ @locale = path.locale(XNODE_EXT)
42
+
40
43
  @title = components[0]
41
44
 
42
45
  if info
@@ -211,8 +214,8 @@ module Utopia
211
214
  links.group_by(&:name).each do |name, links|
212
215
  default = nil
213
216
 
214
- link = links.reject{|link|
215
- !(link.locale == options[:locale] || link.locale == "")
217
+ link = links.select{|link|
218
+ link.locale == options[:locale] || link.locale == ''
216
219
  }.sort_by{|link| link.locale.size}.last
217
220
 
218
221
  if link
@@ -188,6 +188,28 @@ module Utopia
188
188
  def hash
189
189
  @components.hash
190
190
  end
191
+
192
+ def last
193
+ if directory?
194
+ components[-2]
195
+ else
196
+ components[-1]
197
+ end
198
+ end
199
+
200
+ def self.locale(name, extension = false)
201
+ if String === extension
202
+ name = File.basename(name, extension)
203
+ elsif extension
204
+ name = name.split
205
+ end
206
+
207
+ name.split(".")[1..-1].join(".")
208
+ end
209
+
210
+ def locale (extension = false)
211
+ return Path.locale(last, extension)
212
+ end
191
213
  end
192
214
 
193
215
  end
@@ -17,7 +17,7 @@ module Utopia
17
17
  module VERSION #:nodoc:
18
18
  MAJOR = 0
19
19
  MINOR = 9
20
- TINY = 22
20
+ TINY = 23
21
21
 
22
22
  STRING = [MAJOR, MINOR, TINY].join('.')
23
23
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 9
8
- - 22
9
- version: 0.9.22
8
+ - 23
9
+ version: 0.9.23
10
10
  platform: ruby
11
11
  authors:
12
12
  - Samuel Williams
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-03-30 00:00:00 +13:00
17
+ date: 2010-04-15 00:00:00 +12:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency