lstrip-on-steroids 0.1 → 0.9

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.
Files changed (3) hide show
  1. data/Rakefile +1 -1
  2. data/lib/lstrip_on_steroids.rb +5 -12
  3. metadata +4 -4
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require "rake/gempackagetask"
2
2
 
3
3
  spec = Gem::Specification.new do |s|
4
4
  s.name = "lstrip-on-steroids"
5
- s.version = "0.1"
5
+ s.version = "0.9"
6
6
  s.author = "Caius Durling"
7
7
  s.email = "dev@caius.name"
8
8
  s.homepage = "http://github.com/caius/lstrip-on-steroids"
@@ -1,17 +1,10 @@
1
1
  module LStripOnSteroids
2
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")
3
+ lines = split("\n")[1...-1]
4
+ leading_whitespace = lines.map { |line| line.match(/^ */)[0].length }.min
5
+ lines.map { |line|
6
+ line.sub(/^ {#{leading_whitespace}}/, "")
7
+ }.join("\n")
15
8
  end
16
9
  end
17
10
 
metadata CHANGED
@@ -1,12 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lstrip-on-steroids
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 1
9
- version: "0.1"
8
+ - 9
9
+ version: "0.9"
10
10
  platform: ruby
11
11
  authors:
12
12
  - Caius Durling
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-08-18 00:00:00 +01:00
17
+ date: 2010-08-19 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies: []
20
20