ludy 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +11 -0
- data/Manifest.txt +4 -4
- data/README +6 -5
- data/Rakefile +2 -1
- data/TODO +4 -0
- data/lib/ludy/kernel/if_else.rb +1 -1
- data/lib/ludy/paginator.rb +10 -7
- data/lib/ludy/tasks/common.rb +1 -1
- data/lib/ludy/tasks/{erb_cpp → preprocess_cpp}/attr_builder.rb +0 -0
- data/lib/ludy/tasks/{erb_cpp → preprocess_cpp}/header_guard.rb +3 -3
- data/lib/ludy/tasks/{erb_cpp → preprocess_cpp}/template_forward_parameters.rb +0 -0
- data/lib/ludy/tasks/preprocess_cpp.rb +67 -0
- data/lib/ludy.rb +1 -1
- data/lib/puzzle_generator/map.rb +0 -1
- data/lib/puzzle_generator/misc.rb +1 -0
- data/lib/puzzle_generator/puzzle.rb +1 -0
- data/test/test_paginator.rb +4 -0
- metadata +6 -6
- data/lib/ludy/tasks/erb_cpp.rb +0 -35
data/CHANGES
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
= ludy changes history
|
2
2
|
|
3
|
+
== ludy 0.1.4, 2008.01.31
|
4
|
+
|
5
|
+
* added Page#begin and Page#end for real index in the data
|
6
|
+
* added Paginator#count for counter.call wrapper
|
7
|
+
|
8
|
+
* rename from Ludy::eout to Ludy::erbout
|
9
|
+
* added erubis support
|
10
|
+
* rename task from erb:preprocess to preprocess:erb and preprocess:erubis
|
11
|
+
* task preprocess would preprocess with erb and erubis
|
12
|
+
* rename PROJ to Project with open struct. use Project.name now
|
13
|
+
|
3
14
|
== ludy 0.1.3, 2008.01.23
|
4
15
|
|
5
16
|
* renamed next_page to next, and prev_page to prev
|
data/Manifest.txt
CHANGED
@@ -56,10 +56,10 @@ lib/ludy/symbol/to_msg.rb
|
|
56
56
|
lib/ludy/symbol/to_proc.rb
|
57
57
|
lib/ludy/tasks.rb
|
58
58
|
lib/ludy/tasks/common.rb
|
59
|
-
lib/ludy/tasks/
|
60
|
-
lib/ludy/tasks/
|
61
|
-
lib/ludy/tasks/
|
62
|
-
lib/ludy/tasks/
|
59
|
+
lib/ludy/tasks/preprocess_cpp.rb
|
60
|
+
lib/ludy/tasks/preprocess_cpp/attr_builder.rb
|
61
|
+
lib/ludy/tasks/preprocess_cpp/header_guard.rb
|
62
|
+
lib/ludy/tasks/preprocess_cpp/template_forward_parameters.rb
|
63
63
|
lib/ludy/test/helper.rb
|
64
64
|
lib/ludy/variable.rb
|
65
65
|
lib/ludy/y_combinator.rb
|
data/README
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
= ludy 0.1.
|
1
|
+
= ludy 0.1.4
|
2
2
|
by Lin Jen-Shin (a.k.a. godfat 真常)
|
3
3
|
strip any number: 18god29fat7029 (at] godfat32 -dooot- 20org
|
4
4
|
http://ludy.rubyforge.org
|
@@ -103,7 +103,7 @@ ludy tasks:
|
|
103
103
|
|
104
104
|
header_guard:
|
105
105
|
require 'ludy/tasks/erb_cpp/header_guard'
|
106
|
-
|
106
|
+
Project.name = 'header_sample' # remember to set project name
|
107
107
|
|
108
108
|
# in utils/SimpleTest.hpp.erb
|
109
109
|
<% header_guard do %>
|
@@ -111,7 +111,7 @@ header_guard:
|
|
111
111
|
<% end %>
|
112
112
|
|
113
113
|
# run preprocessing task
|
114
|
-
$ rake
|
114
|
+
$ rake preprocessing
|
115
115
|
|
116
116
|
# produce:
|
117
117
|
#ifndef _HEADER_SAMPLE_UTILS_SIMPLETEST_
|
@@ -130,7 +130,7 @@ attr_builder:
|
|
130
130
|
};
|
131
131
|
|
132
132
|
# run preprocessing task
|
133
|
-
$ rake
|
133
|
+
$ rake preprocessing
|
134
134
|
|
135
135
|
# produce:
|
136
136
|
class MapSetting{
|
@@ -170,7 +170,7 @@ template_forward_parameters:
|
|
170
170
|
<% } %>
|
171
171
|
|
172
172
|
# run preprocessing task
|
173
|
-
$ rake
|
173
|
+
$ rake preprocessing
|
174
174
|
|
175
175
|
# one of the produce: (can't list all...)
|
176
176
|
template <class T0, class T1, class T2, class T3>
|
@@ -183,6 +183,7 @@ template_forward_parameters:
|
|
183
183
|
* ruby 1.8/1.9 (1.9 is prefered...)
|
184
184
|
* rake
|
185
185
|
* gem facets if you are using puzzle_generator
|
186
|
+
* gem erubis if you are using preprocess:erubis
|
186
187
|
|
187
188
|
== INSTALL:
|
188
189
|
|
data/Rakefile
CHANGED
@@ -6,6 +6,7 @@ load 'tasks/setup.rb'
|
|
6
6
|
|
7
7
|
ensure_in_path 'lib'
|
8
8
|
require 'ludy'
|
9
|
+
require 'ludy/tasks'
|
9
10
|
|
10
11
|
task :default do
|
11
12
|
sh 'rake --tasks'
|
@@ -20,7 +21,7 @@ PROJ.description = paragraphs_of('README', 1).join("\n\n")
|
|
20
21
|
PROJ.changes = paragraphs_of('CHANGES', 0..1).join("\n\n")
|
21
22
|
PROJ.rubyforge_name = 'ludy'
|
22
23
|
|
23
|
-
PROJ.version = '0.1.
|
24
|
+
PROJ.version = '0.1.4'
|
24
25
|
PROJ.exclude << '.DS_Store' << '^tmp'
|
25
26
|
PROJ.dependencies << 'rake'
|
26
27
|
|
data/TODO
CHANGED
data/lib/ludy/kernel/if_else.rb
CHANGED
data/lib/ludy/paginator.rb
CHANGED
@@ -24,9 +24,13 @@ module Ludy
|
|
24
24
|
@pager == rhs.instance_variable_get('@pager')
|
25
25
|
end
|
26
26
|
# explicitly fetch the data from pager
|
27
|
-
def fetch; @data = @pager.fetcher[
|
27
|
+
def fetch; @data = @pager.fetcher[self.begin, @pager.per_page]; end
|
28
28
|
# get the data fetched from pager
|
29
29
|
def data; @data ||= fetch; end
|
30
|
+
# the real beginning index
|
31
|
+
def begin; @pager.offset @page; end
|
32
|
+
# the real ending index (need fetch, because we don't know the size)
|
33
|
+
def end; self.begin + self.size - 1; end
|
30
34
|
# any other method call would delegate to the data,
|
31
35
|
# e.g., each, to_a, map, first, method_you_defined, etc.
|
32
36
|
def method_missing msg, *args, &block
|
@@ -68,14 +72,13 @@ module Ludy
|
|
68
72
|
# nil would be returned. note, page start at 1, not zero.
|
69
73
|
def page page
|
70
74
|
offset = (page-1)*@per_page
|
71
|
-
|
72
|
-
return nil unless page > 0 and offset <= size
|
75
|
+
return nil unless page > 0 and offset <= count
|
73
76
|
Page.new self, page
|
74
77
|
end
|
75
|
-
# return the
|
76
|
-
def size
|
77
|
-
|
78
|
-
end
|
78
|
+
# return the amount of pages
|
79
|
+
def size; (count/@per_page.to_f).ceil; end
|
80
|
+
# simply call @counter.call
|
81
|
+
def count; @counter.call; end
|
79
82
|
alias_method :[], :page
|
80
83
|
# get the offset property about the page.
|
81
84
|
# it is simply (page-1)*@per_page
|
data/lib/ludy/tasks/common.rb
CHANGED
File without changes
|
@@ -6,12 +6,12 @@ module Kernel
|
|
6
6
|
# C/C++ header guard generator, you shold provide the final #endif yourself,
|
7
7
|
# and you should provide PROJ name for header guard prefix
|
8
8
|
def header_guard random_suffix = nil, &block
|
9
|
-
defined = "_#{
|
9
|
+
defined = "_#{Project.name.upcase}_#{@dir.upcase}_#{@class.upcase}_#{random_suffix.nil? ? '' : rand.to_s[2..-1]+'_'}"
|
10
10
|
|
11
|
-
Ludy::
|
11
|
+
Ludy::erbout "#ifndef #{defined}
|
12
12
|
#define #{defined}", block.binding
|
13
13
|
block.call
|
14
|
-
Ludy::
|
14
|
+
Ludy::erbout '#endif', block.binding
|
15
15
|
end
|
16
16
|
|
17
17
|
end # of ludy
|
File without changes
|
@@ -0,0 +1,67 @@
|
|
1
|
+
|
2
|
+
require 'rubygems'
|
3
|
+
require 'rake/clean'
|
4
|
+
require 'ludy'
|
5
|
+
Ludy.require_all_in 'tasks/preprocess_cpp'
|
6
|
+
require 'erb'
|
7
|
+
require 'open-uri'
|
8
|
+
require 'ostruct'
|
9
|
+
|
10
|
+
Project = OpenStruct.new
|
11
|
+
|
12
|
+
namespace :preprocess do
|
13
|
+
|
14
|
+
erb_inputs = FileList['**/*.erb']
|
15
|
+
erb_outputs = erb_inputs.ext
|
16
|
+
|
17
|
+
task :erb_begin do; puts "processing templates: #{erb_inputs.inspect}\n\n"; end
|
18
|
+
task :end do; puts "processing done."; end
|
19
|
+
|
20
|
+
desc 'automaticly translate all *.cpp.erb into *.cpp'
|
21
|
+
task :erb => [:erb_begin, erb_outputs, :end].flatten
|
22
|
+
|
23
|
+
def preprocess template_engine, input, output
|
24
|
+
puts "processing... #{output}"
|
25
|
+
open output, 'w' do |o|
|
26
|
+
@class = output.pathmap '%n'
|
27
|
+
@dir = output.pathmap('%-1d')
|
28
|
+
@indent = ' '
|
29
|
+
@prefix = ''
|
30
|
+
Project.name ||= 'please_set_Project_name_for_your_header_name'
|
31
|
+
o << template_engine.new(input).result(binding)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
erb_inputs.zip(erb_outputs).each{ |input, output|
|
36
|
+
file output => input do
|
37
|
+
preprocess ERB, open(input).read, output
|
38
|
+
end
|
39
|
+
}
|
40
|
+
|
41
|
+
erubis_outputs = [] # for people don't have erubis
|
42
|
+
begin
|
43
|
+
require 'erubis'
|
44
|
+
erubis_inputs = FileList['**/*.eruby']
|
45
|
+
erubis_outputs = erubis_inputs.ext
|
46
|
+
|
47
|
+
task :erubis_begin do; puts "processing templates: #{erubis_inputs.inspect}\n\n"; end
|
48
|
+
task :end do; puts "processing done."; end
|
49
|
+
|
50
|
+
desc 'automaticly translate all *.cpp.eruby into *.cpp'
|
51
|
+
task :erubis => [:erubis_begin, erubis_outputs, :end].flatten
|
52
|
+
|
53
|
+
erubis_inputs.zip(erubis_outputs).each{ |input, output|
|
54
|
+
file output => input do
|
55
|
+
class ErboutEruby < Erubis::Eruby; include Erubis::ErboutEnhancer; end
|
56
|
+
preprocess ErboutEruby, open(input).read, output
|
57
|
+
end
|
58
|
+
}
|
59
|
+
rescue LoadError; end # no erubis
|
60
|
+
|
61
|
+
outputs = erb_outputs + erubis_outputs
|
62
|
+
CLEAN.include outputs
|
63
|
+
|
64
|
+
end # of namespace preprocess
|
65
|
+
|
66
|
+
desc 'run all preprocessing stuffs'
|
67
|
+
task :preprocess => ['preprocess:erb','preprocess:erubis']
|
data/lib/ludy.rb
CHANGED
data/lib/puzzle_generator/map.rb
CHANGED
data/test/test_paginator.rb
CHANGED
@@ -29,6 +29,10 @@ class TestPaginator < Test::Unit::TestCase
|
|
29
29
|
assert_equal(5050, pager.inject(0){|r, i| r += i.inject(&:+) })
|
30
30
|
|
31
31
|
assert_equal 4, pager[4].page
|
32
|
+
|
33
|
+
assert_equal 10, pager[2].begin
|
34
|
+
assert_equal 19, pager[2].end
|
35
|
+
assert_equal 100, pager[11].end
|
32
36
|
end
|
33
37
|
def test_basic
|
34
38
|
pager = Ludy::Paginator.new(
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ludy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "Lin Jen-Shin (a.k.a. godfat \xE7\x9C\x9F\xE5\xB8\xB8)"
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-01-
|
12
|
+
date: 2008-01-31 00:00:00 +08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -101,10 +101,10 @@ files:
|
|
101
101
|
- lib/ludy/symbol/to_proc.rb
|
102
102
|
- lib/ludy/tasks.rb
|
103
103
|
- lib/ludy/tasks/common.rb
|
104
|
-
- lib/ludy/tasks/
|
105
|
-
- lib/ludy/tasks/
|
106
|
-
- lib/ludy/tasks/
|
107
|
-
- lib/ludy/tasks/
|
104
|
+
- lib/ludy/tasks/preprocess_cpp.rb
|
105
|
+
- lib/ludy/tasks/preprocess_cpp/attr_builder.rb
|
106
|
+
- lib/ludy/tasks/preprocess_cpp/header_guard.rb
|
107
|
+
- lib/ludy/tasks/preprocess_cpp/template_forward_parameters.rb
|
108
108
|
- lib/ludy/test/helper.rb
|
109
109
|
- lib/ludy/variable.rb
|
110
110
|
- lib/ludy/y_combinator.rb
|
data/lib/ludy/tasks/erb_cpp.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
|
2
|
-
require 'rubygems'
|
3
|
-
require 'rake/clean'
|
4
|
-
require 'ludy'
|
5
|
-
Ludy.require_all_in 'tasks/erb_cpp'
|
6
|
-
|
7
|
-
namespace :erb do
|
8
|
-
|
9
|
-
inputs = FileList['**/*.erb']
|
10
|
-
outputs = inputs.ext
|
11
|
-
CLEAN.include outputs
|
12
|
-
|
13
|
-
desc 'automaticly translate all *.cpp.erb into *.cpp'
|
14
|
-
task :preprocess => [:begin, outputs, :end].flatten
|
15
|
-
task :begin do; puts "processing templates: #{inputs.inspect}\n\n"; end
|
16
|
-
task :end do; puts "processing done."; end
|
17
|
-
|
18
|
-
require 'erb'
|
19
|
-
require 'open-uri'
|
20
|
-
|
21
|
-
inputs.zip(outputs).each{ |input, output|
|
22
|
-
file output => input do
|
23
|
-
puts "processing... #{output}"
|
24
|
-
open output, 'w' do |o|
|
25
|
-
@class = output.pathmap '%n'
|
26
|
-
@dir = output.pathmap('%-1d')
|
27
|
-
@indent = ' '
|
28
|
-
@prefix = ''
|
29
|
-
PROJ ||= 'please_set_PROJ_for_your_header_name'
|
30
|
-
o << ERB.new(open(input).read).result(binding)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
}
|
34
|
-
|
35
|
-
end # of namespace erb
|