tawk_rails 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 43e30ea1a2b258f93bca4a0103f50d17208cb526
4
+ data.tar.gz: 27b74f9eaf8216cafbd989c63b4d556fc046b0ed
5
+ SHA512:
6
+ metadata.gz: 578d12b9a6409cb34336108891679e150452662c251807a4fd6ee8d57edfdbaed2b1a3f4e4c8a0e1dbbb12685b97bce453dbe70a5f1e84b1cbccbdb0781ddb86
7
+ data.tar.gz: 9f50709779ba0571cfdd1511a0ba75049a201690cebcffedafd93d08646dea19bd0df835b18c773ac6031609017e91372f5715e19a1340422ae0f46a94c9662b
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ vendor
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
19
+ *.DS_Store
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in tawk_rails.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Wittawas Wisarnkanchana
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # TawkRails
2
+
3
+ Rails simple helper for [Tawk](https://www.tawk.to/) live chat script.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'tawk_rails'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install tawk_rails
18
+
19
+ ## Usage
20
+
21
+ Create file `tawk.rb` in `config/initialize/tawk.rb` and add
22
+
23
+ TawkRails.configure do |config|
24
+ config.id_site = 'replace-me-with-your-id_site'
25
+ end
26
+
27
+ place render method where you want in view.
28
+
29
+ <%= tawk_init %>
30
+
31
+ ## Contributing
32
+
33
+ 1. Fork it ( https://github.com/luizpicolo/tawk_rails/fork )
34
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
35
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
36
+ 4. Push to the branch (`git push origin my-new-feature`)
37
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,7 @@
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
data/lib/tawk_rails.rb ADDED
@@ -0,0 +1,8 @@
1
+ # coding: utf-8
2
+ require 'tawk_rails/chatbox'
3
+ require 'tawk_rails/configuration'
4
+ require 'tawk_rails/rails/railtie'
5
+ require "tawk_rails/version"
6
+
7
+ module TawkRails
8
+ end
@@ -0,0 +1,11 @@
1
+ # coding: utf-8
2
+
3
+ module TawkRails
4
+ class Chatbox
5
+ def render_script
6
+ <<-JAVASCRIPT
7
+ <script type="text/javascript">var Tawk_API=Tawk_API||{}, Tawk_LoadStart=new Date();(function(){var s1=document.createElement("script"),s0=document.getElementsByTagName("script")[0];s1.async=true;s1.src='https://embed.tawk.to/#{TawkRails.configuration.id_site}/default';s1.charset='UTF-8';s1.setAttribute('crossorigin','*');s0.parentNode.insertBefore(s1,s0);})();</script>
8
+ JAVASCRIPT
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,22 @@
1
+ require_relative 'version'
2
+
3
+ module TawkRails
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 :id_site
15
+ attr_reader :version
16
+
17
+ def initialize
18
+ @version = VERSION
19
+ @id_site = 'replace-me-with-id_site'
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,12 @@
1
+ # coding: utf-8
2
+
3
+ require 'tawk_rails/rails/view_helpers'
4
+
5
+ module TawkRails::Rails
6
+ # @private
7
+ class Railtie < ::Rails::Railtie
8
+ initializer "tawk_rails" do
9
+ ActionView::Base.send :include, ViewHelpers
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,17 @@
1
+ # coding: utf-8
2
+
3
+ require 'active_support/core_ext/string/output_safety'
4
+ require 'active_support/core_ext/object/blank'
5
+
6
+ module TawkRails::Rails
7
+
8
+ module ViewHelpers
9
+
10
+ def tawk_init
11
+
12
+ queue = TawkRails::Chatbox.new
13
+ queue.render_script.html_safe
14
+
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,3 @@
1
+ module TawkRails
2
+ VERSION = "0.0.1"
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/tawk_rails/chatbox'
3
+
4
+ describe TawkRails::Chatbox do
5
+
6
+ before do
7
+ TawkRails.configure do |config|
8
+ config.id_site = 'replace-me-with-your-id_site'
9
+ end
10
+ end
11
+
12
+ let(:chatbox) { TawkRails::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-id_site')
17
+ end
18
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+ require_relative '../../lib/tawk_rails/configuration'
3
+
4
+ describe TawkRails::Configuration do
5
+
6
+ before do
7
+ TawkRails.configure do |config|
8
+ config.id_site = 'replace-me-with-your-id_site'
9
+ end
10
+ end
11
+
12
+ it "should return id_site correctly" do
13
+ expect(TawkRails.configuration.id_site).to be_a_kind_of(String)
14
+ expect(TawkRails.configuration.id_site).to eq 'replace-me-with-your-id_site'
15
+ end
16
+
17
+ it "should return version correctly" do
18
+ expect(TawkRails.configuration.version).to be_a_kind_of(String)
19
+ expect(TawkRails.configuration.version).to eq '0.0.1'
20
+ end
21
+
22
+ end
@@ -0,0 +1,10 @@
1
+ require 'spec_helper'
2
+ require_relative '../../lib/tawk_rails/version'
3
+
4
+ describe TawkRails do
5
+
6
+ it "should return version correctly" do
7
+ expect(TawkRails::VERSION).to be_a_kind_of(String)
8
+ expect(TawkRails::VERSION).to eq '0.0.1'
9
+ end
10
+ end
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'tawk_rails/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "tawk_rails"
8
+ spec.version = TawkRails::VERSION
9
+ spec.authors = ["Luiz Picolo"]
10
+ spec.email = ["luizpicolo@gmail.com"]
11
+ spec.summary = %q{Rails helper for Tawk.to live chat script.}
12
+ spec.description = %q{Rails helper for Tawk.to live chat.}
13
+ spec.homepage = "https://github.com/luizpicolo/tawk_rails"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.5"
22
+ spec.add_development_dependency 'rake', '~> 0'
23
+ spec.add_development_dependency 'rspec', '~> 3.0'
24
+ end
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tawk_rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Luiz Picolo
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-09-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
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'
55
+ description: Rails helper for Tawk.to live chat.
56
+ email:
57
+ - luizpicolo@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".rspec"
64
+ - Gemfile
65
+ - LICENSE.txt
66
+ - README.md
67
+ - Rakefile
68
+ - lib/tawk_rails.rb
69
+ - lib/tawk_rails/chatbox.rb
70
+ - lib/tawk_rails/configuration.rb
71
+ - lib/tawk_rails/rails/railtie.rb
72
+ - lib/tawk_rails/rails/view_helpers.rb
73
+ - lib/tawk_rails/version.rb
74
+ - spec/spec_helper.rb
75
+ - spec/tawk_rails/chatbox_spec.rb
76
+ - spec/tawk_rails/configuration_spec.rb
77
+ - spec/tawk_rails/version_spec.rb
78
+ - tawk_rails.gemspec
79
+ homepage: https://github.com/luizpicolo/tawk_rails
80
+ licenses:
81
+ - MIT
82
+ metadata: {}
83
+ post_install_message:
84
+ rdoc_options: []
85
+ require_paths:
86
+ - lib
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ requirements: []
98
+ rubyforge_project:
99
+ rubygems_version: 2.4.8
100
+ signing_key:
101
+ specification_version: 4
102
+ summary: Rails helper for Tawk.to live chat script.
103
+ test_files:
104
+ - spec/spec_helper.rb
105
+ - spec/tawk_rails/chatbox_spec.rb
106
+ - spec/tawk_rails/configuration_spec.rb
107
+ - spec/tawk_rails/version_spec.rb