utility_belt 1.0.6 → 1.1.0
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/bin/amazon +4 -5
- data/bin/google +5 -16
- data/bin/pastie +6 -0
- data/lib/utility_belt.rb +13 -30
- data/lib/utility_belt/amazon_upload_shortcut.rb +25 -0
- data/lib/utility_belt/clipboard.rb +52 -0
- data/lib/{command_history.rb → utility_belt/command_history.rb} +20 -5
- data/lib/utility_belt/convertable_to_file.rb +34 -0
- data/lib/utility_belt/equipper.rb +72 -0
- data/lib/utility_belt/google.rb +33 -0
- data/lib/utility_belt/hash_math.rb +10 -0
- data/lib/utility_belt/interactive_editor.rb +78 -0
- data/lib/{irb_options.rb → utility_belt/irb_options.rb} +0 -0
- data/lib/{irb_verbosity_control.rb → utility_belt/irb_verbosity_control.rb} +0 -0
- data/lib/{is_an.rb → utility_belt/is_an.rb} +0 -0
- data/lib/{language_greps.rb → utility_belt/language_greps.rb} +0 -0
- data/lib/{not.rb → utility_belt/not.rb} +0 -0
- data/lib/utility_belt/pastie.rb +33 -0
- data/lib/utility_belt/pipe.rb +24 -0
- data/lib/utility_belt/prompt.rb +1 -0
- data/lib/{rails_finder_shortcut.rb → utility_belt/rails_finder_shortcut.rb} +0 -0
- data/lib/{rails_verbosity_control.rb → utility_belt/rails_verbosity_control.rb} +0 -0
- data/lib/{string_to_proc.rb → utility_belt/string_to_proc.rb} +0 -0
- data/lib/{symbol_to_proc.rb → utility_belt/symbol_to_proc.rb} +0 -0
- data/lib/{themes.rb → utility_belt/wirble.rb} +4 -0
- data/lib/{with.rb → utility_belt/with.rb} +0 -0
- data/spec/convertable_to_file_spec.rb +31 -0
- data/spec/equipper_spec.rb +70 -0
- data/spec/hash_math_spec.rb +32 -0
- data/spec/interactive_editor_spec.rb +146 -0
- data/{test → spec}/language_greps_spec.rb +3 -2
- data/spec/pastie_spec.rb +92 -0
- data/spec/pipe_spec.rb +30 -0
- data/spec/spec_helper.rb +8 -0
- data/{test → spec}/string_to_proc_spec.rb +2 -1
- data/{test → spec}/utility_belt_spec.rb +1 -0
- data/utility_belt.gemspec +5 -5
- metadata +42 -29
- data/Rakefile +0 -20
- data/lib/amazon_upload_shortcut.rb +0 -18
- data/lib/hash_math.rb +0 -13
- data/lib/interactive_editor.rb +0 -42
- data/lib/mac_clipboard.rb +0 -15
- data/lib/pastie.rb +0 -15
- data/test/hash_math_spec.rb +0 -16
data/spec/pipe_spec.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require File.join(File.dirname(__FILE__), "spec_helper")
|
3
|
+
|
4
|
+
require 'spec'
|
5
|
+
require 'irb'
|
6
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'utility_belt', 'pipe')
|
7
|
+
|
8
|
+
describe "String#|" do
|
9
|
+
before :each do
|
10
|
+
@pipe = stub(:pipe, :write => nil, :close_write => nil, :read => nil)
|
11
|
+
IO.stub!(:popen).and_yield(@pipe).and_return("RESULT")
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should open a pipe" do
|
15
|
+
IO.should_receive(:popen).with("COMMAND", 'r+').and_return(@pipe)
|
16
|
+
"foo" | "COMMAND"
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should write itself to the the pipe, close it, then read from it" do
|
20
|
+
@pipe.should_receive(:write).with("foo").ordered
|
21
|
+
@pipe.should_receive(:close_write).ordered
|
22
|
+
@pipe.should_receive(:read)
|
23
|
+
|
24
|
+
"foo" | "COMMAND"
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should return the result of the IO.popen block" do
|
28
|
+
("foo" | "COMMAND").should == "RESULT"
|
29
|
+
end
|
30
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
# Make sure Rubygems' mangling of the path is already done before we do our own
|
2
|
+
# mangling.
|
3
|
+
require 'rubygems'
|
4
|
+
|
5
|
+
# Ensure that when we require UtilityBelt libs they are from the files under
|
6
|
+
# test, NOT from the installed gem.
|
7
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), ".."))
|
8
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "spec_helper")
|
1
2
|
# yeah, I know. I know! but you try to write specs for code which launches vi. most of this was
|
2
3
|
# already written by the time I started tasting the BDD Kool-Aid. HOWEVER! any new patches are
|
3
4
|
# very welcome, but MUST be accompanied by a spec or an absolutely airtight reason why not.
|
data/utility_belt.gemspec
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
SPEC = Gem::Specification.new do |s|
|
3
3
|
s.name = "utility_belt"
|
4
|
-
s.version = "1.0
|
4
|
+
s.version = "1.1.0"
|
5
5
|
s.author = "Giles Bowkett"
|
6
6
|
s.email = "gilesb@gmail.com"
|
7
7
|
s.homepage = "http://utilitybelt.rubyforge.org"
|
8
|
+
s.rubyforge_project = "utility_belt"
|
8
9
|
s.platform = Gem::Platform::RUBY
|
9
10
|
s.summary = "A grab-bag of IRB power user madness."
|
10
11
|
s.files = Dir.glob("**/*")
|
11
|
-
%w{amazon google}.each do |
|
12
|
-
s.executables <<
|
12
|
+
%w{amazon google pastie}.each do |command_line_utility|
|
13
|
+
s.executables << command_line_utility
|
13
14
|
end
|
14
15
|
s.require_path = "lib"
|
15
|
-
s.
|
16
|
-
s.test_file = "test/utility_belt_spec.rb"
|
16
|
+
s.test_file = "spec/utility_belt_spec.rb"
|
17
17
|
s.has_rdoc = true
|
18
18
|
s.extra_rdoc_files = ["README"]
|
19
19
|
s.add_dependency("wirble", ">= 0.1.2")
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: utility_belt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Giles Bowkett
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2008-04-28 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -44,6 +44,7 @@ email: gilesb@gmail.com
|
|
44
44
|
executables:
|
45
45
|
- amazon
|
46
46
|
- google
|
47
|
+
- pastie
|
47
48
|
extensions: []
|
48
49
|
|
49
50
|
extra_rdoc_files:
|
@@ -52,6 +53,7 @@ files:
|
|
52
53
|
- bin
|
53
54
|
- bin/amazon
|
54
55
|
- bin/google
|
56
|
+
- bin/pastie
|
55
57
|
- History.txt
|
56
58
|
- html
|
57
59
|
- html/andreas00.css
|
@@ -64,32 +66,43 @@ files:
|
|
64
66
|
- html/test.jpg
|
65
67
|
- html/usage.html
|
66
68
|
- lib
|
67
|
-
- lib/
|
68
|
-
- lib/
|
69
|
-
- lib/
|
70
|
-
- lib/
|
71
|
-
- lib/
|
72
|
-
- lib/
|
73
|
-
- lib/
|
74
|
-
- lib/
|
75
|
-
- lib/
|
76
|
-
- lib/
|
77
|
-
- lib/
|
78
|
-
- lib/
|
79
|
-
- lib/
|
80
|
-
- lib/
|
81
|
-
- lib/
|
82
|
-
- lib/
|
69
|
+
- lib/utility_belt
|
70
|
+
- lib/utility_belt/amazon_upload_shortcut.rb
|
71
|
+
- lib/utility_belt/clipboard.rb
|
72
|
+
- lib/utility_belt/command_history.rb
|
73
|
+
- lib/utility_belt/convertable_to_file.rb
|
74
|
+
- lib/utility_belt/equipper.rb
|
75
|
+
- lib/utility_belt/google.rb
|
76
|
+
- lib/utility_belt/hash_math.rb
|
77
|
+
- lib/utility_belt/interactive_editor.rb
|
78
|
+
- lib/utility_belt/irb_options.rb
|
79
|
+
- lib/utility_belt/irb_verbosity_control.rb
|
80
|
+
- lib/utility_belt/is_an.rb
|
81
|
+
- lib/utility_belt/language_greps.rb
|
82
|
+
- lib/utility_belt/not.rb
|
83
|
+
- lib/utility_belt/pastie.rb
|
84
|
+
- lib/utility_belt/pipe.rb
|
85
|
+
- lib/utility_belt/prompt.rb
|
86
|
+
- lib/utility_belt/rails_finder_shortcut.rb
|
87
|
+
- lib/utility_belt/rails_verbosity_control.rb
|
88
|
+
- lib/utility_belt/string_to_proc.rb
|
89
|
+
- lib/utility_belt/symbol_to_proc.rb
|
90
|
+
- lib/utility_belt/wirble.rb
|
91
|
+
- lib/utility_belt/with.rb
|
83
92
|
- lib/utility_belt.rb
|
84
|
-
- lib/with.rb
|
85
93
|
- Manifest.txt
|
86
|
-
- Rakefile
|
87
94
|
- README
|
88
|
-
-
|
89
|
-
-
|
90
|
-
-
|
91
|
-
-
|
92
|
-
-
|
95
|
+
- spec
|
96
|
+
- spec/convertable_to_file_spec.rb
|
97
|
+
- spec/equipper_spec.rb
|
98
|
+
- spec/hash_math_spec.rb
|
99
|
+
- spec/interactive_editor_spec.rb
|
100
|
+
- spec/language_greps_spec.rb
|
101
|
+
- spec/pastie_spec.rb
|
102
|
+
- spec/pipe_spec.rb
|
103
|
+
- spec/spec_helper.rb
|
104
|
+
- spec/string_to_proc_spec.rb
|
105
|
+
- spec/utility_belt_spec.rb
|
93
106
|
- utility_belt.gemspec
|
94
107
|
has_rdoc: true
|
95
108
|
homepage: http://utilitybelt.rubyforge.org
|
@@ -112,10 +125,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
125
|
version:
|
113
126
|
requirements: []
|
114
127
|
|
115
|
-
rubyforge_project:
|
116
|
-
rubygems_version:
|
128
|
+
rubyforge_project: utility_belt
|
129
|
+
rubygems_version: 1.1.0
|
117
130
|
signing_key:
|
118
131
|
specification_version: 2
|
119
132
|
summary: A grab-bag of IRB power user madness.
|
120
133
|
test_files:
|
121
|
-
-
|
134
|
+
- spec/utility_belt_spec.rb
|
data/Rakefile
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
# -*- ruby -*-
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require 'hoe'
|
5
|
-
require './lib/utility_belt.rb'
|
6
|
-
|
7
|
-
Hoe.new('UtilityBelt', UtilityBelt::VERSION) do |p|
|
8
|
-
p.rubyforge_name = 'utility_belt'
|
9
|
-
# p.author = 'Giles Bowkett'
|
10
|
-
# p.email = 'gilesb@gmail.com'
|
11
|
-
# p.summary = 'IRB funk'
|
12
|
-
# p.description = p.paragraphs_of('README.txt', 2..5).join("\n\n")
|
13
|
-
# p.url = p.paragraphs_of('README.txt', 0).first.split(/\n/)[1..-1]
|
14
|
-
p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
|
15
|
-
end
|
16
|
-
|
17
|
-
# vim: syntax=Ruby
|
18
|
-
|
19
|
-
# I used Hoe to create the dirs etc., but from then on did most of it manually.
|
20
|
-
# (I figure if you're reading this at all, the reason is curiousity.)
|
@@ -1,18 +0,0 @@
|
|
1
|
-
# S3 (http://amazon.rubyforge.org/)
|
2
|
-
UTILITY_BELT_IRB_STARTUP_PROCS[:define_s3_convenience_methods] = lambda do
|
3
|
-
%w{aws/s3 cgi}.each {|lib| require lib}
|
4
|
-
def aws_upload(bucket,filename)
|
5
|
-
AWS::S3::Base.establish_connection!(:access_key_id => ENV['AMAZON_ACCESS_KEY_ID'],
|
6
|
-
:secret_access_key => ENV['AMAZON_SECRET_ACCESS_KEY'])
|
7
|
-
AWS::S3::S3Object.store(filename, open(filename), bucket, :access => :public_read)
|
8
|
-
url = "http://s3.amazonaws.com/#{bucket}/#{filename}".gsub(/ /, "%20")
|
9
|
-
MacClipboard.write(url) if :macosx == Platform::IMPL
|
10
|
-
url
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
# a quick note: the "google" command uses CGI.escape, but the URLs produced by CGI.escape
|
15
|
-
# don't seem to succeed here, in practice. this may differ by OS and/or browser. Let me
|
16
|
-
# know if you see something weird -- the Utility Belt mailing list is here:
|
17
|
-
#
|
18
|
-
# http://rubyforge.org/mailman/listinfo/utilitybelt-tinkering
|
data/lib/hash_math.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
class Hash
|
2
|
-
alias :+ :merge
|
3
|
-
def -(thing_to_be_deleted)
|
4
|
-
if thing_to_be_deleted.is_a? Hash
|
5
|
-
thing_to_be_deleted.each do |key, value|
|
6
|
-
self.delete(key) if self[key] == value
|
7
|
-
end
|
8
|
-
elsif self.keys.include? thing_to_be_deleted
|
9
|
-
self.delete(thing_to_be_deleted)
|
10
|
-
end
|
11
|
-
self
|
12
|
-
end
|
13
|
-
end
|
data/lib/interactive_editor.rb
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
# Giles Bowkett, Greg Brown, and several audience members from Giles' Ruby East presentation.
|
2
|
-
class InteractiveEditor
|
3
|
-
attr_accessor :editor
|
4
|
-
def initialize(editor = :vim)
|
5
|
-
@editor = editor.to_s
|
6
|
-
if @editor == "mate"
|
7
|
-
@editor = "mate -w"
|
8
|
-
end
|
9
|
-
end
|
10
|
-
def edit_interactively
|
11
|
-
unless @file
|
12
|
-
@file = Tempfile.new("irb_tempfile")
|
13
|
-
end
|
14
|
-
system("#{@editor} #{@file.path}")
|
15
|
-
Object.class_eval(`cat #{@file.path}`)
|
16
|
-
rescue Exception => error
|
17
|
-
puts error
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
class Object
|
22
|
-
def edit_interactively(editor)
|
23
|
-
unless IRB.conf[:interactive_editors] && IRB.conf[:interactive_editors][editor]
|
24
|
-
IRB.conf[:interactive_editors] ||= {}
|
25
|
-
IRB.conf[:interactive_editors][editor] = InteractiveEditor.new(editor)
|
26
|
-
end
|
27
|
-
IRB.conf[:interactive_editors][editor].edit_interactively
|
28
|
-
end
|
29
|
-
|
30
|
-
def vi
|
31
|
-
edit_interactively(:vim)
|
32
|
-
end
|
33
|
-
|
34
|
-
def mate
|
35
|
-
edit_interactively(:mate)
|
36
|
-
end
|
37
|
-
|
38
|
-
def emacs
|
39
|
-
edit_interactively(:emacs)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
data/lib/mac_clipboard.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
# original clipboard code: http://project.ioni.st/post/1334#snippet_1334
|
2
|
-
# turned it into a class to make it flexxy:
|
3
|
-
# http://gilesbowkett.blogspot.com/2007/09/improved-auto-pastie-irb-code.html
|
4
|
-
class MacClipboard
|
5
|
-
if :macosx == Platform::IMPL
|
6
|
-
class << self
|
7
|
-
def read
|
8
|
-
IO.popen('pbpaste') {|clipboard| clipboard.read}
|
9
|
-
end
|
10
|
-
def write(stuff)
|
11
|
-
IO.popen('pbcopy', 'w+') {|clipboard| clipboard.write(stuff)}
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
data/lib/pastie.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
# automate creating pasties
|
2
|
-
class Object
|
3
|
-
if :macosx == Platform::IMPL
|
4
|
-
def pastie
|
5
|
-
pastie_url = Net::HTTP.post_form(URI.parse("http://pastie.caboo.se/pastes/create"),
|
6
|
-
{"paste_parser" => "ruby",
|
7
|
-
"paste[authorization]" => "burger",
|
8
|
-
"paste[body]" => MacClipboard.read}).body.match(/href="([^\"]+)"/)[1]
|
9
|
-
MacClipboard.write(pastie_url)
|
10
|
-
system("open #{pastie_url}")
|
11
|
-
pastie_url
|
12
|
-
end
|
13
|
-
alias :pst :pastie
|
14
|
-
end
|
15
|
-
end
|
data/test/hash_math_spec.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
require "lib/hash_math"
|
2
|
-
describe "Hash math" do
|
3
|
-
|
4
|
-
it "should add hashes" do
|
5
|
-
({:a => :b} + {:c => :d}).should == {:a => :b, :c => :d}
|
6
|
-
end
|
7
|
-
|
8
|
-
it "should subtract hashes" do
|
9
|
-
({:a => :b, :c => :d} - {:c => :d}).should == {:a => :b}
|
10
|
-
end
|
11
|
-
|
12
|
-
it "should subtract key/value pairs by key" do
|
13
|
-
({:a => :b, :c => :d} - :c).should == {:a => :b}
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|