testytest 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: cd3cf306804133248a6ba76e1a8a26499c9537ea
4
+ data.tar.gz: daf98c304a87f33802e4715378988075c821fddc
5
+ SHA512:
6
+ metadata.gz: 4f04406917b8eb864a227a8e45ae00119a345478ab6b25365ba5525741c7ae6220238e3d601f03b853be9ede8bc7d47af312c46cc962de90333601b83d471447
7
+ data.tar.gz: 29929ebe2a3575f005e1cd552034db77538e0521d2998eefa227901c233905477363c2ea945f23d0ab2cb596fae44a070252f6dc327e4842e0789093cf27f2af
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in dedent.gemspec
4
+ gemspec
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2012 Caleb Spare
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,59 @@
1
+ ruby-dedent
2
+ ===========
3
+
4
+ Installation
5
+ ------------
6
+
7
+ gem install dedent
8
+
9
+ Only tested with Ruby 1.9.2 and 1.8.7.
10
+
11
+ Usage
12
+ -----
13
+
14
+ This is a tiny gem that adds the `dedent` method to String. This method strips leading whitespace from each
15
+ line, preserving indentation. So, the line with the least amount of leading whitespace will have all leading
16
+ whitespace removed, while other lines will have whitespace relative to that line's offset.
17
+
18
+ The main use of this is with heredocs. It can be annoying because even with the `<<-` form of heredocs, all
19
+ the initial whitespace on each line of the string is preserved, so if you keep the string in the same
20
+ indentation as the code, you end up with a bunch of extra space.
21
+
22
+ Here's an example of using dedent with heredocs:
23
+
24
+ ``` ruby
25
+ # Suppose we're already at some indentation within the code.
26
+ foo = <<-EOS.dedent
27
+ This might be a usage banner for a cli tool. Or, it might be some javascript. Or maybe shell code.
28
+ for f in $(ls /foo/bar/); do
29
+ cat $f >> $myfile;
30
+ done
31
+ EOS
32
+ ```
33
+
34
+ Now the `foo` variable contains the following string:
35
+
36
+ ```
37
+ This might be a usage banner for a cli tool. Or, it might be some javascript. Or maybe shell code.
38
+ for f in $(ls /foo/bar/); do
39
+ cat $f >> $myfile;
40
+ done
41
+ ```
42
+
43
+ One thing to note is that lines with no non-whitespaces characters are not considered when determining the
44
+ indentation of a text block:
45
+
46
+ ```
47
+ "\n foo".dedent # => "\nfoo"
48
+ ```
49
+
50
+ Author
51
+ ------
52
+
53
+ This gem was written by Caleb Spare ([cespare](https://github.com/cespare) on github). It was inspired by
54
+ [Coffeescript's heredocs](http://jashkenas.github.com/coffee-script/#strings).
55
+
56
+ License
57
+ -------
58
+
59
+ This project is release under the [MIT License](http://www.opensource.org/licenses/mit-license.php).
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,14 @@
1
+ require "testytest/version"
2
+
3
+ class String
4
+ def dedent
5
+ lines = split "\n"
6
+ return self if lines.empty?
7
+ indents = lines.map do |line|
8
+ line =~ /\S/ ? (line.start_with?(" ") ? line.match(/^ +/).offset(0)[1] : 0) : nil
9
+ end
10
+ min_indent = indents.compact.min
11
+ return self if min_indent.zero?
12
+ lines.map { |line| line =~ /\S/ ? line.gsub(/^ {#{min_indent}}/, "") : line }.join "\n"
13
+ end
14
+ end
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "testytest"
6
+ s.version = "0.0.1"
7
+ s.authors = ["Caleb Spare"]
8
+ s.email = ["cespare@gmail.com"]
9
+ s.homepage = "https://github.com/cespare/ruby-dedent"
10
+ s.summary = %q{Adds a dedent method to String.}
11
+ s.description = <<-EOS
12
+ This gem adds a dedent method to strings to strip leading spaces from each line while preserving indentation.
13
+ EOS
14
+
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
+ s.require_paths = ["lib"]
19
+
20
+ # specify any dependencies here; for example:
21
+ # s.add_development_dependency "rspec"
22
+ # s.add_runtime_dependency "rest-client"
23
+ end
metadata ADDED
@@ -0,0 +1,51 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: testytest
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Caleb Spare
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-05-27 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: |
14
+ This gem adds a dedent method to strings to strip leading spaces from each line while preserving indentation.
15
+ email:
16
+ - cespare@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .gitignore
22
+ - Gemfile
23
+ - LICENSE.txt
24
+ - README.md
25
+ - Rakefile
26
+ - lib/testytest.rb
27
+ - testytest.gemspec
28
+ homepage: https://github.com/cespare/ruby-dedent
29
+ licenses: []
30
+ metadata: {}
31
+ post_install_message:
32
+ rdoc_options: []
33
+ require_paths:
34
+ - lib
35
+ required_ruby_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ required_rubygems_version: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ requirements: []
46
+ rubyforge_project:
47
+ rubygems_version: 2.0.0
48
+ signing_key:
49
+ specification_version: 4
50
+ summary: Adds a dedent method to String.
51
+ test_files: []