rails_console_toolkit 0.3.0 → 0.5.3

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: 1cd8126fdabd86bec0f64ff953337ae9a4a1435114ea35018406f322b6d7f8c6
4
- data.tar.gz: 3a0984cfe0561fc91ba564ca94d0d97e97e8246628a55da85e408e8e32f24699
3
+ metadata.gz: 784464abe81f7f89070ab3da6ac2f0a928615d6a361cf097135679ad6c86bf69
4
+ data.tar.gz: 656109e3bbac4bf2200ad8e156523f964897ca942a9b419523f694d83b7f3017
5
5
  SHA512:
6
- metadata.gz: d1261ef9b37861766bee33d0d06846042b6068aac61eec05bd9f4c606f42b98a46f8ef0ba6d6969c6a672724e91bed18c427a60263c30cf82155a0c354a457ae
7
- data.tar.gz: 43668cca3112f56ddf0aa255f2d75c4d607c75d4a348a0ca49426a441f6c0c6123d9423bf8ca1e87b9bfc7435cfee137ab1b02c5c150e67290546b9d4854fb8d
6
+ metadata.gz: e8052bbf7c75e2672a54a4dd112c867633cae7a7ba184d2969badfe0e5b511e351882c95cb21f08259920dbf8d73a4880b2bb6cd2c5bb41cd5a07949e555ff88
7
+ data.tar.gz: ff605580ad23d9985bde9df0410c0d3fac8a4f705fca802482a18339b6bbe30a90fbc696bebf1c6a4930b1d394c4d2d6715d0f0c086a86cfbd0d5071c7d1dbdc
data/README.md CHANGED
@@ -14,13 +14,23 @@ Add this line to your application's Gemfile:
14
14
  gem 'rails_console_toolkit'
15
15
  ```
16
16
 
17
- And then configure it within an initializer:
17
+ And then generate the initializer:
18
+
19
+ ```
20
+ $ bin/rails generate rails_console_toolkit:install
21
+ ```
22
+
23
+ or write it manually:
18
24
 
19
25
  ```ruby
20
26
  # config/initializers/console.rb
21
27
 
22
28
  RailsConsoleToolkit.configure do |config|
23
29
  # helper definitions go here...
30
+ #
31
+ # config.use_pack :aliases
32
+ # config.use_pack :utils
33
+ # config.use_pack :solidus if defined? Spree
24
34
  end
25
35
  ```
26
36
 
@@ -123,7 +133,7 @@ end
123
133
  # config/initializers/console.rb
124
134
 
125
135
  RailsConsoleToolkit.configure do |config|
126
- config.model_helper 'Spree::Product', as: :product, by: %i[:name, :slug]
136
+ config.model_helper 'Spree::Product', as: :product, by: %i[name slug]
127
137
  end
128
138
  ```
129
139
 
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsConsoleToolkit
4
+ module Generators
5
+ class InstallGenerator < Rails::Generators::Base
6
+ def copy_initializer
7
+ copy_file 'initializer.rb', 'config/initializers/console.rb'
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ RailsConsoleToolkit.configure do |config|
4
+ # Uncomment to activate a pack:
5
+ #
6
+ # config.use_pack :aliases
7
+ # config.use_pack :utils
8
+ # config.use_pack :solidus if defined? Spree
9
+ #
10
+ # An example of a model-helper:
11
+ #
12
+ # config.model_helper 'Product', as: :product, by: %i[name slug]
13
+ end
@@ -22,7 +22,6 @@ module RailsConsoleToolkit::Helpers
22
22
  def model_helper(klass, as: nil, by: nil, cached: true)
23
23
  klass = klass.constantize if klass.respond_to? :constantize
24
24
  method_name = as || klass.name.gsub('::', '_').underscore
25
- cache_key = method_name
26
25
  attribute_names = by || []
27
26
 
28
27
  record = nil # use the closure as a cache
@@ -32,6 +31,7 @@ module RailsConsoleToolkit::Helpers
32
31
 
33
32
  if key
34
33
  record = nil
34
+ record = key if klass === key
35
35
  record ||= klass.find(key) if Numeric === key
36
36
  attribute_names.find { |name| record ||= klass.find_by(name => key) }
37
37
  end
@@ -41,7 +41,7 @@ module RailsConsoleToolkit::Helpers
41
41
  end
42
42
 
43
43
  def alias_helper(new_name, old_name)
44
- helper(new_name) { send(old_name) }
44
+ helper(new_name) { |*args, &block| send(old_name, *args, &block) }
45
45
  end
46
46
 
47
47
  def remove_helper(name)
@@ -11,3 +11,6 @@ RailsConsoleToolkit.model_helper Spree::Taxon, as: :taxon, by: [:permalink]
11
11
  RailsConsoleToolkit.model_helper Spree::Order, as: :order, by: [:number]
12
12
  RailsConsoleToolkit.model_helper Spree::User, as: :user, by: [:email]
13
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
+ RailsConsoleToolkit.alias_helper :promo, :promotion
@@ -1,3 +1,3 @@
1
1
  module RailsConsoleToolkit
2
- VERSION = "0.3.0"
2
+ VERSION = "0.5.3"
3
3
  end
@@ -30,6 +30,6 @@ Gem::Specification.new do |spec|
30
30
  spec.add_dependency "rails", '>= 4'
31
31
 
32
32
  spec.add_development_dependency "bundler", "~> 2.0"
33
- spec.add_development_dependency "rake", "~> 10.0"
33
+ spec.add_development_dependency "rake", ">= 12.3.3"
34
34
  spec.add_development_dependency "minitest", "~> 5.0"
35
35
  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.3.0
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elia Schito
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-09-27 00:00:00.000000000 Z
11
+ date: 2020-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -42,16 +42,16 @@ dependencies:
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '10.0'
47
+ version: 12.3.3
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '10.0'
54
+ version: 12.3.3
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: minitest
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -83,6 +83,8 @@ files:
83
83
  - Rakefile
84
84
  - bin/console
85
85
  - bin/setup
86
+ - lib/generators/rails_console_toolkit/install/install_generator.rb
87
+ - lib/generators/rails_console_toolkit/install/templates/initializer.rb
86
88
  - lib/rails_console_toolkit.rb
87
89
  - lib/rails_console_toolkit/aliases.rb
88
90
  - lib/rails_console_toolkit/helpers.rb
@@ -96,7 +98,7 @@ licenses:
96
98
  metadata:
97
99
  homepage_uri: https://github.com/nebulab/rails_console_toolkit#readme
98
100
  source_code_uri: https://github.com/nebulab/rails_console_toolkit
99
- post_install_message:
101
+ post_install_message:
100
102
  rdoc_options: []
101
103
  require_paths:
102
104
  - lib
@@ -111,8 +113,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
113
  - !ruby/object:Gem::Version
112
114
  version: '0'
113
115
  requirements: []
114
- rubygems_version: 3.0.3
115
- signing_key:
116
+ rubygems_version: 3.1.4
117
+ signing_key:
116
118
  specification_version: 4
117
119
  summary: Configurable Rails Console Helpers
118
120
  test_files: []