inochi 1.1.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CREDITS +17 -1
- data/bin/inochi +19 -539
- data/lib/inochi.rb +1 -41
- data/lib/inochi/engine.rb +101 -0
- data/lib/inochi/generate.rb +52 -0
- data/lib/inochi/inochi.rb +109 -0
- data/lib/inochi/tasks/ann.rake +230 -0
- data/lib/inochi/tasks/api.rake +28 -0
- data/lib/inochi/tasks/gem.rake +46 -0
- data/lib/inochi/tasks/init.rake +38 -0
- data/lib/inochi/tasks/man.rake +78 -0
- data/lib/inochi/tasks/project.rake +25 -0
- data/lib/inochi/tasks/pub.rake +130 -0
- data/lib/inochi/templates/CREDITS.rbs +18 -0
- data/lib/inochi/templates/EXAMPLES.rbs +24 -0
- data/lib/inochi/templates/FURTHER.rbs +17 -0
- data/lib/inochi/templates/HACKING.rbs +92 -0
- data/lib/inochi/templates/HISTORY.rbs +55 -0
- data/lib/inochi/templates/LICENSE.rbs +15 -0
- data/lib/inochi/templates/MANUAL.rbs +27 -0
- data/lib/inochi/templates/README.rbs +60 -0
- data/lib/inochi/templates/USAGE.rbs +23 -0
- data/lib/inochi/templates/command.rbs +23 -0
- data/lib/inochi/templates/inochi.opts.rbs +43 -0
- data/lib/inochi/templates/inochi.rb.rbs +102 -0
- data/lib/inochi/templates/library.rbs +7 -0
- data/lib/inochi/templates/library_test.rb.rbs +3 -0
- data/lib/inochi/templates/test_helper.rb.rbs +3 -0
- data/lib/inochi/templates/test_runner.rbs +25 -0
- data/{doc → logo}/inochi.png +0 -0
- data/man.html +959 -0
- data/man/man1/inochi.1.gz +0 -0
- metadata +129 -198
- data/doc/README +0 -6
- data/doc/api/apple-touch-icon.png +0 -0
- data/doc/api/classes/Array.html +0 -370
- data/doc/api/classes/File.html +0 -110
- data/doc/api/classes/Inochi.html +0 -1477
- data/doc/api/classes/Inochi/Manual.html +0 -157
- data/doc/api/classes/Inochi/Phrases.html +0 -331
- data/doc/api/classes/Inochi/Version.html +0 -190
- data/doc/api/classes/TempDir.html +0 -164
- data/doc/api/created.rid +0 -1
- data/doc/api/css/main.css +0 -263
- data/doc/api/css/panel.css +0 -383
- data/doc/api/css/reset.css +0 -53
- data/doc/api/favicon.ico +0 -0
- data/doc/api/files/CREDITS.html +0 -61
- data/doc/api/files/LICENSE.html +0 -76
- data/doc/api/files/lib/inochi/book_rb.html +0 -106
- data/doc/api/files/lib/inochi/init_rb.html +0 -66
- data/doc/api/files/lib/inochi/main_rb.html +0 -52
- data/doc/api/files/lib/inochi/rake_rb.html +0 -52
- data/doc/api/files/lib/inochi/test/bacon_rb.html +0 -67
- data/doc/api/files/lib/inochi/test/context_rb.html +0 -69
- data/doc/api/files/lib/inochi/test/dfect_rb.html +0 -67
- data/doc/api/files/lib/inochi/test/matchy_rb.html +0 -69
- data/doc/api/files/lib/inochi/test/minitest_rb.html +0 -71
- data/doc/api/files/lib/inochi/test/mocha_rb.html +0 -67
- data/doc/api/files/lib/inochi/test/rspec_rb.html +0 -67
- data/doc/api/files/lib/inochi/test/shoulda_rb.html +0 -67
- data/doc/api/files/lib/inochi/test/test_spec_rb.html +0 -67
- data/doc/api/files/lib/inochi/test/test_unit_rb.html +0 -67
- data/doc/api/files/lib/inochi/util/combo_rb.html +0 -59
- data/doc/api/files/lib/inochi/util/tempdir_rb.html +0 -68
- data/doc/api/files/lib/inochi/util_rb.html +0 -59
- data/doc/api/files/lib/inochi_rb.html +0 -76
- data/doc/api/i/arrows.png +0 -0
- data/doc/api/i/results_bg.png +0 -0
- data/doc/api/i/tree_bg.png +0 -0
- data/doc/api/index.html +0 -14
- data/doc/api/js/jquery-1.3.2.min.js +0 -19
- data/doc/api/js/jquery-effect.js +0 -593
- data/doc/api/js/main.js +0 -22
- data/doc/api/js/searchdoc.js +0 -628
- data/doc/api/panel/index.html +0 -71
- data/doc/api/panel/search_index.js +0 -1
- data/doc/api/panel/tree.js +0 -1
- data/doc/history.erb +0 -268
- data/doc/index.erb +0 -11
- data/doc/index.html +0 -3179
- data/doc/inochi.svg +0 -405
- data/doc/intro.erb +0 -87
- data/doc/setup.erb +0 -105
- data/doc/usage.erb +0 -641
- data/lib/inochi/book.rb +0 -91
- data/lib/inochi/init.rb +0 -256
- data/lib/inochi/main.rb +0 -85
- data/lib/inochi/rake.rb +0 -902
- data/lib/inochi/test/bacon.rb +0 -3
- data/lib/inochi/test/context.rb +0 -4
- data/lib/inochi/test/dfect.rb +0 -3
- data/lib/inochi/test/matchy.rb +0 -4
- data/lib/inochi/test/minitest.rb +0 -7
- data/lib/inochi/test/mocha.rb +0 -3
- data/lib/inochi/test/rspec.rb +0 -3
- data/lib/inochi/test/shoulda.rb +0 -3
- data/lib/inochi/test/test_spec.rb +0 -3
- data/lib/inochi/test/test_unit.rb +0 -3
- data/lib/inochi/util.rb +0 -99
- data/lib/inochi/util/combo.rb +0 -191
- data/lib/inochi/util/tempdir.rb +0 -29
- data/rakefile +0 -12
- data/test/inochi.rb +0 -111
data/lib/inochi/test/bacon.rb
DELETED
data/lib/inochi/test/context.rb
DELETED
data/lib/inochi/test/dfect.rb
DELETED
data/lib/inochi/test/matchy.rb
DELETED
data/lib/inochi/test/minitest.rb
DELETED
data/lib/inochi/test/mocha.rb
DELETED
data/lib/inochi/test/rspec.rb
DELETED
data/lib/inochi/test/shoulda.rb
DELETED
data/lib/inochi/util.rb
DELETED
@@ -1,99 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright protects this work.
|
3
|
-
# See LICENSE file for details.
|
4
|
-
#++
|
5
|
-
|
6
|
-
class << Inochi
|
7
|
-
##
|
8
|
-
# Returns the name of the main program executable, which
|
9
|
-
# is the same as the project name fully in lowercase.
|
10
|
-
#
|
11
|
-
def calc_program_name project_symbol
|
12
|
-
camel_to_snake_case(project_symbol).downcase
|
13
|
-
end
|
14
|
-
|
15
|
-
##
|
16
|
-
# Calculates the name of the project module from the given project name.
|
17
|
-
#
|
18
|
-
def calc_project_symbol project_name
|
19
|
-
name = project_name.to_s.gsub(/\W+/, '_').squeeze('_').gsub(/^_|_$/, '')
|
20
|
-
(name[0,1].upcase + name[1..-1]).to_sym
|
21
|
-
end
|
22
|
-
|
23
|
-
##
|
24
|
-
# Transforms the given input from CamelCase to snake_case.
|
25
|
-
#
|
26
|
-
def camel_to_snake_case input
|
27
|
-
input = input.to_s.dup
|
28
|
-
|
29
|
-
# handle camel case like FooBar => Foo_Bar
|
30
|
-
while input.gsub!(/([a-z]+)([A-Z])(\w+)/) { $1 + '_' + $2 + $3 }
|
31
|
-
end
|
32
|
-
|
33
|
-
# handle abbreviations like XMLParser => XML_Parser
|
34
|
-
while input.gsub!(/([A-Z]+)([A-Z])([a-z]+)/) { $1 + '_' + $2 + $3 }
|
35
|
-
end
|
36
|
-
|
37
|
-
input
|
38
|
-
end
|
39
|
-
|
40
|
-
##
|
41
|
-
# Establishes version requirements for the given gem.
|
42
|
-
#
|
43
|
-
# Returns the sanitized Gem version requirements.
|
44
|
-
#
|
45
|
-
def require_gem_version gem_name, version_reqs
|
46
|
-
version_reqs = Array(version_reqs).compact
|
47
|
-
|
48
|
-
begin
|
49
|
-
gem gem_name.to_s, *version_reqs
|
50
|
-
rescue Gem::Exception, Gem::LoadError => e
|
51
|
-
warn e.inspect
|
52
|
-
end
|
53
|
-
|
54
|
-
version_reqs
|
55
|
-
end
|
56
|
-
|
57
|
-
private
|
58
|
-
|
59
|
-
INOCHI_LIBRARY_PATH = File.dirname(__FILE__)
|
60
|
-
|
61
|
-
##
|
62
|
-
# Returns the path of the first file outside
|
63
|
-
# Inochi's core from which this method was called.
|
64
|
-
#
|
65
|
-
def first_caller_file
|
66
|
-
caller.each do |step|
|
67
|
-
if file = step[/^.+(?=:\d+(?::|\z))/]
|
68
|
-
file = File.expand_path(file)
|
69
|
-
base = File.dirname(file)
|
70
|
-
|
71
|
-
break file unless base.index(INOCHI_LIBRARY_PATH) == 0
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
##
|
77
|
-
# Returns the project module corresponding to the given symbol.
|
78
|
-
# A new module is created if none already exists.
|
79
|
-
#
|
80
|
-
def fetch_project_module project_symbol
|
81
|
-
if Object.const_defined? project_symbol
|
82
|
-
project_module = Object.const_get(project_symbol)
|
83
|
-
else
|
84
|
-
project_module = Module.new
|
85
|
-
Object.const_set project_symbol, project_module
|
86
|
-
end
|
87
|
-
|
88
|
-
project_module
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
unless File.respond_to? :write
|
93
|
-
##
|
94
|
-
# Writes the given content to the given file.
|
95
|
-
#
|
96
|
-
def File.write path, content
|
97
|
-
open(path, 'wb') {|f| f.write content }
|
98
|
-
end
|
99
|
-
end
|
data/lib/inochi/util/combo.rb
DELETED
@@ -1,191 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright protects this work.
|
3
|
-
# See LICENSE file for details.
|
4
|
-
#++
|
5
|
-
|
6
|
-
class Array
|
7
|
-
unless method_defined? :enumeration
|
8
|
-
##
|
9
|
-
# Returns all possible enumerations made from
|
10
|
-
# sample_size number of items from this list.
|
11
|
-
#
|
12
|
-
# ==== Parameters
|
13
|
-
#
|
14
|
-
# [sample_size]
|
15
|
-
# The length of each enumeration.
|
16
|
-
#
|
17
|
-
# [sampler]
|
18
|
-
# If given, each enumeration is passed to this block.
|
19
|
-
#
|
20
|
-
def enumeration(sample_size = self.length, &sampler)
|
21
|
-
return [] if sample_size < 1
|
22
|
-
|
23
|
-
results = []
|
24
|
-
|
25
|
-
visitor = lambda do |parents|
|
26
|
-
each do |child|
|
27
|
-
result = parents + [child]
|
28
|
-
|
29
|
-
if result.length < sample_size
|
30
|
-
visitor.call result
|
31
|
-
else
|
32
|
-
yield result if block_given?
|
33
|
-
results << result
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
visitor.call []
|
39
|
-
results
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
unless method_defined? :enumerations
|
44
|
-
##
|
45
|
-
# Returns all possible enumerations of all possible lengths.
|
46
|
-
#
|
47
|
-
# ==== Parameters
|
48
|
-
#
|
49
|
-
# [sampler]
|
50
|
-
# If given, each enumeration is passed to this block.
|
51
|
-
#
|
52
|
-
def enumerations &sampler
|
53
|
-
all_lengths_impl :enumeration, &sampler
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
unless method_defined? :combination
|
58
|
-
##
|
59
|
-
# Returns all possible combinations made from
|
60
|
-
# sample_size number of items from this list.
|
61
|
-
#
|
62
|
-
# ==== Parameters
|
63
|
-
#
|
64
|
-
# [sample_size]
|
65
|
-
# The length of each combination.
|
66
|
-
#
|
67
|
-
# [sampler]
|
68
|
-
# If given, each combination is passed to this block.
|
69
|
-
#
|
70
|
-
def combination(sample_size = self.length, &sampler)
|
71
|
-
pnk_cnk_impl(sample_size, true, &sampler)
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
unless method_defined? :combinations
|
76
|
-
##
|
77
|
-
# Returns all possible combinations of all possible lengths.
|
78
|
-
#
|
79
|
-
# ==== Parameters
|
80
|
-
#
|
81
|
-
# [sampler]
|
82
|
-
# If given, each combination is passed to this block.
|
83
|
-
#
|
84
|
-
def combinations &sampler
|
85
|
-
all_lengths_impl :combination, &sampler
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
unless method_defined? :permutation
|
90
|
-
##
|
91
|
-
# Returns all possible permutations made from
|
92
|
-
# sample_size number of items from this list.
|
93
|
-
#
|
94
|
-
# ==== Parameters
|
95
|
-
#
|
96
|
-
# [sample_size]
|
97
|
-
# The length of each permutation.
|
98
|
-
#
|
99
|
-
# [sampler]
|
100
|
-
# If given, each permutation is passed to this block.
|
101
|
-
#
|
102
|
-
def permutation(sample_size = self.length, &sampler)
|
103
|
-
pnk_cnk_impl(sample_size, false, &sampler)
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
unless method_defined? :permutations
|
108
|
-
##
|
109
|
-
# Returns all possible permutations of all possible lengths.
|
110
|
-
#
|
111
|
-
# ==== Parameters
|
112
|
-
#
|
113
|
-
# [sampler]
|
114
|
-
# If given, each permutation is passed to this block.
|
115
|
-
#
|
116
|
-
def permutations &sampler
|
117
|
-
all_lengths_impl :permutation, &sampler
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
private
|
122
|
-
|
123
|
-
##
|
124
|
-
# Returns results of the given method name for all possible sample sizes.
|
125
|
-
#
|
126
|
-
def all_lengths_impl method_name, &sampler
|
127
|
-
results = []
|
128
|
-
|
129
|
-
0.upto(length) do |i|
|
130
|
-
results << __send__(method_name, i, &sampler)
|
131
|
-
end
|
132
|
-
|
133
|
-
results
|
134
|
-
end
|
135
|
-
|
136
|
-
##
|
137
|
-
# Common implementation for permutation and combination functions.
|
138
|
-
#
|
139
|
-
# ==== Parameters
|
140
|
-
#
|
141
|
-
# [sample_size]
|
142
|
-
# Maximum depth of traversal, at which point to stop
|
143
|
-
# further traversal and to start collecting results.
|
144
|
-
#
|
145
|
-
# [exclude_parents]
|
146
|
-
# Prevent already visited vertices from being
|
147
|
-
# visited again in subsequent iterations?
|
148
|
-
#
|
149
|
-
def pnk_cnk_impl sample_size, exclude_parents
|
150
|
-
results = []
|
151
|
-
|
152
|
-
if sample_size >= 0 && sample_size < self.length
|
153
|
-
##
|
154
|
-
# ==== Parameters
|
155
|
-
#
|
156
|
-
# [parents]
|
157
|
-
# list of visited vertices, including the current vertex
|
158
|
-
#
|
159
|
-
# [children]
|
160
|
-
# list of unvisited vertices adjacent to current vertex
|
161
|
-
#
|
162
|
-
# [depth]
|
163
|
-
# current depth of the traversal tree
|
164
|
-
#
|
165
|
-
visitor = lambda do |parents, children, depth|
|
166
|
-
# traverse the graph until we reach the fringe
|
167
|
-
# vertices (leaf nodes of the traversal tree)
|
168
|
-
if depth < sample_size - 1
|
169
|
-
children.each do |c|
|
170
|
-
next_children = children - (exclude_parents ? parents : [c])
|
171
|
-
next_parents = parents + [c]
|
172
|
-
next_depth = depth + 1
|
173
|
-
|
174
|
-
visitor.call next_parents, next_children, next_depth
|
175
|
-
end
|
176
|
-
else
|
177
|
-
# now we have reached the fringe vertices
|
178
|
-
children.each do |c|
|
179
|
-
result = parents + [c]
|
180
|
-
yield result if block_given?
|
181
|
-
results << result
|
182
|
-
end
|
183
|
-
end
|
184
|
-
end
|
185
|
-
|
186
|
-
visitor.call [], self, 0
|
187
|
-
end
|
188
|
-
|
189
|
-
results
|
190
|
-
end
|
191
|
-
end
|
data/lib/inochi/util/tempdir.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright protects this work.
|
3
|
-
# See LICENSE file for details.
|
4
|
-
#++
|
5
|
-
|
6
|
-
require 'tempfile'
|
7
|
-
require 'fileutils'
|
8
|
-
|
9
|
-
class TempDir
|
10
|
-
attr_reader :path
|
11
|
-
|
12
|
-
def initialize basename = nil, dirname = nil
|
13
|
-
args = [basename || File.basename($0), dirname].compact
|
14
|
-
file = Tempfile.new(*args)
|
15
|
-
|
16
|
-
@path = file.path
|
17
|
-
|
18
|
-
# replace the file with a directory
|
19
|
-
file.close!
|
20
|
-
FileUtils.mkdir_p @path
|
21
|
-
|
22
|
-
# clean up on exit
|
23
|
-
at_exit { close }
|
24
|
-
end
|
25
|
-
|
26
|
-
def close
|
27
|
-
FileUtils.rm_rf @path
|
28
|
-
end
|
29
|
-
end
|
data/rakefile
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright protects this work.
|
3
|
-
# See LICENSE file for details.
|
4
|
-
#++
|
5
|
-
|
6
|
-
require 'lib/inochi'
|
7
|
-
|
8
|
-
Inochi.rake :Inochi,
|
9
|
-
:rubyforge_project => 'sunaku',
|
10
|
-
:upload_target => File.expand_path('~/www/lib/inochi/'),
|
11
|
-
:upload_delete => true,
|
12
|
-
:test_with => :minitest
|
data/test/inochi.rb
DELETED
@@ -1,111 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright protects this work.
|
3
|
-
# See LICENSE file for details.
|
4
|
-
#++
|
5
|
-
|
6
|
-
describe 'Inochi.calc_program_name' do
|
7
|
-
it 'converts input into lower-case' do
|
8
|
-
c('foo').must_equal('foo')
|
9
|
-
c('foO').must_equal('foo')
|
10
|
-
c('Foo').must_equal('foo')
|
11
|
-
c('FoO').must_equal('foo')
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'converts camel case into snake case' do
|
15
|
-
c('FooBar').must_equal('foo_bar')
|
16
|
-
c('AnXMLParser').must_equal('an_xml_parser')
|
17
|
-
c('fOo').must_equal('f_oo')
|
18
|
-
c('FOo').must_equal('f_oo')
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
def c *args
|
24
|
-
Inochi.calc_program_name(*args)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe 'Inochi.calc_project_symbol' do
|
29
|
-
it 'capitalizes first letter like a ruby constant' do
|
30
|
-
c('foo').must_equal('Foo')
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'preserves exisitng capitalization' do
|
34
|
-
c('FoO').must_equal('FoO')
|
35
|
-
c('fooBaR').must_equal('FooBaR')
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'converts non-word characters into underscores' do
|
39
|
-
c('a!b#c').must_equal('A_b_c')
|
40
|
-
end
|
41
|
-
|
42
|
-
it 'squeezes mulitple underscores' do
|
43
|
-
c('foo!!bar$$qux').must_equal('Foo_bar_qux')
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'ignores surrounding whitespace' do
|
47
|
-
c(' a ').must_equal('A')
|
48
|
-
end
|
49
|
-
|
50
|
-
it 'ignores surrounding underscores' do
|
51
|
-
c('_a').must_equal('A')
|
52
|
-
c('a_').must_equal('A')
|
53
|
-
c('_a_').must_equal('A')
|
54
|
-
c('__a__').must_equal('A')
|
55
|
-
end
|
56
|
-
|
57
|
-
it 'ignores surrounding non-word characters' do
|
58
|
-
c('!a').must_equal('A')
|
59
|
-
c('a!').must_equal('A')
|
60
|
-
c('!a!').must_equal('A')
|
61
|
-
c('!!a!!').must_equal('A')
|
62
|
-
c('!@a#$').must_equal('A')
|
63
|
-
end
|
64
|
-
|
65
|
-
private
|
66
|
-
|
67
|
-
def c *args
|
68
|
-
Inochi.calc_project_symbol(*args).to_s
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
describe 'Inochi.camel_to_snake_case' do
|
73
|
-
it 'supports empty input' do
|
74
|
-
c('').must_equal('')
|
75
|
-
end
|
76
|
-
|
77
|
-
it 'supports normal camel case' do
|
78
|
-
c('fooBar').must_equal('foo_Bar')
|
79
|
-
c('FooBar').must_equal('Foo_Bar')
|
80
|
-
c('Foobar').must_equal('Foobar')
|
81
|
-
end
|
82
|
-
|
83
|
-
it 'supports nested abbreviations' do
|
84
|
-
c('AnXMLParser').must_equal('An_XML_Parser')
|
85
|
-
c('ANXMLParser').must_equal('ANXML_Parser')
|
86
|
-
c('AnXmLPaRsEr').must_equal('An_Xm_L_Pa_Rs_Er')
|
87
|
-
end
|
88
|
-
|
89
|
-
it 'preserves non-word characters' do
|
90
|
-
c(' a!!b#c').must_equal(' a!!b#c')
|
91
|
-
end
|
92
|
-
|
93
|
-
it 'preserves exsiting underscores' do
|
94
|
-
c('foo_bar').must_equal('foo_bar')
|
95
|
-
c('foo_Bar').must_equal('foo_Bar')
|
96
|
-
c('Foo_Bar').must_equal('Foo_Bar')
|
97
|
-
c('Foo_bar').must_equal('Foo_bar')
|
98
|
-
|
99
|
-
c('Foo___b_a__r').must_equal('Foo___b_a__r')
|
100
|
-
c('_').must_equal('_')
|
101
|
-
c('_a').must_equal('_a')
|
102
|
-
c('a_').must_equal('a_')
|
103
|
-
c('_a_').must_equal('_a_')
|
104
|
-
end
|
105
|
-
|
106
|
-
private
|
107
|
-
|
108
|
-
def c *args
|
109
|
-
Inochi.camel_to_snake_case(*args)
|
110
|
-
end
|
111
|
-
end
|