pry-singular 0.1.2 → 0.1.3
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 +4 -4
- data/.gitignore +2 -1
- data/README.md +18 -5
- data/lib/pry-singular.rb +26 -5
- data/lib/pry-singular/extract_pry_singular_options.rb +9 -0
- data/lib/pry-singular/version.rb +1 -1
- metadata +3 -3
- data/Gemfile.lock +0 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69f3be7a640ee44ce7b6d9f0ba1252917536e9157998bd9bad584b628fc69f6b
|
4
|
+
data.tar.gz: 5b9c03bd193ca0b04f6808a486f378b4eeb0088cf0610bc36a03155ca3f189eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65423169250d8fd390c63728838df58bd03867f92a6be169719a78015a8d7d8720dbd777657decbfd9612f1bacb2230abc4a56623896ba229740078f52395809
|
7
|
+
data.tar.gz: 4d7f1fe36760dc73fb8c72c8af6ee8f5cb13f216233f59bc4aab4ca19bcbe804dcea3b07cd1f30bf7a5771e32f4bffb734bafb2b43c9c9c2e207914c795d04e1
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,5 @@
|
|
1
|
-
# Pry
|
2
|
-
|
3
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/pry/singular`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
1
|
+
# Pry-Singular
|
2
|
+
[](https://travis-ci.org/QWYNG/pry-singular)
|
6
3
|
|
7
4
|
## Installation
|
8
5
|
|
@@ -34,6 +31,22 @@ then you can use singular method of set class as pry command
|
|
34
31
|
also you can use argument
|
35
32
|
|
36
33
|
pry(main)> create :user
|
34
|
+
|
35
|
+
Pry-Singular add only `singleton_methods(true)` for do not create core Ruby methods commands
|
36
|
+
|
37
|
+
If you have a method you want to specify write as below
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
PrySingular.set_class FactoryBot, only: [:build, :attributes_for]
|
41
|
+
```
|
42
|
+
|
43
|
+
Also, If you have a method that you don't want to command
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
PrySingular.set_class FactoryBot, except: [:create]
|
47
|
+
```
|
48
|
+
|
49
|
+
|
37
50
|
|
38
51
|
## Development
|
39
52
|
|
data/lib/pry-singular.rb
CHANGED
@@ -1,17 +1,28 @@
|
|
1
1
|
require "pry-singular/version"
|
2
|
+
require 'pry-singular/extract_pry_singular_options'
|
2
3
|
require 'pry'
|
3
4
|
|
4
5
|
module PrySingular
|
5
6
|
class << self
|
6
7
|
def set_class(*klasses)
|
7
|
-
klasses.
|
8
|
+
options = klasses.extract_pry_singular_options!
|
9
|
+
normalize_pry_singular_options!(options)
|
10
|
+
klasses.each do |klass|
|
11
|
+
import_class_command(klass, options)
|
12
|
+
end
|
8
13
|
end
|
9
14
|
|
10
15
|
private
|
11
16
|
|
12
|
-
def
|
13
|
-
|
14
|
-
|
17
|
+
def normalize_pry_singular_options!(options)
|
18
|
+
options[:only] = Array(options[:only])
|
19
|
+
options[:except] = Array(options[:except])
|
20
|
+
end
|
21
|
+
|
22
|
+
def import_class_command(klass, options)
|
23
|
+
singular_methods = adapt_options_singleton_methods(klass, options)
|
24
|
+
set_pry_command do
|
25
|
+
singular_methods.each do |klass_method|
|
15
26
|
command "#{klass_method}", "#{klass}.#{klass_method}" do
|
16
27
|
klass.class_eval <<-EOS
|
17
28
|
#{Readline::HISTORY.to_a.last.gsub(' ', '')}
|
@@ -19,8 +30,18 @@ module PrySingular
|
|
19
30
|
end
|
20
31
|
end
|
21
32
|
end
|
33
|
+
end
|
22
34
|
|
35
|
+
def set_pry_command(&block)
|
36
|
+
commands = Pry::CommandSet.new &block
|
23
37
|
Pry.config.commands.import(commands)
|
24
38
|
end
|
39
|
+
|
40
|
+
def adapt_options_singleton_methods(klass, options)
|
41
|
+
if options[:only].any?
|
42
|
+
return options[:only].select { |method_name| klass.respond_to?(method_name) }
|
43
|
+
end
|
44
|
+
klass.singleton_methods - options[:except]
|
45
|
+
end
|
25
46
|
end
|
26
|
-
end
|
47
|
+
end
|
data/lib/pry-singular/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pry-singular
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- qwyng
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|
@@ -77,13 +77,13 @@ files:
|
|
77
77
|
- ".travis.yml"
|
78
78
|
- CODE_OF_CONDUCT.md
|
79
79
|
- Gemfile
|
80
|
-
- Gemfile.lock
|
81
80
|
- LICENSE.txt
|
82
81
|
- README.md
|
83
82
|
- Rakefile
|
84
83
|
- bin/console
|
85
84
|
- bin/setup
|
86
85
|
- lib/pry-singular.rb
|
86
|
+
- lib/pry-singular/extract_pry_singular_options.rb
|
87
87
|
- lib/pry-singular/version.rb
|
88
88
|
- pry-singular.gemspec
|
89
89
|
homepage: https://github.com/QWYNG/pry-singular
|
data/Gemfile.lock
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
pry-singular (0.1.1)
|
5
|
-
pry
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: https://rubygems.org/
|
9
|
-
specs:
|
10
|
-
coderay (1.1.2)
|
11
|
-
method_source (0.9.2)
|
12
|
-
minitest (5.11.3)
|
13
|
-
pry (0.12.2)
|
14
|
-
coderay (~> 1.1.0)
|
15
|
-
method_source (~> 0.9.0)
|
16
|
-
rake (10.5.0)
|
17
|
-
|
18
|
-
PLATFORMS
|
19
|
-
ruby
|
20
|
-
|
21
|
-
DEPENDENCIES
|
22
|
-
bundler (~> 1.17)
|
23
|
-
minitest (~> 5.0)
|
24
|
-
pry-singular!
|
25
|
-
rake (~> 10.0)
|
26
|
-
|
27
|
-
BUNDLED WITH
|
28
|
-
1.17.2
|