pry-toggle 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/pry-toggle +7 -0
- data/lib/pry_toggle/exec.rb +15 -0
- data/lib/pry_toggle/service.rb +31 -0
- data/lib/pry_toggle/version.rb +3 -0
- data/lib/pry_toggle.rb +3 -0
- data/test/minitest_helper.rb +4 -0
- data/test/test_pry_toggle.rb +16 -0
- metadata +94 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9735f5c63dc772693ff6f47de28100ab04418b6e
|
4
|
+
data.tar.gz: 2bf9599c7d6505a2b8045675065188cc108b1bab
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 53900ec8f5c1ef2b46fc306145f5ee6f60319b050e44166203406bc4a84f07a290dd7188a5bb715c8f76307f761d16424135d6fe9eb28fc378242c9c7e6cee87
|
7
|
+
data.tar.gz: c20c7573ec05e475603d3f24b8c432d1c42919682d460c766018dba7ebcacb8f115f8abbfd8615e92418438c9b4c703dee1f1ed084318e8de8f422ccf9527e61
|
data/bin/pry-toggle
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'pry'
|
2
|
+
require 'pry_toggle'
|
3
|
+
|
4
|
+
module PryToggle
|
5
|
+
class Exec
|
6
|
+
def initialize(args)
|
7
|
+
args.first =~ /\A(.+):(\d+?)\z/
|
8
|
+
@service = PryToggle::Service.new($1, $2.to_i, '', "binding.pry\n")
|
9
|
+
end
|
10
|
+
|
11
|
+
def execute!
|
12
|
+
@service.execute
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module PryToggle
|
4
|
+
class Service < ::Struct.new(:origin_path, :line_num, :mth_name, :str)
|
5
|
+
|
6
|
+
def execute
|
7
|
+
fail '' unless origin_path
|
8
|
+
tempfile = File.open(tmp_file_path, 'w')
|
9
|
+
f = File.open(abs_file_path, 'r')
|
10
|
+
f.each.with_index(1) do |line, i|
|
11
|
+
tempfile << line
|
12
|
+
if i == line_num
|
13
|
+
tempfile << str
|
14
|
+
end
|
15
|
+
end
|
16
|
+
f.close
|
17
|
+
tempfile.close
|
18
|
+
|
19
|
+
FileUtils.mv(tmp_file_path, abs_file_path)
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
def tmp_file_path
|
24
|
+
@tmp_file_path ||= "#{File.expand_path File.dirname(origin_path) }/pry_toggle.tmp"
|
25
|
+
end
|
26
|
+
|
27
|
+
def abs_file_path
|
28
|
+
@abs_file_path ||= File.expand_path origin_path
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/pry_toggle.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'minitest_helper'
|
2
|
+
require 'pry'
|
3
|
+
class TestPryToggle < MiniTest::Unit::TestCase
|
4
|
+
def test_general
|
5
|
+
test_file_path = "./test/test_files/test.rb"
|
6
|
+
test_file = File.open(test_file_path, 'w')
|
7
|
+
10.times { test_file << "test\n" }
|
8
|
+
test_file.close
|
9
|
+
service = PryToggle::Service.new(test_file_path, 5, '', "binding.pry\n")
|
10
|
+
service.execute
|
11
|
+
|
12
|
+
assert_equal "test\ntest\ntest\ntest\ntest\nbinding.pry\ntest\ntest\ntest\ntest\ntest\n", File.open(test_file_path, 'r').read
|
13
|
+
|
14
|
+
FileUtils.rm(test_file_path)
|
15
|
+
end
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pry-toggle
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- gogotanaka
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-01-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: ' Toggle "binding.pry" easily from command line. '
|
56
|
+
email:
|
57
|
+
- mail@tanakakazuki.com
|
58
|
+
executables:
|
59
|
+
- pry-toggle
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- bin/pry-toggle
|
64
|
+
- lib/pry_toggle.rb
|
65
|
+
- lib/pry_toggle/exec.rb
|
66
|
+
- lib/pry_toggle/service.rb
|
67
|
+
- lib/pry_toggle/version.rb
|
68
|
+
- test/minitest_helper.rb
|
69
|
+
- test/test_pry_toggle.rb
|
70
|
+
homepage: ''
|
71
|
+
licenses:
|
72
|
+
- MIT
|
73
|
+
metadata: {}
|
74
|
+
post_install_message:
|
75
|
+
rdoc_options: []
|
76
|
+
require_paths:
|
77
|
+
- lib
|
78
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
requirements: []
|
89
|
+
rubyforge_project:
|
90
|
+
rubygems_version: 2.2.2
|
91
|
+
signing_key:
|
92
|
+
specification_version: 4
|
93
|
+
summary: Toggle "binding.pry" easily from command line.
|
94
|
+
test_files: []
|