localization 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3b8f504bcba9472312a3797b12e24c2f4729e0e7
4
- data.tar.gz: e2f6305a7f7f8e0b17bcf30822f2e968b58aff82
3
+ metadata.gz: ad7714ba916da59eea687808b2a6bb17a19c99bf
4
+ data.tar.gz: 2bdc455bcf85124e39dc30a0c36893e068f7219e
5
5
  SHA512:
6
- metadata.gz: a066b992b9b977eb3cf4bce7d69b0b1a0c7e9d118cdf50aad338ea64da405a3855f879d4b1d196c6cc76e317a7398f98a8816d04c69e5b41b9cfe2e768cfb1eb
7
- data.tar.gz: 29f904d17882b31f36dc35a410965bfc0e08ad32ef6e5f1dd374fc20a2b6f00ac9d81080cdaf3c9b02b2f2a374cbd7270df7b18603bd49cb4b7900233c78cd67
6
+ metadata.gz: 91d2766bd9e21f9697934565803b8129934b1c596788faf8f9b879e090b8fcc3ece521512aceeb198927df4ef621c28f644aacfbdf1ae98b97ab46a53fb7dcb6
7
+ data.tar.gz: c75b20b45bea5d0cb5f55ae3025e913801c9c413d160193735158bcfb5d4779f0770f74d382460745965a00c222ca825723ca4bb77956217cb7291b7aec0fd95
@@ -14,11 +14,7 @@ class Localization
14
14
 
15
15
  def initialize(tree = nil, assignments = nil)
16
16
  @assignments = assignments || {}
17
- @tree = tree || roots.inject({}) do |memo, subtree|
18
- memo.tap do |object|
19
- object.merge!(subtree)
20
- end
21
- end
17
+ @tree = tree || default_tree
22
18
  end
23
19
 
24
20
  def method_missing(name, *arguments, &block)
@@ -35,6 +31,14 @@ class Localization
35
31
 
36
32
  private
37
33
 
34
+ def default_tree
35
+ roots.inject({}) do |memo, subtree|
36
+ memo.tap do |object|
37
+ object.merge!(subtree)
38
+ end
39
+ end
40
+ end
41
+
38
42
  def roots
39
43
  Localization.sources.map do |root|
40
44
  { key_from(root) => subtree_from(root) }
@@ -18,14 +18,16 @@ class Localization
18
18
  end
19
19
  end
20
20
 
21
- class Railtie < ::Rails::Railtie
22
- initializer "localization_railtie.extend_action_controller" do
23
- ActionController::Base.send :include, Localization::Shortcut
24
- ActionController::Base.helper :localize
25
- end
21
+ if defined?(::Rails)
22
+ class Railtie < ::Rails::Railtie
23
+ initializer "localization_railtie.extend_action_controller" do
24
+ ActionController::Base.send :include, Localization::Shortcut
25
+ ActionController::Base.helper :localize
26
+ end
26
27
 
27
- initializer "localization_railtie.set_localization_paths" do
28
- Localization.sources.push(Dir[File.join(Rails.root, "lib", "locale", "*.yml"))
28
+ initializer "localization_railtie.set_localization_paths" do
29
+ Localization.sources.push(Dir[File.join(Rails.root, "lib", "locale", "*.yml")])
30
+ end
29
31
  end
30
- end if defined?(Rails)
32
+ end
31
33
  end
@@ -1,3 +1,3 @@
1
1
  class Localization
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.1"
3
3
  end
@@ -0,0 +1,10 @@
1
+ require "spec_helper"
2
+ require "localization/main"
3
+
4
+ describe Localization::Main do
5
+ # def localize
6
+ # Localization.new
7
+ # end
8
+
9
+ # include Localization::Main
10
+ end
@@ -0,0 +1,20 @@
1
+ require "spec_helper"
2
+ require "localization/railtie"
3
+
4
+ describe Localization::Rails do
5
+ # def action_localize
6
+ # control_local.send(action_name)
7
+ # end
8
+ # alias_method :action_local, :action_localize
9
+ # alias_method :view_localize, :action_localize
10
+
11
+ # def control_localize
12
+ # localize.send(controller_name)
13
+ # end
14
+ # alias_method :control_local, :control_localize
15
+
16
+ # def localize
17
+ # Localization.new.send(I18n.locale)
18
+ # end
19
+ end
20
+
@@ -1,5 +1,33 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe Localization do
4
+ # def self.sources=(items)
5
+ # @@sources = items
6
+ # end
4
7
 
8
+ # def self.sources
9
+ # @@sources
10
+ # end
11
+
12
+ # def default_tree
13
+ # roots.inject({}) do |memo, subtree|
14
+ # memo.tap do |object|
15
+ # object.merge!(subtree)
16
+ # end
17
+ # end
18
+ # end
19
+
20
+ # def roots
21
+ # Localization.sources.map do |root|
22
+ # { key_from(root) => subtree_from(root) }
23
+ # end
24
+ # end
25
+
26
+ # def key_from(root)
27
+ # Pathname.new(root).basename(".yml").to_s
28
+ # end
29
+
30
+ # def subtree_from(path)
31
+ # YAML.load(File.read(path))
32
+ # end
5
33
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: localization
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kurtis Rainbolt-Greene
@@ -147,6 +147,8 @@ files:
147
147
  - lib/localization/railtie.rb
148
148
  - lib/localization/version.rb
149
149
  - lib/localization.rb
150
+ - spec/lib/localization/main_spec.rb
151
+ - spec/lib/localization/railtie_spec.rb
150
152
  - spec/lib/localization/version_spec.rb
151
153
  - spec/lib/localization_spec.rb
152
154
  - spec/spec_helper.rb
@@ -175,6 +177,8 @@ signing_key:
175
177
  specification_version: 4
176
178
  summary: A dirt simple localization gem
177
179
  test_files:
180
+ - spec/lib/localization/main_spec.rb
181
+ - spec/lib/localization/railtie_spec.rb
178
182
  - spec/lib/localization/version_spec.rb
179
183
  - spec/lib/localization_spec.rb
180
184
  - spec/spec_helper.rb