spree_gtm 0.0.1 → 0.0.2

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: e14458a5d72e3278735b10990c61767ecd3df01b
4
- data.tar.gz: f7e9d7837143de274a695ce8bb485f0c78a8b113
3
+ metadata.gz: 7a521ac101c9a3bcd672359fa18096718737b13e
4
+ data.tar.gz: cdc48eea47006b9246e6652b1ed3455e5c4b7ee4
5
5
  SHA512:
6
- metadata.gz: fbdd722c8e2d9e28d408a533052f3d5d8c3476fd6ee44237a6bb9373ae996bb3f15af95ea3a22481bbe3dd855bc953da2894994f019c34f5878407f676b23aeb
7
- data.tar.gz: feb9a71d15098f7fdfbb0b91e372b504ca23010cbed31def96cdf2b412f651c88bec29f46e9016c489948d3f2533833e99dd43b38574cce0c49fffd7ffb97b95
6
+ metadata.gz: bfdfbc16e0babbe9cf04b7d186621c34fbfdd14c42bf4105381996e858a36252506abc03fea8153d2bb74176e6c933caff968cc8a82852e5d84fb5f9dfdd1f13
7
+ data.tar.gz: 8bcce70a18a4177a28a6978efe19e97d69009616db18e6f0c88af6baaf2f2091faae715f501a71532b0d97ef2a317a3c2a1559445b27f71f95f5d7489bbd92ab
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ \#*
2
+ *~
3
+ .#*
4
+ .DS_Store
5
+ .idea
6
+ .project
7
+ .sass-cache
8
+ coverage
9
+ Gemfile.lock
10
+ tmp
11
+ nbproject
12
+ pkg
13
+ *.swp
14
+ spec/dummy
15
+ .bundle
16
+ .rvmrc
17
+ .ruby-version
18
+ .ruby-gemset
19
+ spree_gtm*.gem
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,11 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.3.1
4
+ sudo: false
5
+ cache: bundler
6
+ before_script:
7
+ - sh -e /etc/init.d/xvfb start
8
+ - bundle exec rake test_app
9
+ script:
10
+ - export DISPLAY=:99.0
11
+ - bundle exec rspec spec
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'spree', github: 'spree/spree', branch: '3-1-stable'
4
+ # Provides basic authentication functionality for testing parts of your engine
5
+ gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: '3-1-stable'
6
+
7
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,26 @@
1
+ Copyright (c) 2016 [name of plugin creator]
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification,
5
+ are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright notice,
8
+ this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+ * Neither the name Spree nor the names of its contributors may be used to
13
+ endorse or promote products derived from this software without specific
14
+ prior written permission.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md ADDED
@@ -0,0 +1,20 @@
1
+ Spree Google Tag Maneger Plugin
2
+ --------------------------------
3
+
4
+ [![Gem Version](https://badge.fury.io/rb/spree_gtm.svg)](https://badge.fury.io/rb/spree_gtm)
5
+ [![Code Climate](https://codeclimate.com/github/RostislavKorin/spree_gtm/badges/gpa.svg)](https://codeclimate.com/github/RostislavKorin/spree_gtm)
6
+ [![Build Status](https://travis-ci.org/RostislavKorin/spree_gtm.svg?branch=master)](https://travis-ci.org/RostislavKorin/spree_gtm)
7
+
8
+ Installation
9
+ ============
10
+
11
+ Add to your spree shop Gemfile
12
+
13
+ gem 'spree_gtm'
14
+
15
+ Run bundle install
16
+
17
+ Configuration
18
+ =============
19
+
20
+ Go to admin > Configuration > gtm, fill in your gtm account id
data/Rakefile ADDED
@@ -0,0 +1,21 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'rspec/core/rake_task'
5
+ require 'spree/testing_support/extension_rake'
6
+
7
+ RSpec::Core::RakeTask.new
8
+
9
+ task :default do
10
+ if Dir["spec/dummy"].empty?
11
+ Rake::Task[:test_app].invoke
12
+ Dir.chdir("../../")
13
+ end
14
+ Rake::Task[:spec].invoke
15
+ end
16
+
17
+ desc 'Generates a dummy app for testing'
18
+ task :test_app do
19
+ ENV['LIB_NAME'] = 'spree_gtm'
20
+ Rake::Task['extension:test_app'].invoke
21
+ end
@@ -0,0 +1,2 @@
1
+ // Placeholder manifest file.
2
+ // the installer will append this file to the app vendored assets here: vendor/assets/javascripts/spree/backend/all.js'
@@ -0,0 +1,2 @@
1
+ // Placeholder manifest file.
2
+ // the installer will append this file to the app vendored assets here: vendor/assets/javascripts/spree/frontend/all.js'
@@ -0,0 +1,4 @@
1
+ /*
2
+ Placeholder manifest file.
3
+ the installer will append this file to the app vendored assets here: 'vendor/assets/stylesheets/spree/backend/all.css'
4
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Placeholder manifest file.
3
+ the installer will append this file to the app vendored assets here: 'vendor/assets/stylesheets/spree/frontend/all.css'
4
+ */
@@ -0,0 +1,13 @@
1
+ class Spree::Admin::GtmsController < Spree::Admin::ResourceController
2
+
3
+ def index
4
+ @gtm = Spree::Gtm.first || Spree::Gtm.new
5
+ end
6
+
7
+ def new
8
+ end
9
+
10
+ def edit
11
+ @gtm = Spree::Gtm.first
12
+ end
13
+ end
@@ -0,0 +1,9 @@
1
+ class Spree::Gtm < ActiveRecord::Base
2
+ validates :gtm_accountid, presence: true
3
+
4
+
5
+ def self.gtm_accountid
6
+ first.gtm_accountid
7
+ end
8
+
9
+ end
@@ -0,0 +1,5 @@
1
+ module Spree
2
+ def self.table_name_prefix
3
+ 'spree_'
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ <!-- insert_bottom "[data-hook='admin_configurations_sidebar_menu']" -->
2
+ <%= configurations_sidebar_menu_item t('gtm'), admin_gtms_path %>
@@ -0,0 +1,11 @@
1
+ Deface::Override.new(:virtual_path => "spree/layouts/spree_application",
2
+ :name => "gtm_head",
3
+ :insert_bottom => "[data-hook='inside_head']",
4
+ :partial => "spree/gtm/google_tag_manager_head",
5
+ :disabled => false)
6
+
7
+ Deface::Override.new(:virtual_path => "spree/layouts/spree_application",
8
+ :name => "gtm_body",
9
+ :insert_bottom => "[data-hook='body']",
10
+ :partial => "spree/gtm/google_tag_manager_body",
11
+ :disabled => false)
@@ -0,0 +1,4 @@
1
+ <%= f.label :gtm_accountid %>
2
+ <%= f.text_field :gtm_accountid, :class => 'form-control' %>
3
+ <br />
4
+ <%= f.submit 'Save', :name => 'save', :class => 'btn btn-primary'%>
@@ -0,0 +1,13 @@
1
+ <% if @gtm.errors.any? %>
2
+ <h2>Errors:</h2>
3
+ <ul>
4
+ <% @gtm.errors.full_messages.each do |message| %>
5
+ <li><%= message %></li>
6
+ <% end %>
7
+ </ul>
8
+ <% end %>
9
+
10
+
11
+ <%= form_for [:admin, @gtm] do |f| %>
12
+ <%= render :partial => "form", :locals => { :f => f } %>
13
+ <% end %>
@@ -0,0 +1,14 @@
1
+ <h1><%= t('spree.gtm') %></h1>
2
+ <div class="col-md-6">
3
+ <br />
4
+ <br />
5
+ <% if @gtm.new_record? %>
6
+ <%= form_for [:admin, @gtm] do |f| %>
7
+ <%= render :partial => "form", :locals => { :f => f } %>
8
+ <% end %>
9
+ <% else %>
10
+ <%= form_for [:admin, @gtm], :method => :put do |f| %>
11
+ <%= render :partial => "form", :locals => { :f => f } %>
12
+ <% end %>
13
+ <% end %>
14
+ </div>
@@ -0,0 +1,7 @@
1
+ <!-- Google Tag Manager (noscript) -->
2
+ <noscript>
3
+ <iframe src="//www.googletagmanager.com/ns.html?id=<%= Spree::Gtm.gtm_accountid %>"
4
+ height="0" width="0" style="display:none;visibility:hidden">
5
+ </iframe>
6
+ </noscript>
7
+ <!-- End Google Tag Manager (noscript) -->
@@ -0,0 +1,10 @@
1
+ <!-- Google Tag Manager -->
2
+
3
+ <script>
4
+ (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
5
+ new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
6
+ j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
7
+ 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
8
+ })(window,document,'script','dataLayer','<%= Spree::Gtm.gtm_accountid %>');
9
+ </script>
10
+ <!-- End Google Tag Manager -->
data/bin/rails ADDED
@@ -0,0 +1,7 @@
1
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
2
+
3
+ ENGINE_ROOT = File.expand_path('../..', __FILE__)
4
+ ENGINE_PATH = File.expand_path('../../lib/spree_gtm/engine', __FILE__)
5
+
6
+ require 'rails/all'
7
+ require 'rails/engine/commands'
@@ -0,0 +1,5 @@
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ en:
5
+ hello: "Hello world"
data/config/routes.rb ADDED
@@ -0,0 +1,5 @@
1
+ Spree::Core::Engine.routes.draw do
2
+ namespace :admin do
3
+ resources :gtms
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ class CreateSpreeGtm < ActiveRecord::Migration
2
+ def change
3
+ create_table :spree_gtms do |t|
4
+ t.string :gtm_accountid
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,31 @@
1
+ module SpreeGtm
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+
5
+ class_option :auto_run_migrations, :type => :boolean, :default => false
6
+
7
+ def add_javascripts
8
+ append_file 'vendor/assets/javascripts/spree/frontend/all.js', "//= require spree/frontend/spree_gtm\n"
9
+ append_file 'vendor/assets/javascripts/spree/backend/all.js', "//= require spree/backend/spree_gtm\n"
10
+ end
11
+
12
+ def add_stylesheets
13
+ inject_into_file 'vendor/assets/stylesheets/spree/frontend/all.css', " *= require spree/frontend/spree_gtm\n", :before => /\*\//, :verbose => true
14
+ inject_into_file 'vendor/assets/stylesheets/spree/backend/all.css', " *= require spree/backend/spree_gtm\n", :before => /\*\//, :verbose => true
15
+ end
16
+
17
+ def add_migrations
18
+ run 'bundle exec rake railties:install:migrations FROM=spree_gtm'
19
+ end
20
+
21
+ def run_migrations
22
+ run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask 'Would you like to run the migrations now? [Y/n]')
23
+ if run_migrations
24
+ run 'bundle exec rake db:migrate'
25
+ else
26
+ puts 'Skipping rake db:migrate, don\'t forget to run it!'
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,20 @@
1
+ module SpreeGtm
2
+ class Engine < Rails::Engine
3
+ require 'spree/core'
4
+ isolate_namespace Spree
5
+ engine_name 'spree_gtm'
6
+
7
+ # use rspec for tests
8
+ config.generators do |g|
9
+ g.test_framework :rspec
10
+ end
11
+
12
+ def self.activate
13
+ Dir.glob(File.join(File.dirname(__FILE__), '../../app/**/*_decorator*.rb')) do |c|
14
+ Rails.configuration.cache_classes ? require(c) : load(c)
15
+ end
16
+ end
17
+
18
+ config.to_prepare &method(:activate).to_proc
19
+ end
20
+ end
@@ -0,0 +1,6 @@
1
+ FactoryGirl.define do
2
+ # Define your Spree extensions Factories within this file to enable applications, and other extensions to use and override them.
3
+ #
4
+ # Example adding this to your spec_helper will load these Factories for use:
5
+ # require 'spree_gtm/factories'
6
+ end
data/lib/spree_gtm.rb ADDED
@@ -0,0 +1,2 @@
1
+ require 'spree_core'
2
+ require 'spree_gtm/engine'
@@ -0,0 +1,93 @@
1
+ # Run Coverage report
2
+ require 'simplecov'
3
+ SimpleCov.start do
4
+ add_filter 'spec/dummy'
5
+ add_group 'Controllers', 'app/controllers'
6
+ add_group 'Helpers', 'app/helpers'
7
+ add_group 'Mailers', 'app/mailers'
8
+ add_group 'Models', 'app/models'
9
+ add_group 'Views', 'app/views'
10
+ add_group 'Libraries', 'lib'
11
+ end
12
+
13
+ # Configure Rails Environment
14
+ ENV['RAILS_ENV'] = 'test'
15
+
16
+ require File.expand_path('../dummy/config/environment.rb', __FILE__)
17
+
18
+ require 'rspec/rails'
19
+ require 'database_cleaner'
20
+ require 'ffaker'
21
+
22
+ # Requires supporting ruby files with custom matchers and macros, etc,
23
+ # in spec/support/ and its subdirectories.
24
+ Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f }
25
+
26
+ # Requires factories and other useful helpers defined in spree_core.
27
+ require 'spree/testing_support/authorization_helpers'
28
+ require 'spree/testing_support/capybara_ext'
29
+ require 'spree/testing_support/controller_requests'
30
+ require 'spree/testing_support/factories'
31
+ require 'spree/testing_support/url_helpers'
32
+
33
+ # Requires factories defined in lib/spree_gtm/factories.rb
34
+ require 'spree_gtm/factories'
35
+
36
+ RSpec.configure do |config|
37
+ config.include FactoryGirl::Syntax::Methods
38
+
39
+ # Infer an example group's spec type from the file location.
40
+ config.infer_spec_type_from_file_location!
41
+
42
+ # == URL Helpers
43
+ #
44
+ # Allows access to Spree's routes in specs:
45
+ #
46
+ # visit spree.admin_path
47
+ # current_path.should eql(spree.products_path)
48
+ config.include Spree::TestingSupport::UrlHelpers
49
+
50
+ # == Requests support
51
+ #
52
+ # Adds convenient methods to request Spree's controllers
53
+ # spree_get :index
54
+ config.include Spree::TestingSupport::ControllerRequests, type: :controller
55
+
56
+ # == Mock Framework
57
+ #
58
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
59
+ #
60
+ # config.mock_with :mocha
61
+ # config.mock_with :flexmock
62
+ # config.mock_with :rr
63
+ config.mock_with :rspec
64
+ config.color = true
65
+
66
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
67
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
68
+
69
+ # Capybara javascript drivers require transactional fixtures set to false, and we use DatabaseCleaner
70
+ # to cleanup after each test instead. Without transactional fixtures set to false the records created
71
+ # to setup a test will be unavailable to the browser, which runs under a separate server instance.
72
+ config.use_transactional_fixtures = false
73
+
74
+ # Ensure Suite is set to use transactions for speed.
75
+ config.before :suite do
76
+ DatabaseCleaner.strategy = :transaction
77
+ DatabaseCleaner.clean_with :truncation
78
+ end
79
+
80
+ # Before each spec check if it is a Javascript test and switch between using database transactions or not where necessary.
81
+ config.before :each do
82
+ DatabaseCleaner.strategy = RSpec.current_example.metadata[:js] ? :truncation : :transaction
83
+ DatabaseCleaner.start
84
+ end
85
+
86
+ # After each spec clean the database.
87
+ config.after :each do
88
+ DatabaseCleaner.clean
89
+ end
90
+
91
+ config.fail_fast = ENV['FAIL_FAST'] || false
92
+ config.order = "random"
93
+ end
data/spree_gtm.gemspec ADDED
@@ -0,0 +1,32 @@
1
+ # encoding: UTF-8
2
+ Gem::Specification.new do |s|
3
+ s.platform = Gem::Platform::RUBY
4
+ s.name = 'spree_gtm'
5
+ s.version = '0.0.2'
6
+ s.summary = 'some summary here'
7
+ s.description = 'some gem description here'
8
+ s.required_ruby_version = '>= 2.1.0'
9
+
10
+ s.authors = ['Stanislav O. Pogrebnyak', 'Rostislav O. Korin']
11
+ s.email = 'you@example.com'
12
+ # s.homepage = 'http://www.spreecommerce.com'
13
+ s.license = 'BSD-3'
14
+
15
+ s.files = `git ls-files`.split($/)
16
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
17
+ s.require_path = 'lib'
18
+ s.requirements << 'none'
19
+
20
+ s.add_dependency 'spree_core', '~> 3.1.3'
21
+
22
+ s.add_development_dependency 'capybara', '~> 2.6'
23
+ s.add_development_dependency 'coffee-rails'
24
+ s.add_development_dependency 'database_cleaner'
25
+ s.add_development_dependency 'factory_girl', '~> 4.5'
26
+ s.add_development_dependency 'ffaker'
27
+ s.add_development_dependency 'rspec-rails', '~> 3.4'
28
+ s.add_development_dependency 'sass-rails', '~> 5.0.0'
29
+ s.add_development_dependency 'selenium-webdriver'
30
+ s.add_development_dependency 'simplecov'
31
+ s.add_development_dependency 'sqlite3'
32
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_gtm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stanislav O. Pogrebnyak
@@ -170,7 +170,38 @@ email: you@example.com
170
170
  executables: []
171
171
  extensions: []
172
172
  extra_rdoc_files: []
173
- files: []
173
+ files:
174
+ - ".gitignore"
175
+ - ".rspec"
176
+ - ".travis.yml"
177
+ - Gemfile
178
+ - LICENSE
179
+ - README.md
180
+ - Rakefile
181
+ - app/assets/javascripts/spree/backend/spree_gtm.js
182
+ - app/assets/javascripts/spree/frontend/spree_gtm.js
183
+ - app/assets/stylesheets/spree/backend/spree_gtm.css
184
+ - app/assets/stylesheets/spree/frontend/spree_gtm.css
185
+ - app/controllers/spree/admin/gtms_controller.rb
186
+ - app/models/spree.rb
187
+ - app/models/spree/gtm.rb
188
+ - app/overrides/spree/admin/shared/sub_menu/_configuration/add_gtm_to_admin_configurations_sidebar_menu.html.erb.deface
189
+ - app/overrides/spree/gtm.rb
190
+ - app/views/spree/admin/gtms/_form.html.erb
191
+ - app/views/spree/admin/gtms/edit.html.erb
192
+ - app/views/spree/admin/gtms/index.html.erb
193
+ - app/views/spree/gtm/_google_tag_manager_body.html.erb
194
+ - app/views/spree/gtm/_google_tag_manager_head.html.erb
195
+ - bin/rails
196
+ - config/locales/en.yml
197
+ - config/routes.rb
198
+ - db/migrate/20161217192741_create_spree_gtm.rb
199
+ - lib/generators/spree_gtm/install/install_generator.rb
200
+ - lib/spree_gtm.rb
201
+ - lib/spree_gtm/engine.rb
202
+ - lib/spree_gtm/factories.rb
203
+ - spec/spec_helper.rb
204
+ - spree_gtm.gemspec
174
205
  homepage:
175
206
  licenses:
176
207
  - BSD-3
@@ -196,4 +227,5 @@ rubygems_version: 2.5.1
196
227
  signing_key:
197
228
  specification_version: 4
198
229
  summary: some summary here
199
- test_files: []
230
+ test_files:
231
+ - spec/spec_helper.rb