phrasing 2.1.0 → 2.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.
- data/README.md +1 -1
 - data/app/models/phrasing_phrase.rb +11 -7
 - data/lib/phrasing.rb +0 -6
 - data/lib/phrasing/version.rb +1 -1
 - metadata +2 -4
 - data/lib/phrasing/ambiguous_phrases_error.rb +0 -3
 - data/lib/phrasing/phrasable_error_handler.rb +0 -9
 
    
        data/README.md
    CHANGED
    
    | 
         @@ -90,4 +90,4 @@ Phrasing.allow_update_on_all_models_and_attributes = true 
     | 
|
| 
       90 
90 
     | 
    
         | 
| 
       91 
91 
     | 
    
         
             
            Copyright (c) 2013, Infinum
         
     | 
| 
       92 
92 
     | 
    
         | 
| 
       93 
     | 
    
         
            -
            Phrasing relies heavily (or is built) on two other libraries: the Copycat gem and the ZenPen library. So thank you to the authors and all the contributors! 
         
     | 
| 
      
 93 
     | 
    
         
            +
            Phrasing relies heavily (or is built) on two other libraries: the [Copycat gem](https://github.com/Zorros/copycat) and the [ZenPen library](https://github.com/tholman/zenpen/tree/master/). So thank you to the authors and all the contributors! 
         
     | 
| 
         @@ -1,5 +1,4 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            class PhrasingPhrase < ActiveRecord::Base
         
     | 
| 
       2 
     | 
    
         
            -
              require 'phrasing/ambiguous_phrases_error'
         
     | 
| 
       3 
2 
     | 
    
         | 
| 
       4 
3 
     | 
    
         
             
              unless ENV['PHRASING_DEBUG']
         
     | 
| 
       5 
4 
     | 
    
         
             
                self.logger = Logger.new('/dev/null')
         
     | 
| 
         @@ -7,11 +6,13 @@ class PhrasingPhrase < ActiveRecord::Base 
     | 
|
| 
       7 
6 
     | 
    
         | 
| 
       8 
7 
     | 
    
         
             
              validates_presence_of :key, :locale
         
     | 
| 
       9 
8 
     | 
    
         | 
| 
       10 
     | 
    
         
            -
               
     | 
| 
      
 9 
     | 
    
         
            +
              # These validation methods are used so the YAML file can be exported/imported properly.
         
     | 
| 
      
 10 
     | 
    
         
            +
              validate :check_ambiguity, on: :create, :unless => Proc.new { |phrase| phrase.key.nil? }
         
     | 
| 
      
 11 
     | 
    
         
            +
              validate :key_muts_not_end_with_a_dot, on: :create, :unless => Proc.new { |phrase| phrase.key.nil? }
         
     | 
| 
       11 
12 
     | 
    
         | 
| 
       12 
13 
     | 
    
         
             
              def self.create_phrase(key)
         
     | 
| 
       13 
14 
     | 
    
         
             
                phrasing_phrase = PhrasingPhrase.new
         
     | 
| 
       14 
     | 
    
         
            -
                phrasing_phrase.key = key
         
     | 
| 
      
 15 
     | 
    
         
            +
                phrasing_phrase.key = key.to_s
         
     | 
| 
       15 
16 
     | 
    
         
             
                phrasing_phrase.value = key.to_s.humanize
         
     | 
| 
       16 
17 
     | 
    
         
             
                phrasing_phrase.locale = I18n.locale
         
     | 
| 
       17 
18 
     | 
    
         
             
                phrasing_phrase.save!
         
     | 
| 
         @@ -69,7 +70,6 @@ class PhrasingPhrase < ActiveRecord::Base 
     | 
|
| 
       69 
70 
     | 
    
         | 
| 
       70 
71 
     | 
    
         
             
              extend Serialize
         
     | 
| 
       71 
72 
     | 
    
         | 
| 
       72 
     | 
    
         
            -
             
     | 
| 
       73 
73 
     | 
    
         
             
              private
         
     | 
| 
       74 
74 
     | 
    
         | 
| 
       75 
75 
     | 
    
         
             
                def check_ambiguity
         
     | 
| 
         @@ -82,16 +82,20 @@ class PhrasingPhrase < ActiveRecord::Base 
     | 
|
| 
       82 
82 
     | 
    
         
             
                  while stripped_key.include?('.')
         
     | 
| 
       83 
83 
     | 
    
         
             
                    stripped_key = stripped_key.split('.')[0..-2].join('.')
         
     | 
| 
       84 
84 
     | 
    
         
             
                    if PhrasingPhrase.where(key: stripped_key).count > 0
         
     | 
| 
       85 
     | 
    
         
            -
                         
     | 
| 
      
 85 
     | 
    
         
            +
                        errors.add(:key, "can't be named '#{key}', there already exists a key named '#{stripped_key}'. Ambiguous calling!")
         
     | 
| 
       86 
86 
     | 
    
         
             
                    end
         
     | 
| 
       87 
87 
     | 
    
         
             
                  end
         
     | 
| 
       88 
88 
     | 
    
         
             
                end
         
     | 
| 
       89 
89 
     | 
    
         | 
| 
       90 
90 
     | 
    
         
             
                def check_ambiguity_on_successors
         
     | 
| 
       91 
91 
     | 
    
         
             
                  key_successor = "#{key}."
         
     | 
| 
       92 
     | 
    
         
            -
                  if PhrasingPhrase.where(PhrasingPhrase.arel_table[:key].matches(" 
     | 
| 
       93 
     | 
    
         
            -
                     
     | 
| 
      
 92 
     | 
    
         
            +
                  if PhrasingPhrase.where(PhrasingPhrase.arel_table[:key].matches("#{key_successor}%")).count > 0
         
     | 
| 
      
 93 
     | 
    
         
            +
                    errors.add(:key, "can't be named '#{key}', there already exists one or multiple keys beginning with '#{key_successor}'. Ambiguous calling!")
         
     | 
| 
       94 
94 
     | 
    
         
             
                  end
         
     | 
| 
       95 
95 
     | 
    
         
             
                end
         
     | 
| 
       96 
96 
     | 
    
         | 
| 
      
 97 
     | 
    
         
            +
                def key_muts_not_end_with_a_dot
         
     | 
| 
      
 98 
     | 
    
         
            +
                  errors.add(:key, "mustn't end with a dot") if key[-1] == "."
         
     | 
| 
      
 99 
     | 
    
         
            +
                end
         
     | 
| 
      
 100 
     | 
    
         
            +
             
     | 
| 
       97 
101 
     | 
    
         
             
            end
         
     | 
    
        data/lib/phrasing.rb
    CHANGED
    
    | 
         @@ -1,7 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require 'phrasing'
         
     | 
| 
       2 
2 
     | 
    
         
             
            require "phrasing/implementation"
         
     | 
| 
       3 
3 
     | 
    
         
             
            require "phrasing/simple"
         
     | 
| 
       4 
     | 
    
         
            -
            require 'phrasing/phrasable_error_handler'
         
     | 
| 
       5 
4 
     | 
    
         | 
| 
       6 
5 
     | 
    
         
             
            module Phrasing
         
     | 
| 
       7 
6 
     | 
    
         
             
              module Rails
         
     | 
| 
         @@ -11,11 +10,6 @@ module Phrasing 
     | 
|
| 
       11 
10 
     | 
    
         
             
                    ::Rails.application.config.assets.paths << ::Rails.root.join('app', 'assets', 'images')
         
     | 
| 
       12 
11 
     | 
    
         
             
                    ::Rails.application.config.assets.precompile += ['editor.js', 'phrasing_engine.css', 'icomoon.dev.svg', 'icomoon.svg', 'icomoon.eot', 'icomoon.ttf', 'icomoon.woff', 'phrasing_information_icon.png']
         
     | 
| 
       13 
12 
     | 
    
         
             
                  end
         
     | 
| 
       14 
     | 
    
         
            -
                  initializer "phrasing" do
         
     | 
| 
       15 
     | 
    
         
            -
                    ActiveSupport.on_load(:action_controller) do
         
     | 
| 
       16 
     | 
    
         
            -
                      # ActionController::Base.send(:include, PhrasableErrorHandler)
         
     | 
| 
       17 
     | 
    
         
            -
                    end
         
     | 
| 
       18 
     | 
    
         
            -
                  end
         
     | 
| 
       19 
13 
     | 
    
         
             
                end
         
     | 
| 
       20 
14 
     | 
    
         
             
              end
         
     | 
| 
       21 
15 
     | 
    
         
             
            end
         
     | 
    
        data/lib/phrasing/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: phrasing
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 2.1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 2.1.1
         
     | 
| 
       5 
5 
     | 
    
         
             
              prerelease: 
         
     | 
| 
       6 
6 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       7 
7 
     | 
    
         
             
            authors:
         
     | 
| 
         @@ -10,7 +10,7 @@ authors: 
     | 
|
| 
       10 
10 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       11 
11 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       12 
12 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       13 
     | 
    
         
            -
            date: 2013-10- 
     | 
| 
      
 13 
     | 
    
         
            +
            date: 2013-10-15 00:00:00.000000000 Z
         
     | 
| 
       14 
14 
     | 
    
         
             
            dependencies:
         
     | 
| 
       15 
15 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       16 
16 
     | 
    
         
             
              name: rails
         
     | 
| 
         @@ -101,9 +101,7 @@ files: 
     | 
|
| 
       101 
101 
     | 
    
         
             
            - config/routes.rb
         
     | 
| 
       102 
102 
     | 
    
         
             
            - db/migrate/20120313191745_create_phrasing_phrases.rb
         
     | 
| 
       103 
103 
     | 
    
         
             
            - lib/phrasing.rb
         
     | 
| 
       104 
     | 
    
         
            -
            - lib/phrasing/ambiguous_phrases_error.rb
         
     | 
| 
       105 
104 
     | 
    
         
             
            - lib/phrasing/implementation.rb
         
     | 
| 
       106 
     | 
    
         
            -
            - lib/phrasing/phrasable_error_handler.rb
         
     | 
| 
       107 
105 
     | 
    
         
             
            - lib/phrasing/simple.rb
         
     | 
| 
       108 
106 
     | 
    
         
             
            - lib/phrasing/version.rb
         
     | 
| 
       109 
107 
     | 
    
         
             
            - lib/tasks/phrasing_tasks.rake
         
     |