venomi 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/generators/templates/{locale.rb → locale.rb.erb} +1 -1
- data/lib/generators/templates/{translation.rb → translation.rb.erb} +1 -1
- data/lib/generators/venomi/install_generator.rb +11 -4
- data/lib/venomi/rails_admin.rb +24 -19
- data/lib/venomi/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bdfe5cb92d029ab926fd9516985cdd6d7ce4c847
|
4
|
+
data.tar.gz: dbe657a8ff762bdc06c30b91d6d73d837831c179
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c2c90aee469846e71ed0ef5e475b60399d390779e857808781dd9fa702c4708304233f25ef116386f39c0804b8f9876374c62ceafcfc339e376724947a88826
|
7
|
+
data.tar.gz: 523e59f67875eb800bf2e862e1af6e5bcaad380ec0250c8dd329deee8aff668f73a006dbd0de636c60cea20b03f55760f14051cd5515d18fb9e32af146d98330
|
data/README.md
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
require_relative("../../lib/i18n/backend/mongoid")
|
2
2
|
|
3
|
-
I18n.backend = I18n::Backend::Chain.new( I18n::Backend::Simple.new, I18n::Backend::Mongoid.new(
|
3
|
+
I18n.backend = I18n::Backend::Chain.new( I18n::Backend::Simple.new, I18n::Backend::Mongoid.new(<%= table_name %>) )
|
@@ -8,11 +8,13 @@ module Venomi
|
|
8
8
|
include Venomi::Generators::Utils::InstanceMethods
|
9
9
|
source_root File.expand_path("../../templates", __FILE__)
|
10
10
|
|
11
|
+
argument :translation_table_name, :type => :string
|
12
|
+
|
11
13
|
def copy_initializer
|
12
14
|
if libraries_available?("mongoid", "rails-i18n")
|
13
15
|
template "mongoid.rb", "lib/i18n/backend/mongoid.rb"
|
14
|
-
template "translation.rb", "app/models
|
15
|
-
template "locale.rb", "config/initializers/locale.rb"
|
16
|
+
template "translation.rb.erb", "app/models/#{table_name.downcase}.rb"
|
17
|
+
template "locale.rb.erb", "config/initializers/locale.rb"
|
16
18
|
else
|
17
19
|
say("Mongoid or rails-i18n aren't installed!", :yellow)
|
18
20
|
end
|
@@ -22,15 +24,20 @@ module Venomi
|
|
22
24
|
case self.behavior
|
23
25
|
when :invoke
|
24
26
|
if libraries_available?("mongoid","rails_admin")
|
25
|
-
Venomi::RailsAdmin.configure
|
27
|
+
Venomi::RailsAdmin.configure table_name
|
26
28
|
else
|
27
29
|
say("Rails-admin isn`t required or installed!", :yellow)
|
28
30
|
end
|
29
31
|
when :revoke
|
30
|
-
Venomi::RailsAdmin.rollback
|
32
|
+
Venomi::RailsAdmin.rollback table_name
|
31
33
|
end
|
32
34
|
end
|
33
35
|
|
36
|
+
private
|
37
|
+
def table_name
|
38
|
+
translation_table_name.downcase.capitalize
|
39
|
+
end
|
40
|
+
|
34
41
|
end
|
35
42
|
end
|
36
43
|
end
|
data/lib/venomi/rails_admin.rb
CHANGED
@@ -19,7 +19,8 @@ module Venomi
|
|
19
19
|
class << self
|
20
20
|
include Venomi::Generators::Utils::InstanceMethods
|
21
21
|
|
22
|
-
def configure
|
22
|
+
def configure(table = "Translation")
|
23
|
+
init_parts_for(table)
|
23
24
|
if file?(@rails_admin_root)
|
24
25
|
unless file_include?(@rails_admin_root, "config.model Translation do")
|
25
26
|
replace(@rails_admin_root, "RailsAdmin.config do |config|", ("RailsAdmin.config do |config|\n" + @translation))
|
@@ -35,7 +36,8 @@ module Venomi
|
|
35
36
|
end
|
36
37
|
end
|
37
38
|
|
38
|
-
def rollback
|
39
|
+
def rollback(table = "Translation")
|
40
|
+
init_parts_for(table)
|
39
41
|
if file? @rails_admin_root
|
40
42
|
text = File.read(@rails_admin_root)
|
41
43
|
text.gsub!(@delete, " delete\n")
|
@@ -44,34 +46,37 @@ module Venomi
|
|
44
46
|
File.open(@rails_admin_root, "w") {|file| file.puts text }
|
45
47
|
end
|
46
48
|
end
|
47
|
-
end
|
48
49
|
|
49
|
-
|
50
|
+
def init_parts_for(table_name)
|
51
|
+
@table = table_name
|
52
|
+
@new = <<-MSG
|
50
53
|
new do
|
51
|
-
except [
|
54
|
+
except [:#{@table}]
|
52
55
|
end
|
53
56
|
MSG
|
54
57
|
|
55
|
-
|
58
|
+
@delete = <<-MSG
|
56
59
|
delete do
|
57
|
-
except [
|
60
|
+
except [:#{@table}]
|
58
61
|
end
|
59
62
|
MSG
|
60
63
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
64
|
+
@translation = <<-MSG
|
65
|
+
config.model #{@table} do
|
66
|
+
list do
|
67
|
+
field :key
|
68
|
+
field :value
|
69
|
+
end
|
70
|
+
edit do
|
71
|
+
field :key do
|
72
|
+
read_only true
|
73
|
+
end
|
74
|
+
field :value
|
70
75
|
end
|
71
|
-
field :value
|
72
76
|
end
|
73
|
-
|
74
|
-
|
77
|
+
MSG
|
78
|
+
end
|
75
79
|
|
80
|
+
end
|
76
81
|
end
|
77
82
|
end
|
data/lib/venomi/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: venomi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexandr Turchyn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -114,9 +114,9 @@ files:
|
|
114
114
|
- bin/console
|
115
115
|
- bin/setup
|
116
116
|
- lib/debug/initializers/rails_admin.rb
|
117
|
-
- lib/generators/templates/locale.rb
|
117
|
+
- lib/generators/templates/locale.rb.erb
|
118
118
|
- lib/generators/templates/mongoid.rb
|
119
|
-
- lib/generators/templates/translation.rb
|
119
|
+
- lib/generators/templates/translation.rb.erb
|
120
120
|
- lib/generators/utils.rb
|
121
121
|
- lib/generators/venomi/install_generator.rb
|
122
122
|
- lib/tasks/venomi.rake
|