unindent 0.9 → 1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -5,23 +5,25 @@ multi-line strings embeded in already indented code.
5
5
 
6
6
  ### Examples
7
7
 
8
- class Profile
9
- def default_text
10
- <<-STR
11
- Anonymous Coward
12
- - Community Guest
13
- STR
14
- end
15
- end
8
+ ```ruby
9
+ class Profile
10
+ def default_text
11
+ <<-STR
12
+ Anonymous Coward
13
+ - Community Guest
14
+ STR
15
+ end
16
+ end
16
17
 
17
- puts Profile.new.default_text
18
- # Anonymous Coward
19
- # - Community Guest
18
+ puts Profile.new.default_text
19
+ # Anonymous Coward
20
+ # - Community Guest
20
21
 
21
- puts Profile.new.default_text.unindent
22
- #Anonymous Coward
23
- # - Community Guest
22
+ puts Profile.new.default_text.unindent
23
+ #Anonymous Coward
24
+ # - Community Guest
25
+ ```
24
26
 
25
27
  ### Install
26
28
 
27
- gem install unindent
29
+ `gem install unindent`
@@ -1,6 +1,6 @@
1
1
  class String
2
2
  def unindent
3
- indent = self.split("\n").select {|line| !line.strip.empty? }.map {|line| line.index(/[^\s]/) }.compact.min
3
+ indent = self.split("\n").select {|line| !line.strip.empty? }.map {|line| line.index(/[^\s]/) }.compact.min || 0
4
4
  self.gsub(/^[[:blank:]]{#{indent}}/, '')
5
5
  end
6
6
  def unindent!
@@ -5,6 +5,7 @@ require 'test/test_helper'
5
5
  assert { "\s\sabc" .unindent == "abc" } # removes space indentation
6
6
  assert { "\tabc" .unindent == "abc" } # removes tab indentation
7
7
  assert { "\t\s\sabc".unindent == "abc" } # removes space/tab indentation
8
+ assert { "" .unindent == "" } # handles empty strings
8
9
 
9
10
  ## multi-line indentation
10
11
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "unindent"
3
- s.version = "0.9"
3
+ s.version = "1.0"
4
4
  s.summary = "Ruby method to unindent strings."
5
5
  s.description = "Ruby method to unindent strings. Useful for multiline strings embeded in already indented code."
6
6
  s.author = "mynyml"
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unindent
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.9"
4
+ hash: 15
5
+ prerelease:
6
+ segments:
7
+ - 1
8
+ - 0
9
+ version: "1.0"
5
10
  platform: ruby
6
11
  authors:
7
12
  - mynyml
@@ -9,19 +14,23 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-01-08 00:00:00 -05:00
17
+ date: 2011-09-30 00:00:00 -07:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
- name: nanotest
17
21
  type: :development
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ version_requirements: &id001 !ruby/object:Gem::Requirement
23
+ none: false
20
24
  requirements:
21
25
  - - ">="
22
26
  - !ruby/object:Gem::Version
27
+ hash: 3
28
+ segments:
29
+ - 0
23
30
  version: "0"
24
- version:
31
+ name: nanotest
32
+ requirement: *id001
33
+ prerelease: false
25
34
  description: Ruby method to unindent strings. Useful for multiline strings embeded in already indented code.
26
35
  email: mynyml@gmail.com
27
36
  executables: []
@@ -52,21 +61,27 @@ rdoc_options: []
52
61
  require_paths:
53
62
  - lib
54
63
  required_ruby_version: !ruby/object:Gem::Requirement
64
+ none: false
55
65
  requirements:
56
66
  - - ">="
57
67
  - !ruby/object:Gem::Version
68
+ hash: 3
69
+ segments:
70
+ - 0
58
71
  version: "0"
59
- version:
60
72
  required_rubygems_version: !ruby/object:Gem::Requirement
73
+ none: false
61
74
  requirements:
62
75
  - - ">="
63
76
  - !ruby/object:Gem::Version
77
+ hash: 3
78
+ segments:
79
+ - 0
64
80
  version: "0"
65
- version:
66
81
  requirements: []
67
82
 
68
83
  rubyforge_project: unindent
69
- rubygems_version: 1.3.5
84
+ rubygems_version: 1.3.10
70
85
  signing_key:
71
86
  specification_version: 3
72
87
  summary: Ruby method to unindent strings.