phrasing 3.2.10 → 4.0.0rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +8 -11
  3. data/CHANGELOG.md +0 -20
  4. data/Gemfile +4 -1
  5. data/README-3.md +134 -0
  6. data/README.md +10 -14
  7. data/Release_notes_version_4.md +26 -0
  8. data/app/assets/javascripts/phrasing.js.erb +37 -17
  9. data/app/assets/stylesheets/phrasing_edit_mode_bubble.css.scss +3 -3
  10. data/app/controllers/phrasing_phrase_versions_controller.rb +4 -4
  11. data/app/controllers/phrasing_phrases_controller.rb +42 -75
  12. data/app/helpers/inline_helper.rb +24 -31
  13. data/app/models/phrasing_phrase.rb +29 -23
  14. data/app/views/phrasing/_production_warning.html.haml +0 -2
  15. data/app/views/phrasing_phrases/edit.html.haml +2 -2
  16. data/app/views/phrasing_phrases/import_export.html.haml +0 -5
  17. data/config/routes.rb +11 -9
  18. data/lib/generators/phrasing/phrasing_generator.rb +26 -0
  19. data/lib/generators/phrasing/templates/app/helpers/phrasing_helper.rb +12 -0
  20. data/lib/generators/phrasing/templates/config/initializers/phrasing.rb +11 -0
  21. data/{db/migrate/20131010101010_create_phrasing_phrase_versions.rb → lib/generators/phrasing/templates/db/migrate/create_phrasing_phrase_versions.rb} +2 -2
  22. data/{db/migrate/20120313191745_create_phrasing_phrases.rb → lib/generators/phrasing/templates/db/migrate/create_phrasing_phrases.rb} +2 -2
  23. data/lib/phrasing.rb +11 -37
  24. data/lib/phrasing/version.rb +2 -2
  25. data/phrasing.gemspec +1 -3
  26. data/spec/features/dummy_spec.rb +27 -24
  27. data/spec/features/phrasing_spec.rb +128 -84
  28. data/spec/lib/phrasing_spec.rb +50 -50
  29. metadata +14 -26
  30. data/4.0.0_changes.md +0 -1
  31. data/lib/phrasing/implementation.rb +0 -21
  32. data/lib/phrasing/simple.rb +0 -3
  33. data/lib/tasks/phrasing_tasks.rake +0 -69
@@ -1,50 +1,50 @@
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
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: 3.2.10
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: 2015-10-02 00:00:00.000000000 Z
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
- - db/migrate/20120313191745_create_phrasing_phrases.rb
155
- - db/migrate/20131010101010_create_phrasing_phrase_versions.rb
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: '0'
212
+ version: 1.3.1
226
213
  requirements: []
227
214
  rubyforge_project:
228
- rubygems_version: 2.4.5
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:
@@ -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
@@ -1,3 +0,0 @@
1
- class I18n::Backend::Simple
2
- include Phrasing::Implementation
3
- end
@@ -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