ima 0.4.2
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.
- checksums.yaml +7 -0
- data/LICENSE.md +90 -0
- data/README.md +30 -0
- data/Rakefile +448 -0
- data/docs/sunwukong.md +38 -0
- data/lib/ima/_lib.rb +75 -0
- data/lib/ima/options.rb +188 -0
- data/lib/ima.rb +4 -0
- data/sunwukong.gemspec +37 -0
- metadata +53 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 19f36834df74117346643d6d1f9aa6f06b6640a43c6891c62f5f92a944dcf3ed
|
4
|
+
data.tar.gz: 9e0f0c71b97dc82eb927ca02d5529cd2364b30de3c047c971b8f3f2a391ebe02
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9d97210d31d5d76297ca8f6b6914e39e02b9f6fd588acc5c06f4c7b733b6943e3d6e3d0e9717362c46322b5a9888955ff901b29ef005d30e2322b12124335ad7
|
7
|
+
data.tar.gz: 4180522725bb3fdb72f5c41c6dbaa944bb8676da932d8b32fb01b8171aab342418a862385555ea9b366b03a4cf30d69483335aa6b44e824998b30589068534d9
|
data/LICENSE.md
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
# Komorebi License
|
2
|
+
|
3
|
+
Version 1.0.0
|
4
|
+
|
5
|
+
## Acceptance
|
6
|
+
|
7
|
+
In order to get any license under these terms, you must agree to them as both
|
8
|
+
strict obligations and conditions to all your licenses.
|
9
|
+
|
10
|
+
## Copyright License
|
11
|
+
|
12
|
+
The licensor grants you a copyright license for the software to do everything
|
13
|
+
you might do with the software that would otherwise infringe the licensor's
|
14
|
+
copyright in it for any permitted purpose. However, you may only make changes
|
15
|
+
according to the [Changes License](#changes-license), and you may not
|
16
|
+
distribute the software or new works based on the software.
|
17
|
+
|
18
|
+
## Changes License
|
19
|
+
|
20
|
+
The licensor grants you an additional copyright license to make changes for any
|
21
|
+
permitted purpose.
|
22
|
+
|
23
|
+
## Patent License
|
24
|
+
|
25
|
+
The licensor grants you a patent license for the software that covers patent
|
26
|
+
claims the licensor can license, or becomes able to license, that you would
|
27
|
+
infringe by using the software.
|
28
|
+
|
29
|
+
## Personal Uses
|
30
|
+
|
31
|
+
Personal use for research, experiment, and testing for the benefit of public
|
32
|
+
knowledge, personal study, private entertainment, hobby projects, amateur
|
33
|
+
pursuits, or religious observance, without any anticipated commercial
|
34
|
+
application, is use for a permitted purpose.
|
35
|
+
|
36
|
+
## Fair Use
|
37
|
+
|
38
|
+
You may have "fair use" rights for the software under the law. These terms do
|
39
|
+
not limit them.
|
40
|
+
|
41
|
+
## No Other Rights
|
42
|
+
|
43
|
+
These terms do not allow you to sublicense or transfer any of your licenses to
|
44
|
+
anyone else, or prevent the licensor from granting licenses to anyone else.
|
45
|
+
These terms do not imply any other licenses.
|
46
|
+
|
47
|
+
## Patent Defense
|
48
|
+
|
49
|
+
If you make any written claim that the software infringes or contributes to
|
50
|
+
infringement of any patent, your patent license for the software granted under
|
51
|
+
these terms ends immediately. If your company makes such a claim, your patent
|
52
|
+
license ends immediately for work on behalf of your company.
|
53
|
+
|
54
|
+
## Violations
|
55
|
+
|
56
|
+
The first time you are notified in writing that you have violated any of these
|
57
|
+
terms, or done anything with the software not covered by your licenses, your
|
58
|
+
licenses can nonetheless continue if you come into full compliance with these
|
59
|
+
terms, and take practical steps to correct past violations, within 32 days of
|
60
|
+
receiving notice. Otherwise, all your licenses end immediately.
|
61
|
+
|
62
|
+
## No Liability
|
63
|
+
|
64
|
+
***As far as the law allows, the software comes as is, without any warranty or
|
65
|
+
condition, and the licensor will not be liable to you for any damages arising
|
66
|
+
out of these terms or the use or nature of the software, under any kind of
|
67
|
+
legal claim.***
|
68
|
+
|
69
|
+
## Definitions
|
70
|
+
|
71
|
+
The **licensor** is the individual or entity offering these terms, and the
|
72
|
+
**software** is the software the licensor makes available under these terms.
|
73
|
+
|
74
|
+
**You** refers to the individual or entity agreeing to these terms.
|
75
|
+
|
76
|
+
**Your company** is any legal entity, sole proprietorship, or other kind of
|
77
|
+
organization that you work for, plus all organizations that have control over,
|
78
|
+
are under the control of, or are under common control with that organization.
|
79
|
+
**Control** means ownership of substantially all the assets of an entity, or
|
80
|
+
the power to direct its management and policies by vote, contract, or
|
81
|
+
otherwise. Control can be direct or indirect.
|
82
|
+
|
83
|
+
**Your licenses** are all the licenses granted to you for the software under
|
84
|
+
these terms.
|
85
|
+
|
86
|
+
**Use** means anything you do with the software requiring one of your licenses.
|
87
|
+
|
88
|
+
## References
|
89
|
+
|
90
|
+
https://github.com/LGUG2Z/komorebi-license
|
data/README.md
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
NAME
|
2
|
+
----
|
3
|
+
ima
|
4
|
+
|
5
|
+
TL;DR;
|
6
|
+
--------
|
7
|
+
* fork this repo
|
8
|
+
* edit ./config/goals.md
|
9
|
+
* edit ./config/background.md
|
10
|
+
* edit ./config/instructions.md
|
11
|
+
* pluck your hairs
|
12
|
+
* multiply them into clones of yourself
|
13
|
+
* sit back and enjoy the [magic](docs/ima.md)
|
14
|
+
|
15
|
+
INSTALL
|
16
|
+
-------
|
17
|
+
gem install ima
|
18
|
+
|
19
|
+
URI
|
20
|
+
---
|
21
|
+
http://github.com/ahoward/ima
|
22
|
+
|
23
|
+
DESCRIPTION
|
24
|
+
-----------
|
25
|
+
|
26
|
+
# WIP
|
27
|
+
|
28
|
+
REFERENCES
|
29
|
+
-----------
|
30
|
+
* [ima.md](docs/ima.md)
|
data/Rakefile
ADDED
@@ -0,0 +1,448 @@
|
|
1
|
+
This.author = "Ara T. Howard"
|
2
|
+
This.email = "ara.t.howard@gmail.com"
|
3
|
+
This.github = "ahoward"
|
4
|
+
This.homepage = "https://github.com/#{ This.github }/#{ This.basename }"
|
5
|
+
This.repo = "https://github.com/#{ This.github }/#{ This.basename }"
|
6
|
+
|
7
|
+
task :default do
|
8
|
+
puts((Rake::Task.tasks.map{|task| task.name.gsub(/::/,':')} - ['default']).sort)
|
9
|
+
end
|
10
|
+
|
11
|
+
task :test do
|
12
|
+
run_tests!
|
13
|
+
end
|
14
|
+
|
15
|
+
namespace :test do
|
16
|
+
task(:unit){ run_tests!(:unit) }
|
17
|
+
task(:functional){ run_tests!(:functional) }
|
18
|
+
task(:integration){ run_tests!(:integration) }
|
19
|
+
end
|
20
|
+
|
21
|
+
def run_tests!(which = nil)
|
22
|
+
which ||= '**'
|
23
|
+
test_dir = File.join(This.dir, "test")
|
24
|
+
test_glob ||= File.join(test_dir, "#{ which }/**_test.rb")
|
25
|
+
test_rbs = Dir.glob(test_glob).sort
|
26
|
+
|
27
|
+
div = ('=' * 119)
|
28
|
+
line = ('-' * 119)
|
29
|
+
|
30
|
+
test_rbs.each_with_index do |test_rb, index|
|
31
|
+
testno = index + 1
|
32
|
+
command = "#{ This.ruby } -w -I ./lib -I ./test/lib #{ test_rb }"
|
33
|
+
|
34
|
+
puts
|
35
|
+
say(div, :color => :cyan, :bold => true)
|
36
|
+
say("@#{ testno } => ", :bold => true, :method => :print)
|
37
|
+
say(command, :color => :cyan, :bold => true)
|
38
|
+
say(line, :color => :cyan, :bold => true)
|
39
|
+
|
40
|
+
system(command)
|
41
|
+
|
42
|
+
say(line, :color => :cyan, :bold => true)
|
43
|
+
|
44
|
+
status = $?.exitstatus
|
45
|
+
|
46
|
+
if status.zero?
|
47
|
+
say("@#{ testno } <= ", :bold => true, :color => :white, :method => :print)
|
48
|
+
say("SUCCESS", :color => :green, :bold => true)
|
49
|
+
else
|
50
|
+
say("@#{ testno } <= ", :bold => true, :color => :white, :method => :print)
|
51
|
+
say("FAILURE", :color => :red, :bold => true)
|
52
|
+
end
|
53
|
+
say(line, :color => :cyan, :bold => true)
|
54
|
+
|
55
|
+
exit(status) unless status.zero?
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
task :gemspec do
|
61
|
+
ignore_extensions = ['git', 'svn', 'tmp', /sw./, 'bak', 'gem']
|
62
|
+
ignore_directories = ['pkg']
|
63
|
+
ignore_files = ['test/log']
|
64
|
+
|
65
|
+
shiteless =
|
66
|
+
lambda do |list|
|
67
|
+
list.delete_if do |entry|
|
68
|
+
next unless test(?e, entry)
|
69
|
+
extension = File.basename(entry).split(%r/[.]/).last
|
70
|
+
ignore_extensions.any?{|ext| ext === extension}
|
71
|
+
end
|
72
|
+
|
73
|
+
list.delete_if do |entry|
|
74
|
+
next unless test(?d, entry)
|
75
|
+
dirname = File.expand_path(entry)
|
76
|
+
ignore_directories.any?{|dir| File.expand_path(dir) == dirname}
|
77
|
+
end
|
78
|
+
|
79
|
+
list.delete_if do |entry|
|
80
|
+
next unless test(?f, entry)
|
81
|
+
filename = File.expand_path(entry)
|
82
|
+
ignore_files.any?{|file| File.expand_path(file) == filename}
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
name = This.basename
|
87
|
+
object = This.object
|
88
|
+
version = This.version
|
89
|
+
files = shiteless[Dir::glob("**/**")]
|
90
|
+
executables = shiteless[Dir::glob("bin/*")].map{|exe| File.basename(exe)}
|
91
|
+
summary = Util.unindent(This.summary).strip
|
92
|
+
description = Util.unindent(This.description).strip
|
93
|
+
license = "LicenseRef-LICENSE.md"
|
94
|
+
|
95
|
+
if This.extensions.nil?
|
96
|
+
This.extensions = []
|
97
|
+
extensions = This.extensions
|
98
|
+
%w( Makefile configure extconf.rb ).each do |ext|
|
99
|
+
extensions << ext if File.exist?(ext)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
extensions = [extensions].flatten.compact
|
103
|
+
|
104
|
+
if This.dependencies.nil?
|
105
|
+
dependencies = []
|
106
|
+
else
|
107
|
+
case This.dependencies
|
108
|
+
when Hash
|
109
|
+
dependencies = This.dependencies.values
|
110
|
+
when Array
|
111
|
+
dependencies = This.dependencies
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
template =
|
116
|
+
if test(?e, 'gemspec.erb')
|
117
|
+
Template{ IO.read('gemspec.erb') }
|
118
|
+
else
|
119
|
+
Template {
|
120
|
+
<<-__
|
121
|
+
## <%= name %>.gemspec
|
122
|
+
#
|
123
|
+
|
124
|
+
Gem::Specification::new do |spec|
|
125
|
+
spec.name = <%= name.inspect %>
|
126
|
+
spec.version = <%= version.inspect %>
|
127
|
+
spec.required_ruby_version = '>= 3.0'
|
128
|
+
spec.platform = Gem::Platform::RUBY
|
129
|
+
spec.summary = <%= summary.inspect %>
|
130
|
+
spec.description = <%= description.inspect %>
|
131
|
+
spec.license = <%= license.inspect %>
|
132
|
+
|
133
|
+
spec.files =\n<%= files.sort.pretty_inspect %>
|
134
|
+
spec.executables = <%= executables.inspect %>
|
135
|
+
|
136
|
+
spec.require_path = "lib"
|
137
|
+
|
138
|
+
<% dependencies.each do |lib_version| %>
|
139
|
+
spec.add_dependency(*<%= Array(lib_version).flatten.inspect %>)
|
140
|
+
<% end %>
|
141
|
+
|
142
|
+
spec.extensions.push(*<%= extensions.inspect %>)
|
143
|
+
|
144
|
+
spec.author = <%= This.author.inspect %>
|
145
|
+
spec.email = <%= This.email.inspect %>
|
146
|
+
spec.homepage = <%= This.homepage.inspect %>
|
147
|
+
end
|
148
|
+
__
|
149
|
+
}
|
150
|
+
end
|
151
|
+
|
152
|
+
Fu.mkdir_p(This.pkgdir)
|
153
|
+
gemspec = "#{ name }.gemspec"
|
154
|
+
open(gemspec, "w"){|fd| fd.puts(template)}
|
155
|
+
This.gemspec = gemspec
|
156
|
+
end
|
157
|
+
|
158
|
+
task :gem => [:clean, :gemspec] do
|
159
|
+
Fu.mkdir_p(This.pkgdir)
|
160
|
+
before = Dir['*.gem']
|
161
|
+
cmd = "gem build #{ This.gemspec }"
|
162
|
+
`#{ cmd }`
|
163
|
+
after = Dir['*.gem']
|
164
|
+
gem = ((after - before).first || after.first) or abort('no gem!')
|
165
|
+
Fu.mv(gem, This.pkgdir)
|
166
|
+
This.gem = File.join(This.pkgdir, File.basename(gem))
|
167
|
+
end
|
168
|
+
|
169
|
+
task :README => [:readme]
|
170
|
+
|
171
|
+
task :readme do
|
172
|
+
samples = ''
|
173
|
+
prompt = '~ > '
|
174
|
+
lib = This.lib
|
175
|
+
version = This.version
|
176
|
+
|
177
|
+
Dir['sample*/**/**.rb'].sort.each do |sample|
|
178
|
+
link = "[#{ sample }](#{ This.repo }/blob/main/#{ sample })"
|
179
|
+
samples << " #### <========< #{ link } >========>\n"
|
180
|
+
|
181
|
+
cmd = "cat #{ sample }"
|
182
|
+
samples << "```sh\n"
|
183
|
+
samples << Util.indent(prompt + cmd, 2) << "\n"
|
184
|
+
samples << "```\n"
|
185
|
+
samples << "```ruby\n"
|
186
|
+
samples << Util.indent(IO.binread(sample), 4) << "\n"
|
187
|
+
samples << "```\n"
|
188
|
+
|
189
|
+
samples << "\n"
|
190
|
+
|
191
|
+
cmd = "ruby #{ sample }"
|
192
|
+
samples << "```sh\n"
|
193
|
+
samples << Util.indent(prompt + cmd, 2) << "\n"
|
194
|
+
samples << "```\n"
|
195
|
+
|
196
|
+
cmd = "ruby -e'STDOUT.sync=true; exec %(ruby -I ./lib #{ sample })'"
|
197
|
+
oe = `#{ cmd } 2>&1`
|
198
|
+
samples << "```txt\n"
|
199
|
+
samples << Util.indent(oe, 4) << "\n"
|
200
|
+
samples << "```\n"
|
201
|
+
|
202
|
+
samples << "\n"
|
203
|
+
end
|
204
|
+
|
205
|
+
This.samples = samples
|
206
|
+
|
207
|
+
template =
|
208
|
+
case
|
209
|
+
when test(?e, 'README.md.erb')
|
210
|
+
Template{ IO.read('README.md.erb') }
|
211
|
+
when test(?e, 'README.erb')
|
212
|
+
Template{ IO.read('README.erb') }
|
213
|
+
else
|
214
|
+
Template {
|
215
|
+
<<-__
|
216
|
+
NAME
|
217
|
+
#{ lib }
|
218
|
+
|
219
|
+
DESCRIPTION
|
220
|
+
|
221
|
+
INSTALL
|
222
|
+
gem install #{ lib }
|
223
|
+
|
224
|
+
SAMPLES
|
225
|
+
#{ samples }
|
226
|
+
__
|
227
|
+
}
|
228
|
+
end
|
229
|
+
|
230
|
+
IO.binwrite('README.md', template)
|
231
|
+
end
|
232
|
+
|
233
|
+
task :clean do
|
234
|
+
Dir[File.join(This.pkgdir, '**/**')].each{|entry| Fu.rm_rf(entry)}
|
235
|
+
end
|
236
|
+
|
237
|
+
task :release => [:dist, :gem] do
|
238
|
+
gems = Dir[File.join(This.pkgdir, '*.gem')].flatten
|
239
|
+
abort "which one? : #{ gems.inspect }" if gems.size > 1
|
240
|
+
abort "no gems?" if gems.size < 1
|
241
|
+
|
242
|
+
cmd = "gem push #{ This.gem }"
|
243
|
+
puts cmd
|
244
|
+
puts
|
245
|
+
system(cmd)
|
246
|
+
abort("cmd(#{ cmd }) failed with (#{ $?.inspect })") unless $?.exitstatus.zero?
|
247
|
+
end
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
BEGIN {
|
254
|
+
# support for this rakefile
|
255
|
+
#
|
256
|
+
$VERBOSE = nil
|
257
|
+
|
258
|
+
require 'ostruct'
|
259
|
+
require 'erb'
|
260
|
+
require 'fileutils'
|
261
|
+
require 'rbconfig'
|
262
|
+
require 'pp'
|
263
|
+
|
264
|
+
# fu shortcut!
|
265
|
+
#
|
266
|
+
Fu = FileUtils
|
267
|
+
|
268
|
+
# guess a bunch of stuff about this rakefile/environment based on the
|
269
|
+
#
|
270
|
+
This = OpenStruct.new
|
271
|
+
|
272
|
+
This.file = File.expand_path(__FILE__)
|
273
|
+
This.dir = File.dirname(This.file)
|
274
|
+
This.pkgdir = File.join(This.dir, 'pkg')
|
275
|
+
This.basename = File.basename(This.dir)
|
276
|
+
|
277
|
+
# load actual shit _lib
|
278
|
+
#
|
279
|
+
_libpath = ["./lib/#{ This.basename }/_lib.rb", "./lib/#{ This.basename }.rb"]
|
280
|
+
_lib = _libpath.detect{|l| test(?s, l)}
|
281
|
+
|
282
|
+
abort "could not find a _lib in ./lib/ via #{ _libpath.join(':') }" unless _lib
|
283
|
+
|
284
|
+
This._lib = _lib
|
285
|
+
require This._lib
|
286
|
+
|
287
|
+
# extract the name from the _lib
|
288
|
+
#
|
289
|
+
lines = IO.binread(This._lib).split("\n")
|
290
|
+
re = %r`\A \s* (module|class) \s+ ([^\s]+) \s* \z`iomx
|
291
|
+
name = nil
|
292
|
+
lines.each do |line|
|
293
|
+
match = line.match(re)
|
294
|
+
if match
|
295
|
+
name = match.to_a.last
|
296
|
+
break
|
297
|
+
end
|
298
|
+
end
|
299
|
+
unless name
|
300
|
+
abort "could not extract `name` from #{ This._lib }"
|
301
|
+
end
|
302
|
+
This.name = name
|
303
|
+
This.basename = This.name.downcase
|
304
|
+
|
305
|
+
# now, fully grok This
|
306
|
+
#
|
307
|
+
This.object = eval(This.name)
|
308
|
+
This.version = This.object.version
|
309
|
+
This.dependencies = This.object.dependencies
|
310
|
+
This.summary = This.object.summary
|
311
|
+
This.description = This.object.respond_to?(:description) ? This.object.description : This.summary
|
312
|
+
This.license = "LicenseRef-LICENSE.md"
|
313
|
+
|
314
|
+
# discover full path to this ruby executable
|
315
|
+
#
|
316
|
+
c = RbConfig::CONFIG
|
317
|
+
bindir = c["bindir"] || c['BINDIR']
|
318
|
+
ruby_install_name = c['ruby_install_name'] || c['RUBY_INSTALL_NAME'] || 'ruby'
|
319
|
+
ruby_ext = c['EXEEXT'] || ''
|
320
|
+
ruby = File.join(bindir, (ruby_install_name + ruby_ext))
|
321
|
+
This.ruby = ruby
|
322
|
+
|
323
|
+
# some utils, alwayze teh utils...
|
324
|
+
#
|
325
|
+
module Util
|
326
|
+
def indent(s, n = 2)
|
327
|
+
s = unindent(s)
|
328
|
+
ws = ' ' * n
|
329
|
+
s.gsub(%r/^/, ws)
|
330
|
+
end
|
331
|
+
|
332
|
+
def unindent(s)
|
333
|
+
indent = nil
|
334
|
+
s.each_line do |line|
|
335
|
+
next if line =~ %r/^\s*$/
|
336
|
+
indent = line[%r/^\s*/] and break
|
337
|
+
end
|
338
|
+
unindented = indent ? s.gsub(%r/^#{ indent }/, "") : s
|
339
|
+
unindented.strip
|
340
|
+
end
|
341
|
+
extend self
|
342
|
+
end
|
343
|
+
|
344
|
+
# template support
|
345
|
+
#
|
346
|
+
class Template
|
347
|
+
def Template.indent(string, n = 2)
|
348
|
+
string = string.to_s
|
349
|
+
n = n.to_i
|
350
|
+
padding = (42 - 10).chr * n
|
351
|
+
initial = %r/^#{ Regexp.escape(padding) }/
|
352
|
+
#require 'debug'
|
353
|
+
#binding.break
|
354
|
+
Util.indent(string, n).sub(initial, '')
|
355
|
+
end
|
356
|
+
def initialize(&block)
|
357
|
+
@block = block
|
358
|
+
@template = block.call.to_s
|
359
|
+
end
|
360
|
+
def expand(b=nil)
|
361
|
+
ERB.new(Util.unindent(@template), trim_mode: '%<>-').result((b||@block).binding)
|
362
|
+
end
|
363
|
+
alias_method 'to_s', 'expand'
|
364
|
+
end
|
365
|
+
def Template(*args, &block) Template.new(*args, &block) end
|
366
|
+
|
367
|
+
# os / platform support
|
368
|
+
#
|
369
|
+
module Platform
|
370
|
+
def Platform.windows?
|
371
|
+
(/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
|
372
|
+
end
|
373
|
+
|
374
|
+
def Platform.darwin?
|
375
|
+
(/darwin/ =~ RUBY_PLATFORM) != nil
|
376
|
+
end
|
377
|
+
|
378
|
+
def Platform.mac?
|
379
|
+
Platform.darwin?
|
380
|
+
end
|
381
|
+
|
382
|
+
def Platform.unix?
|
383
|
+
!Platform.windows?
|
384
|
+
end
|
385
|
+
|
386
|
+
def Platform.linux?
|
387
|
+
Platform.unix? and not Platform.darwin?
|
388
|
+
end
|
389
|
+
|
390
|
+
def Platform.jruby?
|
391
|
+
RUBY_ENGINE == 'jruby'
|
392
|
+
end
|
393
|
+
end
|
394
|
+
|
395
|
+
# colored console output support
|
396
|
+
#
|
397
|
+
This.ansi = {
|
398
|
+
:clear => "\e[0m",
|
399
|
+
:reset => "\e[0m",
|
400
|
+
:erase_line => "\e[K",
|
401
|
+
:erase_char => "\e[P",
|
402
|
+
:bold => "\e[1m",
|
403
|
+
:dark => "\e[2m",
|
404
|
+
:underline => "\e[4m",
|
405
|
+
:underscore => "\e[4m",
|
406
|
+
:blink => "\e[5m",
|
407
|
+
:reverse => "\e[7m",
|
408
|
+
:concealed => "\e[8m",
|
409
|
+
:black => "\e[30m",
|
410
|
+
:red => "\e[31m",
|
411
|
+
:green => "\e[32m",
|
412
|
+
:yellow => "\e[33m",
|
413
|
+
:blue => "\e[34m",
|
414
|
+
:magenta => "\e[35m",
|
415
|
+
:cyan => "\e[36m",
|
416
|
+
:white => "\e[37m",
|
417
|
+
:on_black => "\e[40m",
|
418
|
+
:on_red => "\e[41m",
|
419
|
+
:on_green => "\e[42m",
|
420
|
+
:on_yellow => "\e[43m",
|
421
|
+
:on_blue => "\e[44m",
|
422
|
+
:on_magenta => "\e[45m",
|
423
|
+
:on_cyan => "\e[46m",
|
424
|
+
:on_white => "\e[47m"
|
425
|
+
}
|
426
|
+
def say(phrase, *args)
|
427
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
428
|
+
options[:color] = args.shift.to_s.to_sym unless args.empty?
|
429
|
+
keys = options.keys
|
430
|
+
keys.each{|key| options[key.to_s.to_sym] = options.delete(key)}
|
431
|
+
|
432
|
+
color = options[:color]
|
433
|
+
bold = options.has_key?(:bold)
|
434
|
+
|
435
|
+
parts = [phrase]
|
436
|
+
parts.unshift(This.ansi[color]) if color
|
437
|
+
parts.unshift(This.ansi[:bold]) if bold
|
438
|
+
parts.push(This.ansi[:clear]) if parts.size > 1
|
439
|
+
|
440
|
+
method = options[:method] || :puts
|
441
|
+
|
442
|
+
Kernel.send(method, parts.join)
|
443
|
+
end
|
444
|
+
|
445
|
+
# always run out of the project dir
|
446
|
+
#
|
447
|
+
Dir.chdir(This.dir)
|
448
|
+
}
|
data/docs/sunwukong.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
**Sun Wukong (Journey to the West)**
|
2
|
+
|
3
|
+
Sun Wukong, also known as the Monkey King, is an iconic figure from the 16th-century Chinese novel "Journey to the West." He's a character brimming with personality and extraordinary abilities.
|
4
|
+
|
5
|
+
**Origins and Abilities:**
|
6
|
+
|
7
|
+
* **Born from Stone:**
|
8
|
+
* Emerges from a magical stone atop Flower Fruit Mountain, imbued with the powers of heaven and earth.
|
9
|
+
* **Supernatural Powers:**
|
10
|
+
* **72 Transformations:** Shapeshifts into virtually anything.
|
11
|
+
* **Cloud Somersault:** Travels immense distances in a single leap.
|
12
|
+
* **Immortality:** Achieves a form of immortality.
|
13
|
+
* **Cloning:** Creates clones by plucking his hairs.
|
14
|
+
* Great martial arts skills, and immense strength.
|
15
|
+
* **Rebellious Nature:**
|
16
|
+
* Mischievous and rebellious spirit, challenging authority, especially the heavenly court.
|
17
|
+
|
18
|
+
**The Journey to the West:**
|
19
|
+
|
20
|
+
* **Pilgrimage:**
|
21
|
+
* Protector and disciple of the Buddhist monk Tang Sanzang on a journey to retrieve sacred scriptures.
|
22
|
+
* **Redemption:**
|
23
|
+
* Journey serves as a path of redemption, learning to control his impulsive nature.
|
24
|
+
* **Character Arc:**
|
25
|
+
* Matures from a wild, self-centered being to a protector of the innocent.
|
26
|
+
|
27
|
+
**Cultural Significance:**
|
28
|
+
|
29
|
+
* **Enduring Popularity:**
|
30
|
+
* Inspires countless adaptations in various media.
|
31
|
+
* **Symbolism:**
|
32
|
+
* Represents themes of freedom, rebellion, and the pursuit of enlightenment.
|
33
|
+
* **Influence:**
|
34
|
+
* Son Goku from "Dragon Ball" is heavily based on Sun Wukong.
|
35
|
+
|
36
|
+
**References**
|
37
|
+
|
38
|
+
* https://en.wikipedia.org/wiki/Sun_Wukong#:~:text=Sun%20Wukong%20(Chinese%3A%20%E5%AD%AB%E6%82%9F%E7%A9%BA%2C,known%20as%20one%20of%20the
|
data/lib/ima/_lib.rb
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
class Ima
|
2
|
+
VERSION = '0.4.2'
|
3
|
+
|
4
|
+
class << Ima
|
5
|
+
def version
|
6
|
+
VERSION
|
7
|
+
end
|
8
|
+
|
9
|
+
def repo
|
10
|
+
'https://github.com/ahoward/ima'
|
11
|
+
end
|
12
|
+
|
13
|
+
def summary
|
14
|
+
<<~____
|
15
|
+
ima is the ai agenic framework for super monkeys
|
16
|
+
____
|
17
|
+
end
|
18
|
+
|
19
|
+
def description
|
20
|
+
<<~____
|
21
|
+
ima is a a library, framework, and set of tools that allow
|
22
|
+
non-technical users to manage and deploy complex ai agenic frameworks
|
23
|
+
in seconds for free at best, and cheap at worst.
|
24
|
+
____
|
25
|
+
end
|
26
|
+
|
27
|
+
def libs
|
28
|
+
%w[
|
29
|
+
]
|
30
|
+
end
|
31
|
+
|
32
|
+
def dependencies
|
33
|
+
{
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
def libdir(*args, &block)
|
38
|
+
@libdir ||= File.dirname(File.expand_path(__FILE__))
|
39
|
+
args.empty? ? @libdir : File.join(@libdir, *args)
|
40
|
+
ensure
|
41
|
+
if block
|
42
|
+
begin
|
43
|
+
$LOAD_PATH.unshift(@libdir)
|
44
|
+
block.call
|
45
|
+
ensure
|
46
|
+
$LOAD_PATH.shift
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def load(*libs)
|
52
|
+
libs = libs.join(' ').scan(/[^\s+]+/)
|
53
|
+
libdir { libs.each { |lib| Kernel.load(lib) } }
|
54
|
+
end
|
55
|
+
|
56
|
+
def load_dependencies!
|
57
|
+
libs.each do |lib|
|
58
|
+
require lib
|
59
|
+
end
|
60
|
+
|
61
|
+
begin
|
62
|
+
require 'rubygems'
|
63
|
+
rescue LoadError
|
64
|
+
nil
|
65
|
+
end
|
66
|
+
|
67
|
+
has_rubygems = defined?(gem)
|
68
|
+
|
69
|
+
dependencies.each do |lib, dependency|
|
70
|
+
gem(*dependency) if has_rubygems
|
71
|
+
require(lib)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
data/lib/ima/options.rb
ADDED
@@ -0,0 +1,188 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
class Map
|
3
|
+
module Options
|
4
|
+
class << Options
|
5
|
+
def for(arg)
|
6
|
+
options =
|
7
|
+
case arg
|
8
|
+
when Hash
|
9
|
+
arg
|
10
|
+
when Array
|
11
|
+
parse(arg)
|
12
|
+
when String, Symbol
|
13
|
+
{arg => true}
|
14
|
+
else
|
15
|
+
raise(ArgumentError, arg.inspect) unless arg.respond_to?(:to_hash)
|
16
|
+
arg.to_hash
|
17
|
+
end
|
18
|
+
|
19
|
+
unless options.is_a?(Options)
|
20
|
+
options = Map.for(options)
|
21
|
+
options.extend(Options)
|
22
|
+
end
|
23
|
+
|
24
|
+
raise unless options.is_a?(Map)
|
25
|
+
|
26
|
+
options
|
27
|
+
end
|
28
|
+
|
29
|
+
def parse(arg)
|
30
|
+
case arg
|
31
|
+
when Array
|
32
|
+
arguments = arg
|
33
|
+
arguments.extend(Arguments) unless arguments.is_a?(Arguments)
|
34
|
+
options = arguments.options
|
35
|
+
when Hash
|
36
|
+
options = arg
|
37
|
+
options = Options.for(options)
|
38
|
+
else
|
39
|
+
raise(ArgumentError, "`arg` should be an Array or Hash")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
attr_accessor :arguments
|
45
|
+
|
46
|
+
def pop
|
47
|
+
arguments.pop if arguments.last.object_id == object_id
|
48
|
+
self
|
49
|
+
end
|
50
|
+
|
51
|
+
def popped?
|
52
|
+
!(arguments.last.object_id == object_id)
|
53
|
+
end
|
54
|
+
|
55
|
+
def pop!
|
56
|
+
arguments.pop if arguments.last.object_id == object_id
|
57
|
+
self
|
58
|
+
end
|
59
|
+
|
60
|
+
%w( to_options stringify_keys ).each do |method|
|
61
|
+
module_eval <<-__, __FILE__, __LINE__
|
62
|
+
def #{ method }() dup end
|
63
|
+
def #{ method }!() self end
|
64
|
+
__
|
65
|
+
end
|
66
|
+
|
67
|
+
def get_opt(opts, options = {})
|
68
|
+
options = Map.for(options.is_a?(Hash) ? options : {:default => options})
|
69
|
+
default = options[:default]
|
70
|
+
[ opts ].flatten.each do |opt|
|
71
|
+
return fetch(opt) if has_key?(opt)
|
72
|
+
end
|
73
|
+
default
|
74
|
+
end
|
75
|
+
alias_method('getopt', 'get_opt')
|
76
|
+
|
77
|
+
def get_opts(*opts)
|
78
|
+
opts.flatten.map{|opt| getopt(opt)}
|
79
|
+
end
|
80
|
+
alias_method('getopts', 'get_opts')
|
81
|
+
|
82
|
+
def has_opt(opts)
|
83
|
+
[ opts ].flatten.each do |opt|
|
84
|
+
return true if has_key?(opt)
|
85
|
+
end
|
86
|
+
false
|
87
|
+
end
|
88
|
+
alias_method('hasopt', 'has_opt')
|
89
|
+
alias_method('hasopt?', 'has_opt')
|
90
|
+
alias_method('has_opt?', 'has_opt')
|
91
|
+
|
92
|
+
def has_opts(*opts)
|
93
|
+
opts.flatten.all?{|opt| hasopt(opt)}
|
94
|
+
end
|
95
|
+
alias_method('hasopts?', 'has_opts')
|
96
|
+
alias_method('has_opts?', 'has_opts')
|
97
|
+
|
98
|
+
def del_opt(opts)
|
99
|
+
[ opts ].flatten.each do |opt|
|
100
|
+
return delete(opt) if has_key?(opt)
|
101
|
+
end
|
102
|
+
nil
|
103
|
+
end
|
104
|
+
alias_method('delopt', 'del_opt')
|
105
|
+
|
106
|
+
def del_opts(*opts)
|
107
|
+
opts.flatten.map{|opt| delopt(opt)}
|
108
|
+
opts
|
109
|
+
end
|
110
|
+
alias_method('delopts', 'del_opts')
|
111
|
+
alias_method('delopts!', 'del_opts')
|
112
|
+
|
113
|
+
def set_opt(opts, value = nil)
|
114
|
+
[ opts ].flatten.each do |opt|
|
115
|
+
return self[opt]=value
|
116
|
+
end
|
117
|
+
return value
|
118
|
+
end
|
119
|
+
alias_method('setopt', 'set_opt')
|
120
|
+
alias_method('setopt!', 'set_opt')
|
121
|
+
|
122
|
+
def set_opts(opts)
|
123
|
+
opts.each{|key, value| setopt(key, value)}
|
124
|
+
opts
|
125
|
+
end
|
126
|
+
alias_method('setopts', 'set_opts')
|
127
|
+
alias_method('setopts!', 'set_opts')
|
128
|
+
end
|
129
|
+
|
130
|
+
module Arguments
|
131
|
+
def options
|
132
|
+
@options ||=(
|
133
|
+
if last.is_a?(Hash)
|
134
|
+
options = Options.for(pop)
|
135
|
+
options.arguments = self
|
136
|
+
push(options)
|
137
|
+
options
|
138
|
+
else
|
139
|
+
options = Options.for({})
|
140
|
+
options.arguments = self
|
141
|
+
options
|
142
|
+
end
|
143
|
+
)
|
144
|
+
end
|
145
|
+
|
146
|
+
class << Arguments
|
147
|
+
def for(args)
|
148
|
+
args.extend(Arguments) unless args.is_a?(Arguments)
|
149
|
+
args
|
150
|
+
end
|
151
|
+
|
152
|
+
def parse(args)
|
153
|
+
[args, Options.parse(args)]
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
|
160
|
+
def Map.options_for(*args, &block)
|
161
|
+
Map::Options.for(*args, &block)
|
162
|
+
end
|
163
|
+
|
164
|
+
def Map.options_for!(*args, &block)
|
165
|
+
Map::Options.for(*args, &block).pop
|
166
|
+
end
|
167
|
+
|
168
|
+
def Map.update_options_for!(args, &block)
|
169
|
+
options = Map.options_for(args)
|
170
|
+
block.call(options)
|
171
|
+
end
|
172
|
+
|
173
|
+
class << Map
|
174
|
+
src = 'options_for'
|
175
|
+
%w( options opts extract_options ).each do |dst|
|
176
|
+
alias_method(dst, src)
|
177
|
+
end
|
178
|
+
|
179
|
+
src = 'options_for!'
|
180
|
+
%w( options! opts! extract_options! ).each do |dst|
|
181
|
+
alias_method(dst, src)
|
182
|
+
end
|
183
|
+
|
184
|
+
src = 'update_options_for!'
|
185
|
+
%w( update_options! update_opts! ).each do |dst|
|
186
|
+
alias_method(dst, src)
|
187
|
+
end
|
188
|
+
end
|
data/lib/ima.rb
ADDED
data/sunwukong.gemspec
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
## ima.gemspec
|
2
|
+
#
|
3
|
+
|
4
|
+
Gem::Specification::new do |spec|
|
5
|
+
spec.name = "ima"
|
6
|
+
spec.version = "0.4.2"
|
7
|
+
spec.required_ruby_version = '>= 3.0'
|
8
|
+
spec.platform = Gem::Platform::RUBY
|
9
|
+
spec.summary = "ima is the ai agenic framework for super monkeys"
|
10
|
+
spec.description = "ima is a a library, framework, and set of tools that allow\nnon-technical users to manage and deploy complex ai agenic frameworks\nin seconds for free at best, and cheap at worst."
|
11
|
+
spec.license = "LicenseRef-LICENSE.md"
|
12
|
+
|
13
|
+
spec.files =
|
14
|
+
["LICENSE.md",
|
15
|
+
"README.md",
|
16
|
+
"Rakefile",
|
17
|
+
"SUNWUKONG.md",
|
18
|
+
"lib",
|
19
|
+
"lib/ima",
|
20
|
+
"lib/ima.rb",
|
21
|
+
"lib/ima/_lib.rb",
|
22
|
+
"lib/ima/options.rb",
|
23
|
+
"ima.gemspec",
|
24
|
+
"test"]
|
25
|
+
|
26
|
+
spec.executables = []
|
27
|
+
|
28
|
+
spec.require_path = "lib"
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
spec.extensions.push(*[])
|
33
|
+
|
34
|
+
spec.author = "Ara T. Howard"
|
35
|
+
spec.email = "ara.t.howard@gmail.com"
|
36
|
+
spec.homepage = "https://github.com/ahoward/ima"
|
37
|
+
end
|
metadata
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ima
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.4.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ara T. Howard
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2025-02-24 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: |-
|
14
|
+
ima is a a library, framework, and set of tools that allow
|
15
|
+
non-technical users to manage and deploy complex ai agenic frameworks
|
16
|
+
in seconds for free at best, and cheap at worst.
|
17
|
+
email: ara.t.howard@gmail.com
|
18
|
+
executables: []
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- LICENSE.md
|
23
|
+
- README.md
|
24
|
+
- Rakefile
|
25
|
+
- docs/sunwukong.md
|
26
|
+
- lib/ima.rb
|
27
|
+
- lib/ima/_lib.rb
|
28
|
+
- lib/ima/options.rb
|
29
|
+
- sunwukong.gemspec
|
30
|
+
homepage: https://github.com/ahoward/ima
|
31
|
+
licenses:
|
32
|
+
- LicenseRef-LICENSE.md
|
33
|
+
metadata: {}
|
34
|
+
post_install_message:
|
35
|
+
rdoc_options: []
|
36
|
+
require_paths:
|
37
|
+
- lib
|
38
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '3.0'
|
43
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
requirements: []
|
49
|
+
rubygems_version: 3.5.18
|
50
|
+
signing_key:
|
51
|
+
specification_version: 4
|
52
|
+
summary: ima is the ai agenic framework for super monkeys
|
53
|
+
test_files: []
|