spree_erp_variants 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,14 @@
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
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Provides basic authentication functionality for testing parts of your engine
4
+ gem 'spree_auth_devise', github: 'spree/spree_auth_devise'
5
+
6
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,26 @@
1
+ Copyright (c) 2014 [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.ja.md ADDED
@@ -0,0 +1,57 @@
1
+ SpreeErpVariants
2
+ ==================
3
+
4
+ Purpose
5
+ -------
6
+ * ERPパッケージを関連付けるためのバリアント情報を管理することができます。
7
+ * このExtentionはデータを管理するだけで何も同期しません
8
+
9
+ 商品のサイドメニューへのリンクを表示。
10
+ ![ErpVariants](https://raw.githubusercontent.com/wiki/digitalm/spree_erp_variants/images/erpvariants2.jpg)
11
+
12
+ 「メーカー別情報」 - edit(種類を選択)
13
+ ![ErpVariants](https://raw.githubusercontent.com/wiki/digitalm/spree_erp_variants/images/erpvariants3.jpg)
14
+
15
+ 管理者は、商品に関連付けるためのメーカーの"製品コード(13桁以内)","在庫数"を管理することができます。
16
+ ![ErpVariants](https://raw.githubusercontent.com/wiki/digitalm/spree_erp_variants/images/erpvariants1.jpg)
17
+
18
+ Installation
19
+ ------------
20
+
21
+ Add spree_erp_variants to your Gemfile:
22
+
23
+ ```ruby
24
+ gem 'spree_erp_variants'
25
+ ```
26
+
27
+ or edge
28
+ ```ruby
29
+ gem 'spree_erp_variants', github: 'digitalm/spree_erp_variants'
30
+ ```
31
+
32
+ Bundle your dependencies and run the installation generator:
33
+
34
+ ```shell
35
+ bundle
36
+ bundle exec rails g spree_erp_variants:install
37
+ ```
38
+
39
+ Testing
40
+ -------
41
+
42
+ Be sure to bundle your dependencies and then create a dummy test app for the specs to run against.
43
+
44
+ ```shell
45
+ bundle
46
+ bundle exec rake test_app
47
+ bundle exec rspec spec
48
+ ```
49
+
50
+ When testing your applications integration with this extension you may use it's factories.
51
+ Simply add this require statement to your spec_helper:
52
+
53
+ ```ruby
54
+ require 'spree_erp_variants/factories'
55
+ ```
56
+
57
+ Copyright (c) 2014 [Exsight.inc](http://www.exsight.co.jp/) , released under the New BSD License
data/README.md ADDED
@@ -0,0 +1,57 @@
1
+ SpreeErpVariants
2
+ ================
3
+
4
+ Purpose
5
+ -------
6
+ * Enable to manage Variants information to associate ERP(Enterprise Resource Planning).
7
+ * It does not synchronize anything just to manage the data.
8
+
9
+ Show link "ERP VARIANTS" to Product side menu.
10
+ ![ErpVariants](https://raw.githubusercontent.com/wiki/digitalm/spree_erp_variants/images/erpvariants2.jpg)
11
+
12
+ "ERP VARIANTS" show variant list. Select particular variant and edit
13
+ ![ErpVariants](https://raw.githubusercontent.com/wiki/digitalm/spree_erp_variants/images/erpvariants3.jpg)
14
+
15
+ Admin can manage Maker Variant informations "Product Code(13 digits within)", "Stock" to associate as ERP Variant.
16
+ ![ErpVariants](https://raw.githubusercontent.com/wiki/digitalm/spree_erp_variants/images/erpvariants1.jpg)
17
+
18
+ Installation
19
+ ------------
20
+
21
+ Add spree_erp_variants to your Gemfile:
22
+
23
+ ```ruby
24
+ gem 'spree_erp_variants'
25
+ ```
26
+
27
+ or edge
28
+ ```ruby
29
+ gem 'spree_erp_variants', github: 'digitalm/spree_erp_variants'
30
+ ```
31
+
32
+ Bundle your dependencies and run the installation generator:
33
+
34
+ ```shell
35
+ bundle
36
+ bundle exec rails g spree_erp_variants:install
37
+ ```
38
+
39
+ Testing
40
+ -------
41
+
42
+ Be sure to bundle your dependencies and then create a dummy test app for the specs to run against.
43
+
44
+ ```shell
45
+ bundle
46
+ bundle exec rake test_app
47
+ bundle exec rspec spec
48
+ ```
49
+
50
+ When testing your applications integration with this extension you may use it's factories.
51
+ Simply add this require statement to your spec_helper:
52
+
53
+ ```ruby
54
+ require 'spree_erp_variants/factories'
55
+ ```
56
+
57
+ Copyright (c) 2014 [Exsight.inc](http://www.exsight.co.jp/) , released under the New BSD License
data/Rakefile ADDED
@@ -0,0 +1,15 @@
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 => [:spec]
10
+
11
+ desc 'Generates a dummy app for testing'
12
+ task :test_app do
13
+ ENV['LIB_NAME'] = 'spree_erp_variants'
14
+ Rake::Task['extension:test_app'].invoke
15
+ end
@@ -0,0 +1 @@
1
+ //= require admin/spree_backend
@@ -0,0 +1 @@
1
+ //= require store/spree_frontend
@@ -0,0 +1,3 @@
1
+ /*
2
+ *= require admin/spree_backend
3
+ */
@@ -0,0 +1,3 @@
1
+ /*
2
+ *= require store/spree_frontend
3
+ */
@@ -0,0 +1,107 @@
1
+ module Spree
2
+ module Admin
3
+ class AddOnErpVariantsController < ResourceController
4
+ before_filter :load_data, :except => :index
5
+
6
+ def show
7
+ session[:return_to] ||= request.referer
8
+ redirect_to( :action => :edit )
9
+ end
10
+
11
+ def index
12
+ logger.info "###############index#####################"
13
+ session[:return_to] = request.url
14
+ @product = Spree::Product.find_by_permalink!(params[:product_id])
15
+ logger.info "@product.inspect"
16
+ logger.info @product.variants.inspect
17
+ if @product.has_variants?
18
+ @variant = @product.variants
19
+ else
20
+ @variant = Spree::Variant.where(:id => @product.master.id)
21
+ end
22
+ logger.info "@variant"
23
+ logger.info @variant.inspect
24
+ @add_on_erp_variant = Spree::AddOnErpVariant.where(:variant_id => @variant).page(params[:page])
25
+ logger.info "@add_on_erp_variant"
26
+ logger.info @add_on_erp_variant.inspect
27
+ render :index
28
+ end
29
+
30
+ def edit
31
+ logger.info "###############edit#####################"
32
+ session[:return_to] = request.url
33
+ @product = Spree::Product.find_by_permalink!(params[:product_id])
34
+ @add_on_erp_variant = Spree::AddOnErpVariant.where(:variant_id => params[:variant_id]).first_or_initialize
35
+ logger.info "@add_on_erp_variant.inspect"
36
+ logger.info @add_on_erp_variant.inspect
37
+ render :edit
38
+ end
39
+
40
+ def create
41
+ @add_on_erp_variant = Spree::AddOnErpVariant.new(add_on_erp_variant_params.merge(:variant_id => params[:variant_id]))
42
+
43
+ respond_to do |format|
44
+ if @add_on_erp_variant.save
45
+ flash[:success] = t('add_on.notice_messages.admin_product_variant_add_on_maker_variant_created')
46
+ format.html { redirect_to admin_product_variant_add_on_erp_variants_path }
47
+ format.json { render action: 'index', status: :created, location: @add_on_erp_variant }
48
+ else
49
+ flash[:error] = t('add_on.notice_messages.admin_product_variant_add_on_maker_variant_has_error')
50
+ format.html { render action: 'new' }
51
+ format.json { render json: @add_on_erp_variant.errors }
52
+ end
53
+ end
54
+ end
55
+
56
+ def update
57
+ respond_to do |format|
58
+ if @add_on_erp_variant.update(add_on_erp_variant_params)
59
+ flash[:success] = t('add_on.notice_messages.admin_product_variant_add_on_maker_variant_updated')
60
+ format.html { redirect_to :action => :index }
61
+ format.json { head :no_content }
62
+ else
63
+ flash[:error] = t('add_on.notice_messages.admin_product_variant_add_on_maker_variant_has_error')
64
+ format.html { render action: 'edit' }
65
+ format.json { render json: @add_on_erp_variant.errors }
66
+ end
67
+ end
68
+ end
69
+
70
+ def destroy
71
+ @variant = Spree::Variant.find(params[:id])
72
+ if @variant.destroy
73
+ flash[:success] = Spree.t('notice_messages.variant_deleted')
74
+ else
75
+ flash[:success] = Spree.t('notice_messages.variant_not_deleted')
76
+ end
77
+
78
+ respond_with(@variant) do |format|
79
+ format.html { redirect_to admin_product_erp_variant_path(params[:product_id]) }
80
+ format.js { render_js_for_destroy }
81
+ end
82
+ end
83
+
84
+ protected
85
+ def variant_includes
86
+ [:add_on_erp_variants]
87
+ end
88
+
89
+ def load_data
90
+ @product = Spree::Product.find_by_permalink!(params[:product_id])
91
+ @taxons = Taxon.order(:name)
92
+ @option_types = OptionType.order(:name)
93
+ @tax_categories = TaxCategory.order(:name)
94
+ @shipping_categories = ShippingCategory.order(:name)
95
+ end
96
+
97
+ private
98
+ def permit_attributes
99
+ params.require(:add_on_erp_variant).permit!
100
+ end
101
+
102
+ def add_on_erp_variant_params
103
+ params.require(:add_on_erp_variant).permit(:variant_id, :erp_product_code, :stock)
104
+ end
105
+ end
106
+ end
107
+ end
@@ -0,0 +1,11 @@
1
+ class AbilityDecorator
2
+ include CanCan::Ability
3
+ def initialize(user)
4
+
5
+ if user.respond_to?(:has_spree_role?) && user.has_spree_role?('admin')
6
+ can [:admin, :index, :read, :update, :edit], Spree::AddOnErpVariant
7
+ end
8
+ end
9
+ end
10
+
11
+ Spree::Ability.register_ability(AbilityDecorator)
@@ -0,0 +1,10 @@
1
+ module Spree
2
+ class AddOnErpVariant < ActiveRecord::Base
3
+ belongs_to :variant, class_name: 'Spree::Variant', :foreign_key => :variant_id
4
+ belongs_to :product, class_name: 'Spree::Product'
5
+
6
+ validates :erp_product_code, length: {maximum: 32}, allow_nil: true
7
+ validates :stock, numericality: { only_integer: true }, allow_nil: true
8
+
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ module Spree
2
+ Product.class_eval do
3
+ has_many :add_on_erp_variants, :through => :variants
4
+
5
+
6
+ # enable products to CRUD each own add_on_maker_variants by accept nesting as child
7
+ accepts_nested_attributes_for :add_on_erp_variants, allow_destroy: true
8
+ end
9
+ end
@@ -0,0 +1,19 @@
1
+ module Spree
2
+ Variant.class_eval do
3
+ has_one :add_on_erp_variant, class_name: 'Spree::AddOnErpVariant'
4
+
5
+ # builds add_on_maker_variants from created variant ids
6
+ after_create :create_add_on_erp_variants_from_variants
7
+
8
+ # enable variants to CRUD each own add_on_maker_variants by accept nesting as child
9
+ accepts_nested_attributes_for :add_on_erp_variant, allow_destroy: true
10
+
11
+ def create_add_on_erp_variants_from_variants
12
+ Spree::AddOnErpVariant.where(variant_id: self.id).first_or_initialize do |a|
13
+ a.variant_id = self.id
14
+ a.save!
15
+ end
16
+ end
17
+
18
+ end
19
+ end
@@ -0,0 +1,10 @@
1
+ Deface::Override.new(:virtual_path => 'spree/admin/shared/_product_tabs',
2
+ :name => 'add_add_on_erp_variant_to_product_menu',
3
+ :insert_bottom => "[data-hook='admin_product_tabs']",
4
+ :sequence => {:after => "add_add_on_mall_price_variant_to_product_menu"},
5
+ :text => "
6
+ <%= content_tag :li, :class => ('active' if current == 'Add On Erp Variants') do %>
7
+ <%= link_to_with_icon 'icon-edit', t('add_on.add_on_erp_variant'), admin_product_add_on_erp_variants_path(@product) %>
8
+ <% end if can?(:admin, Spree::AddOnErpVariant) %>
9
+
10
+ ")
@@ -0,0 +1,40 @@
1
+ <%= render :partial => 'spree/admin/shared/product_sub_menu' %>
2
+
3
+ <%= render :partial => 'spree/admin/shared/product_tabs', :locals => {:current => 'Add On Erp Variants'} %>
4
+
5
+ <% content_for :page_title do %>
6
+ : <%= @add_on_erp_variant.variant.sku %>
7
+ <% end %>
8
+
9
+ <% content_for :page_actions do %>
10
+ <li>
11
+ <%= button_link_to t('add_on.back_to_product_add_on_maker_variants_list'), admin_product_add_on_erp_variants_path, :icon => 'icon-arrow-left' %>
12
+ </li>
13
+ <% end %>
14
+
15
+ <%= form_for [:admin, @product, @variant, @add_on_erp_variant], url: admin_product_variant_add_on_erp_variant_path(:variant_id => params[:variant_id], :id => params[:id]) do |f| %>
16
+ <div data-hook="admin_inside_add_on_erp_variant_form" class="row">
17
+ <div class='alpha six columns'>
18
+ <div class='field'>
19
+ <%= f.field_container :erp_product_code do %>
20
+ <%= f.label :erp_product_code, t('activerecord.attributes.add_on_erp_variant.erp_product_code') %><br />
21
+ <%= f.text_field :erp_product_code, :class => 'fullwidth' %>
22
+ <%= f.error_message_on :erp_product_code %>
23
+ <% end %>
24
+ </div>
25
+ <div class='field'>
26
+ <%= f.field_container :stock do %>
27
+ <%= f.label :stock, t('activerecord.attributes.add_on_erp_variant.stock') %>
28
+ <%= f.text_field :stock, :class => 'fullwidth' %>
29
+ <%= f.error_message_on :stock %>
30
+ <% end %>
31
+ </div>
32
+ </div>
33
+
34
+ </div>
35
+
36
+
37
+ <%= f.submit %>
38
+
39
+ </div>
40
+ <% end %>
@@ -0,0 +1,38 @@
1
+ <%= render :partial => 'spree/admin/shared/product_sub_menu' %>
2
+
3
+ <%= render :partial => 'spree/admin/shared/product_tabs', :locals => {:current => 'Add On Erp Variants'} %>
4
+
5
+ <% content_for :page_title do %>
6
+ <%= t("add_on.listing_add_on_erp_variant") %>
7
+ <% end %>
8
+
9
+ <%= paginate @add_on_erp_variant %>
10
+
11
+ <table class='index'>
12
+ <thead>
13
+ <tr>
14
+ <th><%= t("activerecord.attributes.variant.id") %></th>
15
+ <th><%= Spree.t(:options) %></th>
16
+ <th><%= Spree.t(:price) %></th>
17
+ <th><%= Spree.t(:sku) %></th>
18
+ </tr>
19
+ </thead>
20
+
21
+ <tbody>
22
+ <% for variant in @variant %>
23
+ <tr class="<%= cycle('odd', 'even') %>">
24
+ <td class="align-center"><%= variant.id %></td>
25
+ <td class="align-center"><%= variant.options_text %></td>
26
+ <td class="align-center"><%= variant.price %></td>
27
+ <td class="align-center"><%= variant.sku %></td>
28
+
29
+ <% if variant.add_on_erp_variant.blank? %>
30
+ <td class="actions"><%= link_to t("edit"), ("/admin/products/" + params[:product_id] + "/variants/#{variant.id}/add_on_erp_variants/new") , :class => 'edit' %></td>
31
+ <% else %>
32
+ <td class="actions"><%= link_to t("edit"), ("/admin/products/" + params[:product_id] + "/variants/#{variant.id}/add_on_erp_variants/#{variant.add_on_erp_variant.id}/edit") , :class => 'edit' %></td>
33
+ <% end %>
34
+
35
+ </tr>
36
+ <% end %>
37
+ </tbody>
38
+ </table>
@@ -0,0 +1,38 @@
1
+ <%= render :partial => 'spree/admin/shared/product_sub_menu' %>
2
+
3
+ <%= render :partial => 'spree/admin/shared/product_tabs', :locals => {:current => 'Add On Erp Variants'} %><% content_for :page_title do %>
4
+ <%= t('add_on.add_on_erp_variant') %>
5
+ <% end %>
6
+
7
+ <% content_for :page_actions do %>
8
+ <li>
9
+ <%= button_link_to t('add_on.back_to_product_add_on_erp_variants_list'), admin_product_add_on_erp_variants_path, :icon => 'icon-arrow-left' %>
10
+ </li>
11
+ <% end %>
12
+
13
+ <%= form_for [:admin, @product, @variant, @add_on_erp_variant], url: admin_product_variant_add_on_erp_variants_path(:variant_id => params[:variant_id]) do |f| %>
14
+ <div data-hook="admin_inside_add_on_erp_variant_form" class="row">
15
+ <div class='alpha six columns'>
16
+ <div class='field'>
17
+ <%= f.field_container :erp_product_code do %>
18
+ <%= f.label :erp_product_code, t('activerecord.attributes.add_on_erp_variant.erp_product_code') %><br />
19
+ <%= f.text_field :erp_product_code, :class => 'fullwidth' %>
20
+ <%= f.error_message_on :erp_product_code %>
21
+ <% end %>
22
+ </div>
23
+ <div class='field'>
24
+ <%= f.field_container :stock do %>
25
+ <%= f.label :stock, t('activerecord.attributes.add_on_erp_variant.stock') %>
26
+ <%= f.text_field :stock, :class => 'fullwidth' %>
27
+ <%= f.error_message_on :stock %>
28
+ <% end %>
29
+ </div>
30
+ </div>
31
+
32
+ </div>
33
+
34
+
35
+ <%= f.submit %>
36
+
37
+ </div>
38
+ <% end %>
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_erp_variants/engine', __FILE__)
5
+
6
+ require 'rails/all'
7
+ require 'rails/engine/commands'
@@ -0,0 +1,21 @@
1
+ en:
2
+ add_on:
3
+ add_on_erp_variant: ERP Variant
4
+ add_on_erp_variants: ERP Variants
5
+ listing_add_on_erp_variant: Listing ERP Variants
6
+ new_add_on_erp_variant: New ERP Variant
7
+ edit_add_on_erp_variant: Edit ERP Variant
8
+ destroy: Destroy
9
+ add_one: Add One
10
+ back_to_add_on_erp_variants_list: Back To ERP Variants List
11
+ back_to_product_add_on_erp_variants_list: Back To ERP Variants List
12
+ notice_messages:
13
+ admin_product_variant_add_on_maker_variant_created: ERP Variant has been successfully created!
14
+ admin_product_variant_add_on_maker_variant_updated: ERP Variant has been successfully updated!
15
+ admin_product_variant_add_on_maker_variant_has_error: Cannnot save for invalid data.
16
+ activerecord:
17
+ attributes:
18
+ add_on_erp_variant:
19
+ variant_id: Variant ID
20
+ erp_product_code: Product Code in ERP
21
+ stock: Stock in ERP
@@ -0,0 +1,20 @@
1
+ ja:
2
+ add_on:
3
+ add_on_erp_variant: 販売ソフト別情報
4
+ listing_add_on_erp_variant: 販売ソフト別情報一覧
5
+ new_add_on_erp_variant: 新規
6
+ edit_add_on_erp_variant: 編集
7
+ destroy: 削除
8
+ add_one: 新規追加
9
+ back_to_add_on_erp_variants_list: 登録済販売ソフト別情報一覧
10
+ back_to_product_add_on_erp_variants_list: 販売ソフト別情報一覧へ戻る
11
+ notice_messages:
12
+ admin_product_variant_add_on_maker_variant_created: 登録済販売ソフト別情報を作成しました
13
+ admin_product_variant_add_on_maker_variant_updated: 登録済販売ソフト別情報を更新しました
14
+ admin_product_variant_add_on_maker_variant_has_error: エラーが発生しました
15
+ activerecord:
16
+ attributes:
17
+ add_on_erp_variant:
18
+ variant_id: 種類
19
+ erp_product_code: 販売ソフトの商品コード
20
+ stock: 販売ソフトの在庫数
data/config/routes.rb ADDED
@@ -0,0 +1,12 @@
1
+ Spree::Core::Engine.routes.draw do
2
+ # Add your extension routes here
3
+ namespace :admin do
4
+ resources :products do
5
+ get 'add_on_erp_variants' => 'add_on_erp_variants#index'
6
+ resources :variants do
7
+ resources :add_on_erp_variants do
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,10 @@
1
+ class CreateSpreeErpVariants < ActiveRecord::Migration
2
+ def change
3
+ create_table :spree_add_on_erp_variants do |t|
4
+ t.integer :variant_id
5
+ t.string :erp_product_code, :limit => 32
6
+ t.integer :stock
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,31 @@
1
+ module SpreeErpVariants
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 'app/assets/javascripts/store/all.js', "//= require store/spree_erp_variants\n"
9
+ append_file 'app/assets/javascripts/admin/all.js', "//= require admin/spree_erp_variants\n"
10
+ end
11
+
12
+ def add_stylesheets
13
+ inject_into_file 'app/assets/stylesheets/store/all.css', " *= require store/spree_erp_variants\n", :before => /\*\//, :verbose => true
14
+ inject_into_file 'app/assets/stylesheets/admin/all.css', " *= require admin/spree_erp_variants\n", :before => /\*\//, :verbose => true
15
+ end
16
+
17
+ def add_migrations
18
+ run 'bundle exec rake railties:install:migrations FROM=spree_erp_variants'
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,2 @@
1
+ require 'spree_core'
2
+ require 'spree_erp_variants/engine'
@@ -0,0 +1,22 @@
1
+ module SpreeErpVariants
2
+ class Engine < Rails::Engine
3
+ require 'spree/core'
4
+ isolate_namespace Spree
5
+ engine_name 'spree_erp_variants'
6
+
7
+ config.autoload_paths += %W(#{config.root}/lib)
8
+
9
+ # use rspec for tests
10
+ config.generators do |g|
11
+ g.test_framework :rspec
12
+ end
13
+
14
+ def self.activate
15
+ Dir.glob(File.join(File.dirname(__FILE__), '../../app/**/*_decorator*.rb')) do |c|
16
+ Rails.configuration.cache_classes ? require(c) : load(c)
17
+ end
18
+ end
19
+
20
+ config.to_prepare &method(:activate).to_proc
21
+ end
22
+ 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_erp_variants/factories'
6
+ end
@@ -0,0 +1,82 @@
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 defined in spree_core
27
+ require 'spree/testing_support/factories'
28
+ require 'spree/testing_support/controller_requests'
29
+ require 'spree/testing_support/authorization_helpers'
30
+ require 'spree/testing_support/url_helpers'
31
+
32
+ # Requires factories defined in lib/spree_erp_variants/factories.rb
33
+ require 'spree_erp_variants/factories'
34
+
35
+ RSpec.configure do |config|
36
+ config.include FactoryGirl::Syntax::Methods
37
+
38
+ # == URL Helpers
39
+ #
40
+ # Allows access to Spree's routes in specs:
41
+ #
42
+ # visit spree.admin_path
43
+ # current_path.should eql(spree.products_path)
44
+ config.include Spree::TestingSupport::UrlHelpers
45
+
46
+ # == Mock Framework
47
+ #
48
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
49
+ #
50
+ # config.mock_with :mocha
51
+ # config.mock_with :flexmock
52
+ # config.mock_with :rr
53
+ config.mock_with :rspec
54
+ config.color = true
55
+
56
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
57
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
58
+
59
+ # Capybara javascript drivers require transactional fixtures set to false, and we use DatabaseCleaner
60
+ # to cleanup after each test instead. Without transactional fixtures set to false the records created
61
+ # to setup a test will be unavailable to the browser, which runs under a seperate server instance.
62
+ config.use_transactional_fixtures = false
63
+
64
+ # Ensure Suite is set to use transactions for speed.
65
+ config.before :suite do
66
+ DatabaseCleaner.strategy = :transaction
67
+ DatabaseCleaner.clean_with :truncation
68
+ end
69
+
70
+ # Before each spec check if it is a Javascript test and switch between using database transactions or not where necessary.
71
+ config.before :each do
72
+ DatabaseCleaner.strategy = example.metadata[:js] ? :truncation : :transaction
73
+ DatabaseCleaner.start
74
+ end
75
+
76
+ # After each spec clean the database.
77
+ config.after :each do
78
+ DatabaseCleaner.clean
79
+ end
80
+
81
+ config.fail_fast = ENV['FAIL_FAST'] || false
82
+ end
metadata ADDED
@@ -0,0 +1,254 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: spree_erp_variants
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - digitalm
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-05-30 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: spree_core
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 2.1.4
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 2.1.4
30
+ - !ruby/object:Gem::Dependency
31
+ name: capybara
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '2.1'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '2.1'
46
+ - !ruby/object:Gem::Dependency
47
+ name: coffee-rails
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: database_cleaner
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: factory_girl
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: '4.2'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: '4.2'
94
+ - !ruby/object:Gem::Dependency
95
+ name: ffaker
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: rspec-rails
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: '2.13'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ version: '2.13'
126
+ - !ruby/object:Gem::Dependency
127
+ name: sass-rails
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ - !ruby/object:Gem::Dependency
143
+ name: selenium-webdriver
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ! '>='
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ type: :development
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ! '>='
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ - !ruby/object:Gem::Dependency
159
+ name: simplecov
160
+ requirement: !ruby/object:Gem::Requirement
161
+ none: false
162
+ requirements:
163
+ - - ! '>='
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ type: :development
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - ! '>='
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ - !ruby/object:Gem::Dependency
175
+ name: sqlite3
176
+ requirement: !ruby/object:Gem::Requirement
177
+ none: false
178
+ requirements:
179
+ - - ! '>='
180
+ - !ruby/object:Gem::Version
181
+ version: '0'
182
+ type: :development
183
+ prerelease: false
184
+ version_requirements: !ruby/object:Gem::Requirement
185
+ none: false
186
+ requirements:
187
+ - - ! '>='
188
+ - !ruby/object:Gem::Version
189
+ version: '0'
190
+ description: Admin can manage Maker Variant informations "Product Code(13 digits within)",
191
+ "Stock" to associate as ERP Variant.
192
+ email: digitalm.github@gmail.com
193
+ executables: []
194
+ extensions: []
195
+ extra_rdoc_files: []
196
+ files:
197
+ - .gitignore
198
+ - .rspec
199
+ - Gemfile
200
+ - LICENSE
201
+ - README.ja.md
202
+ - README.md
203
+ - Rakefile
204
+ - app/assets/javascripts/admin/spree_erp_variants.js
205
+ - app/assets/javascripts/store/spree_erp_variants.js
206
+ - app/assets/stylesheets/admin/spree_erp_variants.css
207
+ - app/assets/stylesheets/store/spree_erp_variants.css
208
+ - app/controllers/spree/admin/add_on_erp_variants_controller.rb
209
+ - app/models/spree/ability_decorator.rb
210
+ - app/models/spree/add_on_erp_variant.rb
211
+ - app/models/spree/product_decorator.rb
212
+ - app/models/spree/variant_decorator.rb
213
+ - app/overrides/add_add_on_erp_variant_to_product_menu.rb
214
+ - app/views/spree/admin/add_on_erp_variants/edit.html.erb
215
+ - app/views/spree/admin/add_on_erp_variants/index.html.erb
216
+ - app/views/spree/admin/add_on_erp_variants/new.html.erb
217
+ - bin/rails
218
+ - config/locales/en.yml
219
+ - config/locales/ja.yml
220
+ - config/routes.rb
221
+ - db/migrate/20140428075516_create_spree_erp_variants.rb
222
+ - lib/generators/spree_erp_variants/install/install_generator.rb
223
+ - lib/spree_erp_variants.rb
224
+ - lib/spree_erp_variants/engine.rb
225
+ - lib/spree_erp_variants/factories.rb
226
+ - spec/spec_helper.rb
227
+ homepage: https://github.com/digitalm/spree_erp_variants
228
+ licenses: []
229
+ post_install_message:
230
+ rdoc_options: []
231
+ require_paths:
232
+ - lib
233
+ required_ruby_version: !ruby/object:Gem::Requirement
234
+ none: false
235
+ requirements:
236
+ - - ! '>='
237
+ - !ruby/object:Gem::Version
238
+ version: 1.9.3
239
+ required_rubygems_version: !ruby/object:Gem::Requirement
240
+ none: false
241
+ requirements:
242
+ - - ! '>='
243
+ - !ruby/object:Gem::Version
244
+ version: '0'
245
+ requirements:
246
+ - none
247
+ rubyforge_project:
248
+ rubygems_version: 1.8.23
249
+ signing_key:
250
+ specification_version: 3
251
+ summary: ! 'Spree Extension : Enable to manage Variants information to associate ERP(Enterprise
252
+ Resource Planning).'
253
+ test_files:
254
+ - spec/spec_helper.rb