lstrip-on-steroids 0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/Rakefile +17 -0
  2. data/lib/lstrip_on_steroids.rb +18 -0
  3. metadata +67 -0
data/Rakefile ADDED
@@ -0,0 +1,17 @@
1
+ require "rake/gempackagetask"
2
+
3
+ spec = Gem::Specification.new do |s|
4
+ s.name = "lstrip-on-steroids"
5
+ s.version = "0.1"
6
+ s.author = "Caius Durling"
7
+ s.email = "dev@caius.name"
8
+ s.homepage = "http://github.com/caius/lstrip-on-steroids"
9
+ s.platform = Gem::Platform::RUBY
10
+ s.summary = "Intelligently strips leading whitespace from a multiline string"
11
+ s.files = FileList["lib/**/*.rb", "[A-Z]*"].to_a
12
+ s.has_rdoc = false
13
+ end
14
+
15
+ Rake::GemPackageTask.new(spec) do |pkg|
16
+ pkg.need_tar = true
17
+ end
@@ -0,0 +1,18 @@
1
+ module LStripOnSteroids
2
+ def -@
3
+ # Split into lines so we can process them
4
+ lines = self.split("\n")
5
+ # Lose the first line (it's empty anyway)
6
+ lines.delete_at(0)
7
+ # Grab the last line, which should just contain spaces
8
+ leading_whitespace = lines.delete_at(-1)
9
+ # Strip leading_whitespace from each line and join into one again
10
+ lines.map do |l|
11
+ i = leading_whitespace.length
12
+ l[/^ {#{i}}/] = "" if l[/^ {#{i}}/]
13
+ l
14
+ end.join("\n")
15
+ end
16
+ end
17
+
18
+ String.__send__(:include, LStripOnSteroids)
metadata ADDED
@@ -0,0 +1,67 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lstrip-on-steroids
3
+ version: !ruby/object:Gem::Version
4
+ hash: 9
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ version: "0.1"
10
+ platform: ruby
11
+ authors:
12
+ - Caius Durling
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-08-18 00:00:00 +01:00
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description:
22
+ email: dev@caius.name
23
+ executables: []
24
+
25
+ extensions: []
26
+
27
+ extra_rdoc_files: []
28
+
29
+ files:
30
+ - lib/lstrip_on_steroids.rb
31
+ - Rakefile
32
+ has_rdoc: true
33
+ homepage: http://github.com/caius/lstrip-on-steroids
34
+ licenses: []
35
+
36
+ post_install_message:
37
+ rdoc_options: []
38
+
39
+ require_paths:
40
+ - lib
41
+ required_ruby_version: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ hash: 3
47
+ segments:
48
+ - 0
49
+ version: "0"
50
+ required_rubygems_version: !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ hash: 3
56
+ segments:
57
+ - 0
58
+ version: "0"
59
+ requirements: []
60
+
61
+ rubyforge_project:
62
+ rubygems_version: 1.3.7
63
+ signing_key:
64
+ specification_version: 3
65
+ summary: Intelligently strips leading whitespace from a multiline string
66
+ test_files: []
67
+