Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mamhoff committed Oct 25, 2024
1 parent 25a41bf commit 593ec3c
Show file tree
Hide file tree
Showing 34 changed files with 575 additions and 0 deletions.
53 changes: 53 additions & 0 deletions friendly_promotions/.circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
version: 2.1

orbs:
# Required for feature specs.
browser-tools: circleci/browser-tools@1.1

# Always take the latest version of the orb, this allows us to
# run specs against Solidus supported versions only without the need
# to change this configuration every time a Solidus version is released
# or goes EOL.
solidusio_extensions: solidusio/extensions@volatile

jobs:
run-specs-with-sqlite:
executor: solidusio_extensions/sqlite
steps:
- browser-tools/install-chrome
- solidusio_extensions/run-tests
run-specs-with-postgres:
executor: solidusio_extensions/postgres
steps:
- browser-tools/install-chrome
- solidusio_extensions/run-tests
run-specs-with-mysql:
executor: solidusio_extensions/mysql
steps:
- browser-tools/install-chrome
- solidusio_extensions/run-tests
lint-code:
executor: solidusio_extensions/sqlite-memory
steps:
- solidusio_extensions/lint-code

workflows:
"Run specs on supported Solidus versions":
jobs:
- run-specs-with-sqlite
- run-specs-with-postgres
- run-specs-with-mysql
- lint-code

"Weekly run specs against master":
triggers:
- schedule:
cron: "0 0 * * 4" # every Thursday
filters:
branches:
only:
- master
jobs:
- run-specs-with-sqlite
- run-specs-with-postgres
- run-specs-with-mysql
5 changes: 5 additions & 0 deletions friendly_promotions/.gem_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
bump:
recurse: false
file: 'lib/solidus_friendly_promotions/version.rb'
message: Bump SolidusFriendlyPromotions to %{version}
tag: true
1 change: 1 addition & 0 deletions friendly_promotions/.github/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_extends: .github
2 changes: 2 additions & 0 deletions friendly_promotions/.github_changelog_generator
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
issues=false
exclude-labels=infrastructure
21 changes: 21 additions & 0 deletions friendly_promotions/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
*.gem
\#*
*~
.#*
.DS_Store
.idea
.project
.sass-cache
coverage
Gemfile.lock
Gemfile-local
tmp
nbproject
pkg
*.swp
spec/dummy
spec/examples.txt
/sandbox
.rvmrc
.ruby-version
.ruby-gemset
2 changes: 2 additions & 0 deletions friendly_promotions/.rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--color
--require spec_helper
5 changes: 5 additions & 0 deletions friendly_promotions/.rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require:
- solidus_dev_support/rubocop

AllCops:
NewCops: disable
1 change: 1 addition & 0 deletions friendly_promotions/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Changelog
43 changes: 43 additions & 0 deletions friendly_promotions/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# frozen_string_literal: true

source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

branch = ENV.fetch('SOLIDUS_BRANCH', 'master')
gem 'solidus', github: 'solidusio/solidus', branch: branch

# The solidus_frontend gem has been pulled out since v3.2
gem 'solidus_frontend', github: 'solidusio/solidus_frontend' if branch == 'master'
gem 'solidus_frontend' if branch >= 'v3.2' # rubocop:disable Bundler/DuplicatedGem

# Needed to help Bundler figure out how to resolve dependencies,
# otherwise it takes forever to resolve them.
# See https://github.com/bundler/bundler/issues/6677
gem 'rails', '>0.a'


# Provides basic authentication functionality for testing parts of your engine
gem 'solidus_auth_devise'

case ENV.fetch('DB', nil)
when 'mysql'
gem 'mysql2'
when 'postgresql'
gem 'pg'
else
gem 'sqlite3'
end

# While we still support Ruby < 3 we need to workaround a limitation in
# the 'async' gem that relies on the latest ruby, since RubyGems doesn't
# resolve gems based on the required ruby version.
gem 'async', '< 3' if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3')

gemspec

# Use a local Gemfile to include development dependencies that might not be
# relevant for the project or for other contributors, e.g. pry-byebug.
#
# We use `send` instead of calling `eval_gemfile` to work around an issue with
# how Dependabot parses projects: https://github.com/dependabot/dependabot-core/issues/1658.
send(:eval_gemfile, 'Gemfile-local') if File.exist? 'Gemfile-local'
26 changes: 26 additions & 0 deletions friendly_promotions/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Copyright (c) 2023 Martin Meyerhoff
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 Solidus 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.
73 changes: 73 additions & 0 deletions friendly_promotions/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Solidus Friendly Promotions

[![CircleCI](https://circleci.com/gh/solidusio-contrib/solidus_friendly_promotions.svg?style=shield)](https://circleci.com/gh/solidusio-contrib/solidus_friendly_promotions)
[![codecov](https://codecov.io/gh/solidusio-contrib/solidus_friendly_promotions/branch/master/graph/badge.svg)](https://codecov.io/gh/solidusio-contrib/solidus_friendly_promotions)

<!-- Explain what your extension does. -->

## Installation

Add solidus_friendly_promotions to your Gemfile:

```ruby
gem 'solidus_friendly_promotions'
```

Bundle your dependencies and run the installation generator:

```shell
bin/rails generate solidus_friendly_promotions:install
```

## Usage

<!-- Explain how to use your extension once it's been installed. -->

## Development

### Testing the extension

First bundle your dependencies, then run `bin/rake`. `bin/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
`bin/rake extension:test_app`.

```shell
bin/rake
```

To run [Rubocop](https://github.com/bbatsov/rubocop) static code analysis run

```shell
bundle exec rubocop
```

When testing your application's integration with this extension you may use its factories.
You can load Solidus core factories along with this extension's factories using this statement:

```ruby
SolidusDevSupport::TestingSupport::Factories.load_for(SolidusFriendlyPromotions::Engine)
```

### Running the sandbox

To run this extension in a sandboxed Solidus application, you can run `bin/sandbox`. The path for
the sandbox app is `./sandbox` and `bin/rails` will forward any Rails commands to
`sandbox/bin/rails`.

Here's an example:

```
$ bin/rails server
=> Booting Puma
=> Rails 6.0.2.1 application starting in development
* Listening on tcp://127.0.0.1:3000
Use Ctrl-C to stop
```

### Releasing new versions

Please refer to the [dedicated page](https://github.com/solidusio/solidus/wiki/How-to-release-extensions) in the Solidus wiki.

## License

Copyright (c) 2023 Martin Meyerhoff, released under the New BSD License.
6 changes: 6 additions & 0 deletions friendly_promotions/Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# frozen_string_literal: true

require 'solidus_dev_support/rake_tasks'
SolidusDevSupport::RakeTasks.install

task default: 'extension:specs'
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'
*/
17 changes: 17 additions & 0 deletions friendly_promotions/bin/console
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env ruby

# frozen_string_literal: true

require "bundler/setup"
require "solidus_friendly_promotions"

# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.
$LOAD_PATH.unshift(*Dir["#{__dir__}/../app/*"])

# (If you use this, don't forget to add pry to your Gemfile!)
# require "pry"
# Pry.start

require "irb"
IRB.start(__FILE__)
7 changes: 7 additions & 0 deletions friendly_promotions/bin/rails
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env ruby

if %w[g generate].include? ARGV.first
exec "#{__dir__}/rails-engine", *ARGV
else
exec "#{__dir__}/rails-sandbox", *ARGV
end
13 changes: 13 additions & 0 deletions friendly_promotions/bin/rails-engine
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails gems
# installed from the root of your application.

ENGINE_ROOT = File.expand_path('..', __dir__)
ENGINE_PATH = File.expand_path('../lib/solidus_friendly_promotions/engine', __dir__)

# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])

require 'rails/all'
require 'rails/engine/commands'
16 changes: 16 additions & 0 deletions friendly_promotions/bin/rails-sandbox
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env ruby

app_root = 'sandbox'

unless File.exist? "#{app_root}/bin/rails"
warn 'Creating the sandbox app...'
Dir.chdir "#{__dir__}/.." do
system "#{__dir__}/sandbox" or begin
warn 'Automatic creation of the sandbox app failed'
exit 1
end
end
end

Dir.chdir app_root
exec 'bin/rails', *ARGV
7 changes: 7 additions & 0 deletions friendly_promotions/bin/rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require "rubygems"
require "bundler/setup"

load Gem.bin_path("rake", "rake")
Loading

0 comments on commit 593ec3c

Please sign in to comment.