copycat 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -40,6 +40,18 @@ Since this process requires no code commits, non-developers can also 'deploy' co
40
40
 
41
41
  You can also commit Copycat's YAML export, which is compatible with i18n, to your git repository.
42
42
 
43
+ ## Routes ##
44
+
45
+ The default route to edit copy is '/copycat_translations'. This can be customized in the initializer.
46
+
47
+ The Copycat routes are configured automatically by the engine, after your Rails application's routes.rb file is run. This means that if your routes include a catchall route at the bottom, the Copycat route will be masked. In this case you can manually draw the Copycat routes prior to the catchall route with the following line in config/routes.rb:
48
+
49
+ ```ruby
50
+ Rails.application.routes.draw do
51
+ Copycat.routes(self)
52
+ end
53
+ ```
54
+
43
55
  ## Example ##
44
56
 
45
57
  See an example application [here](https://github.com/Vermonster/copycat-demo).
data/config/routes.rb CHANGED
@@ -1,13 +1,3 @@
1
1
  Rails.application.routes.draw do
2
- resources Copycat.route,
3
- :as => 'copycat_translations',
4
- :controller => 'copycat_translations',
5
- :only => [:index, :edit, :update, :destroy] do
6
- collection do
7
- get 'help'
8
- get 'import_export'
9
- get 'download'
10
- post 'upload'
11
- end
12
- end
2
+ Copycat.routes(self)
13
3
  end
@@ -1,13 +1,15 @@
1
- module CopycatImplementation
2
- # this method overrides part of the i18n gem, lib/i18n/backend/simple.rb
3
- def lookup(locale, key, scope = [], options = {})
4
- return super unless ActiveRecord::Base.connected? && CopycatTranslation.table_exists?
5
- cct = CopycatTranslation.where(locale: locale, key: key).first
6
- return cct.value if cct
7
- value = super(locale, key, scope, options)
8
- if value.is_a?(String) || value.nil?
9
- CopycatTranslation.create(locale: locale, key: key, value: value)
1
+ module Copycat
2
+ module Implementation
3
+ # this method overrides part of the i18n gem, lib/i18n/backend/simple.rb
4
+ def lookup(locale, key, scope = [], options = {})
5
+ return super unless ActiveRecord::Base.connected? && CopycatTranslation.table_exists?
6
+ cct = CopycatTranslation.where(locale: locale, key: key).first
7
+ return cct.value if cct
8
+ value = super(locale, key, scope, options)
9
+ if value.is_a?(String) || value.nil?
10
+ CopycatTranslation.create(locale: locale, key: key, value: value)
11
+ end
12
+ value
10
13
  end
11
- value
12
14
  end
13
15
  end
@@ -0,0 +1,17 @@
1
+ module Copycat
2
+ def self.routes(mapper)
3
+ mapper.instance_eval do
4
+ resources Copycat.route,
5
+ :as => 'copycat_translations',
6
+ :controller => 'copycat_translations',
7
+ :only => [:index, :edit, :update, :destroy] do
8
+ collection do
9
+ get 'help'
10
+ get 'import_export'
11
+ get 'download'
12
+ post 'upload'
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -1,3 +1,3 @@
1
1
  class I18n::Backend::Simple
2
- include CopycatImplementation
2
+ include Copycat::Implementation
3
3
  end
@@ -1,3 +1,3 @@
1
1
  module Copycat
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
data/lib/copycat.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "copycat/engine"
2
2
  require "copycat/implementation"
3
+ require "copycat/routes"
3
4
  require "copycat/simple"
4
5
 
5
6
  module Copycat