methodz 0.1.6 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dc8bad5a7b3c5aa07afb1c8a1d62d9ed337b54c4355bbbe779b022bcb5ca712b
4
- data.tar.gz: f90d2f1d2e7c3b8454ac902670dd3fffa97327e78c75c7395e29f18c058c8de4
3
+ metadata.gz: 30bf0f5355916570ae7628e076a2065414a443500b353396b36afc36fdd01df6
4
+ data.tar.gz: 15aa82a8abc9118063b3466d1f67fa0890a90cade6adcccf6580685054b56c7c
5
5
  SHA512:
6
- metadata.gz: f362e0a297b869e82eeb735a3c51357b4d200454499836082cbb8d8bf2770c7299c162ac134865bfdcf06d6a3d50f63eec7dba0318a532bd21427be470a65384
7
- data.tar.gz: 9ddbe6407f54fac84eca9f8daf91ecec392a1b562f51fbd14e8d342eb1d1328fa4a44012c63e20efa51f0937f0dca18b33b4d00494cf3a927e0c27a0f950558f
6
+ metadata.gz: 84822ea016cf898c9f479789934339a7e8160f2dd144e2b34a9bf04daf379874f3069c362b00cdbdb6a99d0f499e6255c697531ff7f6354b72766d751b221d8a
7
+ data.tar.gz: 8d2e80bb9d118f5f839c1a919d859ea20851c2e653deb90128400aedfe6fd99355004e692419548388d40895b72f91fd14675b78a6e477a319f29daeef9a4f82
data/lib/methodz/core.rb CHANGED
@@ -1,45 +1,43 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Methodz
4
- class ActiveRecord::Base
5
- def methodz(opts = {})
6
- list = public_methods + private_methods + protected_methods - Object.methods
7
- return list if opts.empty?
3
+ class Object
4
+ def methodz(opts = {})
5
+ list = public_methods + private_methods + protected_methods - Object.methods
6
+ return list if opts.empty?
8
7
 
9
- # simple usage, ex: user.methodz('stripe')
10
- opts = { q: opts } if opts.instance_of?(String)
8
+ # simple usage, ex: user.methodz('stripe')
9
+ opts = { q: opts } if opts.instance_of?(String)
11
10
 
12
- # query by keyword in definition
13
- list = list.filter { |m| m.to_s.include?(opts[:q] || '') }
11
+ # query by keyword in definition
12
+ list = list.filter { |m| m.to_s.include?(opts[:q] || '') }
14
13
 
15
- # query specific types, ex: user.methodz('stripe', type: 'private')
16
- if opts[:type] && !%w[all].include?(opts[:type])
17
- list = list.filter { |m| send("#{opts[:type]}_methods").include?(m) }
18
- end
14
+ # query specific types, ex: user.methodz('stripe', type: 'private')
15
+ if opts[:type] && !%w[all].include?(opts[:type])
16
+ list = list.filter { |m| send("#{opts[:type]}_methods").include?(m) }
17
+ end
19
18
 
20
- # remove ActiveModel::Dirty helpers, ex: will_save_change_to_{query}
21
- dirty_attrz.each { |da| list = list.filter { |m| !m.to_s.include?(da.to_s) } }
22
- list = list.filter { |_| dirty_attrz.any? { |da| !da.to_s.include?(opts[:q] || '') } }
19
+ # remove ActiveModel::Dirty helpers, ex: will_save_change_to_{query}
20
+ dirty_attrz.each { |da| list = list.filter { |m| !m.to_s.include?(da.to_s) } }
21
+ list = list.filter { |_| dirty_attrz.any? { |da| !da.to_s.include?(opts[:q] || '') } }
23
22
 
24
- # remove getter/setter attributes (seeking user-defined methods, not activerecord given)
25
- attrz.each { |a| list = list.filter { |m| !m.to_s.include?(a.to_s) } }
23
+ # remove getter/setter attributes (seeking user-defined methods, not activerecord given)
24
+ attrz.each { |a| list = list.filter { |m| !m.to_s.include?(a.to_s) } }
26
25
 
27
- list
28
- end
26
+ list
27
+ end
29
28
 
30
- def attrz
31
- return [] unless respond_to?(:attributes)
29
+ def attrz
30
+ return [] unless respond_to?(:attributes)
32
31
 
33
- attributes.keys.map(&:to_sym)
34
- end
32
+ attributes.keys.map(&:to_sym)
33
+ end
35
34
 
36
- # https://api.rubyonrails.org/classes/ActiveModel/Dirty.html
37
- def dirty_attrz
38
- %i[
39
- restore_ will_save_change_to _change_to_be_saved _for_database
40
- _before_last_save _in_database _change _was _id? _previously_was
41
- _before_last_save_was _came_from_ _before_type_cast _changed?
42
- ]
43
- end
35
+ # https://api.rubyonrails.org/classes/ActiveModel/Dirty.html
36
+ def dirty_attrz
37
+ %i[
38
+ restore_ will_save_change_to _change_to_be_saved _for_database
39
+ _before_last_save _in_database _change _was _id? _previously_was
40
+ _before_last_save_was _came_from_ _before_type_cast _changed?
41
+ ]
44
42
  end
45
- end
43
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Methodz
4
- VERSION = '0.1.6'.freeze
4
+ VERSION = '0.1.7'.freeze
5
5
  end
data/methodz.gemspec ADDED
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/methodz/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "methodz"
7
+ spec.version = Methodz::VERSION
8
+ spec.authors = ["Ryan Kulp"]
9
+ spec.email = ["ryanckulp@gmail.com"]
10
+
11
+ spec.summary = "Lookup object methods by partial name match or type."
12
+ spec.homepage = "https://github.com/ryanckulp/methodz"
13
+ spec.license = "MIT"
14
+ spec.required_ruby_version = ">= 2.6.0"
15
+
16
+ spec.metadata["homepage_uri"] = spec.homepage
17
+ spec.metadata["source_code_uri"] = spec.homepage
18
+
19
+ # Specify which files should be added to the gem when it is released.
20
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
21
+ spec.files = Dir.chdir(__dir__) do
22
+ `git ls-files -z`.split("\x0").reject do |f|
23
+ (File.expand_path(f) == __FILE__) ||
24
+ f.start_with?(*%w[bin/ test/ spec/ features/ .git appveyor Gemfile])
25
+ end
26
+ end
27
+ spec.bindir = "exe"
28
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
29
+ spec.require_paths = ["lib"]
30
+
31
+ # Uncomment to register a new dependency of your gem
32
+ # spec.add_dependency "example-gem", "~> 1.0"
33
+
34
+ # For more information and examples about making a new gem, check out our
35
+ # guide at: https://bundler.io/guides/creating_gem.html
36
+ end
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: methodz
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Kulp
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
11
  date: 2023-12-26 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description:
13
+ description:
14
14
  email:
15
15
  - ryanckulp@gmail.com
16
16
  executables: []
@@ -25,6 +25,7 @@ files:
25
25
  - lib/methodz/core.rb
26
26
  - lib/methodz/error.rb
27
27
  - lib/methodz/version.rb
28
+ - methodz.gemspec
28
29
  - sig/methodz.rbs
29
30
  homepage: https://github.com/ryanckulp/methodz
30
31
  licenses:
@@ -32,7 +33,7 @@ licenses:
32
33
  metadata:
33
34
  homepage_uri: https://github.com/ryanckulp/methodz
34
35
  source_code_uri: https://github.com/ryanckulp/methodz
35
- post_install_message:
36
+ post_install_message:
36
37
  rdoc_options: []
37
38
  require_paths:
38
39
  - lib
@@ -47,8 +48,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
47
48
  - !ruby/object:Gem::Version
48
49
  version: '0'
49
50
  requirements: []
50
- rubygems_version: 3.4.13
51
- signing_key:
51
+ rubygems_version: 3.0.1
52
+ signing_key:
52
53
  specification_version: 4
53
54
  summary: Lookup object methods by partial name match or type.
54
55
  test_files: []