spree_zoned 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ *.tmproj
2
+ \#*
3
+ *~
4
+ .#*
5
+ .DS_Store
6
+ .idea
7
+ .project
8
+ tmp
9
+ nbproject
10
+ *.swp
11
+ spec/dummy
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source 'http://rubygems.org'
2
+
3
+ if RUBY_VERSION < '1.9'
4
+ gem 'ruby-debug'
5
+ else
6
+ gem 'ruby-debug19'
7
+ end
8
+
9
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,26 @@
1
+ Copyright (c) 2012 [Bernd Blume](http://berndblume.com)
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,45 @@
1
+ # SpreeZoned
2
+
3
+ A Spree extension to make your store zoned.
4
+
5
+ &nbsp;
6
+
7
+ Everything you need for a zoned Spree store:
8
+
9
+ ### 1. Zoned Pricing
10
+
11
+ Your products and variants have different prices in different zones/countries.
12
+
13
+ ### 2. Zoned Products
14
+
15
+ Products are listed or not listed in your store, depending on zone/country.
16
+
17
+ ### 3. Zoned Product Ordering
18
+
19
+ Specify the order in which products appear in your store, by zone.
20
+
21
+ ### 4. Zoned Locales
22
+
23
+ Set locales (semi-) automatically by zone.
24
+
25
+ ### 5. More features.
26
+
27
+ Give [SpreeZoned](http://github.com/berndblume/spree_zoned) at try now!
28
+
29
+ &nbsp;
30
+
31
+ This Spree extension is probalbly essential to you if you operate outside of the US.
32
+
33
+ &nbsp;
34
+
35
+ ## Example
36
+
37
+ Example goes here.
38
+
39
+ ## ToDo
40
+
41
+ ToDos go here.
42
+
43
+ ## Legal notice
44
+
45
+ Copyright &copy; 2012 by [Bernd Blume](http://berndblume.com), released under the New BSD License
data/Rakefile ADDED
@@ -0,0 +1,29 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/packagetask'
4
+ require 'rubygems/package_task'
5
+ require 'rspec/core/rake_task'
6
+ require 'spree/core/testing_support/common_rake'
7
+
8
+ RSpec::Core::RakeTask.new
9
+
10
+ task :default => [:spec]
11
+
12
+ spec = eval(File.read('spree_zoned.gemspec'))
13
+
14
+ Gem::PackageTask.new(spec) do |p|
15
+ p.gem_spec = spec
16
+ end
17
+
18
+ desc 'Release to gemcutter'
19
+ task :release => :package do
20
+ require 'rake/gemcutter'
21
+ Rake::Gemcutter::Tasks.new(spec).define
22
+ Rake::Task['gem:push'].invoke
23
+ end
24
+
25
+ desc 'Generates a dummy app for testing'
26
+ task :test_app do
27
+ ENV['LIB_NAME'] = 'spree_zoned'
28
+ Rake::Task['common:test_app'].invoke
29
+ end
data/Versionfile ADDED
@@ -0,0 +1,11 @@
1
+ # This file is used to designate compatibilty with different versions of Spree
2
+ # Please see http://spreecommerce.com/documentation/extensions.html#versionfile for details
3
+
4
+ # Examples
5
+ #
6
+ # '1.2.x' => { :branch => 'master' }
7
+ '1.1.x' => { :branch => 'master' }
8
+ # '1.0.x' => { :branch => '1-0-stable' }
9
+ # '0.70.x' => { :branch => '0-70-stable' }
10
+ # '0.40.x' => { :tag => 'v1.0.0', :version => '1.0.0' }
11
+
@@ -0,0 +1 @@
1
+ //= require admin/spree_core
@@ -0,0 +1 @@
1
+ //= require store/spree_core
@@ -0,0 +1,3 @@
1
+ /*
2
+ *= require admin/spree_core
3
+ */
@@ -0,0 +1,2 @@
1
+ div#zoned-countryselect { text-align: right; }
2
+ div#zoned-countryselect label { color: #a33; }
@@ -0,0 +1,17 @@
1
+ module Spree
2
+
3
+ module Zoned
4
+
5
+ class ZonedController < BaseController
6
+
7
+ def setcountry
8
+ respond_to do |format|
9
+ format.js { render :nothing => true }
10
+ end
11
+ end
12
+
13
+ end
14
+
15
+ end
16
+
17
+ end
@@ -0,0 +1,7 @@
1
+ module Spree
2
+ BaseHelper.module_eval do
3
+ def countrylist
4
+ @zonedCountrylist ||= Country.order :name
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,6 @@
1
+ Deface::Override.new(
2
+ :name => "add_country_selectbox",
3
+ :virtual_path => "spree/layouts/spree_application",
4
+ :insert_before => "nav#top-nav-bar",
5
+ :partial => "spree/zoned/countryselect",
6
+ )
@@ -0,0 +1,18 @@
1
+ <div id="zoned-countryselect" class="columns omega ten">
2
+ <%= label_tag t('country') + ": " %>
3
+ <%= select_tag 'id',
4
+ options_for_select(
5
+ Rails.application.config.commonCountriesForSelect +
6
+ [["-----------------", 0]] +
7
+ countrylist.map { |country| [country.name, country.id] },
8
+ -214, # Unites States of America
9
+ ),
10
+ :data => {
11
+ :remote => true,
12
+ :url => url_for(
13
+ :controller => "zoned",
14
+ :action => "setcountry",
15
+ ),
16
+ }
17
+ %>
18
+ </div>
@@ -0,0 +1,36 @@
1
+ #
2
+ # ZONED_COMMON_COUNTRIES is the list of countries that will be separately listed
3
+ # in the beginning of the country select box for easy selection.
4
+ # Edit the list to your liking.
5
+ #
6
+ ZONED_COMMON_COUNTRIES =
7
+ [
8
+ 214, # United States
9
+ 74, # Germany
10
+ 13, # Austria
11
+ 195, # Switzerland
12
+ 142, # Netherlands
13
+ 20, # Belgium
14
+ 117, # Luxembourg
15
+ ]
16
+
17
+ #
18
+ # ZONED_COMMOM_LOCALES specifies - for each contry contained in ZONED_COMMON_COUNTRIES - a list (array)
19
+ # of locales that are pobbile to select for that specific country.
20
+ # For all countries not included in ZONED_COMMON_COUNTRIES, the locale will automatically be set to :en.
21
+ # The first locale listed for each country is considered that countrie's default locale.
22
+ #
23
+ ZONED_COMMON_LOCALES =
24
+ [
25
+ [:en], # United States
26
+ [:de, :en], # Germany
27
+ [:de, :en], # Austria
28
+ [:de, :en], # Switzerland
29
+ [:nl, :en], # Netherlands
30
+ [:nl, :de, :en], # Belgium
31
+ [:de, :en], # Luxembourg
32
+ ]
33
+
34
+ Rails.configuration.commonCountriesForSelect = ZONED_COMMON_COUNTRIES.map do |id|
35
+ [ Spree::Country.find_by_id(id).name, -id ]
36
+ end
@@ -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,3 @@
1
+ Spree::Core::Engine.routes.draw do
2
+ match '/zonedcs' => "zoned#setcountry"
3
+ end
@@ -0,0 +1,44 @@
1
+ module Spree
2
+ module Zoned
3
+ module Generators
4
+ class InstallGenerator < Rails::Generators::Base
5
+
6
+ source_root File.expand_path("../assets", __FILE__)
7
+
8
+ def add_javascripts
9
+ append_file 'app/assets/javascripts/store/all.js', "//= require store/spree_zoned\n"
10
+ append_file 'app/assets/javascripts/admin/all.js', "//= require admin/spree_zoned\n"
11
+ end
12
+
13
+ def add_stylesheets
14
+ inject_into_file 'app/assets/stylesheets/store/all.css', " *= require store/spree_zoned\n", :before => /\*\//, :verbose => true
15
+ inject_into_file 'app/assets/stylesheets/admin/all.css', " *= require admin/spree_zoned\n", :before => /\*\//, :verbose => true
16
+ end
17
+
18
+ def add_migrations
19
+ run 'bundle exec rake railties:install:migrations FROM=spree_zoned'
20
+ end
21
+
22
+ def run_migrations
23
+ res = ask 'Would you like to run the migrations now? [Y/n]'
24
+ if res == '' || res.downcase == 'y'
25
+ run 'bundle exec rake db:migrate'
26
+ else
27
+ puts 'Skiping rake db:migrate, don\'t forget to run it!'
28
+ end
29
+ end
30
+
31
+ private
32
+
33
+ def copyasset(filename)
34
+ if copy_file "#{filename}", "app/assets/#{filename}"
35
+ puts "Copied #{filename} into app/assets/#{filename}\n"
36
+ else
37
+ puts "[Failed] File copying #{filename} into app/assets/#{filename}\n"
38
+ end
39
+ end
40
+
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,23 @@
1
+ module Spree
2
+ module Zoned
3
+ class Engine < Rails::Engine
4
+ engine_name 'spree_zoned'
5
+ isolate_namespace Spree::Zoned
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
23
+ end
@@ -0,0 +1,2 @@
1
+ require 'spree_core'
2
+ require 'spree_zoned/engine'
data/script/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_zoned/engine', __FILE__)
5
+
6
+ require 'rails/all'
7
+ require 'rails/engine/commands'
@@ -0,0 +1,44 @@
1
+ # Configure Rails Environment
2
+ ENV['RAILS_ENV'] = 'test'
3
+
4
+ require File.expand_path('../dummy/config/environment.rb', __FILE__)
5
+
6
+ require 'rspec/rails'
7
+ require 'ffaker'
8
+
9
+ # Requires supporting ruby files with custom matchers and macros, etc,
10
+ # in spec/support/ and its subdirectories.
11
+ Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f }
12
+
13
+ # Requires factories defined in spree_core
14
+ require 'spree/core/testing_support/factories'
15
+ require 'spree/core/url_helpers'
16
+
17
+ RSpec.configure do |config|
18
+ config.include FactoryGirl::Syntax::Methods
19
+
20
+ # == URL Helpers
21
+ #
22
+ # Allows access to Spree's routes in specs:
23
+ #
24
+ # visit spree.admin_path
25
+ # current_path.should eql(spree.products_path)
26
+ config.include Spree::Core::UrlHelpers
27
+
28
+ # == Mock Framework
29
+ #
30
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
31
+ #
32
+ # config.mock_with :mocha
33
+ # config.mock_with :flexmock
34
+ # config.mock_with :rr
35
+ config.mock_with :rspec
36
+
37
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
38
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
39
+
40
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
41
+ # examples within a transaction, remove the following line or assign false
42
+ # instead of true.
43
+ config.use_transactional_fixtures = true
44
+ end
@@ -0,0 +1,29 @@
1
+ # encoding: UTF-8
2
+ Gem::Specification.new do |s|
3
+ s.platform = Gem::Platform::RUBY
4
+ s.name = 'spree_zoned'
5
+ s.version = '0.5.0'
6
+ s.summary = 'A Spree extension to make your store zoned'
7
+ s.description = "Everything you need for a zoned Spree store: zoned pricing, zoned products, zoned product ordering, zoned locales, ...\nProbalbly essential to you if you operate outside of the US."
8
+ s.required_ruby_version = '>= 1.9.2'
9
+
10
+ s.author = 'Bernd Blume'
11
+ s.email = 'bernd.blume@railando.com'
12
+ s.homepage = 'http://www.berndblume.com'
13
+
14
+ #s.files = `git ls-files`.split("\n")
15
+ #s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ s.files = `git ls-files`.split($\)
17
+ s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
18
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
19
+ s.require_path = 'lib'
20
+ s.requirements << 'none'
21
+
22
+ s.add_dependency 'spree_core', '~> 1.1.1'
23
+
24
+ s.add_development_dependency 'capybara', '1.0.1'
25
+ s.add_development_dependency 'factory_girl', '~> 2.6.4'
26
+ s.add_development_dependency 'ffaker'
27
+ s.add_development_dependency 'rspec-rails', '~> 2.9'
28
+ s.add_development_dependency 'sqlite3'
29
+ end
metadata ADDED
@@ -0,0 +1,170 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: spree_zoned
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Bernd Blume
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-06-08 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: 1.1.1
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: 1.1.1
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: 1.0.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: 1.0.1
46
+ - !ruby/object:Gem::Dependency
47
+ name: factory_girl
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 2.6.4
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: 2.6.4
62
+ - !ruby/object:Gem::Dependency
63
+ name: ffaker
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: rspec-rails
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: '2.9'
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: '2.9'
94
+ - !ruby/object:Gem::Dependency
95
+ name: sqlite3
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
+ description: ! 'Everything you need for a zoned Spree store: zoned pricing, zoned
111
+ products, zoned product ordering, zoned locales, ...
112
+
113
+ Probalbly essential to you if you operate outside of the US.'
114
+ email: bernd.blume@railando.com
115
+ executables: []
116
+ extensions: []
117
+ extra_rdoc_files: []
118
+ files:
119
+ - .gitignore
120
+ - .rspec
121
+ - Gemfile
122
+ - LICENSE
123
+ - README.md
124
+ - Rakefile
125
+ - Versionfile
126
+ - app/assets/javascripts/admin/spree_zoned.js
127
+ - app/assets/javascripts/store/spree_zoned.js
128
+ - app/assets/stylesheets/admin/spree_zoned.css
129
+ - app/assets/stylesheets/store/spree_zoned.css
130
+ - app/controllers/spree/zoned_controller.rb
131
+ - app/helpers/spree/base_helper_decorator.rb
132
+ - app/overrides/add_country_selectbox.rb
133
+ - app/views/spree/zoned/_countryselect.html.erb
134
+ - config/initializers/zoned_init.rb
135
+ - config/locales/en.yml
136
+ - config/routes.rb
137
+ - lib/generators/spree_zoned/install/install_generator.rb
138
+ - lib/spree_zoned.rb
139
+ - lib/spree_zoned/engine.rb
140
+ - script/rails
141
+ - spec/spec_helper.rb
142
+ - spree_zoned-0.5.0.gem
143
+ - spree_zoned.gemspec
144
+ homepage: http://www.berndblume.com
145
+ licenses: []
146
+ post_install_message:
147
+ rdoc_options: []
148
+ require_paths:
149
+ - lib
150
+ required_ruby_version: !ruby/object:Gem::Requirement
151
+ none: false
152
+ requirements:
153
+ - - ! '>='
154
+ - !ruby/object:Gem::Version
155
+ version: 1.9.2
156
+ required_rubygems_version: !ruby/object:Gem::Requirement
157
+ none: false
158
+ requirements:
159
+ - - ! '>='
160
+ - !ruby/object:Gem::Version
161
+ version: '0'
162
+ requirements:
163
+ - none
164
+ rubyforge_project:
165
+ rubygems_version: 1.8.24
166
+ signing_key:
167
+ specification_version: 3
168
+ summary: A Spree extension to make your store zoned
169
+ test_files:
170
+ - spec/spec_helper.rb