less_simple 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ *.swp
2
+ *.swo
3
+ pkg/
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Ryan Angilly
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,11 @@
1
+ = LessSimple
2
+
3
+ Add default values to the Simple backend for I18n
4
+
5
+ = License
6
+
7
+ LessSimple is released under the MIT license.
8
+
9
+ = Support
10
+
11
+ Just email me at ryan@angilly.com with questions, bugs, or patches.
data/Rakefile ADDED
@@ -0,0 +1,21 @@
1
+ begin
2
+ require 'jeweler'
3
+ Jeweler::Tasks.new do |gemspec|
4
+ gemspec.name = "less_simple"
5
+ gemspec.summary = "Adds default interpolation values to the Simple backend for I18n"
6
+ gemspec.description = ""
7
+ gemspec.email = "ryan@angilly.com"
8
+ gemspec.homepage = "http://github.com/ryana/less_simple"
9
+ gemspec.authors = ["Ryan Angilly"]
10
+
11
+ gemspec.add_dependency 'active_support', '2.3.5'
12
+
13
+ gemspec.add_development_dependency 'shoulda', '2.11.0'
14
+ gemspec.add_development_dependency 'mocha', '0.9.8'
15
+ gemspec.add_development_dependency 'factory_girl', '1.3.1'
16
+ gemspec.add_development_dependency 'ruby-debug', '0.10.3'
17
+ end
18
+ Jeweler::GemcutterTasks.new
19
+ rescue LoadError
20
+ puts "Jeweler not available. Install it with: gem install jeweler"
21
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,69 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{less_simple}
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Ryan Angilly"]
12
+ s.date = %q{2010-07-19}
13
+ s.description = %q{}
14
+ s.email = %q{ryan@angilly.com}
15
+ s.extra_rdoc_files = [
16
+ "README"
17
+ ]
18
+ s.files = [
19
+ ".gitignore",
20
+ "MIT-LICENSE",
21
+ "README",
22
+ "Rakefile",
23
+ "VERSION",
24
+ "less_simple.gemspec",
25
+ "lib/less_simple.rb",
26
+ "test/functional/test_helper.rb",
27
+ "test/test_helper.rb",
28
+ "test/unit/en.yml",
29
+ "test/unit/test_helper.rb",
30
+ "test/unit/test_less_simple.rb"
31
+ ]
32
+ s.homepage = %q{http://github.com/ryana/less_simple}
33
+ s.rdoc_options = ["--charset=UTF-8"]
34
+ s.require_paths = ["lib"]
35
+ s.rubygems_version = %q{1.3.6}
36
+ s.summary = %q{Adds default interpolation values to the Simple backend for I18n}
37
+ s.test_files = [
38
+ "test/functional/test_helper.rb",
39
+ "test/test_helper.rb",
40
+ "test/unit/test_helper.rb",
41
+ "test/unit/test_less_simple.rb"
42
+ ]
43
+
44
+ if s.respond_to? :specification_version then
45
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
46
+ s.specification_version = 3
47
+
48
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
49
+ s.add_runtime_dependency(%q<active_support>, ["= 2.3.5"])
50
+ s.add_development_dependency(%q<shoulda>, ["= 2.11.0"])
51
+ s.add_development_dependency(%q<mocha>, ["= 0.9.8"])
52
+ s.add_development_dependency(%q<factory_girl>, ["= 1.3.1"])
53
+ s.add_development_dependency(%q<ruby-debug>, ["= 0.10.3"])
54
+ else
55
+ s.add_dependency(%q<active_support>, ["= 2.3.5"])
56
+ s.add_dependency(%q<shoulda>, ["= 2.11.0"])
57
+ s.add_dependency(%q<mocha>, ["= 0.9.8"])
58
+ s.add_dependency(%q<factory_girl>, ["= 1.3.1"])
59
+ s.add_dependency(%q<ruby-debug>, ["= 0.10.3"])
60
+ end
61
+ else
62
+ s.add_dependency(%q<active_support>, ["= 2.3.5"])
63
+ s.add_dependency(%q<shoulda>, ["= 2.11.0"])
64
+ s.add_dependency(%q<mocha>, ["= 0.9.8"])
65
+ s.add_dependency(%q<factory_girl>, ["= 1.3.1"])
66
+ s.add_dependency(%q<ruby-debug>, ["= 0.10.3"])
67
+ end
68
+ end
69
+
@@ -0,0 +1,15 @@
1
+ gem 'activesupport', '2.3.5'
2
+ require 'active_support/vendor'
3
+
4
+ module I18n
5
+ module Backend
6
+ class LessSimple < Simple
7
+ attr_accessor :interpolation_defaults
8
+
9
+ def translate(locale, key, options = {})
10
+ options = (interpolation_defaults || {}).merge options
11
+ super locale, key, options
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'test_helper')
@@ -0,0 +1,9 @@
1
+ require 'test/unit'
2
+ require 'mocha'
3
+ require 'ruby-debug'
4
+ require 'shoulda'
5
+ require 'factory_girl'
6
+
7
+ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
8
+
9
+ require 'less_simple'
data/test/unit/en.yml ADDED
@@ -0,0 +1,3 @@
1
+ en:
2
+ welcome: Oh hi there
3
+ site: "{{site_name}} Party Planner"
@@ -0,0 +1 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'test_helper')
@@ -0,0 +1,46 @@
1
+ require File.join(File.dirname(__FILE__), 'test_helper')
2
+
3
+ class TestLessSimple < Test::Unit::TestCase
4
+
5
+ should "have LessSimple" do
6
+ assert I18n::Backend::LessSimple
7
+ end
8
+
9
+ context "with a less_simple backend" do
10
+ setup do
11
+ @backend = I18n::Backend::LessSimple.new
12
+ @backend.load_translations(File.join(File.dirname(__FILE__), 'en.yml'))
13
+ end
14
+
15
+ should "have interpolation_defaults" do
16
+ assert @backend.respond_to?(:interpolation_defaults=)
17
+ assert @backend.respond_to?(:interpolation_defaults)
18
+ end
19
+
20
+ should "still work" do
21
+ assert_equal "Oh hi there", @backend.translate('en', 'welcome')
22
+ assert_equal "MPB Party Planner", @backend.translate('en', 'site', :site_name => 'MPB')
23
+ end
24
+
25
+ should "still throw exceptions on missing values" do
26
+ assert_raises I18n::MissingInterpolationArgument do
27
+ puts @backend.translate('en', 'site')
28
+ end
29
+ end
30
+
31
+ context "with defaults" do
32
+ setup do
33
+ @backend.interpolation_defaults = {:site_name => 'skin & bones'}
34
+ end
35
+
36
+ should "still work" do
37
+ assert_equal "Oh hi there", @backend.translate('en', 'welcome')
38
+ assert_equal "MPB Party Planner", @backend.translate('en', 'site', :site_name => 'MPB')
39
+ end
40
+
41
+ should "use defaults" do
42
+ assert_equal 'skin & bones Party Planner', @backend.translate('en', 'site')
43
+ end
44
+ end
45
+ end
46
+ end
metadata ADDED
@@ -0,0 +1,145 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: less_simple
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 0
9
+ version: 0.1.0
10
+ platform: ruby
11
+ authors:
12
+ - Ryan Angilly
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-07-19 00:00:00 -04:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: active_support
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 2
29
+ - 3
30
+ - 5
31
+ version: 2.3.5
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: shoulda
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "="
40
+ - !ruby/object:Gem::Version
41
+ segments:
42
+ - 2
43
+ - 11
44
+ - 0
45
+ version: 2.11.0
46
+ type: :development
47
+ version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ name: mocha
50
+ prerelease: false
51
+ requirement: &id003 !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "="
54
+ - !ruby/object:Gem::Version
55
+ segments:
56
+ - 0
57
+ - 9
58
+ - 8
59
+ version: 0.9.8
60
+ type: :development
61
+ version_requirements: *id003
62
+ - !ruby/object:Gem::Dependency
63
+ name: factory_girl
64
+ prerelease: false
65
+ requirement: &id004 !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "="
68
+ - !ruby/object:Gem::Version
69
+ segments:
70
+ - 1
71
+ - 3
72
+ - 1
73
+ version: 1.3.1
74
+ type: :development
75
+ version_requirements: *id004
76
+ - !ruby/object:Gem::Dependency
77
+ name: ruby-debug
78
+ prerelease: false
79
+ requirement: &id005 !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "="
82
+ - !ruby/object:Gem::Version
83
+ segments:
84
+ - 0
85
+ - 10
86
+ - 3
87
+ version: 0.10.3
88
+ type: :development
89
+ version_requirements: *id005
90
+ description: ""
91
+ email: ryan@angilly.com
92
+ executables: []
93
+
94
+ extensions: []
95
+
96
+ extra_rdoc_files:
97
+ - README
98
+ files:
99
+ - .gitignore
100
+ - MIT-LICENSE
101
+ - README
102
+ - Rakefile
103
+ - VERSION
104
+ - less_simple.gemspec
105
+ - lib/less_simple.rb
106
+ - test/functional/test_helper.rb
107
+ - test/test_helper.rb
108
+ - test/unit/en.yml
109
+ - test/unit/test_helper.rb
110
+ - test/unit/test_less_simple.rb
111
+ has_rdoc: true
112
+ homepage: http://github.com/ryana/less_simple
113
+ licenses: []
114
+
115
+ post_install_message:
116
+ rdoc_options:
117
+ - --charset=UTF-8
118
+ require_paths:
119
+ - lib
120
+ required_ruby_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ segments:
125
+ - 0
126
+ version: "0"
127
+ required_rubygems_version: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ segments:
132
+ - 0
133
+ version: "0"
134
+ requirements: []
135
+
136
+ rubyforge_project:
137
+ rubygems_version: 1.3.6
138
+ signing_key:
139
+ specification_version: 3
140
+ summary: Adds default interpolation values to the Simple backend for I18n
141
+ test_files:
142
+ - test/functional/test_helper.rb
143
+ - test/test_helper.rb
144
+ - test/unit/test_helper.rb
145
+ - test/unit/test_less_simple.rb