pry-toggle 0.0.2 → 0.0.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/bin/{pry-toggle → pry-off} +1 -1
- data/bin/{pry-tgl → pry-on} +1 -1
- data/lib/pry_toggle/exec.rb +13 -8
- data/lib/pry_toggle/service.rb +8 -5
- data/lib/pry_toggle/version.rb +1 -1
- data/test/test_pry_toggle.rb +3 -3
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2bb7c24419c7ab585abcdbe487475dd24d12a680
|
4
|
+
data.tar.gz: 9ec8430d6e2bbb1c0c1deb773527d227ab26934f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 776cdad068d5a30652c97092ed6df3999dd39d402badd8f0e2f4ef34e0876ab2e5901231555b16a5f2884291153459de4777fbd442fa63ada87bc32cf21a9b42
|
7
|
+
data.tar.gz: a5464d5431b7479f0a9fc854be54d7106fbcc87e82e9956722038062e79f194a5440507078942d7ea5d4932f1a9db705279ce3b82c87f08adbdffa8911f18247
|
data/bin/{pry-toggle → pry-off}
RENAMED
data/bin/{pry-tgl → pry-on}
RENAMED
data/lib/pry_toggle/exec.rb
CHANGED
@@ -2,18 +2,23 @@ require 'pry_toggle'
|
|
2
2
|
|
3
3
|
module PryToggle
|
4
4
|
class Exec
|
5
|
-
def initialize(args)
|
5
|
+
def initialize(args, hash)
|
6
6
|
if args.first =~ /\A(.+):(\d+?)\z/
|
7
|
-
@service = PryToggle::Service.new($1, $2.to_i, '', "binding.pry\n")
|
7
|
+
@service = PryToggle::Service.new($1, $2.to_i, '', "binding.pry\n", hash[:on])
|
8
8
|
else
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
if hash[:on]
|
10
|
+
puts <<-DOC
|
11
|
+
=== Invalid command format. should be like that. ===
|
12
|
+
$ pry-on exmain.rb:10
|
13
|
+
DOC
|
14
|
+
else
|
15
|
+
puts <<-DOC
|
16
|
+
=== Invalid command format. should be like that. ===
|
17
|
+
$ pry-off exmain.rb:10
|
18
|
+
DOC
|
19
|
+
end
|
12
20
|
|
13
|
-
OR
|
14
21
|
|
15
|
-
$ pry-tgl exmain.rb#method_name
|
16
|
-
DOC
|
17
22
|
end
|
18
23
|
end
|
19
24
|
|
data/lib/pry_toggle/service.rb
CHANGED
@@ -1,18 +1,21 @@
|
|
1
1
|
require 'fileutils'
|
2
2
|
|
3
3
|
module PryToggle
|
4
|
-
class Service < ::Struct.new(:origin_path, :line_num, :mth_name, :str)
|
4
|
+
class Service < ::Struct.new(:origin_path, :line_num, :mth_name, :str, :on)
|
5
5
|
|
6
6
|
def execute
|
7
7
|
File.open(tmp_file_path, 'w') do |d|
|
8
8
|
File.open(abs_file_path, 'r') do |o|
|
9
|
-
|
10
|
-
|
11
|
-
else
|
9
|
+
if on
|
10
|
+
o.each.with_index(1) do |line, i|
|
12
11
|
d << str if i == line_num
|
13
12
|
d << line
|
13
|
+
d << str if line =~ %r|def( +)#{mth_name}|
|
14
|
+
end
|
15
|
+
else
|
16
|
+
o.each.with_index(1) do |line, i|
|
17
|
+
d << line unless (i == line_num || line_num.nil?) && line == str
|
14
18
|
end
|
15
|
-
d << str if line =~ %r|def( +)#{mth_name}|
|
16
19
|
end
|
17
20
|
end
|
18
21
|
end
|
data/lib/pry_toggle/version.rb
CHANGED
data/test/test_pry_toggle.rb
CHANGED
@@ -7,7 +7,7 @@ class TestPryToggle < MiniTest::Unit::TestCase
|
|
7
7
|
10.times { t << "test\n" }
|
8
8
|
end
|
9
9
|
|
10
|
-
service = PryToggle::Service.new(test_file_path, 6, '', "binding.pry\n")
|
10
|
+
service = PryToggle::Service.new(test_file_path, 6, '', "binding.pry\n", true)
|
11
11
|
service.execute
|
12
12
|
|
13
13
|
assert_equal "test\ntest\ntest\ntest\ntest\nbinding.pry\ntest\ntest\ntest\ntest\ntest\n", File.open(test_file_path, 'r').read
|
@@ -23,7 +23,7 @@ class TestPryToggle < MiniTest::Unit::TestCase
|
|
23
23
|
5.times { t << "test\n" }
|
24
24
|
end
|
25
25
|
|
26
|
-
service = PryToggle::Service.new(test_file_path, nil, '', "binding.pry\n")
|
26
|
+
service = PryToggle::Service.new(test_file_path, nil, '', "binding.pry\n", false)
|
27
27
|
service.execute
|
28
28
|
|
29
29
|
assert_equal "test\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\n", File.open(test_file_path, 'r').read
|
@@ -39,7 +39,7 @@ class TestPryToggle < MiniTest::Unit::TestCase
|
|
39
39
|
5.times { t << "test\n" }
|
40
40
|
end
|
41
41
|
|
42
|
-
service = PryToggle::Service.new(test_file_path, nil, "test_method", "binding.pry\n")
|
42
|
+
service = PryToggle::Service.new(test_file_path, nil, "test_method", "binding.pry\n", true)
|
43
43
|
service.execute
|
44
44
|
|
45
45
|
assert_equal "test\ntest\ntest\ntest\ntest\ndef test_method\nbinding.pry\ntest\ntest\ntest\ntest\ntest\n", File.open(test_file_path, 'r').read
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pry-toggle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- gogotanaka
|
@@ -57,13 +57,13 @@ description: ' All you need to do is copy message from command line like "main.r
|
|
57
57
|
email:
|
58
58
|
- mail@tanakakazuki.com
|
59
59
|
executables:
|
60
|
-
- pry-
|
61
|
-
- pry-
|
60
|
+
- pry-on
|
61
|
+
- pry-off
|
62
62
|
extensions: []
|
63
63
|
extra_rdoc_files: []
|
64
64
|
files:
|
65
|
-
- bin/pry-
|
66
|
-
- bin/pry-
|
65
|
+
- bin/pry-off
|
66
|
+
- bin/pry-on
|
67
67
|
- lib/pry_toggle.rb
|
68
68
|
- lib/pry_toggle/exec.rb
|
69
69
|
- lib/pry_toggle/service.rb
|