phrasing 3.2.10 → 4.0.0rc1
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.
- checksums.yaml +4 -4
- data/.travis.yml +8 -11
- data/CHANGELOG.md +0 -20
- data/Gemfile +4 -1
- data/README-3.md +134 -0
- data/README.md +10 -14
- data/Release_notes_version_4.md +26 -0
- data/app/assets/javascripts/phrasing.js.erb +37 -17
- data/app/assets/stylesheets/phrasing_edit_mode_bubble.css.scss +3 -3
- data/app/controllers/phrasing_phrase_versions_controller.rb +4 -4
- data/app/controllers/phrasing_phrases_controller.rb +42 -75
- data/app/helpers/inline_helper.rb +24 -31
- data/app/models/phrasing_phrase.rb +29 -23
- data/app/views/phrasing/_production_warning.html.haml +0 -2
- data/app/views/phrasing_phrases/edit.html.haml +2 -2
- data/app/views/phrasing_phrases/import_export.html.haml +0 -5
- data/config/routes.rb +11 -9
- data/lib/generators/phrasing/phrasing_generator.rb +26 -0
- data/lib/generators/phrasing/templates/app/helpers/phrasing_helper.rb +12 -0
- data/lib/generators/phrasing/templates/config/initializers/phrasing.rb +11 -0
- data/{db/migrate/20131010101010_create_phrasing_phrase_versions.rb → lib/generators/phrasing/templates/db/migrate/create_phrasing_phrase_versions.rb} +2 -2
- data/{db/migrate/20120313191745_create_phrasing_phrases.rb → lib/generators/phrasing/templates/db/migrate/create_phrasing_phrases.rb} +2 -2
- data/lib/phrasing.rb +11 -37
- data/lib/phrasing/version.rb +2 -2
- data/phrasing.gemspec +1 -3
- data/spec/features/dummy_spec.rb +27 -24
- data/spec/features/phrasing_spec.rb +128 -84
- data/spec/lib/phrasing_spec.rb +50 -50
- metadata +14 -26
- data/4.0.0_changes.md +0 -1
- data/lib/phrasing/implementation.rb +0 -21
- data/lib/phrasing/simple.rb +0 -3
- data/lib/tasks/phrasing_tasks.rake +0 -69
data/spec/lib/phrasing_spec.rb
CHANGED
@@ -1,50 +1,50 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Phrasing do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
end
|
1
|
+
# require 'spec_helper'
|
2
|
+
|
3
|
+
# describe Phrasing do
|
4
|
+
|
5
|
+
# let(:Base) do
|
6
|
+
# Class.new.tap do |b|
|
7
|
+
# b.class_eval do
|
8
|
+
# module SimpleImplementation
|
9
|
+
# def lookup(*args)
|
10
|
+
# "translation missing"
|
11
|
+
# end
|
12
|
+
# end
|
13
|
+
# include SimpleImplementation
|
14
|
+
# end
|
15
|
+
# end
|
16
|
+
# end
|
17
|
+
|
18
|
+
# let(:base) do
|
19
|
+
# Base().new
|
20
|
+
# end
|
21
|
+
|
22
|
+
# before do
|
23
|
+
# Base().class_eval do
|
24
|
+
# include Phrasing::Implementation
|
25
|
+
# end
|
26
|
+
# end
|
27
|
+
|
28
|
+
# describe ".lookup" do
|
29
|
+
# it "returns simple lookup if phrasing_phrase missing" do
|
30
|
+
# base.lookup(nil, '').should == "translation missing"
|
31
|
+
# end
|
32
|
+
|
33
|
+
# it "returns phrasing_phrase if present" do
|
34
|
+
# cct = FactoryGirl.create(:phrasing_phrase)
|
35
|
+
# base.lookup(cct.locale, cct.key).should == cct.value
|
36
|
+
# end
|
37
|
+
|
38
|
+
# it "creates phrasing_phrase if one is missing" do
|
39
|
+
# PhrasingPhrase.where(locale: 'en', key: 'foo').should be_empty
|
40
|
+
# base.lookup('en', 'foo')
|
41
|
+
# PhrasingPhrase.where(locale: 'en', key: 'foo').should_not be_empty
|
42
|
+
# end
|
43
|
+
|
44
|
+
# it "creates scoped phrasing_phrase if one is missing" do
|
45
|
+
# PhrasingPhrase.where(locale: 'en', key: 'the_scope.foo').should be_empty
|
46
|
+
# base.lookup('en', 'foo', :"the_scope")
|
47
|
+
# PhrasingPhrase.where(locale: 'en', key: 'the_scope.foo').should_not be_empty
|
48
|
+
# end
|
49
|
+
# end
|
50
|
+
# end
|
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:
|
4
|
+
version: 4.0.0rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomislav Car
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-09-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -40,7 +40,7 @@ dependencies:
|
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '3.2'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
|
-
name: haml
|
43
|
+
name: haml-rails
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
46
|
- - ">="
|
@@ -95,20 +95,6 @@ dependencies:
|
|
95
95
|
- - ">="
|
96
96
|
- !ruby/object:Gem::Version
|
97
97
|
version: '0'
|
98
|
-
- !ruby/object:Gem::Dependency
|
99
|
-
name: pry
|
100
|
-
requirement: !ruby/object:Gem::Requirement
|
101
|
-
requirements:
|
102
|
-
- - ">="
|
103
|
-
- !ruby/object:Gem::Version
|
104
|
-
version: '0'
|
105
|
-
type: :development
|
106
|
-
prerelease: false
|
107
|
-
version_requirements: !ruby/object:Gem::Requirement
|
108
|
-
requirements:
|
109
|
-
- - ">="
|
110
|
-
- !ruby/object:Gem::Version
|
111
|
-
version: '0'
|
112
98
|
description: Phrasing!
|
113
99
|
email: contact@infinum.co
|
114
100
|
executables: []
|
@@ -117,12 +103,13 @@ extra_rdoc_files: []
|
|
117
103
|
files:
|
118
104
|
- ".gitignore"
|
119
105
|
- ".travis.yml"
|
120
|
-
- 4.0.0_changes.md
|
121
106
|
- CHANGELOG.md
|
122
107
|
- Gemfile
|
123
108
|
- MIT-LICENSE
|
109
|
+
- README-3.md
|
124
110
|
- README.md
|
125
111
|
- Rakefile
|
112
|
+
- Release_notes_version_4.md
|
126
113
|
- app/assets/fonts/icomoon.dev.svg
|
127
114
|
- app/assets/fonts/icomoon.eot
|
128
115
|
- app/assets/fonts/icomoon.svg
|
@@ -151,14 +138,14 @@ files:
|
|
151
138
|
- app/views/phrasing_phrases/import_export.html.haml
|
152
139
|
- app/views/phrasing_phrases/index.html.haml
|
153
140
|
- config/routes.rb
|
154
|
-
-
|
155
|
-
-
|
141
|
+
- lib/generators/phrasing/phrasing_generator.rb
|
142
|
+
- lib/generators/phrasing/templates/app/helpers/phrasing_helper.rb
|
143
|
+
- lib/generators/phrasing/templates/config/initializers/phrasing.rb
|
144
|
+
- lib/generators/phrasing/templates/db/migrate/create_phrasing_phrase_versions.rb
|
145
|
+
- lib/generators/phrasing/templates/db/migrate/create_phrasing_phrases.rb
|
156
146
|
- lib/phrasing.rb
|
157
|
-
- lib/phrasing/implementation.rb
|
158
147
|
- lib/phrasing/serializer.rb
|
159
|
-
- lib/phrasing/simple.rb
|
160
148
|
- lib/phrasing/version.rb
|
161
|
-
- lib/tasks/phrasing_tasks.rake
|
162
149
|
- phrasing.gemspec
|
163
150
|
- spec/dummy/Rakefile
|
164
151
|
- spec/dummy/app/assets/javascripts/application.js
|
@@ -220,13 +207,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
220
207
|
version: '0'
|
221
208
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
222
209
|
requirements:
|
223
|
-
- - "
|
210
|
+
- - ">"
|
224
211
|
- !ruby/object:Gem::Version
|
225
|
-
version:
|
212
|
+
version: 1.3.1
|
226
213
|
requirements: []
|
227
214
|
rubyforge_project:
|
228
|
-
rubygems_version: 2.
|
215
|
+
rubygems_version: 2.2.2
|
229
216
|
signing_key:
|
230
217
|
specification_version: 4
|
231
218
|
summary: Edit phrases inline for Rails applications!
|
232
219
|
test_files: []
|
220
|
+
has_rdoc:
|
data/4.0.0_changes.md
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
# Changes
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module Phrasing
|
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? && PhrasingPhrase.table_exists?
|
6
|
-
|
7
|
-
scoped_key = I18n.normalize_keys(nil, key, scope, options[:separator]).join(".")
|
8
|
-
|
9
|
-
phrase = PhrasingPhrase.where(locale: locale.to_s, key: scoped_key).first
|
10
|
-
return phrase.value if phrase
|
11
|
-
|
12
|
-
value = super(locale, key, scope, options)
|
13
|
-
|
14
|
-
if value and (value.is_a? String or value.is_a? Symbol)
|
15
|
-
# creation in background no matter if developer user the I18n#t or phrase helper
|
16
|
-
PhrasingPhrase.create_phrase(scoped_key, value)
|
17
|
-
end
|
18
|
-
value
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
data/lib/phrasing/simple.rb
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
CONFIG_FILE = <<-CONFIG
|
2
|
-
Phrasing.setup do |config|
|
3
|
-
config.route = 'phrasing'
|
4
|
-
end
|
5
|
-
|
6
|
-
# List all the model attributes you wish to edit with Phrasing, example:
|
7
|
-
# Phrasing.whitelist = ["Post.title", "Post.description"]
|
8
|
-
Phrasing.whitelist = []
|
9
|
-
# Phrasing.allow_update_on_all_models_and_attributes = true;
|
10
|
-
CONFIG
|
11
|
-
|
12
|
-
MODULE_FILE = <<-MODULE
|
13
|
-
module PhrasingHelper
|
14
|
-
# You must implement the can_edit_phrases? method.
|
15
|
-
# Example:
|
16
|
-
#
|
17
|
-
# def can_edit_phrases?
|
18
|
-
# current_user.is_admin?
|
19
|
-
# end
|
20
|
-
|
21
|
-
def can_edit_phrases?
|
22
|
-
raise NotImplementedError.new("You must implement the can_edit_phrases? method")
|
23
|
-
end
|
24
|
-
end
|
25
|
-
MODULE
|
26
|
-
|
27
|
-
namespace :phrasing do
|
28
|
-
desc "Install the plugin, including the migration."
|
29
|
-
task :install do
|
30
|
-
Rake::Task["phrasing_rails_engine:install:migrations"].invoke
|
31
|
-
Rake::Task["phrasing:install_initializer"].invoke
|
32
|
-
Rake::Task["phrasing:install_phrasing_helper"].invoke
|
33
|
-
end
|
34
|
-
|
35
|
-
desc "Create the initializer file"
|
36
|
-
task :install_initializer do
|
37
|
-
filepath = Rails.root.join *%w(config initializers phrasing.rb)
|
38
|
-
if File.exists?(filepath)
|
39
|
-
alert "Phrasing config file already exists."
|
40
|
-
else
|
41
|
-
File.open(filepath, 'w') do |f|
|
42
|
-
f << CONFIG_FILE
|
43
|
-
end
|
44
|
-
notice "created", " config/initializers/phrasing.rb"
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
desc "Create the PhrasingHelper file"
|
49
|
-
task :install_phrasing_helper do
|
50
|
-
filepath = Rails.root.join *%w(app helpers phrasing_helper.rb)
|
51
|
-
if File.exists?(filepath)
|
52
|
-
alert "Phrasing helper file already exists."
|
53
|
-
else
|
54
|
-
File.open(filepath, 'w') do |f|
|
55
|
-
f << MODULE_FILE
|
56
|
-
end
|
57
|
-
notice "created", "app/helpers/phrasing_helper.rb"
|
58
|
-
notice "Now run 'rake db:migrate'."
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def notice(colored_text, tailing_text = nil)
|
64
|
-
puts "\033[#{32}m#{colored_text}\033[0m #{tailing_text}"
|
65
|
-
end
|
66
|
-
|
67
|
-
def alert(colored_text, tailing_text = nil)
|
68
|
-
puts "\033[#{31}m#{colored_text}\033[0m #{tailing_text}"
|
69
|
-
end
|