grizzled-ruby 0.1.3 → 0.1.4
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.
- data/CHANGELOG.md +35 -0
- data/LICENSE.md +31 -0
- data/README.md +32 -0
- data/Rakefile +121 -0
- data/grizzled-ruby.gemspec +32 -0
- metadata +14 -10
- data/bin/grinc +0 -151
data/CHANGELOG.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Change Log for Grizzled Ruby
|
2
|
+
|
3
|
+
Version 0.1.4 (25 March, 2011)
|
4
|
+
|
5
|
+
- Fixed some gem issues.
|
6
|
+
- Moved *grinc* to its own gem and repo.
|
7
|
+
|
8
|
+
---
|
9
|
+
|
10
|
+
Version 0.1.3 (24 March, 2011)
|
11
|
+
|
12
|
+
* Correct minor problems in *grinc* that shouldn't have been pushed, but
|
13
|
+
were.
|
14
|
+
|
15
|
+
---
|
16
|
+
|
17
|
+
Version 0.1.2 (24 March, 2011)
|
18
|
+
|
19
|
+
* Cleaned up API documentation.
|
20
|
+
* Added *grinc* command/executable.
|
21
|
+
|
22
|
+
---
|
23
|
+
|
24
|
+
Version 0.1.1 (18 March, 2011)
|
25
|
+
|
26
|
+
* Added `Grizzled::FileUtil::ZipUtil` module, which contains some
|
27
|
+
simplified, front-end "zip" and "unzip" wrappers for the `rubyzip` gem.
|
28
|
+
* Added the `Grizzled::FileUtil.make_directory_tree` method, which creates
|
29
|
+
a directory tree from a nested hash specification.
|
30
|
+
|
31
|
+
---
|
32
|
+
|
33
|
+
Version 0.1.0 (12 March, 2011)
|
34
|
+
|
35
|
+
* Initial version published to the web and to RubyGems.
|
data/LICENSE.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
Grizzled Ruby is released under a **BSD license**, adapted from
|
2
|
+
<http://opensource.org/licenses/bsd-license.php>
|
3
|
+
|
4
|
+
Copyright © 2011 Brian M. Clapper.
|
5
|
+
All rights reserved.
|
6
|
+
|
7
|
+
Redistribution and use in source and binary forms, with or without
|
8
|
+
modification, are permitted provided that the following conditions are met:
|
9
|
+
|
10
|
+
* Redistributions of source code must retain the above copyright notice,
|
11
|
+
this list of conditions and the following disclaimer.
|
12
|
+
|
13
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
14
|
+
this list of conditions and the following disclaimer in the documentation
|
15
|
+
and/or other materials provided with the distribution.
|
16
|
+
|
17
|
+
* Neither the names "clapper.org", "Grizzled Ruby", nor the names of its
|
18
|
+
contributors may be used to endorse or promote products derived from this
|
19
|
+
software without specific prior written permission.
|
20
|
+
|
21
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
22
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
23
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
24
|
+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
25
|
+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
26
|
+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
27
|
+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
28
|
+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
29
|
+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
30
|
+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
31
|
+
POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# Grizzled Ruby
|
2
|
+
|
3
|
+
## Intro
|
4
|
+
|
5
|
+
The Grizzled Ruby Utility Library is a general-purpose Ruby library
|
6
|
+
with a variety of different modules and classes. Basically, it's an
|
7
|
+
organized dumping ground for various useful APIs I find I need. It's
|
8
|
+
similar, in concept, to my [Grizzled Python][] and [Grizzled Scala][]
|
9
|
+
libraries, for [Python][] and [Scala][], respectively.
|
10
|
+
|
11
|
+
It can be built as a gem, but the gem isn't (yet) public.
|
12
|
+
|
13
|
+
[Grizzled Python]: http://software.clapper.org/grizzled/
|
14
|
+
[Grizzled Scala]: http://software.clapper.org/grizzled-scala/
|
15
|
+
[Scala]: http://www.scala-lang.org/
|
16
|
+
[Python]: http://www.python.org/
|
17
|
+
|
18
|
+
## To build
|
19
|
+
|
20
|
+
$ git clone git://github.com/bmc/grizzled-ruby.git
|
21
|
+
$ cd grizzled-ruby
|
22
|
+
$ gem build grizzled-ruby.gemspec
|
23
|
+
$ gem install grizzled-ruby
|
24
|
+
|
25
|
+
## To use in your code
|
26
|
+
|
27
|
+
require 'grizzled'
|
28
|
+
|
29
|
+
## Copyright and License
|
30
|
+
|
31
|
+
This code is copyright © 2011 Brian M. Clapper and is released under a
|
32
|
+
BSD License.
|
data/Rakefile
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
#
|
3
|
+
# NOTE: Man pages use the 'ronn' gem. http://rtomayko.github.com/ronn/
|
4
|
+
|
5
|
+
require 'rake/clean'
|
6
|
+
require 'pathname'
|
7
|
+
|
8
|
+
PACKAGE = 'grizzled-ruby'
|
9
|
+
GEMSPEC = "#{PACKAGE}.gemspec"
|
10
|
+
RDOC_OUT_DIR = 'rdoc'
|
11
|
+
GH_PAGES_DIR = File.join('..', 'gh-pages')
|
12
|
+
RDOC_PUBLISH_DIR = File.join(GH_PAGES_DIR, 'apidocs')
|
13
|
+
RUBY_SRC_DIR = 'lib'
|
14
|
+
RUBY_FILES = FileList[File.join(RUBY_SRC_DIR, '**', '*.rb')]
|
15
|
+
|
16
|
+
def load_gem(spec)
|
17
|
+
eval File.open(spec).readlines.join('')
|
18
|
+
end
|
19
|
+
|
20
|
+
def gem_name(spec)
|
21
|
+
gem = load_gem(spec)
|
22
|
+
"#{PACKAGE}-#{gem.version.to_s}.gem"
|
23
|
+
end
|
24
|
+
|
25
|
+
GEM = gem_name(GEMSPEC)
|
26
|
+
CLEAN << [RDOC_OUT_DIR, GEM]
|
27
|
+
|
28
|
+
# ---------------------------------------------------------------------------
|
29
|
+
# Rules
|
30
|
+
# ---------------------------------------------------------------------------
|
31
|
+
|
32
|
+
# ---------------------------------------------------------------------------
|
33
|
+
# Tasks
|
34
|
+
# ---------------------------------------------------------------------------
|
35
|
+
|
36
|
+
task :default => :build
|
37
|
+
|
38
|
+
desc "Build everything"
|
39
|
+
task :build => [:test, :gem, :doc]
|
40
|
+
|
41
|
+
desc "Synonym for 'build'"
|
42
|
+
task :all => :build
|
43
|
+
|
44
|
+
desc "Build the gem (#{GEM})"
|
45
|
+
task :gem => GEM
|
46
|
+
|
47
|
+
file GEM => RUBY_FILES + ['Rakefile', GEMSPEC] do |t|
|
48
|
+
require 'rubygems/builder'
|
49
|
+
if !defined? Gem
|
50
|
+
raise StandardError.new("Gem package not defined.")
|
51
|
+
end
|
52
|
+
spec = eval File.new(GEMSPEC).read
|
53
|
+
Gem::Builder.new(spec).build
|
54
|
+
end
|
55
|
+
|
56
|
+
desc "Build the documentation, locally"
|
57
|
+
task :doc => :rdoc
|
58
|
+
|
59
|
+
file 'rdoc' => RUBY_FILES do |t|
|
60
|
+
require 'rdoc/rdoc'
|
61
|
+
puts('Running rdoc...')
|
62
|
+
mkdir_p File.dirname(RDOC_OUT_DIR) unless File.exists? RDOC_OUT_DIR
|
63
|
+
r = RDoc::RDoc.new
|
64
|
+
r.document(['-U', '-m', "#{RUBY_SRC_DIR}/grizzled.rb", '-o', RDOC_OUT_DIR,
|
65
|
+
RUBY_SRC_DIR])
|
66
|
+
end
|
67
|
+
|
68
|
+
desc "Install the gem"
|
69
|
+
task :install => :gem do |t|
|
70
|
+
require 'rubygems/installer'
|
71
|
+
puts("Installing from #{GEM}")
|
72
|
+
Gem::Installer.new(GEM).install
|
73
|
+
end
|
74
|
+
|
75
|
+
desc "Publish the gem"
|
76
|
+
task :publish => :gem do |t|
|
77
|
+
sh "gem push #{GEM}"
|
78
|
+
end
|
79
|
+
|
80
|
+
desc "Publish the docs. Not really of use to anyone but the author"
|
81
|
+
task :pubdoc => [:pubrdoc, :pubchangelog]
|
82
|
+
|
83
|
+
task :pubrdoc => :doc do |t|
|
84
|
+
target = Pathname.new(RDOC_PUBLISH_DIR).expand_path.to_s
|
85
|
+
cd RDOC_OUT_DIR do
|
86
|
+
mkdir_p target
|
87
|
+
cp_r '.', target
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
desc "Synonym for 'pubchangelog'"
|
92
|
+
task :changelog
|
93
|
+
|
94
|
+
desc "Publish the change log. Not really of use to anyone but the author"
|
95
|
+
task :pubchangelog do |t|
|
96
|
+
File.open(File.join(GH_PAGES_DIR, 'CHANGELOG.md'), 'w') do |f|
|
97
|
+
f.write <<EOF
|
98
|
+
---
|
99
|
+
title: Change Log for Grizzled Ruby
|
100
|
+
layout: default
|
101
|
+
---
|
102
|
+
|
103
|
+
EOF
|
104
|
+
f.write File.open('CHANGELOG.md').read
|
105
|
+
f.close
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
task :pub
|
110
|
+
|
111
|
+
desc "Alias for 'docpub'"
|
112
|
+
task :docpub => :pubdoc
|
113
|
+
|
114
|
+
desc "Run the unit tests"
|
115
|
+
task :test do |t|
|
116
|
+
FileList[File.join('test', '**', 't[cs]_*.rb')].each do |tf|
|
117
|
+
cd File.dirname(tf) do |dir|
|
118
|
+
ruby File.basename(tf)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
|
5
|
+
s.name = 'grizzled-ruby'
|
6
|
+
s.version = '0.1.4'
|
7
|
+
s.date = '2011-03-25'
|
8
|
+
s.summary = 'Some general-purpose Ruby modules, classes, and tools'
|
9
|
+
s.authors = ['Brian M. Clapper']
|
10
|
+
s.license = 'BSD'
|
11
|
+
s.email = 'bmc@clapper.org'
|
12
|
+
s.homepage = 'http://software.clapper.org/grizzled-ruby'
|
13
|
+
s.has_rdoc = true
|
14
|
+
|
15
|
+
s.description = <<-ENDDESC
|
16
|
+
Grizzled Ruby is a general purpose library of Ruby modules, classes and tools.
|
17
|
+
ENDDESC
|
18
|
+
|
19
|
+
s.require_paths = ['lib']
|
20
|
+
|
21
|
+
# = MANIFEST =
|
22
|
+
s.files = Dir.glob('[A-Z]*')
|
23
|
+
s.files += Dir.glob('*.gemspec')
|
24
|
+
s.files += Dir.glob('lib/**/*')
|
25
|
+
s.files += Dir.glob('rdoc/**/*')
|
26
|
+
|
27
|
+
|
28
|
+
# = MANIFEST =
|
29
|
+
s.test_files = FileList['test/**/tc_*.rb'].to_a
|
30
|
+
end
|
31
|
+
|
32
|
+
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grizzled-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 4
|
10
|
+
version: 0.1.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Brian M. Clapper
|
@@ -15,21 +15,26 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-03-
|
18
|
+
date: 2011-03-25 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
22
22
|
description: |
|
23
|
-
Grizzled Ruby is a general purpose library of Ruby modules and
|
23
|
+
Grizzled Ruby is a general purpose library of Ruby modules, classes and tools.
|
24
24
|
|
25
25
|
email: bmc@clapper.org
|
26
|
-
executables:
|
27
|
-
|
26
|
+
executables: []
|
27
|
+
|
28
28
|
extensions: []
|
29
29
|
|
30
30
|
extra_rdoc_files: []
|
31
31
|
|
32
32
|
files:
|
33
|
+
- README.md
|
34
|
+
- LICENSE.md
|
35
|
+
- CHANGELOG.md
|
36
|
+
- Rakefile
|
37
|
+
- grizzled-ruby.gemspec
|
33
38
|
- lib/grizzled/fileutil.rb
|
34
39
|
- lib/grizzled/stack.rb
|
35
40
|
- lib/grizzled/fileutil/includer.rb
|
@@ -45,7 +50,6 @@ files:
|
|
45
50
|
- test/fileutil/tc_includer.rb
|
46
51
|
- test/fileutil/tc_make_dir_tree.rb
|
47
52
|
- test/string/tc_template.rb
|
48
|
-
- bin/grinc
|
49
53
|
has_rdoc: true
|
50
54
|
homepage: http://software.clapper.org/grizzled-ruby
|
51
55
|
licenses:
|
@@ -76,10 +80,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
80
|
requirements: []
|
77
81
|
|
78
82
|
rubyforge_project:
|
79
|
-
rubygems_version: 1.
|
83
|
+
rubygems_version: 1.5.0
|
80
84
|
signing_key:
|
81
85
|
specification_version: 3
|
82
|
-
summary:
|
86
|
+
summary: Some general-purpose Ruby modules, classes, and tools
|
83
87
|
test_files:
|
84
88
|
- test/tc_stack.rb
|
85
89
|
- test/tc_forwarder.rb
|
data/bin/grinc
DELETED
@@ -1,151 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# See the man page or http://software.clapper.org/grizzled-ruby/grinc/
|
4
|
-
# for documentation.
|
5
|
-
#--
|
6
|
-
# This software is released under a BSD license, adapted from
|
7
|
-
# http://opensource.org/licenses/bsd-license.php
|
8
|
-
#
|
9
|
-
# Copyright (c) 2011, Brian M. Clapper
|
10
|
-
# All rights reserved.
|
11
|
-
#
|
12
|
-
# Redistribution and use in source and binary forms, with or without
|
13
|
-
# modification, are permitted provided that the following conditions are
|
14
|
-
# met:
|
15
|
-
#
|
16
|
-
# * Redistributions of source code must retain the above copyright notice,
|
17
|
-
# this list of conditions and the following disclaimer.
|
18
|
-
#
|
19
|
-
# * Redistributions in binary form must reproduce the above copyright
|
20
|
-
# notice, this list of conditions and the following disclaimer in the
|
21
|
-
# documentation and/or other materials provided with the distribution.
|
22
|
-
#
|
23
|
-
# * Neither the names "clapper.org", "Grizzled Ruby Library", nor the
|
24
|
-
# names of its contributors may be used to endorse or promote products
|
25
|
-
# derived from this software without specific prior written permission.
|
26
|
-
#
|
27
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
28
|
-
# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
29
|
-
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
30
|
-
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
31
|
-
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
32
|
-
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
33
|
-
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
34
|
-
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
35
|
-
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
36
|
-
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
37
|
-
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
38
|
-
#++
|
39
|
-
|
40
|
-
require 'optparse'
|
41
|
-
require 'grizzled/fileutil/includer'
|
42
|
-
|
43
|
-
include Grizzled::FileUtil
|
44
|
-
|
45
|
-
# ---------------------------------------------------------------------------
|
46
|
-
# Constants
|
47
|
-
# ---------------------------------------------------------------------------
|
48
|
-
|
49
|
-
DEFAULT_MAX_NEST = 100
|
50
|
-
PROGRAM_NAME = 'grinc'
|
51
|
-
|
52
|
-
# ---------------------------------------------------------------------------
|
53
|
-
# Classes
|
54
|
-
# ---------------------------------------------------------------------------
|
55
|
-
|
56
|
-
class Parameters
|
57
|
-
attr_reader :output, :max_nesting, :input_paths
|
58
|
-
|
59
|
-
def initialize(options_hash, argv)
|
60
|
-
@output = options_hash[:output]
|
61
|
-
@max_nesting = options_hash[:max_nesting] || DEFAULT_MAX_NEST
|
62
|
-
@input_paths = argv.length == 0 ? nil : argv
|
63
|
-
end
|
64
|
-
|
65
|
-
def to_s
|
66
|
-
inspect
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
class UsageError < StandardError; end
|
71
|
-
|
72
|
-
# ---------------------------------------------------------------------------
|
73
|
-
# Parameter parsing
|
74
|
-
# ---------------------------------------------------------------------------
|
75
|
-
|
76
|
-
def parse_params
|
77
|
-
options_hash = {}
|
78
|
-
error = nil
|
79
|
-
option_parser = OptionParser.new do |opts|
|
80
|
-
opts.program_name = PROGRAM_NAME
|
81
|
-
opts.banner = "Usage: #{opts.program_name} [OPTIONS] inputfile ..."
|
82
|
-
opts.separator ''
|
83
|
-
opts.separator 'OPTIONS:'
|
84
|
-
|
85
|
-
opts.on('-o FILE', 'Output file. Default: standard output.') do |f|
|
86
|
-
options_hash[:output] = f
|
87
|
-
end
|
88
|
-
|
89
|
-
opts.on('-n', '--nesting n',
|
90
|
-
"Max nesting. Default: #{DEFAULT_MAX_NEST}") do |n|
|
91
|
-
if n !~ /^[0-9]+$/
|
92
|
-
error = "Non-numeric parameter \"#{n}\" to -n option."
|
93
|
-
end
|
94
|
-
options_hash[:max_nesting] = n.to_i
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
begin
|
99
|
-
option_parser.parse!(ARGV)
|
100
|
-
rescue OptionParser::InvalidOption => ex
|
101
|
-
error = ex.to_s
|
102
|
-
end
|
103
|
-
|
104
|
-
if error
|
105
|
-
$stderr.puts(error) unless error.nil?
|
106
|
-
option_parser.display
|
107
|
-
raise UsageError.new
|
108
|
-
end
|
109
|
-
|
110
|
-
if ARGV.length == 0
|
111
|
-
options_hash[:input_files] = nil
|
112
|
-
else
|
113
|
-
options_hash[:input_files] = ARGV
|
114
|
-
end
|
115
|
-
|
116
|
-
Parameters.new(options_hash, ARGV)
|
117
|
-
end
|
118
|
-
|
119
|
-
def process_include(input_file, output_file, max_nesting = 100)
|
120
|
-
Includer.new(input_file, :max_nesting => max_nesting).each do |line|
|
121
|
-
output_file.write(line)
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
# ---------------------------------------------------------------------------
|
126
|
-
# Main logic
|
127
|
-
# ---------------------------------------------------------------------------
|
128
|
-
|
129
|
-
begin
|
130
|
-
params = parse_params
|
131
|
-
out = params.output.nil? ? $stderr : File.open(params.output, 'w')
|
132
|
-
|
133
|
-
if params.input_paths.nil?
|
134
|
-
process_include($stdin, out, params.max_nesting)
|
135
|
-
else
|
136
|
-
params.input_paths.each do |f|
|
137
|
-
process_include(File.open(f), out, params.max_nesting)
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
rescue UsageError
|
142
|
-
exit 1
|
143
|
-
|
144
|
-
rescue
|
145
|
-
$stderr.puts("#{PROGRAM_NAME}: #{$!}")
|
146
|
-
exit 1
|
147
|
-
|
148
|
-
else
|
149
|
-
exit 0
|
150
|
-
end
|
151
|
-
|