lstrip-on-steroids 1.0.1 → 1.0.2

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.
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'http://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in lstrip-on-steroids.gemspec
4
+ gemspec
data/Rakefile CHANGED
@@ -1,17 +1,2 @@
1
- require "rake/gempackagetask"
2
-
3
- spec = Gem::Specification.new do |s|
4
- s.name = "lstrip-on-steroids"
5
- s.version = "1.0.1"
6
- s.authors = ["Caius Durling", "Ash Moran"]
7
- s.email = %w[dev@caius.name ash.moran@patchspace.co.uk]
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", "spec/**/*.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
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -1 +1 @@
1
- require 'lstrip_on_steroids'
1
+ require 'lstrip_on_steroids'
@@ -1,3 +1,5 @@
1
+ require File.expand_path("lstrip_on_steroids/version", File.dirname(__FILE__))
2
+
1
3
  module LStripOnSteroids
2
4
  class JuicedStripper
3
5
  def initialize lines
@@ -0,0 +1,3 @@
1
+ module LStripOnSteroids
2
+ VERSION = "1.0.2"
3
+ end
@@ -0,0 +1,18 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path("../lib/lstrip_on_steroids/version", __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Caius Durling", "Ash Moran"]
6
+ gem.email = %w[dev@caius.name ash.moran@patchspace.co.uk]
7
+ gem.description = %q{Sane indent-aware multiline strings}
8
+ gem.summary = "Intelligently strips leading whitespace from a multiline string"
9
+ gem.homepage = "http://github.com/caius/lstrip-on-steroids"
10
+
11
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ gem.name = "lstrip-on-steroids"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = LStripOnSteroids::VERSION
17
+ gem.has_rdoc = false
18
+ end
@@ -0,0 +1,92 @@
1
+ # lstrip-on-steroids
2
+
3
+ In [another][engorge] late night discussion in the [#nwrug][] IRC room, [Ash Moran][AM] was after sane indent-aware multiline strings for his cucumber scenarios.
4
+
5
+ [engorge]: http://github.com/caius/engorge-ostruct
6
+ [#nwrug]: http://nwrug.org/
7
+ [AM]: https://github.com/ashmoran/
8
+
9
+ As of v0.9.5 you can use either Strings (`''`, `""`, `%{}`, etc) or HEREDOCs (`<<-EOF\nEOF`) with the leading `-` to have the shitespace stripped. *('Shitespace' was coined by Caius in [this tweet][shitespace].)*
10
+
11
+ [shitespace]: https://twitter.com/Caius/status/21600277885
12
+
13
+ ## Installation
14
+
15
+ $ sudo gem install lstrip-on-steroids
16
+
17
+ And then in your code:
18
+
19
+ require "lstrip-on-steroids"
20
+
21
+ ## Examples & Usage
22
+
23
+ Actually, I think my original scenario was RSpec :-) /Ash
24
+
25
+ For example, the following story reads ok, but you end up with extra shitespace at the start of each line:
26
+
27
+ Scenario: Fake thing happens
28
+ When I do something
29
+ Then I should see %{
30
+ someone
31
+ did
32
+ something
33
+ }
34
+
35
+ The problem is, this gets an extra two spaces at the start of each line. You want it to be the string `" someone\n did\n something"`, but you end up with `"\n someone\n did\n something\n "`.
36
+
37
+ The current solution is to delete the indent in the string:
38
+
39
+ Scenario: Fake thing happens
40
+ When I do something
41
+ Then I should see %{
42
+ someone
43
+ did
44
+ something
45
+ }
46
+
47
+ But that just looks horrible, and you've amended your story to fit the code (kinda.)
48
+
49
+ Luckily, you can automatically work out just the right amount of whitespace you want to be removed from each line, so with a bit of jiggery pokery, you can have your cake and eat it too. (The cake is not a lie.)
50
+
51
+ Seeing as `String#-@` isn't defined already, this gem defines that for it, so you just prepend your multiline string with `-` to have it automagically strip the shitespace and leave the rest of your whitespace a-ok. So you end up with:
52
+
53
+ Scenario: Fake thing happens
54
+ When I do something
55
+ Then I should see -%{
56
+ someone
57
+ did
58
+ something
59
+ }
60
+
61
+ which gives you back `" someone\n did\n something"`, exactly what we want!
62
+
63
+ *If you've not used to see `%{}` used to create strings, check out the [Ruby Shortcuts][rs] post on [CaiusTheory][ct] for an explanation of it and more!*
64
+
65
+ [rs]: http://caiustheory.com/ruby-shortcuts
66
+ [ct]: http://caiustheory.com/
67
+
68
+ ## Licence
69
+
70
+ > The MIT License
71
+ >
72
+ > Copyright (c) 2010 Caius Durling <dev@caius.name>
73
+ > Contributions by Ash Moran <ash.moran@patchspace.co.uk>
74
+ >
75
+ > Permission is hereby granted, free of charge, to any person obtaining a copy
76
+ > of this software and associated documentation files (the "Software"), to deal
77
+ > in the Software without restriction, including without limitation the rights
78
+ > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
79
+ > copies of the Software, and to permit persons to whom the Software is
80
+ > furnished to do so, subject to the following conditions:
81
+ >
82
+ > The above copyright notice and this permission notice shall be included in
83
+ > all copies or substantial portions of the Software.
84
+ >
85
+ > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
86
+ > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
87
+ > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
88
+ > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
89
+ > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
90
+ > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
91
+ > THE SOFTWARE.
92
+
metadata CHANGED
@@ -1,51 +1,73 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: lstrip-on-steroids
3
- version: !ruby/object:Gem::Version
4
- version: 1.0.1
5
- prerelease:
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 0
8
+ - 2
9
+ version: 1.0.2
6
10
  platform: ruby
7
- authors:
11
+ authors:
8
12
  - Caius Durling
9
13
  - Ash Moran
10
14
  autorequire:
11
15
  bindir: bin
12
16
  cert_chain: []
13
- date: 2011-10-13 00:00:00.000000000Z
17
+
18
+ date: 2011-11-17 00:00:00 +00:00
19
+ default_executable:
14
20
  dependencies: []
15
- description:
16
- email:
21
+
22
+ description: Sane indent-aware multiline strings
23
+ email:
17
24
  - dev@caius.name
18
25
  - ash.moran@patchspace.co.uk
19
26
  executables: []
27
+
20
28
  extensions: []
29
+
21
30
  extra_rdoc_files: []
22
- files:
31
+
32
+ files:
33
+ - .gitignore
34
+ - Gemfile
35
+ - Rakefile
23
36
  - lib/lstrip-on-steroids.rb
24
37
  - lib/lstrip_on_steroids.rb
38
+ - lib/lstrip_on_steroids/version.rb
39
+ - lstrip-on-steroids.gemspec
40
+ - readme.md
25
41
  - spec/lstrip_on_steroids_spec.rb
26
- - Rakefile
42
+ has_rdoc: true
27
43
  homepage: http://github.com/caius/lstrip-on-steroids
28
44
  licenses: []
45
+
29
46
  post_install_message:
30
47
  rdoc_options: []
31
- require_paths:
48
+
49
+ require_paths:
32
50
  - lib
33
- required_ruby_version: !ruby/object:Gem::Requirement
34
- none: false
35
- requirements:
36
- - - ! '>='
37
- - !ruby/object:Gem::Version
38
- version: '0'
39
- required_rubygems_version: !ruby/object:Gem::Requirement
40
- none: false
41
- requirements:
42
- - - ! '>='
43
- - !ruby/object:Gem::Version
44
- version: '0'
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ segments:
56
+ - 0
57
+ version: "0"
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ segments:
63
+ - 0
64
+ version: "0"
45
65
  requirements: []
66
+
46
67
  rubyforge_project:
47
- rubygems_version: 1.8.11
68
+ rubygems_version: 1.3.6
48
69
  signing_key:
49
70
  specification_version: 3
50
71
  summary: Intelligently strips leading whitespace from a multiline string
51
- test_files: []
72
+ test_files:
73
+ - spec/lstrip_on_steroids_spec.rb