From 6e2e429f1a9ad86ddcb8b23954645346c6aad602 Mon Sep 17 00:00:00 2001 From: ArturT Date: Sat, 12 Aug 2017 20:10:24 +0200 Subject: [PATCH 1/2] Autoload knapsack_pro rake tasks with Rails Railties --- README.md | 10 +++++++--- lib/knapsack_pro.rb | 2 ++ lib/knapsack_pro/railtie.rb | 10 ++++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 lib/knapsack_pro/railtie.rb diff --git a/README.md b/README.md index 3685e68a..935074a5 100644 --- a/README.md +++ b/README.md @@ -159,12 +159,16 @@ end And then execute: - $ bundle install - +``` +$ bundle install +``` -Add this line at the bottom of `Rakefile` if your project has one: +If you are not using Rails then add this line at the bottom of `Rakefile`: ```ruby +# Add this only if you are not using Rails. +# If you use Rails then knapsack_pro rake tasks are already loaded +# so there is no need to explicitly load them. KnapsackPro.load_tasks if defined?(KnapsackPro) ``` diff --git a/lib/knapsack_pro.rb b/lib/knapsack_pro.rb index f4deea29..518d9b7f 100644 --- a/lib/knapsack_pro.rb +++ b/lib/knapsack_pro.rb @@ -61,6 +61,8 @@ require_relative 'knapsack_pro/crypto/decryptor' require_relative 'knapsack_pro/crypto/digestor' +require 'knapsack_pro/railtie' if defined?(Rails::Railtie) + module KnapsackPro class << self def root diff --git a/lib/knapsack_pro/railtie.rb b/lib/knapsack_pro/railtie.rb new file mode 100644 index 00000000..90ca4879 --- /dev/null +++ b/lib/knapsack_pro/railtie.rb @@ -0,0 +1,10 @@ +require 'rails' +require 'knapsack_pro' + +module KnapsackPro + class Railtie < Rails::Railtie + rake_tasks do + KnapsackPro.load_tasks + end + end +end From c5af14e301832a9e4b87aca0ab22fc45db0c755e Mon Sep 17 00:00:00 2001 From: ArturT Date: Sat, 12 Aug 2017 20:14:36 +0200 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2bce8d14..26a23b70 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ * TODO +### 0.46.0 + +* Autoload knapsack_pro rake tasks with Rails Railties + + https://github.com/KnapsackPro/knapsack_pro-ruby/pull/47 + +https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v0.45.0...v0.46.0 + ### 0.45.0 * Add before and after queue hooks