diff --git a/lib/phraseapp-in-context-editor-ruby.rb b/lib/phraseapp-in-context-editor-ruby.rb index bcc64d8..17a29b6 100644 --- a/lib/phraseapp-in-context-editor-ruby.rb +++ b/lib/phraseapp-in-context-editor-ruby.rb @@ -48,6 +48,10 @@ def enabled? def disabled? !config.enabled end + + def origin + config.origin + end end def self.configure diff --git a/lib/phraseapp-in-context-editor-ruby/config.rb b/lib/phraseapp-in-context-editor-ruby/config.rb index 7917318..052b0cf 100644 --- a/lib/phraseapp-in-context-editor-ruby/config.rb +++ b/lib/phraseapp-in-context-editor-ruby/config.rb @@ -9,6 +9,7 @@ class Config backend: PhraseApp::InContextEditor::BackendService.new, prefix: "{{__", suffix: "__}}" + origin: "in-context-editor-ruby" }.freeze CONFIG_OPTIONS.each do |option, default_value| diff --git a/lib/phraseapp-in-context-editor-ruby/view_helpers.rb b/lib/phraseapp-in-context-editor-ruby/view_helpers.rb index 2449714..dc09dad 100644 --- a/lib/phraseapp-in-context-editor-ruby/view_helpers.rb +++ b/lib/phraseapp-in-context-editor-ruby/view_helpers.rb @@ -18,6 +18,7 @@ def load_in_context_editor(opts = {}) "datacenter" => PhraseApp::InContextEditor.datacenter, "prefix" => PhraseApp::InContextEditor.prefix, "suffix" => PhraseApp::InContextEditor.suffix + "origin" => PhraseApp::InContextEditor.origin }.merge(opts) snippet = <<-EOS diff --git a/spec/phraseapp-in-context-editor-ruby/view_helpers_spec.rb b/spec/phraseapp-in-context-editor-ruby/view_helpers_spec.rb index b297fc9..d926e4b 100644 --- a/spec/phraseapp-in-context-editor-ruby/view_helpers_spec.rb +++ b/spec/phraseapp-in-context-editor-ruby/view_helpers_spec.rb @@ -37,6 +37,12 @@ class Helpers it { is_expected.to include("\"suffix\":\"__]]\"") } end + describe "origin setting" do + before(:each) { PhraseApp::InContextEditor.config.origin = "__]]" } + + it { is_expected.to include("\"origin\":\"in-context-editor-ruby\"") } + end + describe "overriding options" do let(:opts) { {prefix: "__%%"} } before(:each) { PhraseApp::InContextEditor.config.prefix = "__]]" }