copycat 0.1.1 → 0.2.0
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 +4 -0
- data/app/controllers/copycat_translations_controller.rb +1 -1
- data/app/models/copycat_translation.rb +1 -0
- data/config/routes.rb +4 -1
- data/lib/copycat/implementation.rb +13 -0
- data/lib/copycat/simple.rb +3 -0
- data/lib/copycat/version.rb +1 -1
- data/lib/copycat.rb +10 -14
- data/lib/tasks/copycat_tasks.rake +6 -3
- data/spec/dummy/config/initializers/copycat.rb +5 -2
- data/spec/dummy/log/development.log +61 -0
- data/spec/dummy/log/test.log +8444 -0
- data/spec/integration/copycat_spec.rb +10 -10
- data/spec/integration/dummy_spec.rb +29 -0
- metadata +6 -4
data/README.md
CHANGED
@@ -40,6 +40,10 @@ 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
|
+
## Example ##
|
44
|
+
|
45
|
+
See an example application [here](https://github.com/Vermonster/copycat-demo).
|
46
|
+
|
43
47
|
## Developing ##
|
44
48
|
|
45
49
|
As a Rails engine, Copycat is developed using a nested dummy Rails app. After cloning the repository and running bundler, the plugin must be installed in the dummy app:
|
data/config/routes.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
Rails.application.routes.draw do
|
2
|
-
resources
|
2
|
+
resources Copycat.route,
|
3
|
+
:as => 'copycat_translations',
|
4
|
+
:controller => 'copycat_translations',
|
5
|
+
:only => [:index, :edit, :update, :destroy] do
|
3
6
|
collection do
|
4
7
|
get 'help'
|
5
8
|
get 'import_export'
|
@@ -0,0 +1,13 @@
|
|
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)
|
10
|
+
end
|
11
|
+
value
|
12
|
+
end
|
13
|
+
end
|
data/lib/copycat/version.rb
CHANGED
data/lib/copycat.rb
CHANGED
@@ -1,19 +1,15 @@
|
|
1
1
|
require "copycat/engine"
|
2
|
+
require "copycat/implementation"
|
3
|
+
require "copycat/simple"
|
2
4
|
|
3
|
-
module
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
CopycatTranslation.create(locale: locale, key: key, value: value)
|
12
|
-
end
|
13
|
-
value
|
5
|
+
module Copycat
|
6
|
+
mattr_accessor :username
|
7
|
+
mattr_accessor :password
|
8
|
+
mattr_accessor :route
|
9
|
+
@@route = 'copycat_translations'
|
10
|
+
|
11
|
+
def self.setup
|
12
|
+
yield self
|
14
13
|
end
|
15
14
|
end
|
16
15
|
|
17
|
-
class I18n::Backend::Simple
|
18
|
-
include CopycatImplementation
|
19
|
-
end
|
@@ -12,9 +12,12 @@ namespace :copycat do
|
|
12
12
|
filepath = Rails.root.join *%w(config initializers copycat.rb)
|
13
13
|
File.open(filepath, 'w') do |f|
|
14
14
|
f << <<-CONFIG
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
Copycat.setup do |config|
|
16
|
+
config.username = '#{username}'
|
17
|
+
config.password = '#{password}'
|
18
|
+
#config.route = 'copycat_translations'
|
19
|
+
end
|
20
|
+
CONFIG
|
18
21
|
end
|
19
22
|
puts <<-INFO
|
20
23
|
Copycat initializer created with
|
@@ -1237,3 +1237,64 @@ Completed 400 Bad Request in 16ms (Views: 13.5ms | ActiveRecord: 0.0ms)
|
|
1237
1237
|
|
1238
1238
|
Started GET "/assets/copycat_engine.css?body=1" for 127.0.0.1 at 2012-03-26 15:15:27 -0400
|
1239
1239
|
Served asset /copycat_engine.css - 200 OK (1ms)
|
1240
|
+
|
1241
|
+
|
1242
|
+
Started GET "/copycat_translations/import_export" for 127.0.0.1 at 2012-03-26 15:31:26 -0400
|
1243
|
+
Processing by CopycatTranslationsController#import_export as HTML
|
1244
|
+
Rendered /vermonster/copycat/app/views/copycat_translations/import_export.html.erb within layouts/copycat (2.6ms)
|
1245
|
+
Completed 200 OK in 15ms (Views: 15.0ms | ActiveRecord: 0.0ms)
|
1246
|
+
|
1247
|
+
|
1248
|
+
Started GET "/assets/copycat_engine.css?body=1" for 127.0.0.1 at 2012-03-26 15:31:26 -0400
|
1249
|
+
Served asset /copycat_engine.css - 304 Not Modified (1ms)
|
1250
|
+
|
1251
|
+
|
1252
|
+
Started POST "/copycat_translations/upload" for 127.0.0.1 at 2012-03-26 15:31:47 -0400
|
1253
|
+
Processing by CopycatTranslationsController#upload as HTML
|
1254
|
+
Parameters: {"utf8"=>"✓", "authenticity_token"=>"Mj1Qcja3mVicC0PXcW5UEYJeskdTdT3UWjWm4M27ZjA=", "file"=>#<ActionDispatch::Http::UploadedFile:0x00000100bf5788 @original_filename="gollum.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"file\"; filename=\"gollum.jpg\"\r\nContent-Type: image/jpeg\r\n", @tempfile=#<File:/var/folders/rn/rnXUYLOZH-mYuzcjL2v8Fk+++TI/-Tmp-/RackMultipart20120326-14172-1infn60>>, "commit"=>"Upload"}
|
1255
|
+
|
1256
|
+
Psych::SyntaxError
|
1257
|
+
(/var/folders/rn/rnXUYLOZH-mYuzcjL2v8Fk+++TI/-Tmp-/RackMultipart20120326-14172-1infn60): couldn't parse YAML at line 0 column 0
|
1258
|
+
Rendered /vermonster/copycat/app/views/copycat_translations/import_export.html.erb within layouts/copycat (0.8ms)
|
1259
|
+
Completed 400 Bad Request in 4ms (Views: 3.2ms | ActiveRecord: 0.0ms)
|
1260
|
+
|
1261
|
+
|
1262
|
+
Started GET "/assets/copycat_engine.css?body=1" for 127.0.0.1 at 2012-03-26 15:31:47 -0400
|
1263
|
+
Served asset /copycat_engine.css - 304 Not Modified (0ms)
|
1264
|
+
|
1265
|
+
|
1266
|
+
Started POST "/copycat_translations/upload" for 127.0.0.1 at 2012-03-26 15:32:05 -0400
|
1267
|
+
Processing by CopycatTranslationsController#upload as HTML
|
1268
|
+
Parameters: {"utf8"=>"✓", "authenticity_token"=>"Mj1Qcja3mVicC0PXcW5UEYJeskdTdT3UWjWm4M27ZjA=", "file"=>#<ActionDispatch::Http::UploadedFile:0x0000010475e950 @original_filename="gollum.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"file\"; filename=\"gollum.jpg\"\r\nContent-Type: image/jpeg\r\n", @tempfile=#<File:/var/folders/rn/rnXUYLOZH-mYuzcjL2v8Fk+++TI/-Tmp-/RackMultipart20120326-14172-1m26ey4>>, "commit"=>"Upload"}
|
1269
|
+
|
1270
|
+
Psych::SyntaxError
|
1271
|
+
(/var/folders/rn/rnXUYLOZH-mYuzcjL2v8Fk+++TI/-Tmp-/RackMultipart20120326-14172-1m26ey4): couldn't parse YAML at line 0 column 0
|
1272
|
+
Rendered /vermonster/copycat/app/views/copycat_translations/import_export.html.erb within layouts/copycat (0.7ms)
|
1273
|
+
Completed 400 Bad Request in 3ms (Views: 2.8ms | ActiveRecord: 0.0ms)
|
1274
|
+
|
1275
|
+
|
1276
|
+
Started GET "/assets/copycat_engine.css?body=1" for 127.0.0.1 at 2012-03-26 15:32:05 -0400
|
1277
|
+
Served asset /copycat_engine.css - 304 Not Modified (0ms)
|
1278
|
+
|
1279
|
+
|
1280
|
+
Started GET "/copycat_translations/import_export" for 127.0.0.1 at 2012-03-26 15:32:15 -0400
|
1281
|
+
Processing by CopycatTranslationsController#import_export as HTML
|
1282
|
+
Rendered /vermonster/copycat/app/views/copycat_translations/import_export.html.erb within layouts/copycat (0.9ms)
|
1283
|
+
Completed 200 OK in 4ms (Views: 3.9ms | ActiveRecord: 0.0ms)
|
1284
|
+
|
1285
|
+
|
1286
|
+
Started GET "/assets/copycat_engine.css?body=1" for 127.0.0.1 at 2012-03-26 15:32:15 -0400
|
1287
|
+
Served asset /copycat_engine.css - 304 Not Modified (0ms)
|
1288
|
+
|
1289
|
+
|
1290
|
+
Started GET "/copycat_translations/import_export" for 127.0.0.1 at 2012-03-26 15:32:18 -0400
|
1291
|
+
Processing by CopycatTranslationsController#import_export as HTML
|
1292
|
+
Rendered /vermonster/copycat/app/views/copycat_translations/import_export.html.erb within layouts/copycat (1.0ms)
|
1293
|
+
Completed 200 OK in 4ms (Views: 4.0ms | ActiveRecord: 0.0ms)
|
1294
|
+
|
1295
|
+
|
1296
|
+
Started GET "/assets/copycat_engine.css?body=1" for 127.0.0.1 at 2012-03-26 15:32:18 -0400
|
1297
|
+
Served asset /copycat_engine.css - 304 Not Modified (0ms)
|
1298
|
+
|
1299
|
+
***** Debugger requested, but was not available (ensure ruby-debug is listed in Gemfile/installed as gem): Start server with --debugger to enable *****
|
1300
|
+
|