Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
bbonislawski committed Oct 13, 2017
0 parents commit 0fb5fd7
Show file tree
Hide file tree
Showing 28 changed files with 465 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .gitignore
@@ -0,0 +1,21 @@
\#*
*~
.#*
.DS_Store
.idea
.localeapp/locales
.project
coverage
default
Gemfile.lock
tmp
nbproject
pkg
*.sw?
spec/dummy
.rvmrc
.sass-cache
public/spree
.ruby-version
.ruby-gemset
gemfiles/*.gemfile.lock
3 changes: 3 additions & 0 deletions .rspec
@@ -0,0 +1,3 @@
--color
-r spec_helper
-f documentation
24 changes: 24 additions & 0 deletions .travis.yml
@@ -0,0 +1,24 @@
sudo: required
dist: trusty

language: ruby

env:
- DB=postgres
- DB=mysql

gemfile:
- gemfiles/spree_3_1.gemfile
- gemfiles/spree_3_2.gemfile
- gemfiles/spree_master.gemfile

script:
- bundle exec rake test_app
- bundle exec rake spec

rvm:
- 2.3.1
- 2.2.7

before_install:
- mysql -u root -e "GRANT ALL ON *.* TO 'travis'@'%';"
29 changes: 29 additions & 0 deletions Appraisals
@@ -0,0 +1,29 @@
appraise 'spree-3-1' do
gem 'spree', '~> 3.1.0'
gem 'spree_auth_devise', '~> 3.1.0'
gem 'rails_test_params_backport', group: :test
end

appraise 'spree-3-2' do
gem 'spree', '~> 3.2.0'
gem 'spree_auth_devise', '~> 3.2.0'
gem 'rails-controller-testing'
end

appraise 'spree-3-3' do
gem 'spree', '~> 3.3.0'
gem 'spree_auth_devise', '~> 3.3.0'
gem 'rails-controller-testing'
end

appraise 'spree-3-4' do
gem 'spree', '~> 3.4.0'
gem 'spree_auth_devise', '~> 3.3.0'
gem 'rails-controller-testing'
end

appraise 'spree-master' do
gem 'spree', github: 'spree/spree', branch: 'master'
gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: 'master'
gem 'rails-controller-testing'
end
7 changes: 7 additions & 0 deletions Gemfile
@@ -0,0 +1,7 @@
source 'https://rubygems.org'

gem 'spree', github: 'spree/spree', branch: 'master'
gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: 'master'
gem 'rails-controller-testing'

gemspec
26 changes: 26 additions & 0 deletions LICENSE
@@ -0,0 +1,26 @@
Copyright (c) 2017 [name of plugin creator]
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name Spree nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
50 changes: 50 additions & 0 deletions README.md
@@ -0,0 +1,50 @@
SpreeAnalytics
==============

Introduction goes here.

## Installation

1. Add this extension to your Gemfile with this line:
```ruby
gem 'spree_analytics', github: '[your-github-handle]/spree_analytics'
```

2. Install the gem using Bundler:
```ruby
bundle install
```

3. Copy & run migrations
```ruby
bundle exec rails g spree_analytics:install
```

4. Restart your server

If your server was running, restart it so that it can find the assets properly.

## Testing

First bundle your dependencies, then run `rake`. `rake` will default to building the dummy app if it does not exist, then it will run specs. The dummy app can be regenerated by using `rake test_app`.

```shell
bundle
bundle exec rake
```

When testing your applications integration with this extension you may use it's factories.
Simply add this require statement to your spec_helper:

```ruby
require 'spree_analytics/factories'
```


## Contributing

If you'd like to contribute, please take a look at the
[instructions](CONTRIBUTING.md) for installing dependencies and crafting a good
pull request.

Copyright (c) 2017 [name of extension creator], released under the New BSD License
21 changes: 21 additions & 0 deletions Rakefile
@@ -0,0 +1,21 @@
require 'bundler'
Bundler::GemHelper.install_tasks

require 'rspec/core/rake_task'
require 'spree/testing_support/extension_rake'

RSpec::Core::RakeTask.new

task :default do
if Dir["spec/dummy"].empty?
Rake::Task[:test_app].invoke
Dir.chdir("../../")
end
Rake::Task[:spec].invoke
end

desc 'Generates a dummy app for testing'
task :test_app do
ENV['LIB_NAME'] = 'spree_analytics'
Rake::Task['extension:test_app'].invoke
end
2 changes: 2 additions & 0 deletions app/assets/javascripts/spree/backend/spree_analytics.js
@@ -0,0 +1,2 @@
// Placeholder manifest file.
// the installer will append this file to the app vendored assets here: vendor/assets/javascripts/spree/backend/all.js'
2 changes: 2 additions & 0 deletions app/assets/javascripts/spree/frontend/spree_analytics.js
@@ -0,0 +1,2 @@
// Placeholder manifest file.
// the installer will append this file to the app vendored assets here: vendor/assets/javascripts/spree/frontend/all.js'
4 changes: 4 additions & 0 deletions app/assets/stylesheets/spree/backend/spree_analytics.css
@@ -0,0 +1,4 @@
/*
Placeholder manifest file.
the installer will append this file to the app vendored assets here: 'vendor/assets/stylesheets/spree/backend/all.css'
*/
4 changes: 4 additions & 0 deletions app/assets/stylesheets/spree/frontend/spree_analytics.css
@@ -0,0 +1,4 @@
/*
Placeholder manifest file.
the installer will append this file to the app vendored assets here: 'vendor/assets/stylesheets/spree/frontend/all.css'
*/
7 changes: 7 additions & 0 deletions bin/rails
@@ -0,0 +1,7 @@
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.

ENGINE_ROOT = File.expand_path('../..', __FILE__)
ENGINE_PATH = File.expand_path('../../lib/spree_analytics/engine', __FILE__)

require 'rails/all'
require 'rails/engine/commands'
5 changes: 5 additions & 0 deletions config/locales/en.yml
@@ -0,0 +1,5 @@
# Sample localization file for English. Add more files in this directory for other locales.
# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.

en:
hello: "Hello world"
3 changes: 3 additions & 0 deletions config/routes.rb
@@ -0,0 +1,3 @@
Spree::Core::Engine.add_routes do
# Add your extension routes here
end
2 changes: 2 additions & 0 deletions gemfiles/.bundle/config
@@ -0,0 +1,2 @@
---
BUNDLE_RETRY: "1"
9 changes: 9 additions & 0 deletions gemfiles/spree_3_1.gemfile
@@ -0,0 +1,9 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "spree", "~> 3.1.0"
gem "spree_auth_devise", "~> 3.1.0"
gem "rails_test_params_backport", group: :test

gemspec path: "../"
9 changes: 9 additions & 0 deletions gemfiles/spree_3_2.gemfile
@@ -0,0 +1,9 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "spree", "~> 3.2.0"
gem "spree_auth_devise", "~> 3.2.0"
gem "rails-controller-testing"

gemspec path: "../"
9 changes: 9 additions & 0 deletions gemfiles/spree_3_3.gemfile
@@ -0,0 +1,9 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "spree", "~> 3.3.0"
gem "spree_auth_devise", "~> 3.3.0"
gem "rails-controller-testing"

gemspec path: "../"
9 changes: 9 additions & 0 deletions gemfiles/spree_3_4.gemfile
@@ -0,0 +1,9 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "spree", "~> 3.4.0"
gem "spree_auth_devise", "~> 3.3.0"
gem "rails-controller-testing"

gemspec path: "../"
9 changes: 9 additions & 0 deletions gemfiles/spree_master.gemfile
@@ -0,0 +1,9 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "spree", github: "spree/spree", branch: "master"
gem "spree_auth_devise", github: "spree/spree_auth_devise", branch: "master"
gem "rails-controller-testing"

gemspec path: "../"
31 changes: 31 additions & 0 deletions lib/generators/spree_analytics/install/install_generator.rb
@@ -0,0 +1,31 @@
module SpreeAnalytics
module Generators
class InstallGenerator < Rails::Generators::Base

class_option :auto_run_migrations, type: :boolean, default: false

def add_javascripts
append_file 'vendor/assets/javascripts/spree/frontend/all.js', "//= require spree/frontend/spree_analytics\n"
append_file 'vendor/assets/javascripts/spree/backend/all.js', "//= require spree/backend/spree_analytics\n"
end

def add_stylesheets
inject_into_file 'vendor/assets/stylesheets/spree/frontend/all.css', " *= require spree/frontend/spree_analytics\n", before: /\*\//, verbose: true
inject_into_file 'vendor/assets/stylesheets/spree/backend/all.css', " *= require spree/backend/spree_analytics\n", before: /\*\//, verbose: true
end

def add_migrations
run 'bundle exec rake railties:install:migrations FROM=spree_analytics'
end

def run_migrations
run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask 'Would you like to run the migrations now? [Y/n]')
if run_migrations
run 'bundle exec rake db:migrate'
else
puts 'Skipping rake db:migrate, don\'t forget to run it!'
end
end
end
end
end
3 changes: 3 additions & 0 deletions lib/spree_analytics.rb
@@ -0,0 +1,3 @@
require 'spree_core'
require 'spree_analytics/engine'
require 'spree_analytics/version'
20 changes: 20 additions & 0 deletions lib/spree_analytics/engine.rb
@@ -0,0 +1,20 @@
module SpreeAnalytics
class Engine < Rails::Engine
require 'spree/core'
isolate_namespace Spree
engine_name 'spree_analytics'

# use rspec for tests
config.generators do |g|
g.test_framework :rspec
end

def self.activate
Dir.glob(File.join(File.dirname(__FILE__), '../../app/**/*_decorator*.rb')) do |c|
Rails.configuration.cache_classes ? require(c) : load(c)
end
end

config.to_prepare &method(:activate).to_proc
end
end
6 changes: 6 additions & 0 deletions lib/spree_analytics/factories.rb
@@ -0,0 +1,6 @@
FactoryGirl.define do
# Define your Spree extensions Factories within this file to enable applications, and other extensions to use and override them.
#
# Example adding this to your spec_helper will load these Factories for use:
# require 'spree_analytics/factories'
end
18 changes: 18 additions & 0 deletions lib/spree_analytics/version.rb
@@ -0,0 +1,18 @@
module SpreeAnalytics
module_function

# Returns the version of the currently loaded SpreeAnalytics as a
# <tt>Gem::Version</tt>.
def version
Gem::Version.new VERSION::STRING
end

module VERSION
MAJOR = 0
MINOR = 0
TINY = 1
PRE = 'alpha'.freeze

STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
end
end

0 comments on commit 0fb5fd7

Please sign in to comment.