Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade the extension using solidus_dev_support #168

Merged
merged 1 commit into from
Jan 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gem_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
bump:
recurse: false
file: 'lib/solidus_i18n/version.rb'
message: Bump SolidusI18n to %{version}
tag: true
17 changes: 17 additions & 0 deletions .github/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 60
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 7
# Issues with these labels will never be considered stale
exemptLabels:
- pinned
- security
# Label to use when marking an issue as stale
staleLabel: wontfix
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: false
11 changes: 4 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
*.gem
\#*
*~
.#*
.DS_Store
.idea
.localeapp/locales
.project
.sass-cache
coverage
config/locales/en.yml
Gemfile.lock
tmp
nbproject
pkg
*.sw?
*.swp
spec/dummy
.rvmrc
.sass-cache
public/spree
.ruby-gemset
spec/examples.txt
2 changes: 2 additions & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--color
--require spec_helper
15 changes: 3 additions & 12 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
---
inherit_from: .hound.yml
require:
- solidus_dev_support/rubocop

Metrics/BlockLength:
Exclude:
- spec/**/*
- lib/tasks/**/*

AllCops:
Exclude:
- 'spec/dummy/**/*'
- 'bin/**/*'
- 'vendor/**/*'
inherit_from: .rubocop_todo.yml
18 changes: 18 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2020-01-24 11:23:54 +0100 using RuboCop version 0.76.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 1
RSpec/DescribeClass:
Exclude:
- 'spec/solidus_i18n_spec.rb'

# Offense count: 2
# Configuration parameters: IgnoreSharedExamples.
RSpec/NamedSubject:
Exclude:
- 'spec/solidus_i18n_spec.rb'
20 changes: 16 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,31 @@
# 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

if ENV['DB'] == 'mysql'
gem 'mysql2', '~> 0.4.10'
# 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'

case ENV['DB']
when 'mysql'
gem 'mysql2'
when 'postgresql'
gem 'pg'
else
gem 'pg', '~> 0.21'
gem 'sqlite3'
end

group :development, :test do
gem 'i18n-tasks', '~> 0.9' if branch == 'master'
gem 'pry-rails'
end

gemspec

# Use a local Gemfile to include development dependencies that might not be
# relevant for the project or for other contributors, e.g.: `gem 'pry-debug'`.
eval_gemfile 'Gemfile-local' if File.exist? 'Gemfile-local'
4 changes: 2 additions & 2 deletions LICENSE.md → LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2011-2015 Spree Commerce Inc., and other contributors.
Copyright (c) 2011-2015 Spree Commerce Inc. and other contributors
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
Expand All @@ -9,7 +9,7 @@ are permitted provided that the following conditions are met:
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name Spree nor the names of its contributors may be used to
* 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.

Expand Down
26 changes: 5 additions & 21 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,30 +1,12 @@
# frozen_string_literal: true

require 'bundler'
Bundler::GemHelper.install_tasks

require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new

task :default do
if Dir['spec/dummy'].empty?
Rake::Task[:test_app].invoke
Dir.chdir('../../')
end
Rake::Task[:spec].invoke
end

require 'spree/testing_support/common_rake'
desc 'Generates a dummy app for testing'
task :test_app do
ENV['LIB_NAME'] = 'solidus_i18n'
Rake::Task['common:test_app'].invoke
end
require 'solidus_dev_support/rake_tasks'
SolidusDevSupport::RakeTasks.install

require 'solidus_i18n'
namespace :solidus_i18n do
aldesantis marked this conversation as resolved.
Show resolved Hide resolved
desc 'Update by retrieving the latest Solidus locale files'
task :update_default do
task update_default: :environment do
require 'open-uri'
puts 'Fetching latest Solidus locale file'
location = 'https://raw.github.com/solidusio/solidus/master/core/config/locales/en.yml'
Expand All @@ -36,3 +18,5 @@ namespace :solidus_i18n do
File.join File.dirname(__FILE__), 'config/locales'
end
end

task default: 'extension:specs'
17 changes: 17 additions & 0 deletions 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_i18n"

# 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__)
16 changes: 12 additions & 4 deletions bin/rails
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
#!/usr/bin/env ruby

ENGINE_ROOT = File.expand_path('../..', __FILE__)
ENGINE_PATH = File.expand_path('../../lib/solidus_i18n/engine', __FILE__)
# frozen_string_literal: true

require 'rails/all'
require 'rails/engine/commands'
app_root = 'spec/dummy'

unless File.exist? "#{app_root}/bin/rails"
system "bin/rake", app_root or begin # rubocop:disable Style/AndOr
warn "Automatic creation of the dummy app failed"
exit 1
end
end

Dir.chdir app_root
exec 'bin/rails', *ARGV
8 changes: 8 additions & 0 deletions bin/setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
set -vx

gem install bundler --conservative
bundle update
bundle exec rake clobber
24 changes: 24 additions & 0 deletions lib/generators/solidus_i18n/install/install_generator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# frozen_string_literal: true

module SolidusI18n
module Generators
class InstallGenerator < Rails::Generators::Base
class_option :auto_run_migrations, type: :boolean, default: false

def add_migrations
run 'bundle exec rake railties:install:migrations FROM=solidus_i18n'
end

def run_migrations
run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(
ask('Would you like to run the migrations now? [Y/n]')
)
if run_migrations
run 'bundle exec rake db:migrate'
else
puts 'Skipping rake db:migrate, don\'t forget to run it!' # rubocop:disable Rails/Output
end
end
end
end
end
4 changes: 3 additions & 1 deletion lib/solidus_i18n.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require 'solidus_core'
require 'solidus_i18n/engine'
require 'solidus_support'

require 'solidus_i18n/version'
require 'solidus_i18n/engine'
11 changes: 11 additions & 0 deletions lib/solidus_i18n/engine.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
# frozen_string_literal: true

require 'spree/core'

module SolidusI18n
class Engine < Rails::Engine
include SolidusSupport::EngineExtensions::Decorators

isolate_namespace ::Spree

engine_name 'solidus_i18n'

# use rspec for tests
config.generators do |g|
g.test_framework :rspec
end
end
end
4 changes: 4 additions & 0 deletions lib/solidus_i18n/factories.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# frozen_string_literal: true

FactoryBot.define do
end
43 changes: 24 additions & 19 deletions solidus_i18n.gemspec
Original file line number Diff line number Diff line change
@@ -1,31 +1,36 @@
# frozen_string_literal: true

lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
$:.push File.expand_path('lib', __dir__)
require 'solidus_i18n/version'

Gem::Specification.new do |spec|
spec.name = 'solidus_i18n'
spec.version = SolidusI18n.version
spec.authors = ['Thomas von Deyen']
spec.email = ['tvd@magiclabs.de']
Gem::Specification.new do |s|
s.name = 'solidus_i18n'
s.version = SolidusI18n.version
s.summary = 'Provides locale information for use in Solidus.'
s.description = 'A collection of translations for Solidus.'

spec.summary = 'Provides locale information for use in Solidus.'
spec.description = 'A collection of translations for Solidus.'
spec.homepage = 'https://solidus.io'
spec.license = 'BSD-3-Clause'
s.required_ruby_version = '~> 2.4'

spec.files = Dir.chdir(File.expand_path(__dir__)) do
s.author = 'Thomas von Deyen'
s.email = 'tvd@magiclabs.de'
s.homepage = 'https://github.com/solidusio/solidus_i18n'
s.license = 'BSD-3-Clause'

s.files = Dir.chdir(File.expand_path(__dir__)) do
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
end
s.test_files = Dir['spec/**/*']
s.bindir = "exe"
s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
s.require_paths = ["lib"]

spec.require_paths = ['lib']
if s.respond_to?(:metadata)
s.metadata["homepage_uri"] = s.homepage if s.homepage
s.metadata["source_code_uri"] = s.homepage if s.homepage
end

spec.add_runtime_dependency 'solidus_core', ['>= 1.1', '< 3']
s.add_runtime_dependency 'solidus_core', ['>= 1.1', '< 3']
s.add_runtime_dependency 'solidus_support', '~> 0.4.0'

spec.add_development_dependency 'pry-rails', '~> 0.3.0'
spec.add_development_dependency 'rspec-rails', '~> 3.1'
spec.add_development_dependency 'rubocop', '~> 0.67.2'
spec.add_development_dependency 'simplecov', '~> 0.9'
spec.add_development_dependency 'sqlite3', '~> 1.3'
s.add_development_dependency 'solidus_dev_support'
end
27 changes: 14 additions & 13 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
# frozen_string_literal: true

require 'simplecov'
SimpleCov.start 'rails'

# Configure Rails Environment
ENV['RAILS_ENV'] ||= 'test'

begin
require File.expand_path('dummy/config/environment', __dir__)
rescue LoadError
puts 'Could not load dummy application. Please ensure you have run `bundle exec rake test_app`'
exit
end
# Run Coverage report
require 'solidus_dev_support/rspec/coverage'

require File.expand_path('dummy/config/environment.rb', __dir__)

require 'pry'
require 'rspec/rails'
# Requires factories and other useful helpers defined in spree_core.
require 'solidus_dev_support/rspec/feature_helper'

# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f }

# Requires factories defined in lib/solidus_i18n/factories.rb
require 'solidus_i18n/factories'

RSpec.configure do |config|
config.fail_fast = false
Expand All @@ -28,5 +31,3 @@
expectations.syntax = :expect
end
end

Dir[File.join(File.dirname(__FILE__), '/support/**/*.rb')].each { |file| require file }