subby 0.0.1.pre

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,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: e9be21c0f2a338fa8e4519600edf26b7970df2941ec94ac9e3c0a2177a6b3673
4
+ data.tar.gz: 6723a9f504781dda58f0fcc32682f05ea8db83b74577c6efa2bd916086ca2b25
5
+ SHA512:
6
+ metadata.gz: f4e2191bf09d3318c42751bf2148ed185ed1debb8cb5a8690d6da16f92a70249f10799ddcd85c2ba111571855968600a3c3b576248a73d08fa8016fcca32e861
7
+ data.tar.gz: '0085b020e7b00327173eebd841a8516d1c2b26825822091e9e817b7ef4e5714fb400d444db35d912d6adb179f489be1112290aae305023755bb9ca4c64f75508'
@@ -0,0 +1,114 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Uncomment to work locally.
4
+ # Not recommended for Gem release as Rubygems handles this.
5
+ # $LOAD_PATH << File.expand_path(File.dirname(__FILE__) + '/../lib')
6
+
7
+
8
+ # This file only gets the main require.
9
+ # Put *all* requires in lib/subby.rb
10
+ require 'subby'
11
+ require 'optparse'
12
+
13
+ ################################################################################
14
+ # Constants
15
+ ################################################################################
16
+
17
+ EXECUTABLE_NAME = File.basename($PROGRAM_NAME)
18
+ USAGE = "Usage: #{EXECUTABLE_NAME} [options] string_in string_out"
19
+ BANNER = "Substitutes a string and its case variations.\n" + USAGE
20
+ CASES = %w( camel class constant dash lower module sentence snake title
21
+ underscore upper )
22
+
23
+ ################################################################################
24
+ # Parse options
25
+ ################################################################################
26
+ options = {}
27
+ option_parser = OptionParser.new do |opts|
28
+
29
+ opts.banner = BANNER
30
+
31
+ opts.on("-i CASE_IN,...", "--case-in", Array,
32
+ "limit cases to #{CASES.join('|')}") do |ci|
33
+ if ci.any? { |c| !CASES.include? c }
34
+ raise OptionParser::InvalidArgument
35
+ else
36
+ options[:case_in] = ci
37
+ end
38
+ end
39
+
40
+ opts.on("-o CASE_OUT", "--case-out", CASES,
41
+ "convert all incoming to CASE_OUT") do |co|
42
+ options[:case_out] = co
43
+ end
44
+
45
+ end
46
+
47
+ # Handle invalid options
48
+ begin
49
+ option_parser.parse!
50
+ rescue OptionParser::InvalidArgument => ex
51
+ STDERR.puts ex.message
52
+ STDERR.puts
53
+ STDERR.puts option_parser
54
+ exit(1)
55
+ rescue OptionParser::InvalidOption => ex
56
+ STDERR.puts ex.message
57
+ STDERR.puts
58
+ STDERR.puts option_parser
59
+ exit(1)
60
+ end
61
+
62
+ ################################################################################
63
+ # Parse arguments
64
+ ################################################################################
65
+ if ARGV.count == 0
66
+ STDERR.puts option_parser.help
67
+ exit(1)
68
+ elsif ARGV.count == 1 && options[:case_out]
69
+ string_in = ARGV[0]
70
+ string_out = ARGV[0]
71
+ elsif ARGV.count == 1
72
+ STDERR.puts "Subby: expected string_in string_out, got string_in only\n"
73
+ STDERR.puts option_parser.help
74
+ exit(1)
75
+ elsif ARGV.count == 2
76
+ string_in = ARGV[0]
77
+ string_out = ARGV[1]
78
+ else
79
+ STDERR.puts "Subby: expected 2 arguments, got #{ARGV.count}\n\n"
80
+ STDERR.puts " If you are trying to pass text, use STDIN."
81
+ STDERR.puts " Example"
82
+ STDERR.puts " $ cat myfile.txt | subby old new\n\n"
83
+ STDERR.puts option_parser.help
84
+ exit(1)
85
+ end
86
+
87
+ ################################################################################
88
+ # IF NO FILE GET IT FROM TERMINAL
89
+ ################################################################################
90
+ # Handle ^C
91
+ Signal.trap("SIGINT") do
92
+ STDERR.puts
93
+ exit 1
94
+ end
95
+
96
+ if STDIN.tty?
97
+ # sed / tr style Read Eval Print Loop
98
+ while true
99
+ # Handle EOF
100
+ if STDIN.eof?
101
+ exit 0
102
+ end
103
+ input = STDIN.gets.chomp
104
+ STDOUT.puts Subby.sub( input, string_in, string_out, options )
105
+ end
106
+ ################################################################################
107
+ # ELSE WE HAVE A FILE
108
+ ################################################################################
109
+ else
110
+ input = STDIN.read.chomp
111
+ STDOUT.puts Subby.sub( input, string_in, string_out, options )
112
+ exit 0
113
+ end
114
+
@@ -0,0 +1,4 @@
1
+ # Only put require's here!
2
+ require 'subby/base.rb'
3
+ require 'subby/case_changer.rb'
4
+
@@ -0,0 +1,90 @@
1
+ require 'subby/case_changer.rb'
2
+
3
+ module Subby
4
+ #
5
+ # Cases and Examples
6
+ # Case Example
7
+ # -------------------------------
8
+ # camel applePie
9
+ # class | module ApplePie
10
+ # constant APPLE_PIE
11
+ # dash apple-pie
12
+ # lower apple pie
13
+ # sentence Apple pie
14
+ # snake | underscore apple_pie
15
+ # title Apple Pie
16
+ # upper APPLE PIE
17
+ CASES = %w( camel class constant dash lower module sentence snake title underscore upper )
18
+
19
+ # Substitutes string case variations in text.
20
+ # By default this method command is *greedy*.
21
+ # It will substitute all string_in case variations that it knows.
22
+ # The case variations with examples are listed above in the +CASES+ constant.
23
+ #
24
+ # @example Default usage
25
+ # Subby.sub("apple pie applePie apple_pie", "applePie", "chocolateCake")
26
+ # # => "chocolate cake chocolateCake chocolate_cake"
27
+ #
28
+ # @example Change one case to another
29
+ # Subby.sub("apple pie applePie apple_pie", "applePie", "applePie",
30
+ # :case_in => :camel,
31
+ # :case_out => :snake)
32
+ # # => "apple pie apple_pie apple_pie"
33
+ #
34
+ # @example Only target certain cases
35
+ # Subby.sub("apple pie applePie apple_pie", "applePie", "chocolateCake",
36
+ # :case_in => [:camel, :snake])
37
+ # # => "apple pie chocolateCake chocolate_cake"
38
+ #
39
+ # @param text [String] The text to be scanned for substitutions.
40
+ # @param string_in [String] The string to be replaced.
41
+ # @param string_out [String] The replacement string.
42
+ # @param opts [Hash] Options
43
+ # * +:case_in+: Takes a CASE or [CASE]. Operates only on the given cases in
44
+ # order specified.
45
+ # * +:case_out+: Takes a CASE. All incoming cases will be converted to this
46
+ # case.
47
+ # @return [String]
48
+ def self.sub( text="", string_in="", string_out="", opts={} )
49
+
50
+ # Setup
51
+ res = text.to_s
52
+ case_in = self.normalize_options( opts )[:case_in]
53
+ case_out = self.normalize_options( opts )[:case_out]
54
+
55
+ # Main Loop
56
+ case_in.each do |case_in|
57
+ res = res.gsub(
58
+ CaseChanger.send( case_in, string_in ),
59
+ CaseChanger.send( (case_out || case_in), string_out) )
60
+ end
61
+
62
+ res
63
+ end
64
+
65
+ private
66
+
67
+ CASES_TO_METHOD = {
68
+ "camel" => :to_camelcase,
69
+ "class" => :to_modulecase,
70
+ "constant" => :to_constantcase,
71
+ "dash" => :to_dashcase,
72
+ "lower" => :to_lowercase,
73
+ "module" => :to_modulecase,
74
+ "snake" => :to_underscorecase,
75
+ "sentence" => :to_sentencecase,
76
+ "title" => :to_titlecase,
77
+ "underscore" => :to_underscorecase,
78
+ "upper" => :to_uppercase
79
+ }
80
+
81
+ def self.normalize_options( opts )
82
+ case_in = ( (opts[:case_in] && [opts[:case_in]].flatten.map(&:to_s)) || CASES).
83
+ map { |c| CASES_TO_METHOD[c] }.uniq
84
+ case_out = CASES_TO_METHOD[opts[:case_out].to_s]
85
+
86
+ { case_in: case_in, case_out: case_out }
87
+ end
88
+
89
+ end
90
+
@@ -0,0 +1,101 @@
1
+
2
+ require 'active_support/core_ext/string/inflections.rb'
3
+
4
+ # Subby is a module for substituting string case variations.
5
+ #
6
+ # It has one class method, *::sub*, and a supporting sub-module
7
+ # which converts the strings from one case to another.
8
+ module Subby
9
+
10
+ # CaseChanger is a module for converting strings from one case to another.
11
+ module CaseChanger
12
+
13
+ # Convert string to camel-case.
14
+ # @example
15
+ # CaseChanger.to_camelcase("apple pie") # => "applePie"
16
+ # @param str [String] Argument need only respond to +to_s+.
17
+ # @return [String]
18
+ def self.to_camelcase( str )
19
+ str.to_s.camelize(:lower)
20
+ end
21
+
22
+ # Convert string to class-case.
23
+ # @example
24
+ # CaseChanger.to_classcase("applePie") # => "ApplePie"
25
+ # +to_classcase+ is also aliased as +to_modulecase+.
26
+ # @param str [String] Argument need only respond to +to_s+.
27
+ # @return [String]
28
+ def self.to_classcase( str )
29
+ str.to_s.camelize(:upper)
30
+ end
31
+
32
+ # Convert string to constant-case.
33
+ # @example
34
+ # CaseChanger.to_constantcase("applePie") # => "APPLE_PIE"
35
+ # @param str [String] Argument need only respond to +to_s+.
36
+ # @return [String]
37
+ def self.to_constantcase( str )
38
+ str.to_s.underscore.upcase
39
+ end
40
+
41
+ # Convert string to dash-case.
42
+ # @example
43
+ # CaseChanger.to_constantcase("applePie") # => "apple-pie"
44
+ # @param str [String] Argument need only respond to +to_s+.
45
+ # @return [String]
46
+ def self.to_dashcase( str )
47
+ str.to_s.underscore.dasherize
48
+ end
49
+
50
+ # Convert string to lower-case.
51
+ # @example
52
+ # CaseChanger.to_lowercase("applePie") # => "apple pie"
53
+ # @param str [String] Argument need only respond to +to_s+.
54
+ # @return [String]
55
+ def self.to_lowercase( str )
56
+ str.to_s.underscore.tr('_', ' ')
57
+ end
58
+
59
+ # Convert string to sentence-case.
60
+ # @example
61
+ # CaseChanger.to_sentencecase("applePie") # => "Apple pie"
62
+ # @param str [String] Argument need only respond to +to_s+.
63
+ # @return [String]
64
+ def self.to_sentencecase( str )
65
+ str.to_s.underscore.tr('_', ' ').capitalize
66
+ end
67
+
68
+ # Convert string to underscore-case.
69
+ # @example
70
+ # CaseChanger.to_underscorecase("applePie") # => "apple_pie"
71
+ # +to_snakecase+ is also aliased as +to_underscorecase+.
72
+ # @param str [String] Argument need only respond to +to_s+.
73
+ # @return [String]
74
+ def self.to_snakecase( str )
75
+ str.to_s.underscore
76
+ end
77
+
78
+ # Convert string to title-case.
79
+ # @example
80
+ # CaseChanger.to_titlecase("applePie") # => "Apple Pie"
81
+ # @param str [String] Argument need only respond to +to_s+.
82
+ # @return [String]
83
+ def self.to_titlecase( str )
84
+ str.to_s.underscore.tr('_', ' ').split.map(&:capitalize).join(' ')
85
+ end
86
+
87
+ # Convert string to upper-case.
88
+ # @example
89
+ # CaseChanger.to_uppercase("applePie") # => "APPLE PIE"
90
+ # @param str [String] Argument need only respond to +to_s+.
91
+ # @return [String]
92
+ def self.to_uppercase( str )
93
+ str.to_s.underscore.tr('_', ' ').upcase
94
+ end
95
+
96
+ singleton_class.send(:alias_method, :to_modulecase, :to_classcase)
97
+ singleton_class.send(:alias_method, :to_underscorecase, :to_snakecase)
98
+
99
+ end
100
+ end
101
+
@@ -0,0 +1,145 @@
1
+ .\" generated with Ronn/v0.7.3
2
+ .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
+ .
4
+ .TH "SUBBY" "1" "August 2018" "" ""
5
+ .
6
+ .SH "NAME"
7
+ \fBsubby\fR
8
+ .
9
+ .SH "SYNOPSIS"
10
+ \fBsubby\fR \fIstring_in\fR \fIstring_out\fR
11
+ .
12
+ .br
13
+ \fBsubby\fR [\fB\-i\fR \fIcase_in\fR\.\.\.] [\fB\-o\fR \fIcase_out\fR] \fIstring_in\fR \fIstring_out\fR
14
+ .
15
+ .br
16
+ \fBsubby\fR [\fB\-i\fR \fIcase_in\fR\.\.\.] \fB\-o\fR \fIcase_out\fR \fIstring_in\fR [\fIstring_out\fR]
17
+ .
18
+ .br
19
+ .
20
+ .SH "DESCRIPTION"
21
+ \fBSubby\fR is a command\-line tool for substituting string case variations\.
22
+ .
23
+ .P
24
+ \fBSubby\fR reads from standard input and writes to standard output\.
25
+ .
26
+ .P
27
+ By default \fBsubby\fR is greedy\. It will substitute the 9 \fIstring_in\fR case variations that it knows\.
28
+ .
29
+ .P
30
+ Here\'s the list of cases that \fBsubby\fR handles\. Note that class and module are synonyms, as are snake and underscore, Also note that camel does not have an upper and lower case form\. Upper camel is called class or module\.
31
+ .
32
+ .IP "" 4
33
+ .
34
+ .nf
35
+
36
+ CASE EXAMPLE
37
+ =====================================
38
+ camel applePie
39
+ class | module ApplePie
40
+ constant APPLE_PIE
41
+ dash apple\-pie
42
+ lower apple pie
43
+ sentence Apple pie
44
+ snake | underscore apple_pie
45
+ title Apple Pie
46
+ upper APPLE PIE
47
+ .
48
+ .fi
49
+ .
50
+ .IP "" 0
51
+ .
52
+ .P
53
+ If you wish to limit the cases that \fBsubby\fR matches pass the \fB\-i\fR option with a comma\-separated list of desired cases\.
54
+ .
55
+ .P
56
+ If you wish to change the order of substitution \fBsubby\fR will follow the order given in the \fB\-i\fR option\. By default \fBsubby\fR will use the order given in the table above\.
57
+ .
58
+ .P
59
+ If you wish to convert all incoming cases to one particular case pass the \fB\-o\fR option with your desired case\. You may omit \fIstring_out\fR if it\'s the same as \fIstring_in\fR when using \fB\-o\fR\.
60
+ .
61
+ .P
62
+ If you wish to map case variations from one to another, note that \fB\-i\fR takes an array, while \fB\-o\fR does not\. A separate \fBsubby\fR command would be required for each unique outcome variation\.
63
+ .
64
+ .SH "OPTIONS"
65
+ .
66
+ .IP "\(bu" 4
67
+ \fB\-i\fR, \fB\-\-case\-in CASE_IN\.\.\.\fR:
68
+ .
69
+ .br
70
+ acts as a filter/array for the list of cases to match
71
+ .
72
+ .br
73
+ valid arguments are the following:
74
+ .
75
+ .br
76
+ camel|class|constant|dash|lower|module|sentence|snake|title|underscore|upper
77
+ .
78
+ .br
79
+ default is all of the above
80
+ .
81
+ .IP "\(bu" 4
82
+ \fB\-o\fR, \fB\-\-case\-out CASE_OUT\fR:
83
+ .
84
+ .br
85
+ all incoming strings will be converted to this case
86
+ .
87
+ .br
88
+ valid arguments are the following:
89
+ .
90
+ .br
91
+ camel|class|constant|dash|lower|module|sentence|snake|title|underscore|upper
92
+ .
93
+ .br
94
+ default is match (to CASE_IN)
95
+ .
96
+ .IP "" 0
97
+ .
98
+ .SH "EXAMPLES"
99
+ .
100
+ .IP "\(bu" 4
101
+ Replace \'applePie\' variations with \'chocolateCake\':
102
+ .
103
+ .IP
104
+ \fB$ cat apple_pie\.txt\fR
105
+ .
106
+ .br
107
+ applePie apple_pie ApplePie ApplePies
108
+ .
109
+ .IP
110
+ \fB$ subby applePie chocolateCake < apple_pie\.txt\fR
111
+ .
112
+ .IP
113
+ chocolateCake chocolate_cake ChocolateCake ChocolateCakes
114
+ .
115
+ .IP "\(bu" 4
116
+ Limit which cases to process:
117
+ .
118
+ .IP
119
+ \fB$ subby \-i camel,snake applePie chocolateCake < apple_pie\.txt\fR
120
+ .
121
+ .br
122
+ chocolateCake chocolate_cake ApplePie ApplePies
123
+ .
124
+ .IP "\(bu" 4
125
+ Convert camel\-cases to snake\-cases\.
126
+ .
127
+ .IP
128
+ \fB$ subby \-i camel \-o snake applePie chocolateCake < apple_pie\.txt\fR
129
+ .
130
+ .br
131
+ chocolateCake chocolate_cake ApplePie ApplePies
132
+ .
133
+ .IP "" 0
134
+ .
135
+ .SH "LIMITATIONS"
136
+ Substituting strings "recursively" may yield undesired results\. Consider this example\.
137
+ .
138
+ .P
139
+ \fB$ echo "a" | subby a aa\fR
140
+ .
141
+ .br
142
+ aaaaaaaaaaaaaaaa
143
+ .
144
+ .P
145
+ The run on of aaa\'s happens because \fBsubby\fR runs 9 separate substitute commands, each time substituting "aa" for "a"\. This behavior will most likely change in the future\.
@@ -0,0 +1,180 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv='content-type' value='text/html;charset=utf8'>
5
+ <meta name='generator' value='Ronn/v0.7.3 (http://github.com/rtomayko/ronn/tree/0.7.3)'>
6
+ <title>subby(1)</title>
7
+ <style type='text/css' media='all'>
8
+ /* style: man */
9
+ body#manpage {margin:0}
10
+ .mp {max-width:100ex;padding:0 9ex 1ex 4ex}
11
+ .mp p,.mp pre,.mp ul,.mp ol,.mp dl {margin:0 0 20px 0}
12
+ .mp h2 {margin:10px 0 0 0}
13
+ .mp > p,.mp > pre,.mp > ul,.mp > ol,.mp > dl {margin-left:8ex}
14
+ .mp h3 {margin:0 0 0 4ex}
15
+ .mp dt {margin:0;clear:left}
16
+ .mp dt.flush {float:left;width:8ex}
17
+ .mp dd {margin:0 0 0 9ex}
18
+ .mp h1,.mp h2,.mp h3,.mp h4 {clear:left}
19
+ .mp pre {margin-bottom:20px}
20
+ .mp pre+h2,.mp pre+h3 {margin-top:22px}
21
+ .mp h2+pre,.mp h3+pre {margin-top:5px}
22
+ .mp img {display:block;margin:auto}
23
+ .mp h1.man-title {display:none}
24
+ .mp,.mp code,.mp pre,.mp tt,.mp kbd,.mp samp,.mp h3,.mp h4 {font-family:monospace;font-size:14px;line-height:1.42857142857143}
25
+ .mp h2 {font-size:16px;line-height:1.25}
26
+ .mp h1 {font-size:20px;line-height:2}
27
+ .mp {text-align:justify;background:#fff}
28
+ .mp,.mp code,.mp pre,.mp pre code,.mp tt,.mp kbd,.mp samp {color:#131211}
29
+ .mp h1,.mp h2,.mp h3,.mp h4 {color:#030201}
30
+ .mp u {text-decoration:underline}
31
+ .mp code,.mp strong,.mp b {font-weight:bold;color:#131211}
32
+ .mp em,.mp var {font-style:italic;color:#232221;text-decoration:none}
33
+ .mp a,.mp a:link,.mp a:hover,.mp a code,.mp a pre,.mp a tt,.mp a kbd,.mp a samp {color:#0000ff}
34
+ .mp b.man-ref {font-weight:normal;color:#434241}
35
+ .mp pre {padding:0 4ex}
36
+ .mp pre code {font-weight:normal;color:#434241}
37
+ .mp h2+pre,h3+pre {padding-left:0}
38
+ ol.man-decor,ol.man-decor li {margin:3px 0 10px 0;padding:0;float:left;width:33%;list-style-type:none;text-transform:uppercase;color:#999;letter-spacing:1px}
39
+ ol.man-decor {width:100%}
40
+ ol.man-decor li.tl {text-align:left}
41
+ ol.man-decor li.tc {text-align:center;letter-spacing:4px}
42
+ ol.man-decor li.tr {text-align:right;float:right}
43
+ </style>
44
+ </head>
45
+ <!--
46
+ The following styles are deprecated and will be removed at some point:
47
+ div#man, div#man ol.man, div#man ol.head, div#man ol.man.
48
+
49
+ The .man-page, .man-decor, .man-head, .man-foot, .man-title, and
50
+ .man-navigation should be used instead.
51
+ -->
52
+ <body id='manpage'>
53
+ <div class='mp' id='man'>
54
+
55
+ <div class='man-navigation' style='display:none'>
56
+ <a href="#NAME">NAME</a>
57
+ <a href="#SYNOPSIS">SYNOPSIS</a>
58
+ <a href="#DESCRIPTION">DESCRIPTION</a>
59
+ <a href="#OPTIONS">OPTIONS</a>
60
+ <a href="#EXAMPLES">EXAMPLES</a>
61
+ <a href="#LIMITATIONS">LIMITATIONS</a>
62
+ </div>
63
+
64
+ <ol class='man-decor man-head man head'>
65
+ <li class='tl'>subby(1)</li>
66
+ <li class='tc'></li>
67
+ <li class='tr'>subby(1)</li>
68
+ </ol>
69
+
70
+ <h2 id="NAME">NAME</h2>
71
+ <p class="man-name">
72
+ <code>subby</code>
73
+ </p>
74
+ <h2 id="SYNOPSIS">SYNOPSIS</h2>
75
+
76
+ <p><code>subby</code> <var>string_in</var> <var>string_out</var><br />
77
+ <code>subby</code> [<code>-i</code> <var>case_in</var>...] [<code>-o</code> <var>case_out</var>] <var>string_in</var> <var>string_out</var><br />
78
+ <code>subby</code> [<code>-i</code> <var>case_in</var>...] <code>-o</code> <var>case_out</var> <var>string_in</var> [<var>string_out</var>]<br /></p>
79
+
80
+ <h2 id="DESCRIPTION">DESCRIPTION</h2>
81
+
82
+ <p><strong>Subby</strong> is a command-line tool for substituting string case variations.</p>
83
+
84
+ <p><strong>Subby</strong> reads from standard input and writes to standard output.</p>
85
+
86
+ <p>By default <strong>subby</strong> is greedy. It will substitute the 9 <var>string_in</var>
87
+ case variations that it knows.</p>
88
+
89
+ <p>Here's the list of cases that <strong>subby</strong> handles.
90
+ Note that class and module are synonyms, as are snake and underscore,
91
+ Also note that camel does not have an upper and lower case form. Upper camel
92
+ is called class or module.</p>
93
+
94
+ <pre><code>CASE EXAMPLE
95
+ =====================================
96
+ camel applePie
97
+ class | module ApplePie
98
+ constant APPLE_PIE
99
+ dash apple-pie
100
+ lower apple pie
101
+ sentence Apple pie
102
+ snake | underscore apple_pie
103
+ title Apple Pie
104
+ upper APPLE PIE
105
+ </code></pre>
106
+
107
+ <p>If you wish to limit the cases that <strong>subby</strong> matches pass the <code>-i</code> option with a
108
+ comma-separated list of desired cases.</p>
109
+
110
+ <p>If you wish to change the order of substitution <strong>subby</strong> will follow the order given in
111
+ the <code>-i</code> option. By default <strong>subby</strong> will use the order given in the table above.</p>
112
+
113
+ <p>If you wish to convert all incoming cases to one particular case pass the
114
+ <code>-o</code> option with your desired case. You may omit <var>string_out</var> if it's the same
115
+ as <var>string_in</var> when using <code>-o</code>.</p>
116
+
117
+ <p>If you wish to map case variations from one to another, note that <code>-i</code> takes an
118
+ array, while <code>-o</code> does not. A separate <code>subby</code> command would be
119
+ required for each unique outcome variation.</p>
120
+
121
+ <h2 id="OPTIONS">OPTIONS</h2>
122
+
123
+ <ul>
124
+ <li><code>-i</code>, <code>--case-in CASE_IN...</code>:<br />
125
+ acts as a filter/array for the list of cases to match<br />
126
+ valid arguments are the following:<br />
127
+ camel|class|constant|dash|lower|module|sentence|snake|title|underscore|upper<br />
128
+ default is all of the above</li>
129
+ <li><code>-o</code>, <code>--case-out CASE_OUT</code>: <br />
130
+ all incoming strings will be converted to this case<br />
131
+ valid arguments are the following:<br />
132
+ camel|class|constant|dash|lower|module|sentence|snake|title|underscore|upper<br />
133
+ default is match (to CASE_IN)</li>
134
+ </ul>
135
+
136
+
137
+ <h2 id="EXAMPLES">EXAMPLES</h2>
138
+
139
+ <ul>
140
+ <li><p>Replace 'applePie' variations with 'chocolateCake':</p>
141
+
142
+ <p><code>$ cat apple_pie.txt</code><br />
143
+ applePie apple_pie ApplePie ApplePies</p>
144
+
145
+ <p><code>$ subby applePie chocolateCake &lt; apple_pie.txt</code></p>
146
+
147
+ <p>chocolateCake chocolate_cake ChocolateCake ChocolateCakes</p></li>
148
+ <li><p>Limit which cases to process:</p>
149
+
150
+ <p><code>$ subby -i camel,snake applePie chocolateCake &lt; apple_pie.txt</code><br />
151
+ chocolateCake chocolate_cake ApplePie ApplePies</p></li>
152
+ <li><p>Convert camel-cases to snake-cases.</p>
153
+
154
+ <p><code>$ subby -i camel -o snake applePie chocolateCake &lt; apple_pie.txt</code><br />
155
+ chocolateCake chocolate_cake ApplePie ApplePies</p></li>
156
+ </ul>
157
+
158
+
159
+ <h2 id="LIMITATIONS">LIMITATIONS</h2>
160
+
161
+ <p>Substituting strings "recursively" may yield undesired results.
162
+ Consider this example.</p>
163
+
164
+ <p> <code>$ echo "a" | subby a aa</code> <br />
165
+ aaaaaaaaaaaaaaaa</p>
166
+
167
+ <p>The run on of aaa's happens because <strong>subby</strong> runs 9 separate substitute commands,
168
+ each time substituting "aa" for "a". This behavior will most likely change
169
+ in the future.</p>
170
+
171
+
172
+ <ol class='man-decor man-foot man foot'>
173
+ <li class='tl'></li>
174
+ <li class='tc'>August 2018</li>
175
+ <li class='tr'>subby(1)</li>
176
+ </ol>
177
+
178
+ </div>
179
+ </body>
180
+ </html>
metadata ADDED
@@ -0,0 +1,121 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: subby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.pre
5
+ platform: ruby
6
+ authors:
7
+ - Kevin Jackson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-09-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: minitest
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '5'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '5'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10'
55
+ - !ruby/object:Gem::Dependency
56
+ name: ronn
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: yard
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: "Subby is a command-line tool for substituting string case\n variations.\n
84
+ \ "
85
+ email:
86
+ - kj31428@gmail.com
87
+ executables:
88
+ - subby
89
+ extensions: []
90
+ extra_rdoc_files: []
91
+ files:
92
+ - bin/subby
93
+ - lib/subby.rb
94
+ - lib/subby/base.rb
95
+ - lib/subby/case_changer.rb
96
+ - man/subby.1
97
+ - man/subby.1.html
98
+ homepage:
99
+ licenses: []
100
+ metadata: {}
101
+ post_install_message: Thanks for installing!
102
+ rdoc_options: []
103
+ require_paths:
104
+ - lib
105
+ required_ruby_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ required_rubygems_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ">"
113
+ - !ruby/object:Gem::Version
114
+ version: 1.3.1
115
+ requirements: []
116
+ rubyforge_project:
117
+ rubygems_version: 2.7.6
118
+ signing_key:
119
+ specification_version: 4
120
+ summary: Substitutes string case variations.
121
+ test_files: []