acme-bleach 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -10
- data/lib/acme/bleach.rb +19 -14
- data/lib/acme/bleach/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1517ba8e887458c188c43868a6a65de3e9764b58
|
4
|
+
data.tar.gz: 820d40d867fdf882afcac442074f587f6994e3a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0cf0a591fa8bd0e4e1efe8340e22c9a93a38f714bee35fe0d6b0d5604b20f51b2f84d82146400844815de6c9a1839f3c07486b7c9af76e42d976bbd0bd238b0
|
7
|
+
data.tar.gz: cc540d04141a29e5cbe035f3b3d259b7c14c1f2935652e4aa53c4d3e8abbdcd684edb1c4c8859eea0624e593b41b1ba1e332992749c9ae72e92cbde699435672
|
data/README.md
CHANGED
@@ -4,26 +4,21 @@ A silly gem that cleans your source file.
|
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
gem 'acme-bleach'
|
10
|
-
|
11
|
-
And then execute:
|
12
|
-
|
13
|
-
$ bundle
|
14
|
-
|
15
|
-
Or install it yourself as:
|
7
|
+
Just install it yourself as:
|
16
8
|
|
17
9
|
$ gem install acme-bleach
|
18
10
|
|
19
11
|
## Usage
|
20
12
|
|
21
|
-
|
13
|
+
Require this gem and the first time you run your script your file will be
|
22
14
|
cleaned of all the messy things like printable characters. The next time it
|
23
15
|
will still run as usual, but without any visible code.
|
24
16
|
|
25
17
|
require 'acme/bleach'
|
26
18
|
|
19
|
+
NB: this should be in a `.rb` script that you're going to run. This is not a
|
20
|
+
gem for Rails or to be included in another gem.
|
21
|
+
|
27
22
|
## Acknowledgements
|
28
23
|
|
29
24
|
Damian Conway for the [original Perl version](http://search.cpan.org/~dconway/Acme-Bleach-1.150/lib/Acme/Bleach.pm) from which I stole liberally.
|
data/lib/acme/bleach.rb
CHANGED
@@ -19,21 +19,26 @@ module Acme
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
22
|
+
begin
|
23
|
+
content = File.read $0
|
24
|
+
|
25
|
+
m = content.match %r{\A(?<before>.*)^(?<require>\s*require\s+(?<quote>['"])acme/bleach\k<quote>[^\n]*\n)(?<after>.*)\z}m
|
26
|
+
|
27
|
+
before = m['before']
|
28
|
+
req = m['require']
|
29
|
+
after = m['after']
|
30
|
+
|
31
|
+
if bleached? after
|
32
|
+
eval before + brighten( after)
|
33
|
+
exit
|
34
|
+
else
|
35
|
+
File.open $0, 'w' do |f|
|
36
|
+
f.puts before + req + whiten( after)
|
37
|
+
end
|
36
38
|
end
|
39
|
+
rescue Errno::ENOENT => e
|
40
|
+
$stderr.puts "I got an error which might be because of how you tried to use this gem, it's designed to be `require`d in a `.rb` file that you run directly, not in Rails or another gem, anyway here's the exception I got:"
|
41
|
+
raise
|
37
42
|
end
|
38
43
|
end
|
39
44
|
end
|
data/lib/acme/bleach/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acme-bleach
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason King
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-05-
|
11
|
+
date: 2013-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|