babylonia 0.2.0 → 0.2.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,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- YzYzMTcwNjBhNThmMTUxYzVkZWE3ZTcwMzM4ZjhmM2MxZWMxMmVlNg==
5
- data.tar.gz: !binary |-
6
- YzkxZTg3YTc2YmY2NTFjMzdjMDIwYjg0OWQ3N2M0ZDA3OGE2MTkyMw==
2
+ SHA1:
3
+ metadata.gz: d6eff528d6e67b0f2657ec84208deb8ffa75c4e4
4
+ data.tar.gz: a76700f8ac3bf6080e35d3077bc7adb51b9a8cc0
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- ZTUxYjJhYTJjY2Q4Nzg3NmIzMGY1YzYxZjJjYTA0NTJjNWM5ZjAwODUxMWUx
10
- NzE4YjdlN2RjZGRlYWMzNjlhN2Q1ZjJiZGEyZDhmMGU2NTlhMzQyODk2YjQ3
11
- ZWI5M2UwYmQwNDI5YzIxY2I1MzE0NGNjMGFkYWU1YzIzMWEwZWE=
12
- data.tar.gz: !binary |-
13
- NTZmMzRhYzIwYjg0MTA3YTAyOWY3NWIwNjgzYTY1Y2UxOWY1MmUzNTY2YTdj
14
- ZmNiODU0NmY5MTNkNzU2ZDFmZTQxNzA5MmY5MGIzNjY1N2RiNDk0ZmM3ZDg1
15
- MzA3YmI1NTM2MWFlMTllYWIyMTFjMDYxNzMxNzFlMTQ4ZTY4MDM=
6
+ metadata.gz: 20a4f106bf3980f540d67e27febb751e525df8f1817b0dc76cb2faa6917812d8120ed2663a3b2619d323ff8fba3bd460dbfb72f362e269272122ffe0bbb10189
7
+ data.tar.gz: 36b9dd7fadf4dc395ef97f4319be4d90762d7a3cd023cd6b6b9da6edae429712da97f7906efa964b3abe61aa36c82960457215f7765389592ee9b11ceb588c2f
@@ -42,7 +42,28 @@ Or this:
42
42
 
43
43
  t.text = {en: 'This is english', fr: 'This is french'}
44
44
  I18n.locale = :fr
45
- t.text #=> :fr
45
+ t.text #=> 'This is french'
46
+
47
+ == Virtual Attributes
48
+ There are virtual attributes for you to work with
49
+
50
+ t = Transsylvania.new
51
+ t.text_de = 'Make it more Deutsch'
52
+ t.text_de #=> 'Make it more Deutsch'
53
+
54
+ They come in especially handy in forms, since they do not(!) use a fallback unless used with `fallback: true`
55
+
56
+ <form action="/do" method="POST">
57
+ <label for="english_translation">
58
+ English Translation Here Please
59
+ <input type="text" name="text_de" value="<%= form_object.text_en %>"/>
60
+ </label>
61
+ <label for="deutsche_uebersetzung">
62
+ Deutsche Übersetzung hier
63
+ <input type="text" name="text_de" value="<%= form_object.text_de %>"/>
64
+ </label>
65
+ <input type="submit" name="Go"/>
66
+ </form>
46
67
 
47
68
  == Extended Usage
48
69
  Let's once assume a pretty basic class. Extend it with the Babylonian Class method and add some options
@@ -82,8 +103,6 @@ Got to have helpers to build that tower with: These come with every babylonian t
82
103
 
83
104
  == Contributing to babylonia
84
105
 
85
- Please note that only open source APIs can be accepted as contributions to this gem. Private / Premium APIs have to be written as your own extension and will not be added to the gem code.
86
-
87
106
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
88
107
  * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
89
108
  * Fork the project.
@@ -111,7 +111,7 @@ module Babylonia
111
111
  private
112
112
 
113
113
  def extract_locale_method_parts meth
114
- if (parts = meth.to_s.match(/\A([^_]+)_(\w+)(=)?\z/).to_a[1..3]) && localized?(parts[0]) && has_available_locale?(parts[1])
114
+ if (parts = meth.to_s.match(/\A(\w+)_(\w+)(=)?\z/).to_a[1..3]) && localized?(parts[0]) && has_available_locale?(parts[1])
115
115
  parts
116
116
  end
117
117
  end
@@ -1,5 +1,5 @@
1
1
  module Babylonia
2
2
  # The current gem version
3
3
  #
4
- VERSION = '0.2.0'
4
+ VERSION = '0.2.1'.freeze
5
5
  end
@@ -6,9 +6,9 @@ describe Babylonia::ClassMethods do
6
6
  class BabylonianFields
7
7
  extend Babylonia::ClassMethods
8
8
 
9
- attr_accessor :marshes, :sky
9
+ attr_accessor :marshes, :sky, :some_attr
10
10
 
11
- build_babylonian_tower_on :marshes, :sky
11
+ build_babylonian_tower_on :marshes, :sky, :some_attr
12
12
  end
13
13
 
14
14
  before(:each) do
@@ -88,6 +88,13 @@ describe Babylonia::ClassMethods do
88
88
  lambda { subject.send(meth) }.should raise_error(NoMethodError)
89
89
  end
90
90
  end
91
+ context "with the missing method having underscores in the original method name" do
92
+ let(:meth) { :some_attr_en }
93
+ it "should call the attribute method with an argument" do
94
+ subject.should_receive(:some_attr).with(:en, {}).once
95
+ subject.send(meth)
96
+ end
97
+ end
91
98
  context "with the missing method matching the pattern but an unavailable language" do
92
99
  let(:meth) { :marshes_he }
93
100
  it "should raise Method Missing" do
@@ -170,6 +177,7 @@ describe Babylonia::ClassMethods do
170
177
  before(:each) do
171
178
  subject.marshes_raw = "---\n:it: SOME ITALIAN\n:en: SOME ENGLISH\n:de: SOME DEUTSCH\n"
172
179
  subject.sky_raw = "---\n:it: SOME ITALIAN\n:en: SOME ENGLISH\n:de: SOME DEUTSCH\n"
180
+ subject.some_attr_raw = "---\n:it: SOME ITALIAN\n:en: SOME ENGLISH\n:de: SOME DEUTSCH\n"
173
181
  end
174
182
  it "should return the translated languages of the field" do
175
183
  subject.locales.sort.should == [:de, :en, :it]
@@ -179,6 +187,7 @@ describe Babylonia::ClassMethods do
179
187
  before(:each) do
180
188
  subject.marshes_raw = "---\n:it: SOME ITALIAN\n:en: SOME ENGLISH\n:de: SOME DEUTSCH\n"
181
189
  subject.sky_raw = "---\n:it: SOME ITALIAN\n:en: SOME ENGLISH\n:de: SOME DEUTSCH\n"
190
+ subject.some_attr_raw = "---\n:it: SOME ITALIAN\n:en: SOME ENGLISH\n:de: SOME DEUTSCH\n"
182
191
  end
183
192
  context "with the locale present in the translation hashes" do
184
193
  it "should return true" do
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: babylonia
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Beat Richartz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-21 00:00:00.000000000 Z
11
+ date: 2013-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: 0.5.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ! '>='
24
+ - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.5.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: 1.0.0
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: 1.0.0
41
41
  description: Let your users translate their content into their languages without additional
@@ -70,20 +70,21 @@ require_paths:
70
70
  - lib
71
71
  required_ruby_version: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ! '>='
73
+ - - '>='
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  required_rubygems_version: !ruby/object:Gem::Requirement
77
77
  requirements:
78
- - - ! '>='
78
+ - - '>='
79
79
  - !ruby/object:Gem::Version
80
80
  version: '0'
81
81
  requirements: []
82
82
  rubyforge_project:
83
- rubygems_version: 2.1.11
83
+ rubygems_version: 2.0.7
84
84
  signing_key:
85
85
  specification_version: 4
86
86
  summary: Let there be languages!
87
87
  test_files:
88
88
  - spec/babylonia/class_methods_spec.rb
89
89
  - spec/spec_helper.rb
90
+ has_rdoc: