phraseapp-in-context-editor-ruby 1.0.6 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 08bedc61fbf888fdc0b936c856eb63d6d0bb3475
4
- data.tar.gz: 3442d9094518b0890d302eab1f1d9fc1f38efec4
3
+ metadata.gz: cdfdab7c2d226806be3b94c62dcbf1e371139917
4
+ data.tar.gz: 53a0f7c4065ce2c72d8e3df1830c203fe6707b7a
5
5
  SHA512:
6
- metadata.gz: bf0e674700424e314ea0fcb2bc310e6f3be03ce199bac2be6fd6cb0b0ca608a7f1cdc9c9884861ba22b5014af61871eb7a6ee917cd47c632f860c85d7b98ce42
7
- data.tar.gz: 4f3c6391d340f416939a9ad2f0843f037f74cfc064570024e457814cfbaf3dabb89ee876e7df81d3b6fa885f61ab964dd65df64e54beb1169f1bde49ace4c2fe
6
+ metadata.gz: ce15350f192f740f52bf84838954638d4fc9743ea1c3e245cd867690903eb1e3503c2167fe32b7ce39001955fe37de2d670e352a07f837bb813ab561aaedc393
7
+ data.tar.gz: f36383b6b2c563a35336e94c71c8876694071445e1be698d8d9ff27e6b623dfaed26a7522cf5bff06d5ec6c981df96b0a8a63f9dccc2571e32c23f64118c3fca
data/.travis.yml CHANGED
@@ -3,4 +3,5 @@ rvm:
3
3
  - "2.0"
4
4
  - "2.1"
5
5
  - "2.2"
6
+ - "2.3.0"
6
7
  script: bundle exec rspec spec
data/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # Change Log
2
2
 
3
+ ## [v1.1.0](https://github.com/phrase/phraseapp-in-context-editor-ruby/tree/v1.1.0) (2016-10-04)
4
+ [Full Changelog](https://github.com/phrase/phraseapp-in-context-editor-ruby/compare/v1.0.2...v1.1.0)
5
+
6
+ **Closed issues:**
7
+
8
+ - rails\_admin json issue with phraseapp and rails\_admin-i18n [\#16](https://github.com/phrase/phraseapp-in-context-editor-ruby/issues/16)
9
+ - Per thread config [\#14](https://github.com/phrase/phraseapp-in-context-editor-ruby/issues/14)
10
+ - RuntimeError: not found? [\#12](https://github.com/phrase/phraseapp-in-context-editor-ruby/issues/12)
11
+ - Editor conflicts the angular router [\#9](https://github.com/phrase/phraseapp-in-context-editor-ruby/issues/9)
12
+ - Edit icons missing if the enabled false by default [\#8](https://github.com/phrase/phraseapp-in-context-editor-ruby/issues/8)
13
+ - Introduce a changelog [\#7](https://github.com/phrase/phraseapp-in-context-editor-ruby/issues/7)
14
+
15
+ **Merged pull requests:**
16
+
17
+ - Proper storage of config on Thread.current [\#15](https://github.com/phrase/phraseapp-in-context-editor-ruby/pull/15) ([docstun](https://github.com/docstun))
18
+ - disable dependency loading on before as fix for rails5 [\#13](https://github.com/phrase/phraseapp-in-context-editor-ruby/pull/13) ([koljaa](https://github.com/koljaa))
19
+ - Update LICENSE [\#11](https://github.com/phrase/phraseapp-in-context-editor-ruby/pull/11) ([sbruhns](https://github.com/sbruhns))
20
+ - i18n set to \>= 0.6 [\#10](https://github.com/phrase/phraseapp-in-context-editor-ruby/pull/10) ([jethroo](https://github.com/jethroo))
21
+
3
22
  ## [v1.0.2](https://github.com/phrase/phraseapp-in-context-editor-ruby/tree/v1.0.2) (2015-10-12)
4
23
  [Full Changelog](https://github.com/phrase/phraseapp-in-context-editor-ruby/compare/v1.0.1...v1.0.2)
5
24
 
@@ -9,7 +28,7 @@
9
28
 
10
29
  **Merged pull requests:**
11
30
 
12
- - 18n delegate refactoring [\#6](https://github.com/phrase/phraseapp-in-context-editor-ruby/pull/6) ([segitty](https://github.com/segitty))
31
+ - 18n delegate refactoring [\#6](https://github.com/phrase/phraseapp-in-context-editor-ruby/pull/6) ([koljaa](https://github.com/koljaa))
13
32
 
14
33
  ## [v1.0.1](https://github.com/phrase/phraseapp-in-context-editor-ruby/tree/v1.0.1) (2015-10-07)
15
34
  [Full Changelog](https://github.com/phrase/phraseapp-in-context-editor-ruby/compare/v1.0.0...v1.0.1)
data/README.md CHANGED
@@ -54,18 +54,9 @@ If you don't want to use the helper but add the plain Javascript yourself, head
54
54
 
55
55
  Restart your application to see the In-Context-Editor in action!
56
56
 
57
-
58
- ### Upgrading from the old phrase gem
59
-
60
- If you're upgrading from the `phrase` gem (which is now deprecated), you will notice several changes:
61
-
62
- 1. The gem no longer provides the `push`/`pull` commands. This functionality is now provided by our new [command line client](https://github.com/phrase/phraseapp-client).
63
- 2. The gem also no longer implements it's own API client, but uses the [phraseapp-ruby gem](https://github.com/phrase/phraseapp-ruby) for API communication.
64
-
65
-
66
57
  ### OpenSSL issues
67
58
 
68
- Please note that outdated certificates or old versions of OpenSSL may cause connection issues, especially on Mac OSX. We recommend using Ruby 2.2.2 with OpenSSL 1.0.2d or later. If you experience OpenSSL-related errors, try the following.
59
+ Please note that outdated certificates or old versions of OpenSSL may cause connection issues, especially on Mac OSX. We recommend using Ruby 2.2.2 with OpenSSL 1.0.2d or later. If you experience OpenSSL-related errors, try the following.
69
60
 
70
61
  Upgrade OpenSSL using Homebrew:
71
62
 
@@ -87,7 +78,7 @@ As a workaround, you can disable SSL certificate verification in your `config/in
87
78
  config.skip_ssl_verification = true
88
79
  ```
89
80
 
90
- This is **not recommended** and should only be used as a temporary workaround.
81
+ This is **not recommended** and should only be used as a temporary workaround.
91
82
 
92
83
 
93
84
  ## Further Information
@@ -88,7 +88,15 @@ module PhraseApp
88
88
  end
89
89
 
90
90
  def self.configure
91
- yield(self.config)
91
+ yield(PhraseApp::InContextEditor::Config)
92
+ end
93
+
94
+ def self.with_config(config_options={}, &block)
95
+ original_config = self.config.dup
96
+ config.assign_values(config_options)
97
+ yield
98
+ ensure
99
+ self.config = original_config
92
100
  end
93
101
  end
94
102
 
@@ -1,142 +1,83 @@
1
1
  # -*- encoding : utf-8 -*-
2
-
3
2
  module PhraseApp
4
3
  module InContextEditor
5
4
  class Config
6
- def project_id
7
- @@project_id = "" if !defined? @@project_id or @@project_id.nil?
8
- @@project_id
9
- end
10
-
11
- def project_id=(project_id)
12
- @@project_id = project_id
13
- end
14
-
15
- def access_token
16
- @@access_token = "" if !defined? @@access_token or @@access_token.nil?
17
- @@access_token
18
- end
19
-
20
- def access_token=(access_token)
21
- @@access_token = access_token
22
- end
23
-
24
- def enabled
25
- @@enabled = false if !defined? @@enabled or @@enabled.nil?
26
- @@enabled
27
- end
28
-
29
- def enabled=(enabled)
30
- @@enabled = enabled
31
- end
32
-
33
- def skip_ssl_verification
34
- @@skip_ssl_verification = false if !defined? @@skip_ssl_verification or @@skip_ssl_verification.nil?
35
- @@skip_ssl_verification
36
- end
37
-
38
- def skip_ssl_verification=(skip_ssl_verification)
39
- @@skip_ssl_verification = skip_ssl_verification
40
- end
41
-
42
- def backend
43
- @@backend ||= PhraseApp::InContextEditor::BackendService.new
44
- end
45
-
46
- def backend=(backend)
47
- @@backend = backend
5
+ CONFIG_OPTIONS = {
6
+ project_id: nil,
7
+ access_token: nil,
8
+ enabled: false,
9
+ skip_ssl_verification: false,
10
+ backend: PhraseApp::InContextEditor::BackendService.new,
11
+ prefix: "{{__",
12
+ suffix: "__}}",
13
+ api_host: "https://api.phraseapp.com",
14
+ js_host: "phraseapp.com",
15
+ js_use_ssl: true,
16
+ js_path: "/assets/in-context-editor/2.0/app.js",
17
+ js_options: {},
18
+ cache_key_segments_initial: ["simple_form"],
19
+ cache_lifetime: 300,
20
+ ignored_keys: [],
21
+ }.freeze
22
+
23
+ CONFIG_OPTIONS_GLOBAL_ONLY = [
24
+ :access_token,
25
+ :skip_ssl_verification,
26
+ :api_host
27
+ ].freeze
28
+
29
+ CONFIG_OPTIONS.each do |option, default_value|
30
+ class_eval "@@#{option} = CONFIG_OPTIONS[:#{option}]"
31
+
32
+ define_method("#{option}=") do |value|
33
+ instance_eval "@#{option} = value; self.class.invalidate_api_client"
34
+ end unless CONFIG_OPTIONS_GLOBAL_ONLY.include?(option)
35
+
36
+ define_method("#{option}") do
37
+ instance_eval "defined?(@#{option}) ? @#{option} : self.class.#{option}"
38
+ end
39
+
40
+ define_singleton_method("#{option}=") do |value|
41
+ instance_eval "@@#{option} = value; invalidate_api_client"
42
+ end
43
+
44
+ define_singleton_method("#{option}") do
45
+ instance_eval "@@#{option}"
46
+ end
47
+ end
48
+
49
+ def self.api_client
50
+ @@api_client ||= build_api_client
48
51
  end
49
52
 
50
53
  def api_client
51
- @@api_client ||= authorized_api_client
52
- end
53
-
54
- def prefix
55
- @@prefix ||= "{{__"
54
+ self.class.api_client
56
55
  end
57
56
 
58
- def prefix=(prefix)
59
- @@prefix = prefix
57
+ def assign_values(config_options={})
58
+ config_options.each do |config_option, value|
59
+ self.send("#{config_option}=", value)
60
+ end
60
61
  end
61
62
 
62
- def suffix
63
- @@suffix ||= "__}}"
63
+ def self.reset_to_defaults!
64
+ CONFIG_OPTIONS.each do |option, default_value|
65
+ send("#{option}=", default_value)
66
+ end
64
67
  end
65
68
 
66
- def suffix=(suffix)
67
- @@suffix = suffix
68
- end
69
-
70
- def api_host
71
- @@api_host = "https://api.phraseapp.com" if !defined? @@api_host or @@api_host.nil?
72
- @@api_host
73
- end
74
-
75
- def api_host=(api_host)
76
- @@api_host = api_host
77
- end
78
-
79
- def js_host
80
- @@js_host ||= 'phraseapp.com'
81
- end
82
-
83
- def js_host=(js_host)
84
- @@js_host = js_host
85
- end
86
-
87
- def js_use_ssl
88
- @@js_use_ssl = true if !defined? @@js_use_ssl or @@js_use_ssl.nil?
89
- @@js_use_ssl
90
- end
91
-
92
- def js_use_ssl=(js_use_ssl)
93
- @@js_use_ssl = js_use_ssl
94
- end
95
-
96
- def js_path
97
- @@js_path ||= "/assets/in-context-editor/2.0/app.js"
98
- end
99
-
100
- def js_path=(js_path)
101
- @@js_path = js_path
102
- end
103
-
104
- def js_options
105
- @@js_options ||= {}
106
- end
107
-
108
- def js_options=(js_options)
109
- @@js_options = js_options
110
- end
111
-
112
- def cache_key_segments_initial
113
- @@cache_key_segments_initial ||= ["simple_form"]
114
- end
115
-
116
- def cache_key_segments_initial=(cache_key_segments_initial=[])
117
- @@cache_key_segments_initial = cache_key_segments_initial
118
- end
119
-
120
- def cache_lifetime
121
- @@cache_lifetime ||= 300
122
- end
123
-
124
- def cache_lifetime=(cache_lifetime)
125
- @@cache_lifetime = cache_lifetime
126
- end
127
-
128
- def ignored_keys
129
- @@ignored_keys ||= []
130
- end
131
-
132
- def ignored_keys=(ignored_keys)
133
- @@ignored_keys = ignored_keys
69
+ protected
70
+ def self.invalidate_api_client
71
+ @@api_client = nil
134
72
  end
135
73
 
136
- protected
137
- def authorized_api_client
138
- credentials = PhraseApp::Auth::Credentials.new(token: PhraseApp::InContextEditor.access_token, host: PhraseApp::InContextEditor.api_host, skip_ssl_verification: PhraseApp::InContextEditor.skip_ssl_verification)
139
- client = PhraseApp::Client.new(credentials)
74
+ def self.build_api_client
75
+ credentials = PhraseApp::Auth::Credentials.new(
76
+ token: @@access_token,
77
+ host: @@api_host,
78
+ skip_ssl_verification: @@skip_ssl_verification
79
+ )
80
+ PhraseApp::Client.new(credentials)
140
81
  end
141
82
  end
142
83
  end
@@ -7,10 +7,8 @@ if defined? Rails
7
7
  module InContextEditor
8
8
  class Engine < Rails::Engine
9
9
  initializer 'phraseapp-in-context-editor-ruby', before: :disable_dependency_loading do |app|
10
- if PhraseApp::InContextEditor.enabled?
11
- require 'phraseapp-in-context-editor-ruby/adapters/i18n'
12
- require 'phraseapp-in-context-editor-ruby/adapters/fast_gettext'
13
- end
10
+ require 'phraseapp-in-context-editor-ruby/adapters/i18n'
11
+ require 'phraseapp-in-context-editor-ruby/adapters/fast_gettext'
14
12
 
15
13
  ActionView::Base.send :include, PhraseApp::InContextEditor::ViewHelpers
16
14
  end
@@ -50,4 +50,4 @@ module PhraseApp
50
50
  end
51
51
  end
52
52
  end
53
- end
53
+ end
@@ -1,5 +1,5 @@
1
1
  module PhraseApp
2
2
  module InContextEditor
3
- VERSION = "1.0.6"
3
+ VERSION = "1.1.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phraseapp-in-context-editor-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dynport GmbH
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-25 00:00:00.000000000 Z
11
+ date: 2016-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -194,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
194
194
  version: 1.3.6
195
195
  requirements: []
196
196
  rubyforge_project: phraseapp-in-context-editor-ruby
197
- rubygems_version: 2.2.1
197
+ rubygems_version: 2.4.8
198
198
  signing_key:
199
199
  specification_version: 4
200
200
  summary: Translation management solution for web and mobile applications