pry-singular 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.standard.yml +6 -0
- data/.travis.yml +4 -1
- data/Gemfile +1 -1
- data/README.md +3 -3
- data/Rakefile +1 -1
- data/lib/pry-singular.rb +30 -30
- data/lib/pry-singular/option.rb +15 -0
- data/lib/pry-singular/slop.rb +12 -0
- data/lib/pry-singular/version.rb +1 -1
- data/pry-singular.gemspec +3 -3
- metadata +19 -4
- data/lib/pry-singular/extract_pry_singular_options.rb +0 -9
- data/lib/pry-singular/parse_readline.rb +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e29520ac622fa873c590c83aff04d4771ecf4af5678ff56953dadf637410986
|
4
|
+
data.tar.gz: b55d7c89167c2c3923df7cbf8bacb9a157db707f06a4ab1c35834cadcfb1d3f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 382795b995205e1eba5545c581a11dd8b91cbf830fac8a12f6b61f4602b26fd35dbdd9e934b88a9370d3d01ef87d769dbbdec054ae3e42a4d1410e2563c6ad5e
|
7
|
+
data.tar.gz: e068ae185bc88b796a202d884fd4122fb9978b835e16d38961fcbe497897d3c24879b61d68c4a28cc704202d034f20b81f2b3a80baeda08de91d714a074bbda1
|
data/.standard.yml
ADDED
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -21,7 +21,7 @@ Or install it yourself as:
|
|
21
21
|
Set `.pryrc` as below
|
22
22
|
|
23
23
|
```ruby
|
24
|
-
PrySingular.
|
24
|
+
PrySingular.make_commands FooJob, FactoryBot
|
25
25
|
```
|
26
26
|
|
27
27
|
then you can use singular method of set class as pry command
|
@@ -37,13 +37,13 @@ Pry-Singular add only `singleton_methods(true)` for do not create core Ruby meth
|
|
37
37
|
If you have a method you want to specify write as below
|
38
38
|
|
39
39
|
```ruby
|
40
|
-
PrySingular.
|
40
|
+
PrySingular.make_commands FactoryBot, only: [:build, :attributes_for]
|
41
41
|
```
|
42
42
|
|
43
43
|
Also, If you have a method that you don't want to command
|
44
44
|
|
45
45
|
```ruby
|
46
|
-
PrySingular.
|
46
|
+
PrySingular.make_commands FactoryBot, except: :create
|
47
47
|
```
|
48
48
|
|
49
49
|
|
data/Rakefile
CHANGED
data/lib/pry-singular.rb
CHANGED
@@ -1,50 +1,50 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
1
|
+
require "pry-singular/version"
|
2
|
+
require "pry-singular/slop"
|
3
|
+
require "pry-singular/option"
|
4
|
+
require "pry"
|
5
5
|
|
6
6
|
module PrySingular
|
7
7
|
class << self
|
8
|
-
def
|
9
|
-
options =
|
10
|
-
normalize_pry_singular_options!(options)
|
8
|
+
def make_commands(*klasses, **options)
|
9
|
+
options = Options.new(options)
|
11
10
|
klasses.each do |klass|
|
12
|
-
|
11
|
+
create_singular_method_commands(klass, options)
|
13
12
|
end
|
14
13
|
end
|
15
14
|
|
16
15
|
private
|
17
16
|
|
18
|
-
def
|
19
|
-
|
20
|
-
options[:except] = Array(options[:except])
|
21
|
-
end
|
17
|
+
def create_singular_method_commands(klass, options)
|
18
|
+
filtered_singular_methods = filter_methods_by_option(klass.singleton_methods, options)
|
22
19
|
|
23
|
-
|
24
|
-
|
25
|
-
set_pry_command do
|
26
|
-
singular_methods.each do |klass_method|
|
27
|
-
command "#{klass_method}", "#{klass}.#{klass_method}" do
|
28
|
-
extend PrySingular::Slop
|
29
|
-
klass.class_eval <<-EOS
|
30
|
-
#{parse_singular_method_command(Readline::HISTORY.to_a.last)}
|
31
|
-
EOS
|
32
|
-
end
|
33
|
-
end
|
20
|
+
filtered_singular_methods.each do |singular_method|
|
21
|
+
singular_method_command(singular_method, klass)
|
34
22
|
end
|
35
23
|
end
|
36
24
|
|
37
|
-
def
|
38
|
-
|
39
|
-
|
25
|
+
def filter_methods_by_option(methods, options)
|
26
|
+
if options.only.any?
|
27
|
+
options.remove_methods_other_than_only(methods)
|
28
|
+
else
|
29
|
+
options.remove_except_methods(methods)
|
30
|
+
end
|
40
31
|
end
|
41
32
|
|
42
|
-
def
|
43
|
-
|
44
|
-
|
33
|
+
def singular_method_command(singular_method, klass)
|
34
|
+
import_pry_command do
|
35
|
+
command singular_method.to_s, "#{klass}.#{singular_method}" do
|
36
|
+
last_cui_command = Readline::HISTORY.to_a.last
|
37
|
+
|
38
|
+
klass.class_eval <<~EOS, __FILE__, __LINE__ + 1
|
39
|
+
#{PrySingular::Slop.parse_singular_method_command(last_cui_command)}
|
40
|
+
EOS
|
41
|
+
end
|
45
42
|
end
|
43
|
+
end
|
46
44
|
|
47
|
-
|
45
|
+
def import_pry_command(&block)
|
46
|
+
commands = Pry::CommandSet.new(&block)
|
47
|
+
Pry.config.commands.import(commands)
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module PrySingular
|
2
|
+
Options = Struct.new(:only, :except) {
|
3
|
+
def initialize(**options)
|
4
|
+
super(Array(options[:only]), Array(options[:except]))
|
5
|
+
end
|
6
|
+
|
7
|
+
def remove_methods_other_than_only(methods)
|
8
|
+
methods & only
|
9
|
+
end
|
10
|
+
|
11
|
+
def remove_except_methods(methods)
|
12
|
+
methods - except
|
13
|
+
end
|
14
|
+
}
|
15
|
+
end
|
data/lib/pry-singular/version.rb
CHANGED
data/pry-singular.gemspec
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
lib = File.expand_path("../lib", __FILE__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
require "pry-singular/version"
|
@@ -9,13 +8,13 @@ Gem::Specification.new do |spec|
|
|
9
8
|
spec.authors = ["qwyng"]
|
10
9
|
spec.email = ["ikusawasi@gmail.com"]
|
11
10
|
|
12
|
-
spec.summary =
|
11
|
+
spec.summary = "setting class methods as pry command"
|
13
12
|
spec.homepage = "https://github.com/QWYNG/pry-singular"
|
14
13
|
spec.license = "MIT"
|
15
14
|
|
16
15
|
# Specify which files should be added to the gem when it is released.
|
17
16
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
18
|
-
spec.files = Dir.chdir(File.expand_path(
|
17
|
+
spec.files = Dir.chdir(File.expand_path("..", __FILE__)) do
|
19
18
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
20
19
|
end
|
21
20
|
spec.bindir = "exe"
|
@@ -26,4 +25,5 @@ Gem::Specification.new do |spec|
|
|
26
25
|
spec.add_development_dependency "bundler", "~> 1.17"
|
27
26
|
spec.add_development_dependency "rake", "~> 10.0"
|
28
27
|
spec.add_development_dependency "minitest", "~> 5.0"
|
28
|
+
spec.add_development_dependency "standard"
|
29
29
|
end
|
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.8
|
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-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '5.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: standard
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
description:
|
70
84
|
email:
|
71
85
|
- ikusawasi@gmail.com
|
@@ -74,6 +88,7 @@ extensions: []
|
|
74
88
|
extra_rdoc_files: []
|
75
89
|
files:
|
76
90
|
- ".gitignore"
|
91
|
+
- ".standard.yml"
|
77
92
|
- ".travis.yml"
|
78
93
|
- CODE_OF_CONDUCT.md
|
79
94
|
- Gemfile
|
@@ -83,8 +98,8 @@ files:
|
|
83
98
|
- bin/console
|
84
99
|
- bin/setup
|
85
100
|
- lib/pry-singular.rb
|
86
|
-
- lib/pry-singular/
|
87
|
-
- lib/pry-singular/
|
101
|
+
- lib/pry-singular/option.rb
|
102
|
+
- lib/pry-singular/slop.rb
|
88
103
|
- lib/pry-singular/version.rb
|
89
104
|
- pry-singular.gemspec
|
90
105
|
homepage: https://github.com/QWYNG/pry-singular
|