jello 2 → 3
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile.rb +1 -1
- data/bin/jello +31 -1
- data/jello.gemspec +3 -3
- data/lib/jello.rb +7 -2
- data/moulds/grabup.rb +0 -2
- data/moulds/shorten.rb +21 -3
- metadata +2 -2
data/Rakefile.rb
CHANGED
@@ -132,7 +132,7 @@ end
|
|
132
132
|
|
133
133
|
desc 'Check everything over before commiting'
|
134
134
|
task :aok => [:'documentation:generate', :'documentation:open',
|
135
|
-
:'package:manifest',
|
135
|
+
:'package:manifest', :'package:gemspec',
|
136
136
|
:'coverage:run', :'coverage:verify', :'coverage:open']
|
137
137
|
|
138
138
|
task :ci => [:'documentation:generate', :'coverage:run', :'coverage:verify']
|
data/bin/jello
CHANGED
@@ -4,11 +4,41 @@
|
|
4
4
|
|
5
5
|
options = Hash.new
|
6
6
|
OptionParser.new do |opts|
|
7
|
-
opts.banner = "
|
7
|
+
opts.banner = "\
|
8
|
+
= Jello =
|
9
|
+
|
10
|
+
Moulds may be any string that matches a part of a path of a Ruby file relative\
|
11
|
+
to one of the entries in the Jello search path:
|
12
|
+
- ~/.jello
|
13
|
+
- /etc/jello
|
14
|
+
- <`gem contents jello`>/moulds
|
15
|
+
|
16
|
+
If a file matches earlier in the search path, later ones that also match will\
|
17
|
+
be ignored.
|
18
|
+
|
19
|
+
A directory may match, in which case all Ruby files in that directory will be\
|
20
|
+
utilized.
|
21
|
+
|
22
|
+
The follow moulds are included for your enjoyment:
|
23
|
+
- jello say
|
24
|
+
- jello grabup
|
25
|
+
- jello shorten
|
26
|
+
|
27
|
+
== Usage ==
|
28
|
+
`jello [options] <mould> (<mould> <mould> …)`
|
29
|
+
"
|
8
30
|
|
9
31
|
opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
|
10
32
|
options[:verbose] = v
|
11
33
|
end
|
34
|
+
|
35
|
+
opts.on("-f", "--[no-]feedback", "Feedback on successful process") do |f|
|
36
|
+
options[:feedback] = f
|
37
|
+
end
|
38
|
+
|
39
|
+
opts.on("-p", "--period PERIOD", "Period over which to cycle watcher process") do |p|
|
40
|
+
options[:period] = p
|
41
|
+
end
|
12
42
|
end.parse!
|
13
43
|
|
14
44
|
ARGV.each do |mould|
|
data/jello.gemspec
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
|
2
|
-
# Gem::Specification for Jello-
|
2
|
+
# Gem::Specification for Jello-3
|
3
3
|
# Originally generated by Echoe
|
4
4
|
|
5
5
|
--- !ruby/object:Gem::Specification
|
6
6
|
name: jello
|
7
7
|
version: !ruby/object:Gem::Version
|
8
|
-
version: "
|
8
|
+
version: "3"
|
9
9
|
platform: ruby
|
10
10
|
authors:
|
11
11
|
- elliottcable
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
|
15
|
-
date: 2008-09
|
15
|
+
date: 2008-10-09 00:00:00 -08:00
|
16
16
|
default_executable:
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
data/lib/jello.rb
CHANGED
@@ -3,10 +3,13 @@ require 'jello/pasteboard'
|
|
3
3
|
require 'jello/mould'
|
4
4
|
|
5
5
|
module Jello
|
6
|
-
Version =
|
6
|
+
Version = 3
|
7
7
|
|
8
8
|
def self.start! options = {}
|
9
9
|
options = {:verbose => false, :period => 0.5}.merge(options)
|
10
|
+
raise ArgumentError, 'period must be capable of becoming a Numeric Float' unless
|
11
|
+
options[:period].respond_to? :to_f
|
12
|
+
options[:period] = options[:period].to_f
|
10
13
|
|
11
14
|
forever do
|
12
15
|
|
@@ -16,11 +19,13 @@ module Jello
|
|
16
19
|
|
17
20
|
puts "#{pasteboard.board} received: [#{initial_paste}]" if options[:verbose]
|
18
21
|
moulds.each do |mould|
|
19
|
-
|
22
|
+
modified = mould.on_paste[paste]
|
23
|
+
paste = modified if modified.is_a?(String)
|
20
24
|
end
|
21
25
|
|
22
26
|
if paste.is_a?(String) and paste != initial_paste
|
23
27
|
puts " --> [#{paste}]" if options[:verbose]
|
28
|
+
print "\a" if options[:feedback]
|
24
29
|
pasteboard.puts paste
|
25
30
|
end
|
26
31
|
end
|
data/moulds/grabup.rb
CHANGED
data/moulds/shorten.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
+
require 'cgi'
|
1
2
|
require 'rubygems'
|
3
|
+
require 'open-uri'
|
2
4
|
require 'JSON'
|
3
5
|
|
4
6
|
Jello::Mould.new do |paste, board|
|
@@ -6,13 +8,29 @@ Jello::Mould.new do |paste, board|
|
|
6
8
|
if paste =~ %r{^http://.*}
|
7
9
|
uri = $&
|
8
10
|
unless paste =~ %r{^http://tr.im}
|
9
|
-
|
11
|
+
# We're going to add the main part of the domain to the end of the URI
|
12
|
+
# as a bullshit parameter, to give visitors some indication of what
|
13
|
+
# their destination is. If you're in a character-limited location, such
|
14
|
+
# as twitter or a text message, feel free to simply delete this section
|
15
|
+
# of the URL by hand after pasting. (⌥⌫ is helpful!)
|
16
|
+
base = uri.match(%r{^http://([\w\d\.]+\.)?([\w\d]+)\.[\w]{2,4}/})[2]
|
10
17
|
|
11
|
-
|
18
|
+
uri = CGI::escape uri
|
19
|
+
|
20
|
+
# Feel free to copy this Mould to your ~/.jello directory and hardcode
|
21
|
+
# in your username and password, if you don't feel like having your
|
22
|
+
# username and password in your shell history.
|
23
|
+
params = {}
|
24
|
+
params[:username] = ENV['TRIM_USERNAME'] if ENV['TRIM_USERNAME']
|
25
|
+
params[:password] = ENV['TRIM_PASSWORD'] if ENV['TRIM_PASSWORD']
|
26
|
+
params[:url] = uri
|
27
|
+
|
28
|
+
shortener = 'http://tr.im/api/trim_url.json?' +
|
29
|
+
params.to_a.map {|a| a.join '=' }.join('&')
|
12
30
|
|
13
31
|
reply = open(shortener).read
|
14
32
|
short = JSON.parse reply
|
15
|
-
short['url']
|
33
|
+
[short['url'], base].join('?')
|
16
34
|
end
|
17
35
|
end
|
18
36
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jello
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: "
|
4
|
+
version: "3"
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- elliottcable
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-09
|
12
|
+
date: 2008-10-09 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|