grinc 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,13 +3,13 @@
3
3
  Gem::Specification.new do |s|
4
4
 
5
5
  s.name = 'grinc'
6
- s.version = '0.1.1'
7
- s.date = '2011-03-26'
6
+ s.version = '0.1.2'
7
+ s.date = '2011-03-27'
8
8
  s.summary = 'Command line include file preprocessor'
9
9
  s.authors = ['Brian M. Clapper']
10
10
  s.license = 'BSD'
11
11
  s.email = 'bmc@clapper.org'
12
- s.homepage = 'http://software.clapper.org/grinc'
12
+ s.homepage = 'http://software.clapper.org/grinc/'
13
13
 
14
14
  s.description = <<-ENDDESC
15
15
  grinc runs an include file preprocessor on one or more files, writing the
@@ -53,6 +53,7 @@ module Grizzled
53
53
 
54
54
  DEFAULT_MAX_NEST = 100
55
55
  PROGRAM_NAME = 'grinc'
56
+ THIS_GEM_PATH = 'grizzled/grinc'
56
57
 
57
58
  # -----------------------------------------------------------------------
58
59
  # Classes
@@ -62,9 +63,13 @@ module Grizzled
62
63
  attr_reader :output, :max_nesting, :input_paths
63
64
 
64
65
  def initialize(options_hash, argv)
65
- @output = options_hash[:output]
66
- @max_nesting = options_hash[:max_nesting] || DEFAULT_MAX_NEST
67
- @input_paths = argv.length == 0 ? nil : argv
66
+ @options = options_hash
67
+ @options[:max_nesting] = options_hash[:max_nesting] || DEFAULT_MAX_NEST
68
+ @options[:input_paths] = argv.length == 0 ? nil : argv
69
+ end
70
+
71
+ def method_missing(m, *args, &block)
72
+ @options[m]
68
73
  end
69
74
 
70
75
  def to_s
@@ -81,14 +86,10 @@ module Grizzled
81
86
  def run
82
87
  begin
83
88
  params = parse_params
84
- out = params.output.nil? ? $stderr : File.open(params.output, 'w')
85
-
86
- if params.input_paths.nil?
87
- process_include($stdin, out, params.max_nesting)
89
+ if params.show_version
90
+ show_version_only
88
91
  else
89
- params.input_paths.each do |f|
90
- process_include(File.open(f), out, params.max_nesting)
91
- end
92
+ run_includer params
92
93
  end
93
94
 
94
95
  rescue UsageError
@@ -107,6 +108,30 @@ module Grizzled
107
108
  end
108
109
  end
109
110
 
111
+ private
112
+
113
+ def show_version_only
114
+ gem_spec = Gem.searcher.find(THIS_GEM_PATH)
115
+ if not gem_spec
116
+ raise StandardError.new("Can't find Gem specification for path \"" +
117
+ "#{THIS_GEM_PATH}\".")
118
+ end
119
+ puts("#{PROGRAM_NAME}, version #{gem_spec.version}. " +
120
+ "#{gem_spec.homepage}")
121
+ end
122
+
123
+ def run_includer(params)
124
+ out = params.output.nil? ? $stderr : File.open(params.output, 'w')
125
+
126
+ if params.input_paths.nil?
127
+ process_include($stdin, out, params.max_nesting)
128
+ else
129
+ params.input_paths.each do |f|
130
+ process_include(File.open(f), out, params.max_nesting)
131
+ end
132
+ end
133
+ end
134
+
110
135
  def parse_params
111
136
  options_hash = {}
112
137
  error = nil
@@ -127,6 +152,10 @@ module Grizzled
127
152
  end
128
153
  options_hash[:max_nesting] = n.to_i
129
154
  end
155
+
156
+ opts.on('-V', '--version', 'Display version number and exit.') do
157
+ options_hash[:show_version] = true
158
+ end
130
159
  end
131
160
 
132
161
  begin
@@ -7,7 +7,7 @@
7
7
  \fBgrinc\fR \- Process includes on a text file
8
8
  .
9
9
  .SH "SYNOPSIS"
10
- \fBgrinc\fR [\-o output | \-\-output output] [\-n maxnest | \-\-maxnest maxnest] [files]
10
+ \fBgrinc\fR [\-o output | \-\-output output] [\-n N | \-\-nesting N] [files]
11
11
  .
12
12
  .SH "DESCRIPTION"
13
13
  \fIgrinc\fR runs an include file preprocessor on one or more files, writing the result to an output file (or standard output)\.
@@ -3,7 +3,7 @@ grinc(1) -- Process includes on a text file
3
3
 
4
4
  ## SYNOPSIS
5
5
 
6
- `grinc` [-o output | --output output] [-n maxnest | --maxnest maxnest] [files]
6
+ `grinc` [-o output | --output output] [-n N | --nesting N] [files]
7
7
 
8
8
  ## DESCRIPTION
9
9
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grinc
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ - 2
10
+ version: 0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Brian M. Clapper
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-26 00:00:00 -04:00
18
+ date: 2011-03-27 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -46,16 +46,16 @@ extensions: []
46
46
  extra_rdoc_files: []
47
47
 
48
48
  files:
49
+ - README.md
49
50
  - CHANGELOG.md
50
51
  - Rakefile
51
- - README.md
52
52
  - grinc.gemspec
53
53
  - bin/grinc
54
54
  - lib/grizzled/grinc.rb
55
55
  - man/man1/grinc.1
56
56
  - src-man/grinc.1.md
57
57
  has_rdoc: true
58
- homepage: http://software.clapper.org/grinc
58
+ homepage: http://software.clapper.org/grinc/
59
59
  licenses:
60
60
  - BSD
61
61
  post_install_message:
@@ -84,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
84
  requirements: []
85
85
 
86
86
  rubyforge_project:
87
- rubygems_version: 1.6.2
87
+ rubygems_version: 1.5.0
88
88
  signing_key:
89
89
  specification_version: 3
90
90
  summary: Command line include file preprocessor