zopim_rails 0.0.4 → 0.0.6

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: bcf40c21f09b8d08fd0985d53b10cdae2ec026d3
4
- data.tar.gz: e7f7f3703a2fa9dede2f4cecef660da84bd409e0
3
+ metadata.gz: f1ba41c94e4f93d8ae2b46230f0e27ddc98c62d6
4
+ data.tar.gz: c97f55c9aa5c5995f128cca93965a0dadaa923c4
5
5
  SHA512:
6
- metadata.gz: 0be9c5f106037905993ac8e08d5c9732f258edadcbdac45276f1ed57f52a7fcc4ad03049fd4d9e1ab14f616bba125aa9723a4cf15416aa0de87239e6e43c3576
7
- data.tar.gz: 0985011e94b49844193754b63d426a47c61ae69d40b3e4dda400a4ffac9a045b1d0000d62d03f4142fd3982df95e2402a4fa406221cc380025e518768fd63491
6
+ metadata.gz: b8a950d75b5692008a7d9116fc6abde935cf023ae1a30a26768696e5e82484254edb646adabd3f4519b6b423a0e48761fffd08f85ea2c81c4996689deabc54f8
7
+ data.tar.gz: 2e6ffced8a7b16e46b6bc5b67b95fc14ed36a87b60f91133f9381fab18bab456ab751008f782d544a9c2be5b8ec0b5a575ad4980e8fcec2f311484adb742d02d
data/.gitignore CHANGED
@@ -3,6 +3,7 @@
3
3
  .bundle
4
4
  .config
5
5
  .yardoc
6
+ vendor
6
7
  Gemfile.lock
7
8
  InstalledFiles
8
9
  _yardoc
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/README.md CHANGED
@@ -21,7 +21,9 @@ Or install it yourself as:
21
21
 
22
22
  Create file `zopim.rb` in `config/initialize/zopim.rb` and add
23
23
 
24
- ZopimRails.api_key = "<your-api-key>"
24
+ ZopimRails.configure do |config|
25
+ config.api_key = 'replace-me-with-your-api_key'
26
+ end
25
27
 
26
28
  place render method where you want in view.
27
29
 
data/Rakefile CHANGED
@@ -1 +1,7 @@
1
1
  require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new
5
+
6
+ task :default => :spec
7
+ task :test => :spec
@@ -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
@@ -4,7 +4,7 @@ module ZopimRails
4
4
  class Chatbox
5
5
  def render_script
6
6
  <<-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/?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>
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/?#{ZopimRails.configuration.api_key}';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>
8
8
  JAVASCRIPT
9
9
  end
10
10
  end
@@ -0,0 +1,18 @@
1
+ module ZopimRails
2
+ class << self
3
+ attr_accessor :configuration
4
+ end
5
+
6
+ def self.configure
7
+ self.configuration ||= Configuration.new
8
+ yield(configuration)
9
+ end
10
+
11
+ class Configuration
12
+ attr_accessor :api_key
13
+
14
+ def initialize
15
+ @api_key = 'replace-me-with-api_key'
16
+ end
17
+ end
18
+ end
@@ -9,10 +9,6 @@ module ZopimRails::Rails
9
9
 
10
10
  def zopim_init
11
11
 
12
- unless ZopimRails.valid_api_key?
13
- raise ArgumentError, "API key for Zopim chat is missing."
14
- end
15
-
16
12
  queue = ZopimRails::Chatbox.new
17
13
  queue.render_script.html_safe
18
14
 
@@ -1,3 +1,3 @@
1
1
  module ZopimRails
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -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,18 @@
1
+ require 'spec_helper'
2
+ require_relative '../../lib/zopim_rails/chatbox'
3
+
4
+ describe ZopimRails::Chatbox do
5
+
6
+ before do
7
+ ZopimRails.configure do |config|
8
+ config.api_key = 'replace-me-with-your-api_key'
9
+ end
10
+ end
11
+
12
+ let(:chatbox) { ZopimRails::Chatbox.new() }
13
+
14
+ it "should return javascript correctly" do
15
+ expect(chatbox.render_script).to be_a_kind_of(String)
16
+ expect(chatbox.render_script).to include('replace-me-with-your-api_key')
17
+ end
18
+ end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+ require_relative '../../lib/zopim_rails/configuration'
3
+
4
+ describe ZopimRails::Configuration do
5
+
6
+ before do
7
+ ZopimRails.configure do |config|
8
+ config.api_key = 'replace-me-with-your-api_key'
9
+ end
10
+ end
11
+
12
+ it "should return api_key correctly" do
13
+ expect(ZopimRails.configuration.api_key).to be_a_kind_of(String)
14
+ expect(ZopimRails.configuration.api_key).to eq 'replace-me-with-your-api_key'
15
+ end
16
+ end
@@ -20,5 +20,6 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.5"
22
22
  spec.add_development_dependency 'rake', '~> 0'
23
+ spec.add_development_dependency 'rspec', '>= 3.0'
23
24
  spec.add_dependency 'jquery-rails', ['>= 3.0', '< 5']
24
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zopim_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wittawas Wisarnkanchana
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-07 00:00:00.000000000 Z
11
+ date: 2015-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
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,20 @@ extensions: []
66
80
  extra_rdoc_files: []
67
81
  files:
68
82
  - ".gitignore"
83
+ - ".rspec"
69
84
  - Gemfile
70
85
  - LICENSE.txt
71
86
  - README.md
72
87
  - Rakefile
73
88
  - lib/zopim_rails.rb
74
89
  - lib/zopim_rails/chatbox.rb
90
+ - lib/zopim_rails/configuration.rb
75
91
  - lib/zopim_rails/rails/railtie.rb
76
92
  - lib/zopim_rails/rails/view_helpers.rb
77
93
  - lib/zopim_rails/version.rb
94
+ - spec/spec_helper.rb
95
+ - spec/zopim_rails/chatbox_spec.rb
96
+ - spec/zopim_rails/configuration_spec.rb
78
97
  - zopim_rails.gemspec
79
98
  homepage: https://github.com/wittawasw/zopim_rails
80
99
  licenses:
@@ -100,4 +119,7 @@ rubygems_version: 2.4.5
100
119
  signing_key:
101
120
  specification_version: 4
102
121
  summary: Rails helper for Zopim live chat script.
103
- test_files: []
122
+ test_files:
123
+ - spec/spec_helper.rb
124
+ - spec/zopim_rails/chatbox_spec.rb
125
+ - spec/zopim_rails/configuration_spec.rb