diff options
author | Nicholas Van Doorn <nick@super.gd> | 2021-07-26 15:52:23 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-26 15:52:23 -0700 |
commit | 31a3e63e98448544285f129c13bd000187b02576 (patch) | |
tree | 5b2e6730ec161b8ce362e81e6a9c6c43030d9e2f | |
parent | b7af04133f796b14bef0781e918d7eb7a46f6c0e (diff) | |
parent | b96799b59bae6e6a1b974604a7830b29bf44b8e1 (diff) |
Merge pull request #81 from nvandoorn/add-install-generator
Add install generator
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | README.md | 12 | ||||
-rwxr-xr-x | bin/sandbox | 1 | ||||
-rw-r--r-- | lib/generators/super_good/solidus_taxjar/install_generator.rb | 18 |
4 files changed, 24 insertions, 8 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index db68775..724fc2e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ - [#37](https://github.com/SuperGoodSoft/solidus_taxjar/pull/37) Added a basic Taxjar settings admin interface which displays placeholder text. - [#64](https://github.com/SuperGoodSoft/solidus_taxjar/pull/64) Provide Spree::Address.address2 to TaxJar address validation if it is present. - [#80](https://github.com/SuperGoodSoft/solidus_taxjar/pull/80) Support order_recalculated event in < 2.11 +- [#81](https://github.com/SuperGoodSoft/solidus_taxjar/pull/81) Add install generator ## v0.18.1 @@ -16,15 +16,11 @@ This is not a fork of [spree_taxjar](https://github.com/vinsol-spree-contrib/spr $ bundle -2. Next, configure Solidus to use this gem: +2. Next, configure Solidus to use this gem by running the install generator: - ```ruby - # Put this in config/initializers/solidus.rb - - Spree.config do |config| - config.tax_calculator_class = SuperGood::SolidusTaxjar::TaxCalculator - end - ``` + ```sh + bundle exec rails generate super_good:solidus_taxjar:install + ``` 3. Also, configure your error handling: diff --git a/bin/sandbox b/bin/sandbox index 90b8b81..53731cf 100755 --- a/bin/sandbox +++ b/bin/sandbox @@ -75,6 +75,7 @@ unbundled bundle exec rails generate spree:install \ $@ unbundled bundle exec rails generate solidus:auth:install +unbundled bundle exec rails generate super_good:solidus_taxjar:install echo echo "🚀 Sandbox app successfully created for $extension_name!" diff --git a/lib/generators/super_good/solidus_taxjar/install_generator.rb b/lib/generators/super_good/solidus_taxjar/install_generator.rb new file mode 100644 index 0000000..73974ba --- /dev/null +++ b/lib/generators/super_good/solidus_taxjar/install_generator.rb @@ -0,0 +1,18 @@ +module SuperGood + module SolidusTaxjar + module Generators + class InstallGenerator < Rails::Generators::Base + def create_initializer_file + solidus_initializer_path = "config/initializers/solidus.rb" + + create_file(solidus_initializer_path) unless File.exists?(solidus_initializer_path) + append_to_file(solidus_initializer_path, <<~INIT) + Spree.config do |config| + config.tax_calculator_class = SuperGood::SolidusTaxjar::TaxCalculator + end + INIT + end + end + end + end +end |