rbsubst 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +22 -0
  3. data/bin/rbsubst +61 -0
  4. data/rbsubst.gemspec +13 -0
  5. metadata +47 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 13eeef2aafe81496b5c5682eed2f2b6cd21e6853
4
+ data.tar.gz: dba1b69931f538be048b39a64e2179a2db34ec5c
5
+ SHA512:
6
+ metadata.gz: 9b9eb13a0cd6bc5350d624dc5b5b114f993dae1abfe06bad2dfbc13aab32e80c43439bb42ee40b06a62d84b9317706204c758b19afb701e16ae3eecafa4c812d
7
+ data.tar.gz: 741f7868ba046ec0937cf0a74f3b611d95782c33e746e1246405e23a7fe312b77e2da072b5bb8aeb61ec7778e9470da66808d35154b191d688fb4e36c36d99c0
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014, Brice Videau <brice.videau@imag.fr>
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+
7
+ 1. Redistributions of source code must retain the above copyright notice, this
8
+ list of conditions and the following disclaimer.
9
+ 2. Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+
13
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
14
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
17
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/bin/rbsubst ADDED
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env ruby
2
+ RBS_BINDING = binding
3
+ require 'stringio'
4
+ require 'optparse'
5
+
6
+ options = {:prefix => "#!RB!#", :string_marker => "EOF_RB"}
7
+ parser = OptionParser.new do |opts|
8
+ opts.banner = "Usage: rbsubst [options] [file1 file2 ...]"
9
+ opts.separator <<EOF
10
+ Process the standard input or given text files treating lines starting by PREFIX
11
+ as ruby script. Non ruby lines are treated using ruby string substitutions.
12
+ Options:
13
+ EOF
14
+ opts.on("-d", "--[no-]debug", "Print the generated script on standard error") do |v|
15
+ options[:debug] = v
16
+ end
17
+ opts.on("--prefix PREFIX", "Prefix to be used (default #{options[:prefix]})") do |prefix|
18
+ options[:prefix] = prefix
19
+ end
20
+ opts.on("--marker MARKER", "Marker to delimit strings (default #{options[:string_marker]})") do |marker|
21
+ options[:string_marker] = marker
22
+ end
23
+ opts.on_tail("-h", "--help", "Show this message") do
24
+ puts opts
25
+ exit
26
+ end
27
+ end
28
+ parser.parse!
29
+
30
+ prefix = options[:prefix]
31
+ string_marker = options[:string_marker]
32
+
33
+ prog_input = StringIO::new
34
+ intext=false
35
+ ARGF.each_line { |l|
36
+ if l.match(/\A\s*#{prefix}/) then
37
+ if intext then
38
+ prog_input.puts string_marker
39
+ intext = false
40
+ end
41
+ l = l.gsub(prefix,"")
42
+ else
43
+ if not intext then
44
+ prog_input.puts "print <<#{string_marker}"
45
+ intext = true
46
+ end
47
+ end
48
+ prog_input.print l
49
+ }
50
+ if intext then
51
+ prog_input.puts unless prog_input.string.end_with?("\n")
52
+ prog_input.puts string_marker if intext
53
+ end
54
+
55
+ if options[:debug] then
56
+ prog_input.rewind
57
+ STDERR.puts prog_input.read
58
+ end
59
+
60
+ prog_input.rewind
61
+ eval(prog_input.read, RBS_BINDING)
data/rbsubst.gemspec ADDED
@@ -0,0 +1,13 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'rbsubst'
3
+ s.version = "1.0.0"
4
+ s.author = "Brice Videau"
5
+ s.email = "brice.videau@imag.fr"
6
+ s.homepage = "https://github.com/Nanosim-LIG/rbsubst"
7
+ s.summary = "Use ruby as a preprocessor."
8
+ s.files = %w( rbsubst.gemspec LICENSE bin/rbsubst)
9
+ s.executable = "rbsubst"
10
+ s.has_rdoc = false
11
+ s.license = 'BSD'
12
+ s.required_ruby_version = '>= 1.8.7'
13
+ end
metadata ADDED
@@ -0,0 +1,47 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rbsubst
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Brice Videau
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-11-09 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email: brice.videau@imag.fr
15
+ executables:
16
+ - rbsubst
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - LICENSE
21
+ - bin/rbsubst
22
+ - rbsubst.gemspec
23
+ homepage: https://github.com/Nanosim-LIG/rbsubst
24
+ licenses:
25
+ - BSD
26
+ metadata: {}
27
+ post_install_message:
28
+ rdoc_options: []
29
+ require_paths:
30
+ - lib
31
+ required_ruby_version: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: 1.8.7
36
+ required_rubygems_version: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ requirements: []
42
+ rubyforge_project:
43
+ rubygems_version: 2.2.2
44
+ signing_key:
45
+ specification_version: 4
46
+ summary: Use ruby as a preprocessor.
47
+ test_files: []