ro 1.4.6 → 4.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -14
- data/Gemfile +2 -0
- data/Gemfile.lock +43 -0
- data/LICENSE +1 -0
- data/README.md +120 -112
- data/README.md.erb +159 -0
- data/Rakefile +129 -78
- data/bin/ro +241 -68
- data/lib/ro/_lib.rb +95 -0
- data/lib/ro/asset.rb +45 -0
- data/lib/ro/collection/list.rb +23 -0
- data/lib/ro/collection.rb +168 -0
- data/lib/ro/config.rb +68 -0
- data/lib/ro/error.rb +8 -0
- data/lib/ro/klass.rb +25 -0
- data/lib/ro/methods.rb +238 -0
- data/lib/ro/model.rb +83 -114
- data/lib/ro/node.rb +177 -360
- data/lib/ro/pagination.rb +7 -4
- data/lib/ro/path.rb +225 -0
- data/lib/ro/root.rb +52 -31
- data/lib/ro/script/builder.rb +221 -0
- data/lib/ro/script/console.rb +47 -0
- data/lib/ro/script/server.rb +76 -0
- data/lib/ro/script.rb +189 -0
- data/lib/ro/slug.rb +19 -18
- data/lib/ro/template/rouge_formatter.rb +42 -0
- data/lib/ro/template.rb +104 -50
- data/lib/ro.rb +85 -317
- data/public/api/ro/index-1.json +147 -0
- data/public/api/ro/index.json +137 -0
- data/public/api/ro/posts/first_post/index.json +52 -0
- data/public/api/ro/posts/index-1.json +145 -0
- data/public/api/ro/posts/index.json +135 -0
- data/public/api/ro/posts/second_post/index.json +51 -0
- data/public/api/ro/posts/third_post/index.json +51 -0
- data/public/ro/posts/first_post/assets/foo/bar/baz.jpg +0 -0
- data/public/ro/posts/first_post/assets/foo.jpg +0 -0
- data/public/ro/posts/first_post/assets/src/foo/bar.rb +3 -0
- data/public/ro/posts/first_post/attributes.yml +2 -0
- data/public/ro/posts/first_post/blurb.erb.md +7 -0
- data/public/ro/posts/first_post/body.md +16 -0
- data/public/ro/posts/first_post/testing.txt +3 -0
- data/public/ro/posts/second_post/assets/foo/bar/baz.jpg +0 -0
- data/public/ro/posts/second_post/assets/foo.jpg +0 -0
- data/public/ro/posts/second_post/assets/src/foo/bar.rb +3 -0
- data/public/ro/posts/second_post/attributes.yml +2 -0
- data/public/ro/posts/second_post/blurb.erb.md +5 -0
- data/public/ro/posts/second_post/body.md +16 -0
- data/public/ro/posts/third_post/assets/foo/bar/baz.jpg +0 -0
- data/public/ro/posts/third_post/assets/foo.jpg +0 -0
- data/public/ro/posts/third_post/assets/src/foo/bar.rb +3 -0
- data/public/ro/posts/third_post/attributes.yml +2 -0
- data/public/ro/posts/third_post/blurb.erb.md +5 -0
- data/public/ro/posts/third_post/body.md +16 -0
- data/ro.gemspec +89 -29
- metadata +106 -90
- data/TODO.md +0 -50
- data/lib/ro/blankslate.rb +0 -7
- data/lib/ro/cache.rb +0 -26
- data/lib/ro/git.rb +0 -374
- data/lib/ro/initializers/env.rb +0 -5
- data/lib/ro/initializers/tilt.rb +0 -104
- data/lib/ro/lock.rb +0 -53
- data/lib/ro/node/list.rb +0 -142
- data/notes/ara.txt +0 -215
data/Rakefile
CHANGED
@@ -1,8 +1,12 @@
|
|
1
|
-
This.rubyforge_project = 'codeforpeople'
|
2
1
|
This.author = "Ara T. Howard"
|
3
2
|
This.email = "ara.t.howard@gmail.com"
|
4
|
-
This.
|
3
|
+
This.github = "ahoward"
|
4
|
+
This.homepage = "https://github.com/#{ This.github }/#{ This.basename }"
|
5
|
+
This.repo = "https://github.com/#{ This.github }/#{ This.basename }"
|
5
6
|
|
7
|
+
task :license do
|
8
|
+
open('LICENSE', 'w'){|fd| fd.puts "Ruby"}
|
9
|
+
end
|
6
10
|
|
7
11
|
task :default do
|
8
12
|
puts((Rake::Task.tasks.map{|task| task.name.gsub(/::/,':')} - ['default']).sort)
|
@@ -29,7 +33,7 @@ def run_tests!(which = nil)
|
|
29
33
|
|
30
34
|
test_rbs.each_with_index do |test_rb, index|
|
31
35
|
testno = index + 1
|
32
|
-
command = "#{
|
36
|
+
command = "#{ This.ruby } -w -I ./lib -I ./test/lib #{ test_rb }"
|
33
37
|
|
34
38
|
puts
|
35
39
|
say(div, :color => :cyan, :bold => true)
|
@@ -59,8 +63,8 @@ end
|
|
59
63
|
|
60
64
|
task :gemspec do
|
61
65
|
ignore_extensions = ['git', 'svn', 'tmp', /sw./, 'bak', 'gem']
|
62
|
-
ignore_directories = ['pkg'
|
63
|
-
ignore_files = ['test/log'
|
66
|
+
ignore_directories = ['pkg']
|
67
|
+
ignore_files = ['test/log']
|
64
68
|
|
65
69
|
shiteless =
|
66
70
|
lambda do |list|
|
@@ -69,11 +73,13 @@ task :gemspec do
|
|
69
73
|
extension = File.basename(entry).split(%r/[.]/).last
|
70
74
|
ignore_extensions.any?{|ext| ext === extension}
|
71
75
|
end
|
76
|
+
|
72
77
|
list.delete_if do |entry|
|
73
78
|
next unless test(?d, entry)
|
74
79
|
dirname = File.expand_path(entry)
|
75
80
|
ignore_directories.any?{|dir| File.expand_path(dir) == dirname}
|
76
81
|
end
|
82
|
+
|
77
83
|
list.delete_if do |entry|
|
78
84
|
next unless test(?f, entry)
|
79
85
|
filename = File.expand_path(entry)
|
@@ -81,36 +87,24 @@ task :gemspec do
|
|
81
87
|
end
|
82
88
|
end
|
83
89
|
|
84
|
-
|
90
|
+
name = This.basename
|
85
91
|
object = This.object
|
86
92
|
version = This.version
|
87
|
-
files = shiteless[Dir::glob("**/**")]
|
93
|
+
files = shiteless[Dir::glob("**/**")]
|
88
94
|
executables = shiteless[Dir::glob("bin/*")].map{|exe| File.basename(exe)}
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
description = object.respond_to?(:description) ? object.description : "description: #{ lib } kicks the ass"
|
93
|
-
license = object.respond_to?(:license) ? object.license : nil
|
94
|
-
|
95
|
-
if license.nil?
|
96
|
-
license =
|
97
|
-
begin
|
98
|
-
IO.binread('LICENSE')
|
99
|
-
rescue
|
100
|
-
"Same As Ruby's"
|
101
|
-
end
|
102
|
-
end
|
95
|
+
summary = Util.unindent(This.summary).strip
|
96
|
+
description = Util.unindent(This.description).strip
|
97
|
+
license = This.license.strip
|
103
98
|
|
104
99
|
if This.extensions.nil?
|
105
100
|
This.extensions = []
|
106
101
|
extensions = This.extensions
|
107
102
|
%w( Makefile configure extconf.rb ).each do |ext|
|
108
|
-
extensions << ext if File.
|
103
|
+
extensions << ext if File.exist?(ext)
|
109
104
|
end
|
110
105
|
end
|
111
106
|
extensions = [extensions].flatten.compact
|
112
107
|
|
113
|
-
# TODO
|
114
108
|
if This.dependencies.nil?
|
115
109
|
dependencies = []
|
116
110
|
else
|
@@ -128,14 +122,15 @@ task :gemspec do
|
|
128
122
|
else
|
129
123
|
Template {
|
130
124
|
<<-__
|
131
|
-
## <%=
|
125
|
+
## <%= name %>.gemspec
|
132
126
|
#
|
133
127
|
|
134
128
|
Gem::Specification::new do |spec|
|
135
|
-
spec.name = <%=
|
129
|
+
spec.name = <%= name.inspect %>
|
136
130
|
spec.version = <%= version.inspect %>
|
131
|
+
spec.required_ruby_version = '>= 3.0'
|
137
132
|
spec.platform = Gem::Platform::RUBY
|
138
|
-
spec.summary = <%=
|
133
|
+
spec.summary = <%= summary.inspect %>
|
139
134
|
spec.description = <%= description.inspect %>
|
140
135
|
spec.license = <%= license.inspect %>
|
141
136
|
|
@@ -144,15 +139,12 @@ task :gemspec do
|
|
144
139
|
|
145
140
|
spec.require_path = "lib"
|
146
141
|
|
147
|
-
spec.test_files = <%= test_files.inspect %>
|
148
|
-
|
149
142
|
<% dependencies.each do |lib_version| %>
|
150
143
|
spec.add_dependency(*<%= Array(lib_version).flatten.inspect %>)
|
151
144
|
<% end %>
|
152
145
|
|
153
146
|
spec.extensions.push(*<%= extensions.inspect %>)
|
154
147
|
|
155
|
-
spec.rubyforge_project = <%= This.rubyforge_project.inspect %>
|
156
148
|
spec.author = <%= This.author.inspect %>
|
157
149
|
spec.email = <%= This.email.inspect %>
|
158
150
|
spec.homepage = <%= This.homepage.inspect %>
|
@@ -162,7 +154,7 @@ task :gemspec do
|
|
162
154
|
end
|
163
155
|
|
164
156
|
Fu.mkdir_p(This.pkgdir)
|
165
|
-
gemspec = "#{
|
157
|
+
gemspec = "#{ name }.gemspec"
|
166
158
|
open(gemspec, "w"){|fd| fd.puts(template)}
|
167
159
|
This.gemspec = gemspec
|
168
160
|
end
|
@@ -178,29 +170,50 @@ task :gem => [:clean, :gemspec] do
|
|
178
170
|
This.gem = File.join(This.pkgdir, File.basename(gem))
|
179
171
|
end
|
180
172
|
|
173
|
+
task :README => [:readme]
|
174
|
+
|
181
175
|
task :readme do
|
182
176
|
samples = ''
|
183
177
|
prompt = '~ > '
|
184
178
|
lib = This.lib
|
185
179
|
version = This.version
|
186
180
|
|
187
|
-
Dir['sample
|
188
|
-
|
181
|
+
Dir['sample*/**/**.rb'].sort.each do |sample|
|
182
|
+
link = "[#{ sample }](#{ This.repo }/blob/main/#{ sample })"
|
183
|
+
samples << " #### <========< #{ link } >========>\n"
|
189
184
|
|
190
185
|
cmd = "cat #{ sample }"
|
191
|
-
samples <<
|
192
|
-
samples << Util.indent(
|
186
|
+
samples << "```sh\n"
|
187
|
+
samples << Util.indent(prompt + cmd, 2) << "\n"
|
188
|
+
samples << "```\n"
|
189
|
+
samples << "```ruby\n"
|
190
|
+
samples << Util.indent(IO.binread(sample), 4) << "\n"
|
191
|
+
samples << "```\n"
|
192
|
+
|
193
|
+
samples << "\n"
|
193
194
|
|
194
195
|
cmd = "ruby #{ sample }"
|
195
|
-
samples <<
|
196
|
+
samples << "```sh\n"
|
197
|
+
samples << Util.indent(prompt + cmd, 2) << "\n"
|
198
|
+
samples << "```\n"
|
196
199
|
|
197
200
|
cmd = "ruby -e'STDOUT.sync=true; exec %(ruby -I ./lib #{ sample })'"
|
198
|
-
|
201
|
+
oe = `#{ cmd } 2>&1`
|
202
|
+
samples << "```txt\n"
|
203
|
+
samples << Util.indent(oe, 4) << "\n"
|
204
|
+
samples << "```\n"
|
205
|
+
|
206
|
+
samples << "\n"
|
199
207
|
end
|
200
208
|
|
209
|
+
This.samples = samples
|
210
|
+
|
201
211
|
template =
|
202
|
-
|
203
|
-
|
212
|
+
case
|
213
|
+
when test(?e, 'README.md.erb')
|
214
|
+
Template{ IO.read('README.md.erb') }
|
215
|
+
when test(?e, 'README.erb')
|
216
|
+
Template{ IO.read('README.erb') }
|
204
217
|
else
|
205
218
|
Template {
|
206
219
|
<<-__
|
@@ -218,31 +231,23 @@ task :readme do
|
|
218
231
|
}
|
219
232
|
end
|
220
233
|
|
221
|
-
|
234
|
+
IO.binwrite('README.md', template)
|
222
235
|
end
|
223
236
|
|
224
|
-
|
225
237
|
task :clean do
|
226
238
|
Dir[File.join(This.pkgdir, '**/**')].each{|entry| Fu.rm_rf(entry)}
|
227
239
|
end
|
228
240
|
|
229
|
-
|
230
|
-
task :release => [:clean, :gemspec, :gem] do
|
241
|
+
task :release => [:dist, :gem] do
|
231
242
|
gems = Dir[File.join(This.pkgdir, '*.gem')].flatten
|
232
|
-
|
233
|
-
|
243
|
+
abort "which one? : #{ gems.inspect }" if gems.size > 1
|
244
|
+
abort "no gems?" if gems.size < 1
|
234
245
|
|
235
246
|
cmd = "gem push #{ This.gem }"
|
236
247
|
puts cmd
|
237
248
|
puts
|
238
249
|
system(cmd)
|
239
250
|
abort("cmd(#{ cmd }) failed with (#{ $?.inspect })") unless $?.exitstatus.zero?
|
240
|
-
|
241
|
-
cmd = "rubyforge login && rubyforge add_release #{ This.rubyforge_project } #{ This.lib } #{ This.version } #{ This.gem }"
|
242
|
-
puts cmd
|
243
|
-
puts
|
244
|
-
system(cmd)
|
245
|
-
abort("cmd(#{ cmd }) failed with (#{ $?.inspect })") unless $?.exitstatus.zero?
|
246
251
|
end
|
247
252
|
|
248
253
|
|
@@ -260,58 +265,66 @@ BEGIN {
|
|
260
265
|
require 'rbconfig'
|
261
266
|
require 'pp'
|
262
267
|
|
263
|
-
# fu shortcut
|
268
|
+
# fu shortcut!
|
264
269
|
#
|
265
270
|
Fu = FileUtils
|
266
271
|
|
267
|
-
#
|
272
|
+
# guess a bunch of stuff about this rakefile/environment based on the
|
268
273
|
#
|
269
274
|
This = OpenStruct.new
|
270
275
|
|
271
276
|
This.file = File.expand_path(__FILE__)
|
272
277
|
This.dir = File.dirname(This.file)
|
273
278
|
This.pkgdir = File.join(This.dir, 'pkg')
|
279
|
+
This.basename = File.basename(This.dir)
|
274
280
|
|
275
|
-
#
|
281
|
+
# load actual shit _lib
|
276
282
|
#
|
277
|
-
|
278
|
-
|
279
|
-
lib = File.basename(Dir.pwd).sub(/[-].*$/, '')
|
280
|
-
end
|
281
|
-
This.lib = lib
|
283
|
+
_libpath = ["./lib/#{ This.basename }/_lib.rb", "./lib/#{ This.basename }.rb"]
|
284
|
+
_lib = _libpath.detect{|l| test(?s, l)}
|
282
285
|
|
283
|
-
#
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
require "./lib/#{ This.lib }"
|
288
|
-
This.name = lib.capitalize
|
289
|
-
This.object = eval(This.name)
|
290
|
-
version = This.object.send(:version)
|
291
|
-
end
|
292
|
-
This.version = version
|
286
|
+
abort "could not find a _lib in ./lib/ via #{ _libpath.join(':') }" unless _lib
|
287
|
+
|
288
|
+
This._lib = _lib
|
289
|
+
require This._lib
|
293
290
|
|
294
|
-
#
|
291
|
+
# extract the name from the _lib
|
295
292
|
#
|
296
|
-
|
297
|
-
|
293
|
+
lines = IO.binread(This._lib).split("\n")
|
294
|
+
re = %r`\A \s* (module|class) \s+ ([^\s]+) \s* \z`iomx
|
295
|
+
name = nil
|
296
|
+
lines.each do |line|
|
297
|
+
match = line.match(re)
|
298
|
+
if match
|
299
|
+
name = match.to_a.last
|
300
|
+
break
|
301
|
+
end
|
298
302
|
end
|
303
|
+
unless name
|
304
|
+
abort "could not extract `name` from #{ This._lib }"
|
305
|
+
end
|
306
|
+
This.name = name
|
307
|
+
This.basename = This.name.downcase
|
299
308
|
|
300
|
-
#
|
309
|
+
# now, fully grok This
|
301
310
|
#
|
302
|
-
|
303
|
-
|
311
|
+
This.object = eval(This.name)
|
312
|
+
This.version = This.object.version
|
313
|
+
This.dependencies = This.object.dependencies
|
314
|
+
This.summary = This.object.summary
|
315
|
+
This.description = This.respond_to?(:description) ? This.description : This.summary
|
316
|
+
This.license = This.respond_to?(:license) ? This.license : IO.binread('LICENSE').strip
|
304
317
|
|
305
318
|
# discover full path to this ruby executable
|
306
319
|
#
|
307
|
-
c =
|
320
|
+
c = RbConfig::CONFIG
|
308
321
|
bindir = c["bindir"] || c['BINDIR']
|
309
322
|
ruby_install_name = c['ruby_install_name'] || c['RUBY_INSTALL_NAME'] || 'ruby'
|
310
323
|
ruby_ext = c['EXEEXT'] || ''
|
311
324
|
ruby = File.join(bindir, (ruby_install_name + ruby_ext))
|
312
325
|
This.ruby = ruby
|
313
326
|
|
314
|
-
# some utils
|
327
|
+
# some utils, alwayze teh utils...
|
315
328
|
#
|
316
329
|
module Util
|
317
330
|
def indent(s, n = 2)
|
@@ -326,7 +339,8 @@ BEGIN {
|
|
326
339
|
next if line =~ %r/^\s*$/
|
327
340
|
indent = line[%r/^\s*/] and break
|
328
341
|
end
|
329
|
-
indent ? s.gsub(%r/^#{ indent }/, "") : s
|
342
|
+
unindented = indent ? s.gsub(%r/^#{ indent }/, "") : s
|
343
|
+
unindented.strip
|
330
344
|
end
|
331
345
|
extend self
|
332
346
|
end
|
@@ -334,17 +348,54 @@ BEGIN {
|
|
334
348
|
# template support
|
335
349
|
#
|
336
350
|
class Template
|
351
|
+
def Template.indent(string, n = 2)
|
352
|
+
string = string.to_s
|
353
|
+
n = n.to_i
|
354
|
+
padding = (42 - 10).chr * n
|
355
|
+
initial = %r/^#{ Regexp.escape(padding) }/
|
356
|
+
#require 'debug'
|
357
|
+
#binding.break
|
358
|
+
Util.indent(string, n).sub(initial, '')
|
359
|
+
end
|
337
360
|
def initialize(&block)
|
338
361
|
@block = block
|
339
362
|
@template = block.call.to_s
|
340
363
|
end
|
341
364
|
def expand(b=nil)
|
342
|
-
ERB.new(Util.unindent(@template)).result((b||@block).binding)
|
365
|
+
ERB.new(Util.unindent(@template), trim_mode: '%<>-').result((b||@block).binding)
|
343
366
|
end
|
344
367
|
alias_method 'to_s', 'expand'
|
345
368
|
end
|
346
369
|
def Template(*args, &block) Template.new(*args, &block) end
|
347
370
|
|
371
|
+
# os / platform support
|
372
|
+
#
|
373
|
+
module Platform
|
374
|
+
def Platform.windows?
|
375
|
+
(/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
|
376
|
+
end
|
377
|
+
|
378
|
+
def Platform.darwin?
|
379
|
+
(/darwin/ =~ RUBY_PLATFORM) != nil
|
380
|
+
end
|
381
|
+
|
382
|
+
def Platform.mac?
|
383
|
+
Platform.darwin?
|
384
|
+
end
|
385
|
+
|
386
|
+
def Platform.unix?
|
387
|
+
!Platform.windows?
|
388
|
+
end
|
389
|
+
|
390
|
+
def Platform.linux?
|
391
|
+
Platform.unix? and not Platform.darwin?
|
392
|
+
end
|
393
|
+
|
394
|
+
def Platform.jruby?
|
395
|
+
RUBY_ENGINE == 'jruby'
|
396
|
+
end
|
397
|
+
end
|
398
|
+
|
348
399
|
# colored console output support
|
349
400
|
#
|
350
401
|
This.ansi = {
|