couch_i18n 0.0.9 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ rescue LoadError
5
5
  puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
6
  end
7
7
 
8
- require 'rake/rdoctask'
8
+ require 'rdoc/task'
9
9
 
10
10
  Rake::RDocTask.new(:rdoc) do |rdoc|
11
11
  rdoc.rdoc_dir = 'rdoc'
@@ -5,7 +5,7 @@ module CouchI18n
5
5
 
6
6
  property :key
7
7
  property :value
8
- property :translated, :type => :boolean, :default => true
8
+ property :translated, type: :boolean, default: true
9
9
 
10
10
  validates_uniqueness_of :key
11
11
 
@@ -14,13 +14,22 @@ module CouchI18n
14
14
  view :all_documents, :key => :key
15
15
  view :by_key, :key => :key
16
16
 
17
- view :with_key_array, :map => %|function(doc){
17
+ view :with_key_array, map_function: %|function(doc){
18
18
  if(doc.ruby_class && doc.ruby_class == 'CouchI18n::Translation') {
19
19
  emit(doc.key.split('.').slice(0, -1), 1);
20
20
  }
21
- }|, :type => :raw, :reduce => '_sum'
21
+ }|, type: :raw, reduce_function: :_sum
22
22
 
23
- view :untranslated_view, :key => :key, :conditions => "!doc['translated']"
23
+ view :untranslated_view, key: :key, conditions: "!doc['translated']"
24
+ view :by_value, key: :value
25
+ view :by_key_part, type: :custom, map_function: %|function(doc){
26
+ if(doc.ruby_class && doc.ruby_class == 'CouchI18n::Translation') {
27
+ var parts = doc.key.split('.');
28
+ for(var i = 0; i < parts.length; i++){
29
+ emit(parts[i], 1);
30
+ }
31
+ }
32
+ }|
24
33
 
25
34
  def self.get_keys_by_level(level = 0, options = {})
26
35
  data = database.view(with_key_array(options.merge(:group_level => level.succ)))["rows"]
@@ -33,6 +42,10 @@ module CouchI18n
33
42
  CouchI18n::Translation.find_all_by_key("#{offset}.".."#{offset}.ZZZZZZZZZ", options)
34
43
  end
35
44
 
45
+ def self.find_all_by_key_part(part)
46
+ database.view(by_key_part(key: part, reduce: false, include_docs: true))
47
+ end
48
+
36
49
  def self.untranslated(*args)
37
50
  database.view(untranslated_view(*args))
38
51
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: couch_i18n
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-08 00:00:00.000000000Z
12
+ date: 2012-03-28 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activemodel
16
- requirement: &70227779264000 !ruby/object:Gem::Requirement
16
+ requirement: &70199467348060 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '3'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70227779264000
24
+ version_requirements: *70199467348060
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: simply_stored
27
- requirement: &70227779263580 !ruby/object:Gem::Requirement
27
+ requirement: &70199467347600 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70227779263580
35
+ version_requirements: *70199467347600
36
36
  description: couch_i18n is an in database storage for I18n translations, tested for
37
37
  rails, with online management views
38
38
  email: bterkuile@gmail.com