solidus_catalog_mode 0.3.0 → 0.4.1

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
- SHA1:
3
- metadata.gz: ebc1282f14101896c9dbefc5e3bb5d76fbcb222e
4
- data.tar.gz: 3ea300e56887e731a2a55f5069a2076b35f79706
2
+ SHA256:
3
+ metadata.gz: 1546cc84cf16c74e7d04c4edd8b81ab84da475861c80dfa59376a53078275cad
4
+ data.tar.gz: c6c3fbe333209d09ff76a77525bf53f7b492ecf6f34fb51def852dcf4c2275b4
5
5
  SHA512:
6
- metadata.gz: deb888e524debd5c99f2470bf1822a682a74b2037282dc33dba58d3b28644884b45db034a8657919698f18b1dce59ea254e8424dc33e3227748519e19b7f1e7e
7
- data.tar.gz: e05047f10ef5005f00b6b0eb3b67b3cabfae7b0e259cfea67460bff3a4d8e7f007618fa8e5f634374318d4a6e99d9708ac4db2373e902ed1f8e5df1db3c41837
6
+ metadata.gz: d4ea5d6bd86b2e5306f55959b9dc2d824041e6335e6cfcee1ffb1857860c5d45f33f5b7bd8b69efe1cd6d5b4a61906971731374457f569d46d98ac8b5acd32ed
7
+ data.tar.gz: 0fef767678195cdd44ae6459ee87ef16f9fa5b19f5f0587a857568ef48905c0c8f2d09b02a021cead39fc5ec387b612bb4242a468205efdb6b570501a0bf5e4a
@@ -0,0 +1,41 @@
1
+ version: 2.1
2
+
3
+ orbs:
4
+ # Always take the latest version of the orb, this allows us to
5
+ # run specs against Solidus supported versions only without the need
6
+ # to change this configuration every time a Solidus version is released
7
+ # or goes EOL.
8
+ solidusio_extensions: solidusio/extensions@volatile
9
+
10
+ jobs:
11
+ run-specs-with-postgres:
12
+ executor: solidusio_extensions/postgres
13
+ steps:
14
+ - solidusio_extensions/run-tests
15
+ run-specs-with-mysql:
16
+ executor: solidusio_extensions/mysql
17
+ steps:
18
+ - solidusio_extensions/run-tests
19
+ lint-code:
20
+ executor: solidusio_extensions/sqlite-memory
21
+ steps:
22
+ - solidusio_extensions/lint-code
23
+
24
+ workflows:
25
+ "Run specs on supported Solidus versions":
26
+ jobs:
27
+ - run-specs-with-postgres
28
+ - run-specs-with-mysql
29
+ - lint-code
30
+
31
+ "Weekly run specs against master":
32
+ triggers:
33
+ - schedule:
34
+ cron: "0 0 * * 4" # every Thursday
35
+ filters:
36
+ branches:
37
+ only:
38
+ - master
39
+ jobs:
40
+ - run-specs-with-postgres
41
+ - run-specs-with-mysql
@@ -0,0 +1,5 @@
1
+ bump:
2
+ recurse: false
3
+ file: 'lib/solidus_catalog_mode/version.rb'
4
+ message: Bump SolidusCatalogMode to %{version}
5
+ tag: true
@@ -0,0 +1,17 @@
1
+ # Number of days of inactivity before an issue becomes stale
2
+ daysUntilStale: 60
3
+ # Number of days of inactivity before a stale issue is closed
4
+ daysUntilClose: false
5
+ # Issues with these labels will never be considered stale
6
+ exemptLabels:
7
+ - pinned
8
+ - security
9
+ # Label to use when marking an issue as stale
10
+ staleLabel: stale
11
+ # Comment to post when marking an issue as stale. Set to `false` to disable
12
+ markComment: >
13
+ This issue has been automatically marked as stale because it has not had
14
+ recent activity. It might be closed if no further activity occurs. Thank you
15
+ for your contributions.
16
+ # Comment to post when closing a stale issue. Set to `false` to disable
17
+ closeComment: false
@@ -0,0 +1,2 @@
1
+ issues=false
2
+ exclude-labels=infrastructure
@@ -0,0 +1,20 @@
1
+ *.gem
2
+ \#*
3
+ *~
4
+ .#*
5
+ .DS_Store
6
+ .idea
7
+ .project
8
+ .sass-cache
9
+ coverage
10
+ Gemfile.lock
11
+ tmp
12
+ nbproject
13
+ pkg
14
+ *.swp
15
+ spec/dummy
16
+ spec/examples.txt
17
+ /sandbox
18
+ .rvmrc
19
+ .ruby-version
20
+ .ruby-gemset
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
@@ -0,0 +1,5 @@
1
+ require:
2
+ - solidus_dev_support/rubocop
3
+
4
+ AllCops:
5
+ NewCops: enable
@@ -0,0 +1,8 @@
1
+ sudo: false
2
+ cache: bundler
3
+ language: ruby
4
+ bundler_args: --quiet
5
+ script:
6
+ - bundle exec rake
7
+ rvm:
8
+ - 2.1.5
@@ -0,0 +1,25 @@
1
+ # Changelog
2
+
3
+ ## [v0.4.1](https://github.com/afdev82/solidus_catalog_mode/tree/v0.4.1) (2020-11-20)
4
+
5
+ [Full Changelog](https://github.com/afdev82/solidus_catalog_mode/compare/v0.4.0...v0.4.1)
6
+
7
+ ## [v0.4.0](https://github.com/afdev82/solidus_catalog_mode/tree/v0.4.0) (2020-11-20)
8
+
9
+ [Full Changelog](https://github.com/afdev82/solidus_catalog_mode/compare/v0.3.0...v0.4.0)
10
+
11
+ ## [v0.3.0](https://github.com/afdev82/solidus_catalog_mode/tree/v0.3.0) (2017-11-16)
12
+
13
+ [Full Changelog](https://github.com/afdev82/solidus_catalog_mode/compare/v0.2.0...v0.3.0)
14
+
15
+ ## [v0.2.0](https://github.com/afdev82/solidus_catalog_mode/tree/v0.2.0) (2017-11-06)
16
+
17
+ [Full Changelog](https://github.com/afdev82/solidus_catalog_mode/compare/8baefaccffbd9de56324e705a3a3b2580482f092...v0.2.0)
18
+
19
+ **Closed issues:**
20
+
21
+ - Protect routes and controllers [\#1](https://github.com/afdev82/solidus_catalog_mode/issues/1)
22
+
23
+
24
+
25
+ \* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
data/Gemfile ADDED
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
5
+
6
+ branch = ENV.fetch('SOLIDUS_BRANCH', 'master')
7
+ gem 'solidus', github: 'solidusio/solidus', branch: branch
8
+
9
+ # Needed to help Bundler figure out how to resolve dependencies,
10
+ # otherwise it takes forever to resolve them.
11
+ # See https://github.com/bundler/bundler/issues/6677
12
+ gem 'rails', '>0.a'
13
+
14
+ # Provides basic authentication functionality for testing parts of your engine
15
+ gem 'solidus_auth_devise'
16
+
17
+ case ENV['DB']
18
+ when 'mysql'
19
+ gem 'mysql2'
20
+ when 'postgresql'
21
+ gem 'pg'
22
+ else
23
+ gem 'sqlite3'
24
+ end
25
+
26
+ gemspec
27
+
28
+ # Use a local Gemfile to include development dependencies that might not be
29
+ # relevant for the project or for other contributors, e.g. pry-byebug.
30
+ #
31
+ # We use `send` instead of calling `eval_gemfile` to work around an issue with
32
+ # how Dependabot parses projects: https://github.com/dependabot/dependabot-core/issues/1658.
33
+ send(:eval_gemfile, 'Gemfile-local') if File.exist? 'Gemfile-local'
data/LICENSE CHANGED
@@ -9,7 +9,7 @@ are permitted provided that the following conditions are met:
9
9
  * Redistributions in binary form must reproduce the above copyright notice,
10
10
  this list of conditions and the following disclaimer in the documentation
11
11
  and/or other materials provided with the distribution.
12
- * Neither the name Spree nor the names of its contributors may be used to
12
+ * Neither the name Solidus nor the names of its contributors may be used to
13
13
  endorse or promote products derived from this software without specific
14
14
  prior written permission.
15
15
 
data/README.md CHANGED
@@ -1,12 +1,14 @@
1
- SolidusCatalogMode
2
- ==================
1
+ # Solidus Catalog Mode
3
2
 
4
- This extension allow the user to set products not for online sale.
5
- In this way we could use Solidus to show only the catalog of our products,
6
- without the online store functionality.
3
+ [![CircleCI](https://circleci.com/gh/afdev82/solidus_catalog_mode.svg?style=shield)](https://circleci.com/gh/afdev82/solidus_catalog_mode)
4
+ [![codecov](https://codecov.io/gh/afdev82/solidus_catalog_mode/branch/master/graph/badge.svg)](https://codecov.io/gh/afdev82/solidus_catalog_mode)
7
5
 
8
- Installation
9
- ------------
6
+ This gem adds a boolean field to the products and to the stores.
7
+ In this way you could set a single product or the complete store to be in "catalog mode".
8
+ Then in your store frontend you can use this information to disable the link to the cart,
9
+ the price and the cart form in the product page.
10
+
11
+ ## Installation
10
12
 
11
13
  Add solidus_catalog_mode to your Gemfile:
12
14
 
@@ -17,37 +19,82 @@ gem 'solidus_catalog_mode'
17
19
  Bundle your dependencies and run the installation generator:
18
20
 
19
21
  ```shell
20
- bundle
21
- bundle exec rails g solidus_catalog_mode:install
22
+ bin/rails generate solidus_catalog_mode:install
22
23
  ```
23
24
 
24
- Usage
25
- -------
25
+ ## Usage
26
26
 
27
- This gem adds a boolean field to the products and to the stores.
28
- In this way you could set a single product or the complete store to be in "catalog mode".
29
- Then in your store frontend you can use this information to disable the link to the cart,
30
- the price and the cart form in the product page.
27
+ Set the flag in the product details page in the admin to enable catalog mode for the single product.
28
+ To enable the catalog mode for the entire store, just set the same flag in the store edit page.
29
+
30
+ ## Dependencies
31
31
 
32
- Dependencies
33
- -------
34
32
  If you want to be able to set the flag for the stores in the backend, it requires the [solidus_multi_domain](https://github.com/solidusio/solidus_multi_domain) gem.
35
33
 
36
- Testing
37
- -------
34
+ ## Development
35
+
36
+ ### Testing the extension
37
+
38
+ First bundle your dependencies, then run `bin/rake`. `bin/rake` will default to building the dummy
39
+ app if it does not exist, then it will run specs. The dummy app can be regenerated by using
40
+ `bin/rake extension:test_app`.
38
41
 
39
- 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, and [Rubocop](https://github.com/bbatsov/rubocop) static code analysis. The dummy app can be regenerated by using `rake test_app`.
42
+ ```shell
43
+ bin/rake
44
+ ```
45
+
46
+ To run [Rubocop](https://github.com/bbatsov/rubocop) static code analysis run
40
47
 
41
48
  ```shell
42
- bundle
43
- bundle exec rake
49
+ bundle exec rubocop
44
50
  ```
45
51
 
46
- When testing your applications integration with this extension you may use it's factories.
52
+ When testing your application's integration with this extension you may use its factories.
47
53
  Simply add this require statement to your spec_helper:
48
54
 
49
55
  ```ruby
50
56
  require 'solidus_catalog_mode/factories'
51
57
  ```
52
58
 
53
- Copyright (c) 2017 Antonio Facciolo, released under the New BSD License
59
+ ### Running the sandbox
60
+
61
+ To run this extension in a sandboxed Solidus application, you can run `bin/sandbox`. The path for
62
+ the sandbox app is `./sandbox` and `bin/rails` will forward any Rails commands to
63
+ `sandbox/bin/rails`.
64
+
65
+ Here's an example:
66
+
67
+ ```
68
+ $ bin/rails server
69
+ => Booting Puma
70
+ => Rails 6.0.2.1 application starting in development
71
+ * Listening on tcp://127.0.0.1:3000
72
+ Use Ctrl-C to stop
73
+ ```
74
+
75
+ ### Updating the changelog
76
+
77
+ Before and after releases the changelog should be updated to reflect the up-to-date status of
78
+ the project:
79
+
80
+ ```shell
81
+ bin/rake changelog
82
+ git add CHANGELOG.md
83
+ git commit -m "Update the changelog"
84
+ ```
85
+
86
+ ### Releasing new versions
87
+
88
+ Your new extension version can be released using `gem-release` like this:
89
+
90
+ ```shell
91
+ bundle exec gem bump -v 1.6.0
92
+ bin/rake changelog
93
+ git commit -a --amend
94
+ git push
95
+ bundle exec gem release
96
+ ```
97
+
98
+ ## License
99
+
100
+ Copyright (c) 2017 Antonio Facciolo, released under the New BSD License.
data/Rakefile CHANGED
@@ -1,30 +1,6 @@
1
- require 'bundler'
1
+ # frozen_string_literal: true
2
2
 
3
- Bundler::GemHelper.install_tasks
3
+ require 'solidus_dev_support/rake_tasks'
4
+ SolidusDevSupport::RakeTasks.install
4
5
 
5
- begin
6
- require 'spree/testing_support/extension_rake'
7
- require 'rubocop/rake_task'
8
- require 'rspec/core/rake_task'
9
-
10
- RSpec::Core::RakeTask.new(:spec)
11
-
12
- RuboCop::RakeTask.new
13
-
14
- task default: %i(first_run rubocop spec)
15
- rescue LoadError
16
- # no rspec available
17
- end
18
-
19
- task :first_run do
20
- if Dir['spec/dummy'].empty?
21
- Rake::Task[:test_app].invoke
22
- Dir.chdir('../../')
23
- end
24
- end
25
-
26
- desc 'Generates a dummy app for testing'
27
- task :test_app do
28
- ENV['LIB_NAME'] = 'solidus_catalog_mode'
29
- Rake::Task['extension:test_app'].invoke
30
- end
6
+ task default: 'extension:specs'
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spree
4
+ module LineItemDecorator
5
+ def self.prepended(base)
6
+ base.class_eval do
7
+ delegate :catalog_mode, to: :product
8
+ validates :catalog_mode, inclusion: { in: [false], message: :should_be_false }
9
+ end
10
+ end
11
+
12
+ ::Spree::LineItem.prepend self
13
+ end
14
+ end
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Spree
2
4
  module OrderDecorator
3
5
  def checkout_allowed?
4
6
  super && !store.catalog_mode? && line_items.none? { |l| l.variant.product.catalog_mode? }
5
7
  end
8
+
9
+ ::Spree::Order.prepend self
6
10
  end
7
11
  end
8
-
9
- Spree::Order.prepend Spree::OrderDecorator
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Deface::Override.new(
2
4
  virtual_path: "spree/admin/products/_form",
3
5
  name: "catalog_mode_admin_product_form",
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Deface::Override.new(
2
4
  virtual_path: "spree/admin/stores/_form",
3
5
  name: "catalog_mode_admin_store_form",
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # frozen_string_literal: true
4
+
5
+ require "bundler/setup"
6
+ require "solidus_catalog_mode"
7
+
8
+ # You can add fixtures and/or initialization code here to make experimenting
9
+ # with your gem easier. You can also use a different console, if you like.
10
+ $LOAD_PATH.unshift(*Dir["#{__dir__}/../app/*"])
11
+
12
+ # (If you use this, don't forget to add pry to your Gemfile!)
13
+ # require "pry"
14
+ # Pry.start
15
+
16
+ require "irb"
17
+ IRB.start(__FILE__)
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ if %w[g generate].include? ARGV.first
4
+ exec "#{__dir__}/rails-engine", *ARGV
5
+ else
6
+ exec "#{__dir__}/rails-sandbox", *ARGV
7
+ end
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails gems
3
+ # installed from the root of your application.
4
+
5
+ ENGINE_ROOT = File.expand_path('..', __dir__)
6
+ ENGINE_PATH = File.expand_path('../lib/solidus_catalog_mode/engine', __dir__)
7
+
8
+ # Set up gems listed in the Gemfile.
9
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
10
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
11
+
12
+ require 'rails/all'
13
+ require 'rails/engine/commands'
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ app_root = 'sandbox'
4
+
5
+ unless File.exist? "#{app_root}/bin/rails"
6
+ warn 'Creating the sandbox app...'
7
+ Dir.chdir "#{__dir__}/.." do
8
+ system "#{__dir__}/sandbox" or begin
9
+ warn 'Automatic creation of the sandbox app failed'
10
+ exit 1
11
+ end
12
+ end
13
+ end
14
+
15
+ Dir.chdir app_root
16
+ exec 'bin/rails', *ARGV
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "rubygems"
5
+ require "bundler/setup"
6
+
7
+ load Gem.bin_path("rake", "rake")
@@ -0,0 +1,86 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -e
4
+
5
+ case "$DB" in
6
+ postgres|postgresql)
7
+ RAILSDB="postgresql"
8
+ ;;
9
+ mysql)
10
+ RAILSDB="mysql"
11
+ ;;
12
+ sqlite|'')
13
+ RAILSDB="sqlite3"
14
+ ;;
15
+ *)
16
+ echo "Invalid DB specified: $DB"
17
+ exit 1
18
+ ;;
19
+ esac
20
+
21
+ if [ ! -z $SOLIDUS_BRANCH ]
22
+ then
23
+ BRANCH=$SOLIDUS_BRANCH
24
+ else
25
+ BRANCH="master"
26
+ fi
27
+
28
+ extension_name="solidus_catalog_mode"
29
+
30
+ # Stay away from the bundler env of the containing extension.
31
+ function unbundled {
32
+ ruby -rbundler -e'b = proc {system *ARGV}; Bundler.respond_to?(:with_unbundled_env) ? Bundler.with_unbundled_env(&b) : Bundler.with_clean_env(&b)' -- $@
33
+ }
34
+
35
+ rm -rf ./sandbox
36
+ unbundled bundle exec rails new sandbox --database="$RAILSDB" \
37
+ --skip-bundle \
38
+ --skip-git \
39
+ --skip-keeps \
40
+ --skip-rc \
41
+ --skip-spring \
42
+ --skip-test \
43
+ --skip-javascript
44
+
45
+ if [ ! -d "sandbox" ]; then
46
+ echo 'sandbox rails application failed'
47
+ exit 1
48
+ fi
49
+
50
+ cd ./sandbox
51
+ cat <<RUBY >> Gemfile
52
+ gem 'solidus', github: 'solidusio/solidus', branch: '$BRANCH'
53
+ gem 'solidus_auth_devise', '>= 2.1.0'
54
+ gem 'rails-i18n'
55
+ gem 'solidus_i18n'
56
+
57
+ gem '$extension_name', path: '..'
58
+
59
+ group :test, :development do
60
+ platforms :mri do
61
+ gem 'pry-byebug'
62
+ end
63
+ end
64
+ RUBY
65
+
66
+ unbundled bundle install --gemfile Gemfile
67
+
68
+ unbundled bundle exec rake db:drop db:create
69
+
70
+ unbundled bundle exec rails generate spree:install \
71
+ --auto-accept \
72
+ --user_class=Spree::User \
73
+ --enforce_available_locales=true \
74
+ --with-authentication=false \
75
+ --payment-method=none \
76
+ $@
77
+
78
+ unbundled bundle exec rails generate solidus:auth:install
79
+ unbundled bundle exec rails generate ${extension_name}:install
80
+
81
+ echo
82
+ echo "🚀 Sandbox app successfully created for $extension_name!"
83
+ echo "🚀 Using $RAILSDB and Solidus $BRANCH"
84
+ echo "🚀 Use 'export DB=[postgres|mysql|sqlite]' to control the DB adapter"
85
+ echo "🚀 Use 'export SOLIDUS_BRANCH=<BRANCH-NAME>' to control the Solidus version"
86
+ echo "🚀 This app is intended for test purposes."
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ gem install bundler --conservative
7
+ bundle update
8
+ bin/rake clobber
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Spree::Core::Engine.routes.draw do
2
4
  # Add your extension routes here
3
5
  end
@@ -1,18 +1,37 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SolidusCatalogMode
2
4
  module Generators
3
5
  class InstallGenerator < Rails::Generators::Base
4
6
  class_option :auto_run_migrations, type: :boolean, default: false
7
+ source_root File.expand_path('templates', __dir__)
8
+
9
+ def copy_initializer
10
+ template 'initializer.rb', 'config/initializers/solidus_catalog_mode.rb'
11
+ end
12
+
13
+ def add_javascripts
14
+ append_file 'vendor/assets/javascripts/spree/frontend/all.js',
15
+ "//= require spree/frontend/solidus_catalog_mode\n"
16
+ append_file 'vendor/assets/javascripts/spree/backend/all.js',
17
+ "//= require spree/backend/solidus_catalog_mode\n"
18
+ end
19
+
20
+ def add_stylesheets
21
+ inject_into_file 'vendor/assets/stylesheets/spree/frontend/all.css', " *= require spree/frontend/solidus_catalog_mode\n", before: %r{\*/}, verbose: true # rubocop:disable Layout/LineLength
22
+ inject_into_file 'vendor/assets/stylesheets/spree/backend/all.css', " *= require spree/backend/solidus_catalog_mode\n", before: %r{\*/}, verbose: true # rubocop:disable Layout/LineLength
23
+ end
5
24
 
6
25
  def add_migrations
7
- run 'bundle exec rake railties:install:migrations FROM=solidus_catalog_mode'
26
+ run 'bin/rails railties:install:migrations FROM=solidus_catalog_mode'
8
27
  end
9
28
 
10
29
  def run_migrations
11
- run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask('Would you like to run the migrations now? [Y/n]'))
30
+ run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask('Would you like to run the migrations now? [Y/n]')) # rubocop:disable Layout/LineLength
12
31
  if run_migrations
13
- run 'bundle exec rake db:migrate'
32
+ run 'bin/rails db:migrate'
14
33
  else
15
- puts 'Skipping rake db:migrate, don\'t forget to run it!'
34
+ puts 'Skipping bin/rails db:migrate, don\'t forget to run it!' # rubocop:disable Rails/Output
16
35
  end
17
36
  end
18
37
  end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ SolidusCatalogMode.configure do |config|
4
+ # TODO: Remember to change this with the actual preferences you have implemented!
5
+ # config.sample_preference = 'sample_value'
6
+ end
@@ -1,2 +1,20 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'solidus_core'
4
+ require 'solidus_support'
5
+
6
+ require 'solidus_catalog_mode/configuration'
7
+ require 'solidus_catalog_mode/version'
2
8
  require 'solidus_catalog_mode/engine'
9
+
10
+ module SolidusCatalogMode
11
+ class << self
12
+ def configuration
13
+ @configuration ||= Configuration.new
14
+ end
15
+
16
+ def configure
17
+ yield configuration
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SolidusCatalogMode
4
+ class Configuration
5
+ # TODO: Remember to change this with your extension's actual preferences!
6
+ # attr_accessor :sample_preference
7
+ end
8
+ end
@@ -1,20 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spree/core'
4
+ require 'solidus_catalog_mode'
5
+
1
6
  module SolidusCatalogMode
2
7
  class Engine < Rails::Engine
3
- require 'spree/core'
4
- isolate_namespace Spree
8
+ include SolidusSupport::EngineExtensions
9
+
10
+ isolate_namespace ::Spree
11
+
5
12
  engine_name 'solidus_catalog_mode'
6
13
 
7
14
  # use rspec for tests
8
15
  config.generators do |g|
9
16
  g.test_framework :rspec
10
17
  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
18
  end
20
19
  end
@@ -1,5 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  FactoryBot.define do
2
- # Define your Spree extensions Factories within this file to enable applications, and other extensions to use and override them.
4
+ # Define your Spree extensions Factories within this file to enable applications,
5
+ # and other extensions to use and override them.
3
6
  #
4
7
  # Example adding this to your spec_helper will load these Factories for use:
5
8
  # require 'solidus_catalog_mode/factories'
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ FactoryBot.define do
4
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SolidusCatalogMode
2
- VERSION = '0.3.0'
4
+ VERSION = '0.4.1'
3
5
  end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/solidus_catalog_mode/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'solidus_catalog_mode'
7
+ spec.version = SolidusCatalogMode::VERSION
8
+ spec.authors = ['Antonio Facciolo']
9
+ spec.email = 'afdev82@gmail.com'
10
+
11
+ spec.summary = 'Allow to set products to not for online sale'
12
+ spec.description = 'Allow to set products only to show, but not for online sale (catalog mode)'
13
+ spec.homepage = 'https://github.com/afdev82/solidus_catalog_mode'
14
+ spec.license = 'BSD-3-Clause'
15
+
16
+ spec.metadata['homepage_uri'] = spec.homepage
17
+ spec.metadata['source_code_uri'] = 'https://github.com/afdev82/solidus_catalog_mode'
18
+ spec.metadata['changelog_uri'] = 'https://github.com/afdev82/solidus_catalog_mode/releases'
19
+
20
+ spec.required_ruby_version = Gem::Requirement.new('~> 2.5')
21
+
22
+ # Specify which files should be added to the gem when it is released.
23
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
24
+ files = Dir.chdir(__dir__) { `git ls-files -z`.split("\x0") }
25
+
26
+ spec.files = files.grep_v(%r{^(test|spec|features)/})
27
+ spec.test_files = files.grep(%r{^(test|spec|features)/})
28
+ spec.bindir = "exe"
29
+ spec.executables = files.grep(%r{^exe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ["lib"]
31
+
32
+ spec.add_dependency 'solidus_core', ['>= 2.0.0', '< 3']
33
+ spec.add_dependency 'solidus_support', '~> 0.5'
34
+
35
+ spec.add_development_dependency 'solidus_dev_support', '~> 2.1'
36
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Configure Rails Environment
4
+ ENV['RAILS_ENV'] = 'test'
5
+
6
+ # Run Coverage report
7
+ require 'solidus_dev_support/rspec/coverage'
8
+
9
+ # Create the dummy app if it's still missing.
10
+ dummy_env = "#{__dir__}/dummy/config/environment.rb"
11
+ system 'bin/rake extension:test_app' unless File.exist? dummy_env
12
+ require dummy_env
13
+
14
+ # Requires factories and other useful helpers defined in spree_core.
15
+ require 'solidus_dev_support/rspec/feature_helper'
16
+
17
+ # Requires supporting ruby files with custom matchers and macros, etc,
18
+ # in spec/support/ and its subdirectories.
19
+ Dir["#{__dir__}/support/**/*.rb"].sort.each { |f| require f }
20
+
21
+ # Requires factories defined in lib/solidus_catalog_mode/testing_support/factories.rb
22
+ require 'solidus_catalog_mode/testing_support/factories'
23
+
24
+ RSpec.configure do |config|
25
+ config.infer_spec_type_from_file_location!
26
+ config.use_transactional_fixtures = false
27
+
28
+ if Spree.solidus_gem_version < Gem::Version.new('2.11')
29
+ config.extend Spree::TestingSupport::AuthorizationHelpers::Request, type: :system
30
+ end
31
+ end
metadata CHANGED
@@ -1,183 +1,63 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_catalog_mode
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Antonio Facciolo
8
8
  autorequire:
9
- bindir: bin
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2017-11-16 00:00:00.000000000 Z
11
+ date: 2020-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: solidus_core
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '2.3'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '2.3'
27
- - !ruby/object:Gem::Dependency
28
- name: capybara
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
17
+ - - ">="
39
18
  - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: poltergeist
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
19
+ version: 2.0.0
20
+ - - "<"
46
21
  - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: coffee-rails
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: sass-rails
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: database_cleaner
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: factory_bot
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
- - !ruby/object:Gem::Dependency
112
- name: rspec-rails
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - "~>"
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :development
22
+ version: '3'
23
+ type: :runtime
119
24
  prerelease: false
120
25
  version_requirements: !ruby/object:Gem::Requirement
121
26
  requirements:
122
- - - "~>"
27
+ - - ">="
123
28
  - !ruby/object:Gem::Version
124
- version: '0'
125
- - !ruby/object:Gem::Dependency
126
- name: rubocop
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - '='
29
+ version: 2.0.0
30
+ - - "<"
130
31
  - !ruby/object:Gem::Version
131
- version: 0.37.2
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - '='
137
- - !ruby/object:Gem::Version
138
- version: 0.37.2
32
+ version: '3'
139
33
  - !ruby/object:Gem::Dependency
140
- name: rubocop-rspec
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - '='
144
- - !ruby/object:Gem::Version
145
- version: 1.4.0
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - '='
151
- - !ruby/object:Gem::Version
152
- version: 1.4.0
153
- - !ruby/object:Gem::Dependency
154
- name: simplecov
34
+ name: solidus_support
155
35
  requirement: !ruby/object:Gem::Requirement
156
36
  requirements:
157
37
  - - "~>"
158
38
  - !ruby/object:Gem::Version
159
- version: '0'
160
- type: :development
39
+ version: '0.5'
40
+ type: :runtime
161
41
  prerelease: false
162
42
  version_requirements: !ruby/object:Gem::Requirement
163
43
  requirements:
164
44
  - - "~>"
165
45
  - !ruby/object:Gem::Version
166
- version: '0'
46
+ version: '0.5'
167
47
  - !ruby/object:Gem::Dependency
168
- name: sqlite3
48
+ name: solidus_dev_support
169
49
  requirement: !ruby/object:Gem::Requirement
170
50
  requirements:
171
51
  - - "~>"
172
52
  - !ruby/object:Gem::Version
173
- version: '0'
53
+ version: '2.1'
174
54
  type: :development
175
55
  prerelease: false
176
56
  version_requirements: !ruby/object:Gem::Requirement
177
57
  requirements:
178
58
  - - "~>"
179
59
  - !ruby/object:Gem::Version
180
- version: '0'
60
+ version: '2.1'
181
61
  description: Allow to set products only to show, but not for online sale (catalog
182
62
  mode)
183
63
  email: afdev82@gmail.com
@@ -185,6 +65,16 @@ executables: []
185
65
  extensions: []
186
66
  extra_rdoc_files: []
187
67
  files:
68
+ - ".circleci/config.yml"
69
+ - ".gem_release.yml"
70
+ - ".github/stale.yml"
71
+ - ".github_changelog_generator"
72
+ - ".gitignore"
73
+ - ".rspec"
74
+ - ".rubocop.yml"
75
+ - ".travis.yml"
76
+ - CHANGELOG.md
77
+ - Gemfile
188
78
  - LICENSE
189
79
  - README.md
190
80
  - Rakefile
@@ -192,13 +82,19 @@ files:
192
82
  - app/assets/javascripts/spree/frontend/solidus_catalog_mode.js
193
83
  - app/assets/stylesheets/spree/backend/solidus_catalog_mode.css
194
84
  - app/assets/stylesheets/spree/frontend/solidus_catalog_mode.css
195
- - app/models/solidus_catalog_mode/line_item_concerns.rb
196
- - app/models/spree/line_item_decorator.rb
197
- - app/models/spree/order_decorator.rb
85
+ - app/decorators/models/spree/line_item_decorator.rb
86
+ - app/decorators/models/spree/order_decorator.rb
198
87
  - app/overrides/decorate_admin_products_form.rb
199
88
  - app/overrides/decorate_admin_stores_form.rb
200
89
  - app/views/spree/admin/products/_catalog_mode.html.erb
201
90
  - app/views/spree/admin/stores/_catalog_mode.html.erb
91
+ - bin/console
92
+ - bin/rails
93
+ - bin/rails-engine
94
+ - bin/rails-sandbox
95
+ - bin/rake
96
+ - bin/sandbox
97
+ - bin/setup
202
98
  - config/locales/de.yml
203
99
  - config/locales/en.yml
204
100
  - config/locales/it.yml
@@ -206,32 +102,40 @@ files:
206
102
  - db/migrate/20171102143731_add_catalog_mode_to_spree_products.rb
207
103
  - db/migrate/20171103083640_add_catalog_mode_to_spree_stores.rb
208
104
  - lib/generators/solidus_catalog_mode/install/install_generator.rb
105
+ - lib/generators/solidus_catalog_mode/install/templates/initializer.rb
209
106
  - lib/solidus_catalog_mode.rb
107
+ - lib/solidus_catalog_mode/configuration.rb
210
108
  - lib/solidus_catalog_mode/engine.rb
211
109
  - lib/solidus_catalog_mode/factories.rb
110
+ - lib/solidus_catalog_mode/testing_support/factories.rb
212
111
  - lib/solidus_catalog_mode/version.rb
112
+ - solidus_catalog_mode.gemspec
113
+ - spec/spec_helper.rb
213
114
  homepage: https://github.com/afdev82/solidus_catalog_mode
214
115
  licenses:
215
116
  - BSD-3-Clause
216
- metadata: {}
117
+ metadata:
118
+ homepage_uri: https://github.com/afdev82/solidus_catalog_mode
119
+ source_code_uri: https://github.com/afdev82/solidus_catalog_mode
120
+ changelog_uri: https://github.com/afdev82/solidus_catalog_mode/releases
217
121
  post_install_message:
218
122
  rdoc_options: []
219
123
  require_paths:
220
124
  - lib
221
125
  required_ruby_version: !ruby/object:Gem::Requirement
222
126
  requirements:
223
- - - ">="
127
+ - - "~>"
224
128
  - !ruby/object:Gem::Version
225
- version: '0'
129
+ version: '2.5'
226
130
  required_rubygems_version: !ruby/object:Gem::Requirement
227
131
  requirements:
228
132
  - - ">="
229
133
  - !ruby/object:Gem::Version
230
134
  version: '0'
231
135
  requirements: []
232
- rubyforge_project:
233
- rubygems_version: 2.6.8
136
+ rubygems_version: 3.1.2
234
137
  signing_key:
235
138
  specification_version: 4
236
139
  summary: Allow to set products to not for online sale
237
- test_files: []
140
+ test_files:
141
+ - spec/spec_helper.rb
@@ -1,9 +0,0 @@
1
- module SolidusCatalogMode::LineItemConcerns
2
- extend ActiveSupport::Concern
3
-
4
- included do
5
- delegate :catalog_mode, to: :product
6
-
7
- validates :catalog_mode, inclusion: { in: [false], message: :should_be_false }
8
- end
9
- end
@@ -1 +0,0 @@
1
- Spree::LineItem.include(SolidusCatalogMode::LineItemConcerns)