Skip to content

Commit

Permalink
inital commit
Browse files Browse the repository at this point in the history
  • Loading branch information
himanshumishra31 committed Aug 3, 2018
0 parents commit 5f68c82
Show file tree
Hide file tree
Showing 22 changed files with 440 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
--color
-r spec_helper
-f documentation
26 changes: 26 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
sudo: required
dist: trusty

language: ruby

env:
- DB=postgres
- DB=mysql

gemfile:
- gemfiles/spree_3_1.gemfile
- gemfiles/spree_3_2.gemfile
- gemfiles/spree_3_3.gemfile
- gemfiles/spree_3_4.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
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
source 'https://rubygems.org'

gem 'spree', github: 'spree/spree', branch: 'master'
# Provides basic authentication functionality for testing parts of your engine
gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: 'master'
gem 'rails-controller-testing'

gemspec
26 changes: 26 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Copyright (c) 2018 [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
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
SpreeBulkStoreCredits
=====================

Introduction goes here.

## Installation

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

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

3. Copy & run migrations
```ruby
bundle exec rails g spree_bulk_store_credits: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_bulk_store_credits/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) 2018 [name of extension creator], released under the New BSD License
21 changes: 21 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -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_bulk_store_credits'
Rake::Task['extension:test_app'].invoke
end
Original file line number Diff line number Diff line change
@@ -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'
Original file line number Diff line number Diff line change
@@ -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'
Original file line number Diff line number Diff line change
@@ -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'
*/
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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_bulk_store_credits/engine', __FILE__)

require 'rails/all'
require 'rails/engine/commands'
5 changes: 5 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Spree::Core::Engine.add_routes do
# Add your extension routes here
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module SpreeBulkStoreCredits
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_bulk_store_credits\n"
append_file 'vendor/assets/javascripts/spree/backend/all.js', "//= require spree/backend/spree_bulk_store_credits\n"
end

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

def add_migrations
run 'bundle exec rake railties:install:migrations FROM=spree_bulk_store_credits'
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
4 changes: 4 additions & 0 deletions lib/spree_bulk_store_credits.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
require 'spree_core'
require 'spree_extension'
require 'spree_bulk_store_credits/engine'
require 'spree_bulk_store_credits/version'
20 changes: 20 additions & 0 deletions lib/spree_bulk_store_credits/engine.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module SpreeBulkStoreCredits
class Engine < Rails::Engine
require 'spree/core'
isolate_namespace Spree
engine_name 'spree_bulk_store_credits'

# 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_bulk_store_credits/factories.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FactoryBot.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_bulk_store_credits/factories'
end
18 changes: 18 additions & 0 deletions lib/spree_bulk_store_credits/version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module SpreeBulkStoreCredits
module_function

# Returns the version of the currently loaded SpreeBulkStoreCredits 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
Loading

0 comments on commit 5f68c82

Please sign in to comment.