zopim_rails 0.0.4 → 1.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/.rspec +2 -0
- data/.ruby-version +1 -0
- data/.travis.yml +1 -0
- data/README.md +21 -6
- data/Rakefile +6 -0
- data/lib/zopim_rails.rb +1 -29
- data/lib/zopim_rails/chatbox.rb +1 -2
- data/lib/zopim_rails/configuration.rb +22 -0
- data/lib/zopim_rails/rails/railtie.rb +1 -2
- data/lib/zopim_rails/rails/view_helpers.rb +1 -10
- data/lib/zopim_rails/version.rb +1 -1
- data/spec/spec_helper.rb +91 -0
- data/spec/zopim_rails/chatbox_spec.rb +17 -0
- data/spec/zopim_rails/configuration_spec.rb +15 -0
- data/spec/zopim_rails/version_spec.rb +9 -0
- data/zopim_rails.gemspec +3 -2
- metadata +34 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7307c5d2ac156daf01b54ad9780f239132ad8b8276b35d500fc26acad6751238
|
4
|
+
data.tar.gz: fc108b3034b2faba84363d24b96a3ff1917724172c0d9d76661fa00dd2dae237
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e28773ae03f244f24d7609087ff5a2a97f725a03b9716a5a053f869cd50ee2f57bebe036ddc5af2337292214b7e1ca9c0cbfaaeea05051482f2b748b8217669c
|
7
|
+
data.tar.gz: 0c3ea4079fc38f544ed9184654a7abb898bda38da513e1cbdd509445f9d9f8fe31767ea4d393b0b81c2c28a3be5a94a88ac88ede239a58d21a60f6e3ee6f0368
|
data/.gitignore
CHANGED
data/.rspec
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.3.1
|
data/.travis.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
language: ruby
|
data/README.md
CHANGED
@@ -1,13 +1,18 @@
|
|
1
1
|
# ZopimRails
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/zopim_rails.svg)](https://badge.fury.io/rb/zopim_rails)
|
3
|
+
[![Build Status](https://travis-ci.org/wittawasw/zopim_rails.svg?branch=master)](https://travis-ci.org/wittawasw/zopim_rails)
|
4
|
+
|
5
|
+
Rails simple helper for [Zopim](https://www.zopim.com/) live chat script.
|
6
|
+
Now support turbolink 2.5.3+ with help from [Contributing](https://github.com/wittawasw/zopim_rails/graphs/contributors)
|
2
7
|
|
3
|
-
Rails simple helper for [Zopim](https://www.zopim.com/) live chat script.
|
4
|
-
Now support turbolink with help from [luizpicolo](https://github.com/luizpicolo).
|
5
8
|
|
6
9
|
## Installation
|
7
10
|
|
8
11
|
Add this line to your application's Gemfile:
|
9
12
|
|
10
|
-
|
13
|
+
```ruby
|
14
|
+
gem 'zopim_rails'
|
15
|
+
```
|
11
16
|
|
12
17
|
And then execute:
|
13
18
|
|
@@ -19,13 +24,23 @@ Or install it yourself as:
|
|
19
24
|
|
20
25
|
## Usage
|
21
26
|
|
22
|
-
Create file `zopim.rb` in `config/
|
27
|
+
Create file `zopim.rb` in `config/initializers/zopim.rb` and add
|
23
28
|
|
24
|
-
|
29
|
+
```ruby
|
30
|
+
ZopimRails.configure do |config|
|
31
|
+
config.api_key = 'replace-me-with-your-api_key'
|
32
|
+
end
|
33
|
+
```
|
25
34
|
|
26
35
|
place render method where you want in view.
|
27
36
|
|
28
|
-
|
37
|
+
```ruby
|
38
|
+
<%= zopim_init %>
|
39
|
+
```
|
40
|
+
|
41
|
+
## Demostration
|
42
|
+
|
43
|
+
https://zopimrailstest.herokuapp.com/
|
29
44
|
|
30
45
|
## Contributing
|
31
46
|
|
data/Rakefile
CHANGED
data/lib/zopim_rails.rb
CHANGED
@@ -1,36 +1,8 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
require 'zopim_rails/chatbox'
|
3
|
+
require 'zopim_rails/configuration'
|
3
4
|
require 'zopim_rails/rails/railtie'
|
4
5
|
require "zopim_rails/version"
|
5
6
|
|
6
7
|
module ZopimRails
|
7
|
-
|
8
|
-
PLACEHOLDER_KEY = "xxxxxxxxx"
|
9
|
-
# Get the current api key.
|
10
|
-
# @return [String]
|
11
|
-
def self.api_key
|
12
|
-
@@api_key ||= PLACEHOLDER_KEY
|
13
|
-
end
|
14
|
-
|
15
|
-
# Set the current api key.
|
16
|
-
# @param [String] tracker The api key.
|
17
|
-
def self.api_key=(api_key)
|
18
|
-
@@api_key = api_key
|
19
|
-
end
|
20
|
-
|
21
|
-
# @return [Boolean]
|
22
|
-
def self.valid_api_key?
|
23
|
-
api_key.nil? || api_key == "" || api_key == PLACEHOLDER_KEY ? false : true
|
24
|
-
end
|
25
|
-
|
26
|
-
#To be removed
|
27
|
-
def self.render
|
28
|
-
<<-JAVASCRIPT
|
29
|
-
<script type="text/javascript">function zopim_chat(){$('[__jx__id]').remove();window.$zopim = null;(function(d,s){var z=$zopim=function(c){z._.push(c)},$=z.s=d.createElement(s),e=d.getElementsByTagName(s)[0];z.set=function(o){z.set._.push(o)};z._=[];z.set._=[];$.async=!0;$.setAttribute('charset','utf-8');$.src='//v2.zopim.com/?2ykAW7vz8GhsKrykTWPE7a6SNXEaYNcJ';z.t=+new Date;$.type='text/javascript';e.parentNode.insertBefore($,e)})(document,'script')};$(window).off('page:change.zopim').on('page:change.zopim', zopim_chat);</script>
|
30
|
-
JAVASCRIPT
|
31
|
-
end
|
32
|
-
def self.init
|
33
|
-
self.render.html_safe
|
34
|
-
end
|
35
|
-
|
36
8
|
end
|
data/lib/zopim_rails/chatbox.rb
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
# coding: utf-8
|
2
|
-
|
3
2
|
module ZopimRails
|
4
3
|
class Chatbox
|
5
4
|
def render_script
|
6
5
|
<<-JAVASCRIPT
|
7
|
-
<script type="text/javascript">function zopim_chat(){$('[__jx__id]').remove();window.$zopim = null;(function(d,s){var z=$zopim=function(c){z._.push(c)},$=z.s=d.createElement(s),e=d.getElementsByTagName(s)[0];z.set=function(o){z.set._.push(o)};z._=[];z.set._=[];$.async=!0;$.setAttribute('charset','utf-8');$.src='//v2.zopim.com
|
6
|
+
<script type="text/javascript">function zopim_chat(){$('[__jx__id]').remove();window.$zopim = null;(function(d,s){var z=$zopim=function(c){z._.push(c)},$=z.s=d.createElement(s),e=d.getElementsByTagName(s)[0];z.set=function(o){z.set._.push(o)};z._=[];z.set._=[];$.async=!0;$.setAttribute('charset','utf-8');$.src='//v2.zopim.com/?#{ZopimRails.configuration.api_key}';z.t=+new Date;$.type='text/javascript';e.parentNode.insertBefore($,e)})(document,'script')};$(window).off('page:change.zopim turbolinks:load.zopim').on('page:change.zopim turbolinks:load.zopim', zopim_chat);</script>
|
8
7
|
JAVASCRIPT
|
9
8
|
end
|
10
9
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require_relative 'version'
|
2
|
+
|
3
|
+
module ZopimRails
|
4
|
+
class << self
|
5
|
+
attr_accessor :configuration
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.configure
|
9
|
+
self.configuration ||= Configuration.new
|
10
|
+
yield(configuration)
|
11
|
+
end
|
12
|
+
|
13
|
+
class Configuration
|
14
|
+
attr_accessor :api_key
|
15
|
+
attr_reader :version
|
16
|
+
|
17
|
+
def initialize
|
18
|
+
@version = VERSION
|
19
|
+
@api_key = 'replace-me-with-api_key'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -1,21 +1,12 @@
|
|
1
1
|
# coding: utf-8
|
2
|
-
|
3
2
|
require 'active_support/core_ext/string/output_safety'
|
4
3
|
require 'active_support/core_ext/object/blank'
|
5
4
|
|
6
5
|
module ZopimRails::Rails
|
7
|
-
|
8
6
|
module ViewHelpers
|
9
|
-
|
10
7
|
def zopim_init
|
11
|
-
|
12
|
-
unless ZopimRails.valid_api_key?
|
13
|
-
raise ArgumentError, "API key for Zopim chat is missing."
|
14
|
-
end
|
15
|
-
|
16
8
|
queue = ZopimRails::Chatbox.new
|
17
9
|
queue.render_script.html_safe
|
18
|
-
|
19
10
|
end
|
20
11
|
end
|
21
|
-
end
|
12
|
+
end
|
data/lib/zopim_rails/version.rb
CHANGED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
4
|
+
# this file to always be loaded, without a need to explicitly require it in any
|
5
|
+
# files.
|
6
|
+
#
|
7
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
8
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
9
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
10
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
11
|
+
# a separate helper file that requires the additional dependencies and performs
|
12
|
+
# the additional setup, and require it from the spec files that actually need
|
13
|
+
# it.
|
14
|
+
#
|
15
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
16
|
+
# users commonly want.
|
17
|
+
#
|
18
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
19
|
+
RSpec.configure do |config|
|
20
|
+
# rspec-expectations config goes here. You can use an alternate
|
21
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
22
|
+
# assertions if you prefer.
|
23
|
+
config.expect_with :rspec do |expectations|
|
24
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
25
|
+
# and `failure_message` of custom matchers include text for helper methods
|
26
|
+
# defined using `chain`, e.g.:
|
27
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
28
|
+
# # => "be bigger than 2 and smaller than 4"
|
29
|
+
# ...rather than:
|
30
|
+
# # => "be bigger than 2"
|
31
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
32
|
+
end
|
33
|
+
|
34
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
35
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
36
|
+
config.mock_with :rspec do |mocks|
|
37
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
38
|
+
# a real object. This is generally recommended, and will default to
|
39
|
+
# `true` in RSpec 4.
|
40
|
+
mocks.verify_partial_doubles = true
|
41
|
+
end
|
42
|
+
|
43
|
+
# The settings below are suggested to provide a good initial experience
|
44
|
+
# with RSpec, but feel free to customize to your heart's content.
|
45
|
+
=begin
|
46
|
+
# These two settings work together to allow you to limit a spec run
|
47
|
+
# to individual examples or groups you care about by tagging them with
|
48
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
49
|
+
# get run.
|
50
|
+
config.filter_run :focus
|
51
|
+
config.run_all_when_everything_filtered = true
|
52
|
+
|
53
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
54
|
+
# recommended. For more details, see:
|
55
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
56
|
+
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
57
|
+
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
58
|
+
config.disable_monkey_patching!
|
59
|
+
|
60
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
61
|
+
# be too noisy due to issues in dependencies.
|
62
|
+
config.warnings = true
|
63
|
+
|
64
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
65
|
+
# file, and it's useful to allow more verbose output when running an
|
66
|
+
# individual spec file.
|
67
|
+
if config.files_to_run.one?
|
68
|
+
# Use the documentation formatter for detailed output,
|
69
|
+
# unless a formatter has already been configured
|
70
|
+
# (e.g. via a command-line flag).
|
71
|
+
config.default_formatter = 'doc'
|
72
|
+
end
|
73
|
+
|
74
|
+
# Print the 10 slowest examples and example groups at the
|
75
|
+
# end of the spec run, to help surface which specs are running
|
76
|
+
# particularly slow.
|
77
|
+
config.profile_examples = 10
|
78
|
+
|
79
|
+
# Run specs in random order to surface order dependencies. If you find an
|
80
|
+
# order dependency and want to debug it, you can fix the order by providing
|
81
|
+
# the seed, which is printed after each run.
|
82
|
+
# --seed 1234
|
83
|
+
config.order = :random
|
84
|
+
|
85
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
86
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
87
|
+
# test failures related to randomization by passing the same `--seed` value
|
88
|
+
# as the one that triggered the failure.
|
89
|
+
Kernel.srand config.seed
|
90
|
+
=end
|
91
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require_relative '../../lib/zopim_rails/chatbox'
|
3
|
+
|
4
|
+
describe ZopimRails::Chatbox do
|
5
|
+
before do
|
6
|
+
ZopimRails.configure do |config|
|
7
|
+
config.api_key = 'replace-me-with-your-api_key'
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
let(:chatbox) { ZopimRails::Chatbox.new() }
|
12
|
+
|
13
|
+
it "should return javascript correctly" do
|
14
|
+
expect(chatbox.render_script).to be_a_kind_of(String)
|
15
|
+
expect(chatbox.render_script).to include('replace-me-with-your-api_key')
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require_relative '../../lib/zopim_rails/configuration'
|
3
|
+
|
4
|
+
describe ZopimRails::Configuration do
|
5
|
+
before do
|
6
|
+
ZopimRails.configure do |config|
|
7
|
+
config.api_key = 'replace-me-with-your-api_key'
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should return api_key correctly" do
|
12
|
+
expect(ZopimRails.configuration.api_key).to be_a_kind_of(String)
|
13
|
+
expect(ZopimRails.configuration.api_key).to eq 'replace-me-with-your-api_key'
|
14
|
+
end
|
15
|
+
end
|
data/zopim_rails.gemspec
CHANGED
@@ -18,7 +18,8 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_development_dependency "bundler", "
|
22
|
-
spec.add_development_dependency 'rake', '
|
21
|
+
spec.add_development_dependency "bundler", ">= 1.5"
|
22
|
+
spec.add_development_dependency 'rake', '>= 12.3.3'
|
23
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
23
24
|
spec.add_dependency 'jquery-rails', ['>= 3.0', '< 5']
|
24
25
|
end
|
metadata
CHANGED
@@ -1,43 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zopim_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wittawas Wisarnkanchana
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.5'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.5'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 12.3.3
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 12.3.3
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
45
|
- - "~>"
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
47
|
+
version: '3.0'
|
34
48
|
type: :development
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
52
|
- - "~>"
|
39
53
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
54
|
+
version: '3.0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: jquery-rails
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,15 +80,23 @@ extensions: []
|
|
66
80
|
extra_rdoc_files: []
|
67
81
|
files:
|
68
82
|
- ".gitignore"
|
83
|
+
- ".rspec"
|
84
|
+
- ".ruby-version"
|
85
|
+
- ".travis.yml"
|
69
86
|
- Gemfile
|
70
87
|
- LICENSE.txt
|
71
88
|
- README.md
|
72
89
|
- Rakefile
|
73
90
|
- lib/zopim_rails.rb
|
74
91
|
- lib/zopim_rails/chatbox.rb
|
92
|
+
- lib/zopim_rails/configuration.rb
|
75
93
|
- lib/zopim_rails/rails/railtie.rb
|
76
94
|
- lib/zopim_rails/rails/view_helpers.rb
|
77
95
|
- lib/zopim_rails/version.rb
|
96
|
+
- spec/spec_helper.rb
|
97
|
+
- spec/zopim_rails/chatbox_spec.rb
|
98
|
+
- spec/zopim_rails/configuration_spec.rb
|
99
|
+
- spec/zopim_rails/version_spec.rb
|
78
100
|
- zopim_rails.gemspec
|
79
101
|
homepage: https://github.com/wittawasw/zopim_rails
|
80
102
|
licenses:
|
@@ -95,9 +117,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
117
|
- !ruby/object:Gem::Version
|
96
118
|
version: '0'
|
97
119
|
requirements: []
|
98
|
-
|
99
|
-
rubygems_version: 2.4.5
|
120
|
+
rubygems_version: 3.1.4
|
100
121
|
signing_key:
|
101
122
|
specification_version: 4
|
102
123
|
summary: Rails helper for Zopim live chat script.
|
103
|
-
test_files:
|
124
|
+
test_files:
|
125
|
+
- spec/spec_helper.rb
|
126
|
+
- spec/zopim_rails/chatbox_spec.rb
|
127
|
+
- spec/zopim_rails/configuration_spec.rb
|
128
|
+
- spec/zopim_rails/version_spec.rb
|