
Product
Introducing Socket Fix for Safe, Automated Dependency Upgrades
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
= Indentation
== DESCRIPTION:
A small library of extensions to Ruby's Array and String classes that allow indentation manipulation of Strings and Arrays of Strings. Has the capability of working with multi-line strings. If you frequently use String arrays to manipulate text, see synopsis (In README.rdoc) for examples of how indentation can make your life easier.
== EXAMPLES:
=== Indent
"test".indent # => " test"
"test".indent(3) # => " test"
"test".indent(2, "\t") # => "\t\ttest"
"this\nis\na\ntest".indent # => " this\n is\n a\n test"
" test".indent(-1) # => " test"
"\t test".indent(-5) # => "test"
"\t-- Test".indent(-10) # => "-- Test"
"\t-- Test".indent(-10, '-') # => "Test"
"--- Test".indent(-2, '--') # => "- Test"
["one", "two"].indent # => [" one", " two"]
[["one", " two"], ["uno", "\t\tdos"]].indent # => [[" one", " two"], [" uno", " \t\tdos"]]
=== Reset Indentation
" def method_name\n # Do stuff\n end".reset_indentation # => "def method_name\n # Do stuff\nend"
[" def method_name", " # Do stuff", " end"].reset_indentation # => ["def method_name", " # Do stuff", "end"]
my_string = <<-EOS.chomp.reset_indentation
def method_name
# Do stuff
end
EOS
my_string # => "def method_name\n # Do stuff\nend"
" one\n two".reset_indentation(1) # => " one\n two"
" one\n two".reset_indentation(0) # => " one\ntwo" # Default behavior
" one\n two".reset_indentation(-1) # => "one\ntwo"
=== Append Separator
["arg1", "arg2", "arg3"].append_separator("!") # => ["arg1!", "arg2!", "arg3"]
[["line1"], ["line2"], ["line3"]].append_separator("") # => [["line1", ""], ["line2", ""], ["line3"]]
[["line1", "line2"], ["line3", "line4"]].append_separator("") # => [["line1", "line2", ""], ["line3", "line4"]]
vars = ["var1", "var2", "var3", "var4"]
method_def = ["def add_up(#{vars.join(', ')})"]
method_body = vars.append_separator(" + ")
method_def += method_body.indent
method_def << "end"
method_def.join("\n") # =>
# def add_up(var1, var2, var3, var4)
# var1 +
# var2 +
# var3 +
# var4
# end
test_array = [["this", "is", "a", "test"], ["quick", "brown", "fox"], ["lazy", "typist"]]
test_array.append_separator("").join("\n") # =>
# this
# is
# a
# test
#
# quick
# brown
# fox
#
# lazy
# typist
=== Find Least Indentation
" test".find_least_indentation # => 2 " three\n two \n one".find_least_indentation # => 1 [" two", " three", " four"].find_least_indentation # => 2 [" two", " three", [" four", " five\n one"]].find_least_indentation # => 1
" three\n".find_least_indentation # => 3
" three\n".find_least_indentation(:ignore_blank_lines => false) # => 0
" three\n ".find_least_indentation # => 3
" three\n ".find_least_indentation(:ignore_empty_lines => false) # => 1
" three\n".find_least_indentation # => 3
" three\n".find_least_indentation(:ignore_empty_lines => false) # => 0
" three\n ".find_least_indentation(:ignore_blank_lines => true, :ignore_empty_lines => false) # => 1
" three\n".find_least_indentation(:ignore_blank_lines => true, :ignore_empty_lines => false) # => 3
=== English Array Join
['one', 'two'].english_join # => "one and two" ['one', 'two', 'three'].english_join # => "one, two, and three"
['one', 'two', 'three'].english_join('or') # => "one, two, or three"
['one', 'two', 'three'].english_join('or', ' ') # => "one two or three"
== REQUIREMENTS:
== INSTALL:
== LICENSE:
(The MIT License)
Copyright (c) 2010 Prometheus Computing
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:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
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.
FAQs
Unknown package
We found that indentation demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
Security News
CISA denies CVE funding issues amid backlash over a new CVE foundation formed by board members, raising concerns about transparency and program governance.
Product
We’re excited to announce a powerful new capability in Socket: historical data and enhanced analytics.