Skip to content

Commit

Permalink
Actualize gem (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuravel authored Mar 25, 2022
1 parent 32938ab commit ebfe785
Show file tree
Hide file tree
Showing 10 changed files with 109 additions and 77 deletions.
55 changes: 27 additions & 28 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,52 +1,51 @@
version: 2
version: 2.1

orbs:
ruby-orbs: sue445/ruby-orbs@volatile

jobs:
ruby-2.6: &template
ruby-3-1: &template
docker:
- image: circleci/ruby:2.6
environment:
BUNDLER_VERSION: 2.0.1
working_directory: ~/talkable-ruby
- image: cimg/ruby:3.1
steps:
- checkout

- run:
name: Configure Bundler
command: gem install bundler

- run:
name: Display Versions
command: |
function extract_version() { perl -pe 'if(($v)=/([0-9]+([.][0-9]+)+)/){print"$v\n";exit}$_=""' ; }
echo Ruby $(ruby --version | extract_version)
echo RubyGems $(gem --version | extract_version)
echo Bundler $(bundle --version | extract_version)
function extractVersion() {
perl -pe 'if(($v)=/([0-9]+([.][0-9]+)+)/){print"$v\n";exit}$_=""'
}
- run:
name: Bundle Install
command: bundle install
echo Ruby $(ruby --version | extractVersion)
echo RubyGems $(gem --version | extractVersion)
echo Bundler $(bundle --version | extractVersion)
- ruby-orbs/bundle-install:
restore_bundled_with: false
with_gemfile_lock: false
gemspec_name: talkable

- run:
name: RSpec
command: bundle exec rspec
ruby-2.5:
ruby-3-0:
<<: *template
docker:
- image: circleci/ruby:2.5
ruby-2.4:
- image: cimg/ruby:3.0
ruby-2-7:
<<: *template
docker:
- image: circleci/ruby:2.4
ruby-2.3:
- image: cimg/ruby:2.7
ruby-2-6:
<<: *template
docker:
- image: circleci/ruby:2.3
- image: cimg/ruby:2.6

workflows:
version: 2
workflow:
jobs:
- ruby-2.6
- ruby-2.5
- ruby-2.4
- ruby-2.3
- ruby-3-1
- ruby-3-0
- ruby-2-7
- ruby-2-6
1 change: 0 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

16 changes: 6 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,19 @@ Referral marketing is one of the most powerful strategies for ecommerce sales gr

## Demo

See an example application at http://github.com/talkable/talkable-spree-example.
See an example application at https://github.com/talkable/talkable-spree-example.

See a live demo at http://spree-example.talkable.com.

## Tutorial

See a [detailed tutorial](https://railsapps.github.io/talkable-referral-marketing/) by [Learn Ruby on Rails](http://learn-rails.com/learn-ruby-on-rails.html) author Daniel Kehoe.

## Requirements

The gem requires:
- Ruby version 2.3 or newer
- Rack version 1.6.1 or newer
- Ruby version 2.6 or newer
- Rack version 2.2 or newer

For integration with:
- Ruby on Rails 5.0 or newer
- Sinatra 1.4 or newer
- Ruby on Rails 6.0 or newer
- Sinatra 2.0 or newer

## Gem Installation

Expand Down Expand Up @@ -189,7 +185,7 @@ Provide iframe options to show a share page in specific place.

## API Examples

See the [API docs](http://docs.talkable.com/api_v2.html) for full details.
See the [API docs](https://docs.talkable.com/api_v2.html) for full details.

- [Registering a purchase](#registering-a-purchase)
- [Registering other events](#registering-other-events)
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ require 'rspec/core'
require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:spec)

task :default => :spec
task default: :spec
2 changes: 1 addition & 1 deletion TUTORIAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ You may read the [first tutorial](https://railsapps.github.io/talkable-referral-

## Requirements

Ruby 2.3+ and Rails 5.0+ (if you're using Rails).
Ruby 2.6+ and Rails 6.0+ (if you're using Rails).

## Create an Account

Expand Down
12 changes: 11 additions & 1 deletion spec/generators/install_generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require 'ammeter/init'

require 'talkable/generators/install_generator'
require './spec/support/erb_syntax_checker'

describe Talkable::InstallGenerator, type: :generator do
destination File.expand_path("../../../tmp", __FILE__)
Expand Down Expand Up @@ -74,7 +75,16 @@
end

it 'modifies application layout' do
expect(layout).to have_correct_syntax unless generator.options[:slim] # slim isn't supported yet
if generator.options[:slim]
# slim isn't supported yet
elsif extension == 'erb'
# Cannot use `have_correct_syntax` matcher for ERB because of issue
# https://github.com/alexrothenberg/ammeter/issues/66
checker = ErbSyntaxChecker.new(File.read(layout))
expect(checker).to be_correct_syntax
else
expect(layout).to have_correct_syntax
end
expect(layout).to contain("render 'shared/talkable_offer'")
end
end
Expand Down
6 changes: 3 additions & 3 deletions spec/middleware_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@

it 'injects sync url in body' do
_, _, response = subject.call(env)
expect(response.body.first).to include("http://example.com/public/1x1.gif?current_visitor_uuid=#{uuid}")
expect(response.first).to include("http://example.com/public/1x1.gif?current_visitor_uuid=#{uuid}")
end

it 'injects integration js library' do
_, _, response = subject.call(env)
expect(response.body.first).to include('<script src="//d2jjzw81hqbuqv.cloudfront.net/integration/clients/test-middleware.min.js" type="text/javascript"></script>')
expect(response.body.first).to include(%Q{
expect(response.first).to include('<script src="//d2jjzw81hqbuqv.cloudfront.net/integration/clients/test-middleware.min.js" type="text/javascript"></script>')
expect(response.first).to include(%Q{
<script>
window._talkableq = window._talkableq || [];
_talkableq.push(['init', {"site_id":"test-middleware","server":"http://example.com"}]);
Expand Down
3 changes: 1 addition & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
require 'webmock/rspec'
WebMock.disable_net_connect!

$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
require 'talkable'

RSpec.configure do |config|
config.order = "random"

config.filter_run(:focus) unless ENV['TDDIUM']
config.filter_run(:focus) unless ENV['CI']
config.run_all_when_everything_filtered = true
end

Expand Down
18 changes: 18 additions & 0 deletions spec/support/erb_syntax_checker.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
class ErbSyntaxChecker
def initialize(erb_text)
@erb_text = erb_text
end

def correct_syntax?
render { "" }.result
true
rescue NameError
true
rescue SyntaxError
false
end

private def render
ERB.new(@erb_text).result(binding)
end
end
71 changes: 41 additions & 30 deletions talkable.gemspec
Original file line number Diff line number Diff line change
@@ -1,31 +1,42 @@
$:.push File.expand_path('../lib', __FILE__)
require 'talkable/version'

Gem::Specification.new do |s|
s.name = "talkable"
s.version = Talkable::VERSION
s.authors = ["Talkable"]
s.email = "[email protected]"
s.description = "Talkable Ruby Gem to make your own referral program in Sinatra or Rails application"
s.summary = "Talkable Referral Program API"
s.homepage = "https://github.com/talkable/talkable-ruby"
s.license = "MIT"

s.files = `git ls-files`.split("\n").reject { |f| f.match(%r{^(test|spec|features)/}) }
s.require_paths = ["lib"]

s.required_ruby_version = ">= 2.3.0" # min ruby version that still receives security updates

s.add_dependency "rack", ">= 1.6.1"
s.add_dependency "furi", "~> 0.2"
s.add_dependency "hashie", "~> 3.4"

s.add_development_dependency "bundler", "~> 2.0.1"
s.add_development_dependency "rake", "~> 11.2"
s.add_development_dependency "rspec", "~> 3.4"
s.add_development_dependency "simplecov", "~> 0.12"
s.add_development_dependency "webmock", ">= 2.1"

s.add_development_dependency "ammeter" # specs for generators
s.add_development_dependency "haml" # check haml syntax in generators
# frozen_string_literal: true

require_relative "lib/talkable/version"

Gem::Specification.new do |spec|
spec.name = "talkable"
spec.version = Talkable::VERSION
spec.authors = ["Talkable"]
spec.email = "[email protected]"
spec.description = "Talkable Ruby Gem to make your own referral program in Sinatra or Rails application"
spec.license = "MIT"

spec.summary = "Talkable Referral Program API"
spec.homepage = "https://github.com/talkable/talkable-ruby"
spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0")

spec.metadata = {
"homepage_uri" => spec.homepage,
"bug_tracker_uri" => "#{spec.homepage}/issues",
"changelog_uri" => "#{spec.homepage}/releases/tag/v#{spec.version}",
"source_code_uri" => "#{spec.homepage}/tree/v#{spec.version}",
"allowed_push_host" => "https://rubygems.org",
"rubygems_mfa_required" => "true",
}

spec.files = Dir.chdir(File.expand_path(__dir__)) do
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
end
spec.require_paths = ["lib"]

spec.add_dependency "rack", "~> 2.2"
spec.add_dependency "furi", "~> 0.2"
spec.add_dependency "hashie", "~> 5.0"

spec.add_development_dependency "rake", ">= 13.0"
spec.add_development_dependency "rspec", ["~> 3", "< 3.11"]
spec.add_development_dependency "simplecov", "~> 0.21"
spec.add_development_dependency "webmock", "~> 3.14"

spec.add_development_dependency "ammeter" # specs for generators
spec.add_development_dependency "haml" # check haml syntax in generators
end

0 comments on commit ebfe785

Please sign in to comment.