rails_console_toolkit 0.5.3 → 0.6.0

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
2
  SHA256:
3
- metadata.gz: 784464abe81f7f89070ab3da6ac2f0a928615d6a361cf097135679ad6c86bf69
4
- data.tar.gz: 656109e3bbac4bf2200ad8e156523f964897ca942a9b419523f694d83b7f3017
3
+ metadata.gz: 7923cd1b5ca7ce01c1a58372c4d568c348c88f0d351aa4d784eef148328c8700
4
+ data.tar.gz: ea1aaa9db79ced4baee7b73bb9e7652c059f8ca81a585758628bc2087f2e9afc
5
5
  SHA512:
6
- metadata.gz: e8052bbf7c75e2672a54a4dd112c867633cae7a7ba184d2969badfe0e5b511e351882c95cb21f08259920dbf8d73a4880b2bb6cd2c5bb41cd5a07949e555ff88
7
- data.tar.gz: ff605580ad23d9985bde9df0410c0d3fac8a4f705fca802482a18339b6bbe30a90fbc696bebf1c6a4930b1d394c4d2d6715d0f0c086a86cfbd0d5071c7d1dbdc
6
+ metadata.gz: 9f64a1c43c9571509e3280e8eee86bccf571046e8a426b6b464d8f4f5eedfd2a643e2d96702f3ccc52182f4c4278b9d39b596f55ce0b9999394c281502f4ef53
7
+ data.tar.gz: 8c1b5186da25dea915ce02f1f3be6e58c32c115d617bd86f934d193245cdf20027928826e74504cc70bc2a6862cc181448bd6fa3dbd0f9b881faa1bae6602fd3
File without changes
@@ -0,0 +1,47 @@
1
+ name: build
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ - "*/ci-check"
8
+ pull_request:
9
+ branches:
10
+ - master
11
+
12
+ jobs:
13
+ rake:
14
+ name: ${{ matrix.combo.name }}
15
+ strategy:
16
+ fail-fast: false
17
+ matrix:
18
+ combo:
19
+ - name: current-ruby
20
+ ruby: 3.0
21
+ - name: previous-ruby
22
+ ruby: 2.7
23
+ - name: older-ruby
24
+ ruby: 2.6
25
+
26
+ runs-on: 'ubuntu-latest'
27
+ steps:
28
+ - uses: actions/checkout@v2
29
+ - uses: ruby/setup-ruby@v1
30
+ with:
31
+ ruby-version: ${{ matrix.combo.ruby }}
32
+ bundler-cache: false
33
+ - run: bundle lock
34
+ - uses: actions/cache@v2
35
+ with:
36
+ path: ./vendor/bundle
37
+ key: ${{ runner.os }}-${{ matrix.combo.ruby }}-gems-${{ github.ref }}-${{ hashFiles('**/Gemfile.lock') }}
38
+ restore-keys: |
39
+ ${{ runner.os }}-${{ matrix.combo.ruby }}-gems-${{ github.ref }}
40
+ ${{ runner.os }}-${{ matrix.combo.ruby }}-gems-master
41
+ ${{ runner.os }}-${{ matrix.combo.ruby }}-gems-
42
+ - name: bundle install
43
+ run: |
44
+ bundle config path $PWD/vendor/bundle
45
+ bundle install --jobs 4 --retry 3
46
+ bundle clean
47
+ - run: bundle exec rake
data/README.md CHANGED
@@ -4,7 +4,8 @@
4
4
 
5
5
  Find records faster, add custom helpers, improve your console life by 100%.
6
6
 
7
- [![CircleCI](https://img.shields.io/circleci/build/github/nebulab/rails_console_toolkit/master?logo=circleci)](https://circleci.com/gh/nebulab/rails_console_toolkit)
7
+ [![Build](https://github.com/nebulab/rails_console_toolkit/workflows/build/badge.svg)](https://github.com/nebulab/rails_console_toolkit/actions?query=workflow%3Abuild)
8
+
8
9
 
9
10
  ## Installation
10
11
 
@@ -19,14 +19,18 @@ module RailsConsoleToolkit::Helpers
19
19
  helper_methods[name.to_sym] = block
20
20
  end
21
21
 
22
- def model_helper(klass, as: nil, by: nil, cached: true)
23
- klass = klass.constantize if klass.respond_to? :constantize
24
- method_name = as || klass.name.gsub('::', '_').underscore
22
+ def model_helper(klass_name, as: nil, by: nil, cached: true)
23
+ unless String === klass_name
24
+ raise TypeError, "The class name is expected to be a String, got #{klass_name.inspect} (#{klass_name.class}) instead."
25
+ end
26
+
27
+ method_name = as || klass_name.gsub('::', '_').underscore
25
28
  attribute_names = by || []
26
29
 
27
30
  record = nil # use the closure as a cache
28
31
 
29
32
  helper method_name do |key = nil|
33
+ klass = klass_name.constantize
30
34
  record = nil unless cached
31
35
 
32
36
  if key
@@ -5,12 +5,12 @@ RailsConsoleToolkit.helper :load_factories do
5
5
  Rails::ConsoleMethods.send :include, ::FactoryBot::Syntax::Methods
6
6
  end
7
7
 
8
- RailsConsoleToolkit.model_helper Spree::Product, as: :product, by: [:slug, :name]
9
- RailsConsoleToolkit.model_helper Spree::Variant, as: :variant, by: [:sku]
10
- RailsConsoleToolkit.model_helper Spree::Taxon, as: :taxon, by: [:permalink]
11
- RailsConsoleToolkit.model_helper Spree::Order, as: :order, by: [:number]
12
- RailsConsoleToolkit.model_helper Spree::User, as: :user, by: [:email]
13
- RailsConsoleToolkit.model_helper Spree::Country, as: :country, by: [:iso, :iso3, :iso_name, :name]
14
- RailsConsoleToolkit.model_helper Spree::Role, as: :role, by: [:name]
15
- RailsConsoleToolkit.model_helper Spree::Promotion, as: :promotion, by: [:name]
8
+ RailsConsoleToolkit.model_helper "Spree::Product", as: :product, by: [:slug, :name]
9
+ RailsConsoleToolkit.model_helper "Spree::Variant", as: :variant, by: [:sku]
10
+ RailsConsoleToolkit.model_helper "Spree::Taxon", as: :taxon, by: [:permalink]
11
+ RailsConsoleToolkit.model_helper "Spree::Order", as: :order, by: [:number]
12
+ RailsConsoleToolkit.model_helper "Spree::User", as: :user, by: [:email]
13
+ RailsConsoleToolkit.model_helper "Spree::Country", as: :country, by: [:iso, :iso3, :iso_name, :name]
14
+ RailsConsoleToolkit.model_helper "Spree::Role", as: :role, by: [:name]
15
+ RailsConsoleToolkit.model_helper "Spree::Promotion", as: :promotion, by: [:name]
16
16
  RailsConsoleToolkit.alias_helper :promo, :promotion
@@ -1,3 +1,3 @@
1
1
  module RailsConsoleToolkit
2
- VERSION = "0.5.3"
2
+ VERSION = "0.6.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_console_toolkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elia Schito
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-12-19 00:00:00.000000000 Z
11
+ date: 2020-12-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -74,9 +74,9 @@ executables: []
74
74
  extensions: []
75
75
  extra_rdoc_files: []
76
76
  files:
77
- - ".circleci/config.yml"
77
+ - ".github/config.yml"
78
+ - ".github/workflows/build.yml"
78
79
  - ".gitignore"
79
- - ".travis.yml"
80
80
  - Gemfile
81
81
  - LICENSE.txt
82
82
  - README.md
@@ -1,7 +0,0 @@
1
- ---
2
- sudo: false
3
- language: ruby
4
- cache: bundler
5
- rvm:
6
- - 2.6.2
7
- before_install: gem install bundler -v 2.0.1