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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 365250e33c439905e62f2293381e6fce98bfb4f6
4
- data.tar.gz: 7ef952c5a145760cd17ddbfa7d4e4b1cb7cac96a
3
+ metadata.gz: 1517ba8e887458c188c43868a6a65de3e9764b58
4
+ data.tar.gz: 820d40d867fdf882afcac442074f587f6994e3a1
5
5
  SHA512:
6
- metadata.gz: d396225d119ad7658caf93f9be66f448d7c3f157d482cc2169031409ecfd7592eda5260ab047911bf0db9fb21af29857a48bee08045e470f73fe2f8c910cbe48
7
- data.tar.gz: dd03a392a579695e9e87f10f521957ab57043a0f9932b32ecd5fa8f781aebbaf047a3dfc2bba32f2d49c071d7f710cc96073181b9d74fd012879637beb67c1cf
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
- Add this line to your application's Gemfile:
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
- Just require this gem and the first time you run your script your file will be
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.
@@ -19,21 +19,26 @@ module Acme
19
19
  end
20
20
  end
21
21
 
22
- content = File.read $0
23
-
24
- m = content.match %r{\A(?<before>.*)^(?<require>\s*require\s+(?<quote>['"])acme/bleach\k<quote>[^\n]*\n)(?<after>.*)\z}m
25
-
26
- before = m['before']
27
- req = m['require']
28
- after = m['after']
29
-
30
- if bleached? after
31
- eval before + brighten( after)
32
- exit
33
- else
34
- File.open $0, 'w' do |f|
35
- f.puts before + req + whiten( after)
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
@@ -1,5 +1,5 @@
1
1
  module Acme
2
2
  module Bleach
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
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.3
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-03 00:00:00.000000000 Z
11
+ date: 2013-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler