pry-clipboard 0.1.0 → 0.1.1
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.
- data/README.md +4 -1
- data/lib/pry-clipboard.rb +27 -12
- data/lib/pry-clipboard/version.rb +1 -1
- data/test/test_pry_clipboard.rb +9 -0
- metadata +13 -13
data/README.md
CHANGED
|
@@ -78,7 +78,7 @@ pry(main)> paste
|
|
|
78
78
|
=> 15
|
|
79
79
|
```
|
|
80
80
|
|
|
81
|
-
### --head / --tail options
|
|
81
|
+
### N / --head / --tail options
|
|
82
82
|
|
|
83
83
|
```ruby
|
|
84
84
|
pry(main)> history --tail 10
|
|
@@ -92,6 +92,9 @@ pry(main)> history --tail 10
|
|
|
92
92
|
11: history --tail 10
|
|
93
93
|
12: copy-result --tail 3
|
|
94
94
|
13: copy-history --tail 3
|
|
95
|
+
pry(main)> copy-history 9
|
|
96
|
+
-*-*- Copy history to clipboard -*-*-
|
|
97
|
+
'hello' * 3
|
|
95
98
|
pry(main)> copy-history -tail 5
|
|
96
99
|
-*-*- Copy history to clipboard -*-*-
|
|
97
100
|
copy-result
|
data/lib/pry-clipboard.rb
CHANGED
|
@@ -30,10 +30,11 @@ module PryClipboard
|
|
|
30
30
|
description "Copy history to clipboard"
|
|
31
31
|
|
|
32
32
|
banner <<-BANNER
|
|
33
|
-
Usage: copy-history [-
|
|
33
|
+
Usage: copy-history [N] [-T|--tail N] [-H|--head N] [-R|--range N..M] [-G|--grep match] [-l] [-q|--quiet]
|
|
34
34
|
|
|
35
35
|
e.g: `copy-history`
|
|
36
36
|
e.g: `copy-history -l`
|
|
37
|
+
e.g: `copy-history 10`
|
|
37
38
|
e.g: `copy-history -H 10`
|
|
38
39
|
e.g: `copy-history -T 5`
|
|
39
40
|
e.g: `copy-history -R 5..10`
|
|
@@ -50,18 +51,23 @@ module PryClipboard
|
|
|
50
51
|
|
|
51
52
|
def process
|
|
52
53
|
history = Pry::Code(Pry.history.to_a)
|
|
53
|
-
|
|
54
|
-
history =
|
|
55
|
-
|
|
56
|
-
history.between(opts[:range])
|
|
57
|
-
when opts.present?(:head)
|
|
58
|
-
history.take_lines(1, opts[:head] || 10)
|
|
59
|
-
when opts.present?(:tail) || opts.present?(:grep)
|
|
60
|
-
n = opts[:tail] || 10
|
|
61
|
-
n = history.lines.count if n > history.lines.count
|
|
62
|
-
history.take_lines(-n, n)
|
|
54
|
+
|
|
55
|
+
history = if num_arg
|
|
56
|
+
history.take_lines(num_arg, 1)
|
|
63
57
|
else
|
|
64
|
-
history.
|
|
58
|
+
history = history.grep(opts[:grep]) if opts.present?(:grep)
|
|
59
|
+
case
|
|
60
|
+
when opts.present?(:range)
|
|
61
|
+
history.between(opts[:range])
|
|
62
|
+
when opts.present?(:head)
|
|
63
|
+
history.take_lines(1, opts[:head] || 10)
|
|
64
|
+
when opts.present?(:tail) || opts.present?(:grep)
|
|
65
|
+
n = opts[:tail] || 10
|
|
66
|
+
n = history.lines.count if n > history.lines.count
|
|
67
|
+
history.take_lines(-n, n)
|
|
68
|
+
else
|
|
69
|
+
history.take_lines(-1, 1)
|
|
70
|
+
end
|
|
65
71
|
end
|
|
66
72
|
|
|
67
73
|
str = history.raw
|
|
@@ -73,6 +79,15 @@ module PryClipboard
|
|
|
73
79
|
_pry_.output.puts str
|
|
74
80
|
end
|
|
75
81
|
end
|
|
82
|
+
|
|
83
|
+
def num_arg
|
|
84
|
+
first = args[0]
|
|
85
|
+
if first && first.to_i.to_s == first
|
|
86
|
+
first.to_i
|
|
87
|
+
else
|
|
88
|
+
nil
|
|
89
|
+
end
|
|
90
|
+
end
|
|
76
91
|
end
|
|
77
92
|
|
|
78
93
|
create_command "copy-result" do
|
data/test/test_pry_clipboard.rb
CHANGED
|
@@ -48,6 +48,15 @@ EOF
|
|
|
48
48
|
)).should =~ /clipboard.*\n"efg"\n/
|
|
49
49
|
end
|
|
50
50
|
|
|
51
|
+
it "#copy-history 2" do
|
|
52
|
+
mock_pry(*%w(
|
|
53
|
+
'foo'
|
|
54
|
+
'bar'
|
|
55
|
+
'baz'
|
|
56
|
+
copy-history\ 2
|
|
57
|
+
)).should =~ /clipboard.*\n'bar'\n/
|
|
58
|
+
end
|
|
59
|
+
|
|
51
60
|
it "#copy-history -l" do
|
|
52
61
|
mock(Clipboard).copy("10 * 10\n#=> 100\n")
|
|
53
62
|
mock_pry(*%w(
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pry-clipboard
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -13,7 +13,7 @@ date: 2012-04-26 00:00:00.000000000 Z
|
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: pry
|
|
16
|
-
requirement: &
|
|
16
|
+
requirement: &2176894460 !ruby/object:Gem::Requirement
|
|
17
17
|
none: false
|
|
18
18
|
requirements:
|
|
19
19
|
- - ! '>='
|
|
@@ -21,10 +21,10 @@ dependencies:
|
|
|
21
21
|
version: '0'
|
|
22
22
|
type: :runtime
|
|
23
23
|
prerelease: false
|
|
24
|
-
version_requirements: *
|
|
24
|
+
version_requirements: *2176894460
|
|
25
25
|
- !ruby/object:Gem::Dependency
|
|
26
26
|
name: clipboard
|
|
27
|
-
requirement: &
|
|
27
|
+
requirement: &2176893980 !ruby/object:Gem::Requirement
|
|
28
28
|
none: false
|
|
29
29
|
requirements:
|
|
30
30
|
- - ! '>='
|
|
@@ -32,10 +32,10 @@ dependencies:
|
|
|
32
32
|
version: '0'
|
|
33
33
|
type: :runtime
|
|
34
34
|
prerelease: false
|
|
35
|
-
version_requirements: *
|
|
35
|
+
version_requirements: *2176893980
|
|
36
36
|
- !ruby/object:Gem::Dependency
|
|
37
37
|
name: rr
|
|
38
|
-
requirement: &
|
|
38
|
+
requirement: &2176893360 !ruby/object:Gem::Requirement
|
|
39
39
|
none: false
|
|
40
40
|
requirements:
|
|
41
41
|
- - ~>
|
|
@@ -43,10 +43,10 @@ dependencies:
|
|
|
43
43
|
version: '1.0'
|
|
44
44
|
type: :development
|
|
45
45
|
prerelease: false
|
|
46
|
-
version_requirements: *
|
|
46
|
+
version_requirements: *2176893360
|
|
47
47
|
- !ruby/object:Gem::Dependency
|
|
48
48
|
name: bacon
|
|
49
|
-
requirement: &
|
|
49
|
+
requirement: &2176908800 !ruby/object:Gem::Requirement
|
|
50
50
|
none: false
|
|
51
51
|
requirements:
|
|
52
52
|
- - ~>
|
|
@@ -54,10 +54,10 @@ dependencies:
|
|
|
54
54
|
version: '1.1'
|
|
55
55
|
type: :development
|
|
56
56
|
prerelease: false
|
|
57
|
-
version_requirements: *
|
|
57
|
+
version_requirements: *2176908800
|
|
58
58
|
- !ruby/object:Gem::Dependency
|
|
59
59
|
name: open4
|
|
60
|
-
requirement: &
|
|
60
|
+
requirement: &2176908060 !ruby/object:Gem::Requirement
|
|
61
61
|
none: false
|
|
62
62
|
requirements:
|
|
63
63
|
- - ~>
|
|
@@ -65,10 +65,10 @@ dependencies:
|
|
|
65
65
|
version: '1.3'
|
|
66
66
|
type: :development
|
|
67
67
|
prerelease: false
|
|
68
|
-
version_requirements: *
|
|
68
|
+
version_requirements: *2176908060
|
|
69
69
|
- !ruby/object:Gem::Dependency
|
|
70
70
|
name: rake
|
|
71
|
-
requirement: &
|
|
71
|
+
requirement: &2176907520 !ruby/object:Gem::Requirement
|
|
72
72
|
none: false
|
|
73
73
|
requirements:
|
|
74
74
|
- - ! '>='
|
|
@@ -76,7 +76,7 @@ dependencies:
|
|
|
76
76
|
version: '0'
|
|
77
77
|
type: :development
|
|
78
78
|
prerelease: false
|
|
79
|
-
version_requirements: *
|
|
79
|
+
version_requirements: *2176907520
|
|
80
80
|
description: pry clipboard utility
|
|
81
81
|
email:
|
|
82
82
|
- hotchpotch@gmail.com
|