ludy 0.1.13 → 0.1.15
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/.gitignore +8 -0
- data/CHANGES +23 -0
- data/NOTICE +1 -1
- data/README +4 -1
- data/Rakefile +13 -49
- data/lib/ludy.rb +1 -1
- data/lib/ludy/array/choice.rb +1 -1
- data/lib/ludy/array/combos.rb +2 -2
- data/lib/ludy/array/count.rb +1 -1
- data/lib/ludy/array/product.rb +1 -1
- data/lib/ludy/array/rotate.rb +6 -6
- data/lib/ludy/kernel/id.rb +1 -1
- data/lib/ludy/kernel/public_send.rb +1 -1
- data/lib/ludy/kernel/singleton_method.rb +1 -1
- data/lib/ludy/kernel/tap.rb +1 -1
- data/lib/ludy/paginator.rb +7 -7
- data/lib/ludy/pattern_matcher.rb +1 -0
- data/lib/ludy/proc/curry.rb +1 -1
- data/lib/ludy/symbol/curry.rb +6 -2
- data/lib/ludy/symbol/to_proc.rb +1 -1
- data/lib/ludy/version.rb +1 -1
- data/lib/puzzle_generator/chained_map.rb +1 -1
- data/lib/puzzle_generator/puzzle.rb +3 -3
- data/ludy.gemspec +19 -14
- data/task/gemgem.rb +155 -0
- data/tasks/manifest.rake +3 -3
- data/tasks/rubyforge.rake +2 -2
- data/test/example_puzzle.rb +1 -1
- data/test/ludy/test_array.rb +7 -7
- data/test/ludy/test_class.rb +1 -1
- data/test/ludy/test_defun.rb +1 -1
- data/test/ludy/test_dices.rb +1 -1
- data/test/ludy/test_hash.rb +1 -1
- data/test/ludy/test_kernel.rb +1 -1
- data/test/ludy/test_lazy.rb +1 -1
- data/test/ludy/test_paginator.rb +1 -1
- data/test/ludy/test_proc.rb +7 -3
- data/test/ludy/test_require_all.rb +1 -1
- data/test/ludy/test_symbol.rb +8 -3
- data/test/ludy/test_variable.rb +1 -1
- data/test/ludy/test_y_combinator.rb +1 -1
- data/test/ludy/test_z_combinator.rb +1 -1
- metadata +52 -113
data/.gitignore
ADDED
data/CHANGES
CHANGED
@@ -1,5 +1,28 @@
|
|
1
1
|
= ludy changes history
|
2
2
|
|
3
|
+
== ludy 0.1.15, 2011-04-20
|
4
|
+
|
5
|
+
* So, after _3_ years from last release, I don't mean to maintain this
|
6
|
+
anymore. But we need some codes in this library for CuBeat,
|
7
|
+
https://github.com/godfat/cubeat
|
8
|
+
In particular, the preprocessing stuffs for C++. I should move them
|
9
|
+
into another standalone repository, instead of this outdated, mixed
|
10
|
+
repository. This release is only intended for modern Ruby to run those
|
11
|
+
preprocessing stuffs, and tested with 1.8.7 and 1.9.2.
|
12
|
+
|
13
|
+
* removed Ludy::XhtmlFormatter, which is now
|
14
|
+
https://github.com/godfat/friendly_format
|
15
|
+
|
16
|
+
* removed Ludy::HasManyThumbnails, which is now
|
17
|
+
https://github.com/godfat/thumbo
|
18
|
+
|
19
|
+
== ludy 0.1.14, never
|
20
|
+
|
21
|
+
* added Ludy::XhtmlFormatter from another project.
|
22
|
+
* added Ludy::RailsFieldsFilters from project above metioned.
|
23
|
+
* renamed Proc#bind to Proc#_bind because active_support
|
24
|
+
took that name..... *cry*
|
25
|
+
|
3
26
|
== ludy 0.1.13, 2008-06-14
|
4
27
|
|
5
28
|
* fixed the package... i am so dumb
|
data/NOTICE
CHANGED
data/README
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
= ludy 0.1.13
|
2
2
|
by Lin Jen-Shin (a.k.a. godfat-真常[http://godfat.org])
|
3
|
-
|
3
|
+
godfat (XD) godfat.org
|
4
|
+
|
5
|
+
== LINKS:
|
6
|
+
|
4
7
|
* rdoc[http://ludy.rubyforge.org]
|
5
8
|
* rubyforge-project[http://rubyforge.org/projects/ludy]
|
6
9
|
* github-project[http://github.com/godfat/ludy]
|
data/Rakefile
CHANGED
@@ -1,56 +1,20 @@
|
|
1
|
-
#
|
2
|
-
# Look in the tasks/setup.rb file for the various options that can be
|
3
|
-
# configured in this Rakefile. The .rake files in the tasks directory
|
4
|
-
# are where the options are used.
|
5
|
-
load 'tasks/setup.rb'
|
1
|
+
# encoding: utf-8
|
6
2
|
|
7
|
-
|
8
|
-
|
9
|
-
require 'ludy/tasks'
|
3
|
+
require "#{dir = File.dirname(__FILE__)}/task/gemgem"
|
4
|
+
Gemgem.dir = dir
|
10
5
|
|
11
|
-
|
6
|
+
($LOAD_PATH << File.expand_path("#{Gemgem.dir}/lib" )).uniq!
|
12
7
|
|
13
|
-
|
14
|
-
|
15
|
-
Rake.application.display_tasks_and_comments
|
16
|
-
end
|
8
|
+
require 'ludy'
|
9
|
+
require 'ludy/tasks'
|
17
10
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
11
|
+
desc 'Generate gemspec'
|
12
|
+
task 'gem:spec' do
|
13
|
+
Gemgem.spec = Gemgem.create do |s|
|
14
|
+
s.name = 'ludy'
|
15
|
+
s.version = Ludy::VERSION
|
16
|
+
s.executables = [s.name]
|
23
17
|
end
|
24
|
-
end
|
25
18
|
|
26
|
-
|
27
|
-
desc 'push to rubyforge and github'
|
28
|
-
task 'push' do
|
29
|
-
sh 'git push rubyforge master'
|
30
|
-
puts
|
31
|
-
sh 'git push github master'
|
32
|
-
end
|
19
|
+
Gemgem.write
|
33
20
|
end
|
34
|
-
|
35
|
-
PROJ.name = 'ludy'
|
36
|
-
PROJ.authors = 'Lin Jen-Shin (a.k.a. godfat 真常)'
|
37
|
-
PROJ.email = 'strip any number: 18god29fat7029 (at] godfat32 -dooot- 20org'
|
38
|
-
PROJ.url = 'http://ludy.rubyforge.org/'
|
39
|
-
PROJ.description = PROJ.summary = paragraphs_of('README', 'description').join("\n\n")
|
40
|
-
PROJ.changes = paragraphs_of('CHANGES', 0..1).join("\n\n")
|
41
|
-
PROJ.rubyforge.name = 'ludy'
|
42
|
-
PROJ.version = paragraphs_of('README', 0).first.split("\n").first[7..-1]
|
43
|
-
|
44
|
-
PROJ.gem.executables = 'bin/ludy'
|
45
|
-
PROJ.gem.files = []
|
46
|
-
Dir.glob('**/*'){ |file| PROJ.gem.files << file if file !~ /^pkg|^tmp|^doc/ }
|
47
|
-
|
48
|
-
PROJ.rdoc.main = 'README'
|
49
|
-
PROJ.rdoc.exclude << 'Manifest' << 'Rakefile' << 'tmp$' << '^tmp'
|
50
|
-
PROJ.rdoc.include << '\w+'
|
51
|
-
PROJ.rdoc.opts << '--diagram' if !WIN32 and `which dot` =~ %r/\/dot/
|
52
|
-
PROJ.rdoc.opts << '--charset=utf-8' << '--inline-source' << '--line-numbers' << '--promiscuous'
|
53
|
-
|
54
|
-
PROJ.spec.opts << '--color'
|
55
|
-
|
56
|
-
# EOF
|
data/lib/ludy.rb
CHANGED
data/lib/ludy/array/choice.rb
CHANGED
@@ -5,7 +5,7 @@ class Array
|
|
5
5
|
# it would be defined if RUBY_VERSION < '1.9.0', see rdoc in ruby 1.9
|
6
6
|
def choice
|
7
7
|
self[rand(size)]
|
8
|
-
end
|
8
|
+
end unless method_defined?(:choice)
|
9
9
|
# the choosen element would be deleted. return the choosen
|
10
10
|
def choice!
|
11
11
|
i = rand size
|
data/lib/ludy/array/combos.rb
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
require 'ludy/version'
|
3
3
|
|
4
4
|
class Array
|
5
|
-
if Ludy
|
5
|
+
if Ludy.ruby_before '1.9.0'
|
6
6
|
require 'ludy/array/foldr'
|
7
|
-
require 'ludy/symbol/to_proc' if Ludy
|
7
|
+
require 'ludy/symbol/to_proc' if Ludy.ruby_before '1.9.0'
|
8
8
|
# for each combos
|
9
9
|
# [[0,1],[2,3]].combos
|
10
10
|
# => [[0,2],[0,3],[1,2],[1,3]]
|
data/lib/ludy/array/count.rb
CHANGED
data/lib/ludy/array/product.rb
CHANGED
data/lib/ludy/array/rotate.rb
CHANGED
@@ -3,19 +3,19 @@ class Array
|
|
3
3
|
# rotate right with size.
|
4
4
|
# if the size is negative, rotate left.
|
5
5
|
# [1,2,3].rotate
|
6
|
-
# => [3,1
|
6
|
+
# => [2,3,1]
|
7
7
|
#
|
8
8
|
# [1,2,3].rotate -1
|
9
|
-
# => [
|
9
|
+
# => [3,1,2]
|
10
10
|
#
|
11
11
|
# [1,2,3].rotate 2
|
12
|
-
# => [
|
12
|
+
# => [3,1,2]
|
13
13
|
def rotate n = 1
|
14
14
|
return self if empty? or n == 0
|
15
|
-
self[
|
16
|
-
end
|
15
|
+
self[n..-1] + self[0...n]
|
16
|
+
end unless method_defined?(:rotate)
|
17
17
|
# inplace version of rotate
|
18
18
|
def rotate!
|
19
19
|
replace rotate
|
20
|
-
end
|
20
|
+
end unless method_defined?(:rotate!)
|
21
21
|
end
|
data/lib/ludy/kernel/id.rb
CHANGED
data/lib/ludy/kernel/tap.rb
CHANGED
data/lib/ludy/paginator.rb
CHANGED
@@ -11,7 +11,7 @@ module Ludy
|
|
11
11
|
# was fetched, it won't fetch again. it you need refetch,
|
12
12
|
# call Page#fetch
|
13
13
|
class Page
|
14
|
-
undef_method :to_a if Ludy
|
14
|
+
undef_method :to_a if Ludy.ruby_before '1.9.0'
|
15
15
|
# pager to get the original pager; page to get the number of this page
|
16
16
|
attr_reader :pager, :page
|
17
17
|
# don't create a page instance yourself unless you have to
|
@@ -55,8 +55,8 @@ module Ludy
|
|
55
55
|
# fetcher is function that fetch the data,
|
56
56
|
# counter is function that count the data.
|
57
57
|
# the default per_page is 20. you can reset per_page property later.
|
58
|
-
def initialize fetcher, counter
|
59
|
-
@per_page =
|
58
|
+
def initialize fetcher, counter, per_page = 20
|
59
|
+
@per_page = per_page
|
60
60
|
@fetcher = fetcher
|
61
61
|
@counter = counter
|
62
62
|
end
|
@@ -103,13 +103,13 @@ module Ludy
|
|
103
103
|
class RailsPaginator < Paginator
|
104
104
|
# the model class that you passed in this paginator
|
105
105
|
attr_reader :model_class
|
106
|
-
def initialize model_class, opts = {}
|
106
|
+
def initialize model_class, per_page = 20, opts = {}
|
107
107
|
@model_class = model_class
|
108
108
|
super(lambda{ |offset, per_page|
|
109
109
|
@model_class.find :all, opts.merge(:offset => offset, :limit => per_page)
|
110
110
|
}, lambda{
|
111
111
|
@model_class.count opts
|
112
|
-
})
|
112
|
+
}, 20)
|
113
113
|
end
|
114
114
|
# it simply call super(page.to_i), so RailsPaginator also eat string.
|
115
115
|
def page page; super page.to_i; end
|
@@ -121,13 +121,13 @@ module Ludy
|
|
121
121
|
class ArrayPaginator < Paginator
|
122
122
|
# data that you passed in this paginator
|
123
123
|
attr_reader :data
|
124
|
-
def initialize data
|
124
|
+
def initialize data, per_page = 20
|
125
125
|
@data = data
|
126
126
|
super(lambda{ |offset, per_page|
|
127
127
|
@data[offset, per_page]
|
128
128
|
}, lambda{
|
129
129
|
@data.size
|
130
|
-
})
|
130
|
+
}, per_page)
|
131
131
|
end
|
132
132
|
end
|
133
133
|
|
data/lib/ludy/pattern_matcher.rb
CHANGED
data/lib/ludy/proc/curry.rb
CHANGED
data/lib/ludy/symbol/curry.rb
CHANGED
data/lib/ludy/symbol/to_proc.rb
CHANGED
data/lib/ludy/version.rb
CHANGED
@@ -19,7 +19,7 @@ module PuzzleGenerator
|
|
19
19
|
# start generate a puzzle with options that created this puzzle instance.
|
20
20
|
def generate
|
21
21
|
raw_colors = (1..@option[:colors]).to_a
|
22
|
-
step_colors = raw_colors.rotate
|
22
|
+
step_colors = raw_colors.rotate(-1)
|
23
23
|
|
24
24
|
make_chain
|
25
25
|
make_color raw_colors
|
@@ -27,10 +27,10 @@ module PuzzleGenerator
|
|
27
27
|
if step_colors == raw_colors
|
28
28
|
make_chain
|
29
29
|
make_color raw_colors
|
30
|
-
step_colors = raw_colors.rotate
|
30
|
+
step_colors = raw_colors.rotate(-1)
|
31
31
|
else
|
32
32
|
make_color step_colors
|
33
|
-
step_colors.rotate!
|
33
|
+
step_colors.rotate!(-1)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
data/ludy.gemspec
CHANGED
@@ -1,25 +1,30 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
1
2
|
|
2
3
|
Gem::Specification.new do |s|
|
3
4
|
s.name = %q{ludy}
|
4
|
-
s.version = "0.1.
|
5
|
-
|
6
|
-
s.specification_version = 2 if s.respond_to? :specification_version=
|
5
|
+
s.version = "0.1.15"
|
7
6
|
|
8
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
9
|
-
s.authors = ["Lin Jen-Shin (
|
10
|
-
s.date = %q{
|
11
|
-
s.default_executable = %q{ludy}
|
8
|
+
s.authors = ["Lin Jen-Shin (godfat)"]
|
9
|
+
s.date = %q{2011-04-20}
|
12
10
|
s.description = %q{Aims to extend Ruby standard library, providing some useful tools that's not existed in the standard library, especially for functional programming.}
|
13
|
-
s.email =
|
11
|
+
s.email = ["godfat (XD) godfat.org"]
|
14
12
|
s.executables = ["ludy"]
|
15
|
-
s.extra_rdoc_files = ["
|
16
|
-
s.files = ["
|
17
|
-
s.
|
18
|
-
s.
|
19
|
-
s.rdoc_options = ["--diagram", "--charset=utf-8", "--inline-source", "--line-numbers", "--promiscuous", "--main", "README"]
|
13
|
+
s.extra_rdoc_files = ["CHANGES", "LICENSE", "TODO"]
|
14
|
+
s.files = [".gitignore", "CHANGES", "LICENSE", "NOTICE", "README", "Rakefile", "TODO", "bin/ludy", "lib/ludy.rb", "lib/ludy/all.rb", "lib/ludy/array.rb", "lib/ludy/array/body.rb", "lib/ludy/array/choice.rb", "lib/ludy/array/combine.rb", "lib/ludy/array/combos.rb", "lib/ludy/array/count.rb", "lib/ludy/array/filter.rb", "lib/ludy/array/foldl.rb", "lib/ludy/array/foldr.rb", "lib/ludy/array/head.rb", "lib/ludy/array/map_with_index.rb", "lib/ludy/array/pad.rb", "lib/ludy/array/product.rb", "lib/ludy/array/rotate.rb", "lib/ludy/array/tail.rb", "lib/ludy/blackhole.rb", "lib/ludy/class.rb", "lib/ludy/class/undef_all_methods.rb", "lib/ludy/deprecated/aspect.rb", "lib/ludy/deprecated/callstack.rb", "lib/ludy/deprecated/curry.rb", "lib/ludy/deprecated/rambda.rb", "lib/ludy/deprecated/this.rb", "lib/ludy/deprecated/untranspose.rb", "lib/ludy/deprecated/unzip.rb", "lib/ludy/dices.rb", "lib/ludy/hash.rb", "lib/ludy/hash/reverse_merge.rb", "lib/ludy/helpers/check_box.rb", "lib/ludy/kernel.rb", "lib/ludy/kernel/deep_copy.rb", "lib/ludy/kernel/defun.rb", "lib/ludy/kernel/ergo.rb", "lib/ludy/kernel/id.rb", "lib/ludy/kernel/if_else.rb", "lib/ludy/kernel/m.rb", "lib/ludy/kernel/maybe.rb", "lib/ludy/kernel/public_send.rb", "lib/ludy/kernel/singleton_method.rb", "lib/ludy/kernel/tap.rb", "lib/ludy/lazy.rb", "lib/ludy/list.rb", "lib/ludy/message_dispatcher.rb", "lib/ludy/namespace.rb", "lib/ludy/paginator.rb", "lib/ludy/pattern_matcher.rb", "lib/ludy/proc.rb", "lib/ludy/proc/bind.rb", "lib/ludy/proc/chain.rb", "lib/ludy/proc/compose.rb", "lib/ludy/proc/curry.rb", "lib/ludy/symbol.rb", "lib/ludy/symbol/curry.rb", "lib/ludy/symbol/to_msg.rb", "lib/ludy/symbol/to_proc.rb", "lib/ludy/tasks.rb", "lib/ludy/tasks/common.rb", "lib/ludy/tasks/preprocess_cpp.rb", "lib/ludy/tasks/preprocess_cpp/attr_builder.rb", "lib/ludy/tasks/preprocess_cpp/debug_hook.rb", "lib/ludy/tasks/preprocess_cpp/header_guard.rb", "lib/ludy/tasks/preprocess_cpp/template_forward_parameters.rb", "lib/ludy/timer.rb", "lib/ludy/variable.rb", "lib/ludy/version.rb", "lib/ludy/y_combinator.rb", "lib/ludy/z_combinator.rb", "lib/puzzle_generator.rb", "lib/puzzle_generator/chain.rb", "lib/puzzle_generator/chained_map.rb", "lib/puzzle_generator/colored_map.rb", "lib/puzzle_generator/map.rb", "lib/puzzle_generator/misc.rb", "lib/puzzle_generator/puzzle.rb", "ludy.gemspec", "spec/ludy_spec.rb", "spec/spec_helper.rb", "task/gemgem.rb", "tasks/ann.rake", "tasks/bones.rake", "tasks/gem.rake", "tasks/git.rake", "tasks/manifest.rake", "tasks/notes.rake", "tasks/post_load.rake", "tasks/rdoc.rake", "tasks/rubyforge.rake", "tasks/setup.rb", "tasks/spec.rake", "tasks/svn.rake", "tasks/test.rake", "test/deprecated/callstack.rb", "test/deprecated/curry.rb", "test/deprecated/rambda.rb", "test/deprecated/this.rb", "test/deprecated/ts_ludy.rb", "test/deprecated/unzip_and_untranspose.rb", "test/example_puzzle.rb", "test/helper.rb", "test/ludy/test_array.rb", "test/ludy/test_class.rb", "test/ludy/test_defun.rb", "test/ludy/test_dices.rb", "test/ludy/test_hash.rb", "test/ludy/test_kernel.rb", "test/ludy/test_lazy.rb", "test/ludy/test_paginator.rb", "test/ludy/test_proc.rb", "test/ludy/test_require_all.rb", "test/ludy/test_symbol.rb", "test/ludy/test_variable.rb", "test/ludy/test_y_combinator.rb", "test/ludy/test_z_combinator.rb", "test/multiruby.sh"]
|
15
|
+
s.homepage = %q{http://github.com/godfat/}
|
16
|
+
s.rdoc_options = ["--main", "README"]
|
20
17
|
s.require_paths = ["lib"]
|
21
|
-
s.
|
22
|
-
s.rubygems_version = %q{1.1.1}
|
18
|
+
s.rubygems_version = %q{1.7.2}
|
23
19
|
s.summary = %q{Aims to extend Ruby standard library, providing some useful tools that's not existed in the standard library, especially for functional programming.}
|
24
20
|
s.test_files = ["test/ludy/test_array.rb", "test/ludy/test_class.rb", "test/ludy/test_defun.rb", "test/ludy/test_dices.rb", "test/ludy/test_hash.rb", "test/ludy/test_kernel.rb", "test/ludy/test_lazy.rb", "test/ludy/test_paginator.rb", "test/ludy/test_proc.rb", "test/ludy/test_require_all.rb", "test/ludy/test_symbol.rb", "test/ludy/test_variable.rb", "test/ludy/test_y_combinator.rb", "test/ludy/test_z_combinator.rb"]
|
21
|
+
|
22
|
+
if s.respond_to? :specification_version then
|
23
|
+
s.specification_version = 3
|
24
|
+
|
25
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
26
|
+
else
|
27
|
+
end
|
28
|
+
else
|
29
|
+
end
|
25
30
|
end
|
data/task/gemgem.rb
ADDED
@@ -0,0 +1,155 @@
|
|
1
|
+
|
2
|
+
require 'pathname'
|
3
|
+
|
4
|
+
module Gemgem
|
5
|
+
class << self
|
6
|
+
attr_accessor :dir, :spec
|
7
|
+
end
|
8
|
+
|
9
|
+
module_function
|
10
|
+
def create
|
11
|
+
yield(spec = Gem::Specification.new{ |s|
|
12
|
+
s.authors = ['Lin Jen-Shin (godfat)']
|
13
|
+
s.email = ['godfat (XD) godfat.org']
|
14
|
+
s.homepage = "http://github.com/godfat/#{s.name}"
|
15
|
+
|
16
|
+
s.summary = File.read("#{Gemgem.dir}/README").
|
17
|
+
match(/DESCRIPTION:\n\n(.+?)\n\n/m)[1]
|
18
|
+
s.description = s.summary
|
19
|
+
|
20
|
+
s.extra_rdoc_files = %w[CHANGES LICENSE TODO]
|
21
|
+
s.rdoc_options = %w[--main README]
|
22
|
+
s.rubygems_version = Gem::VERSION
|
23
|
+
s.date = Time.now.strftime('%Y-%m-%d')
|
24
|
+
s.files = gem_files
|
25
|
+
s.test_files = gem_files.grep(%r{^test/(.+?/)*test_.+?\.rb$})
|
26
|
+
s.require_paths = %w[lib]
|
27
|
+
})
|
28
|
+
spec
|
29
|
+
end
|
30
|
+
|
31
|
+
def gem_tag
|
32
|
+
"#{spec.name}-#{spec.version}"
|
33
|
+
end
|
34
|
+
|
35
|
+
def write
|
36
|
+
File.open("#{dir}/#{spec.name}.gemspec", 'w'){ |f| f << spec.to_ruby }
|
37
|
+
end
|
38
|
+
|
39
|
+
def all_files
|
40
|
+
@all_files ||= find_files(Pathname.new(dir)).map{ |file|
|
41
|
+
if file.to_s =~ %r{\.git/}
|
42
|
+
nil
|
43
|
+
else
|
44
|
+
file.to_s
|
45
|
+
end
|
46
|
+
}.compact.sort
|
47
|
+
end
|
48
|
+
|
49
|
+
def gem_files
|
50
|
+
@gem_files ||= all_files - ignored_files
|
51
|
+
end
|
52
|
+
|
53
|
+
def ignored_files
|
54
|
+
@ignored_file ||= all_files.select{ |path| ignore_patterns.find{ |ignore|
|
55
|
+
path =~ ignore && !git_files.include?(path)}}
|
56
|
+
end
|
57
|
+
|
58
|
+
def git_files
|
59
|
+
@git_files ||= if File.exist?("#{dir}/.git")
|
60
|
+
`git ls-files`.split("\n")
|
61
|
+
else
|
62
|
+
[]
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# protected
|
67
|
+
def find_files path
|
68
|
+
path.children.select(&:file?).map{|file| file.to_s[(dir.size+1)..-1]} +
|
69
|
+
path.children.select(&:directory?).map{|dir| find_files(dir)}.flatten
|
70
|
+
end
|
71
|
+
|
72
|
+
def ignore_patterns
|
73
|
+
@ignore_files ||= expand_patterns(
|
74
|
+
File.read("#{dir}/.gitignore").split("\n").reject{ |pattern|
|
75
|
+
pattern.strip == ''
|
76
|
+
}).map{ |pattern| %r{^([^/]+/)*?#{Regexp.escape(pattern)}(/[^/]+)*?$} }
|
77
|
+
end
|
78
|
+
|
79
|
+
def expand_patterns pathes
|
80
|
+
pathes.map{ |path|
|
81
|
+
if path !~ /\*/
|
82
|
+
path
|
83
|
+
else
|
84
|
+
expand_patterns(
|
85
|
+
Dir[path] +
|
86
|
+
Pathname.new(File.dirname(path)).children.select(&:directory?).
|
87
|
+
map{ |prefix| "#{prefix}/#{File.basename(path)}" })
|
88
|
+
end
|
89
|
+
}.flatten
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
namespace :gem do
|
94
|
+
|
95
|
+
desc 'Install gem'
|
96
|
+
task :install => [:build] do
|
97
|
+
sh("#{Gem.ruby} -S gem install pkg/#{Gemgem.gem_tag}")
|
98
|
+
end
|
99
|
+
|
100
|
+
desc 'Build gem'
|
101
|
+
task :build => [:spec] do
|
102
|
+
sh("#{Gem.ruby} -S gem build #{Gemgem.spec.name}.gemspec")
|
103
|
+
sh("mkdir -p pkg")
|
104
|
+
sh("mv #{Gemgem.gem_tag}.gem pkg/")
|
105
|
+
end
|
106
|
+
|
107
|
+
desc 'Release gem'
|
108
|
+
task :release => [:spec, :check, :build] do
|
109
|
+
sh("git tag #{Gemgem.gem_tag}")
|
110
|
+
sh("git push")
|
111
|
+
sh("git push --tags")
|
112
|
+
sh("#{Gem.ruby} -S gem push pkg/#{Gemgem.gem_tag}.gem")
|
113
|
+
end
|
114
|
+
|
115
|
+
task :check do
|
116
|
+
ver = Gemgem.spec.version.to_s
|
117
|
+
|
118
|
+
if ENV['VERSION'].nil?
|
119
|
+
puts("\x1b[35mExpected " \
|
120
|
+
"\x1b[33mVERSION\x1b[35m=\x1b[33m#{ver}\x1b[m")
|
121
|
+
exit(1)
|
122
|
+
|
123
|
+
elsif ENV['VERSION'] != ver
|
124
|
+
puts("\x1b[35mExpected \x1b[33mVERSION\x1b[35m=\x1b[33m#{ver} " \
|
125
|
+
"\x1b[35mbut got\n " \
|
126
|
+
"\x1b[33mVERSION\x1b[35m=\x1b[33m#{ENV['VERSION']}\x1b[m")
|
127
|
+
exit(2)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
end # of gem namespace
|
132
|
+
|
133
|
+
desc 'Run tests'
|
134
|
+
task :test do
|
135
|
+
sh("#{Gem.ruby} -I lib -S testrb test/ludy/test_*.rb")
|
136
|
+
end
|
137
|
+
|
138
|
+
desc 'Generate rdoc'
|
139
|
+
task :doc => ['gem:spec'] do
|
140
|
+
sh("yardoc -o rdoc --main README.md" \
|
141
|
+
" --files #{Gemgem.spec.extra_rdoc_files.join(',')}")
|
142
|
+
end
|
143
|
+
|
144
|
+
desc 'Removed ignored files'
|
145
|
+
task :clean => ['gem:spec'] do
|
146
|
+
trash = "~/.Trash/#{Gemgem.spec.name}/"
|
147
|
+
sh "mkdir -p #{trash}" unless File.exist?(File.expand_path(trash))
|
148
|
+
Gemgem.ignored_files.each{ |file| sh "mv #{file} #{trash}" }
|
149
|
+
end
|
150
|
+
|
151
|
+
|
152
|
+
task :default do
|
153
|
+
Rake.application.options.show_task_pattern = /./
|
154
|
+
Rake.application.display_tasks_and_comments
|
155
|
+
end
|
data/tasks/manifest.rake
CHANGED
@@ -15,9 +15,9 @@ namespace :manifest do
|
|
15
15
|
lines.map! do |line|
|
16
16
|
case line
|
17
17
|
when %r/^(-{3}|\+{3})/; nil
|
18
|
-
when %r/^@/;
|
19
|
-
when %r/^\+/;
|
20
|
-
when %r/^\-/;
|
18
|
+
when %r/^@/; ANSICode.blue line
|
19
|
+
when %r/^\+/; ANSICode.green line
|
20
|
+
when %r/^\-/; ANSICode.red line
|
21
21
|
else line end
|
22
22
|
end
|
23
23
|
end
|
data/tasks/rubyforge.rake
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# $Id$
|
2
1
|
|
3
2
|
if PROJ.rubyforge.name.valid? && HAVE_RUBYFORGE
|
4
3
|
|
@@ -17,7 +16,8 @@ namespace :gem do
|
|
17
16
|
puts "rf.add_file #{PROJ.rubyforge.name.inspect}, #{PROJ.name.inspect}, release_id, \"#{pkg}.gem\""
|
18
17
|
end
|
19
18
|
|
20
|
-
rf = RubyForge.new
|
19
|
+
rf = RubyForge.new
|
20
|
+
rf.configure rescue nil
|
21
21
|
puts 'Logging in'
|
22
22
|
rf.login
|
23
23
|
|
data/test/example_puzzle.rb
CHANGED
data/test/ludy/test_array.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
require
|
2
|
+
require './test/helper'
|
3
3
|
require 'ludy/array'
|
4
4
|
require 'ludy/symbol/to_proc' if RUBY_VERSION < '1.9.0'
|
5
5
|
|
@@ -28,13 +28,13 @@ class TestArray < Test::Unit::TestCase
|
|
28
28
|
assert_equal ['ab','ba'], ['a','b'].combine(['b','a'])
|
29
29
|
end
|
30
30
|
def test_rotate
|
31
|
-
assert_equal [3,1
|
32
|
-
assert_equal [2,3,1], [1,2,3].rotate(2)
|
33
|
-
assert_equal [1,2,3], [1,2,3].rotate(3)
|
34
|
-
assert_equal [1,2,3], [1,2,3].rotate(0)
|
35
|
-
assert_equal [2,3,1], [1,2,3].rotate(-1)
|
36
|
-
assert_equal [3,1,2], [1,2,3].rotate(-2)
|
31
|
+
assert_equal [2,3,1], [1,2,3].rotate
|
32
|
+
assert_equal [2,3,1], [1,2,3].rotate(-2)
|
37
33
|
assert_equal [1,2,3], [1,2,3].rotate(-3)
|
34
|
+
assert_equal [1,2,3], [1,2,3].rotate(0)
|
35
|
+
assert_equal [2,3,1], [1,2,3].rotate(1)
|
36
|
+
assert_equal [3,1,2], [1,2,3].rotate(2)
|
37
|
+
assert_equal [1,2,3], [1,2,3].rotate(3)
|
38
38
|
end
|
39
39
|
def test_combos
|
40
40
|
assert_equal [[0,2],[0,3],[1,2],[1,3]], [[0,1],[2,3]].combos
|
data/test/ludy/test_class.rb
CHANGED
data/test/ludy/test_defun.rb
CHANGED
data/test/ludy/test_dices.rb
CHANGED
data/test/ludy/test_hash.rb
CHANGED
data/test/ludy/test_kernel.rb
CHANGED
data/test/ludy/test_lazy.rb
CHANGED
data/test/ludy/test_paginator.rb
CHANGED
data/test/ludy/test_proc.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
|
-
require
|
2
|
+
require './test/helper'
|
3
3
|
require 'ludy/proc'
|
4
|
-
require 'ludy/symbol/to_proc' if
|
4
|
+
require 'ludy/symbol/to_proc' if Ludy.ruby_before '1.9.0'
|
5
5
|
|
6
6
|
class TestProc < Test::Unit::TestCase
|
7
7
|
def test_bind
|
@@ -21,7 +21,11 @@ class TestProc < Test::Unit::TestCase
|
|
21
21
|
xd = multiply['XD', 5]
|
22
22
|
assert_equal 'XDXDXDXDXD', xd
|
23
23
|
|
24
|
-
|
24
|
+
if Ludy.ruby_before '1.9.0'
|
25
|
+
assert_equal 29, :+.to_proc.curry[18][11]
|
26
|
+
else
|
27
|
+
assert_equal 29, :+.to_proc.curry(2)[18][11]
|
28
|
+
end
|
25
29
|
assert_equal((0..4).to_a, lambda{|a,b,c,d,e|[a,b,c,d,e]}.curry[0][1][2][3][4])
|
26
30
|
end
|
27
31
|
def test_compose
|
data/test/ludy/test_symbol.rb
CHANGED
@@ -1,12 +1,17 @@
|
|
1
1
|
|
2
|
-
require
|
2
|
+
require './test/helper'
|
3
3
|
require 'ludy/symbol'
|
4
4
|
|
5
5
|
class TestSymbol < Test::Unit::TestCase
|
6
6
|
def test_curry
|
7
7
|
a = [1,2,3]
|
8
|
-
|
9
|
-
|
8
|
+
if Ludy.ruby_before '1.9.0'
|
9
|
+
assert_equal nil, a.find(&:==.curry[0])
|
10
|
+
assert_equal 2, a.find(&:==.curry[2])
|
11
|
+
else
|
12
|
+
assert_equal nil, a.find(&:==.curry(2)[0])
|
13
|
+
assert_equal 2, a.find(&:==.curry(2)[2])
|
14
|
+
end
|
10
15
|
end
|
11
16
|
def test_to_msg
|
12
17
|
assert_equal [3, 7], [[1,2],[3,4]].map(&:'inject(&:+)'.to_msg)
|
data/test/ludy/test_variable.rb
CHANGED
metadata
CHANGED
@@ -1,73 +1,39 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: ludy
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.15
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
|
-
authors:
|
7
|
-
-
|
7
|
+
authors:
|
8
|
+
- Lin Jen-Shin (godfat)
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
|
12
|
-
date: 2008-06-14 00:00:00 +08:00
|
13
|
-
default_executable:
|
12
|
+
date: 2011-04-20 00:00:00.000000000Z
|
14
13
|
dependencies: []
|
15
|
-
|
16
|
-
|
17
|
-
email:
|
18
|
-
|
14
|
+
description: Aims to extend Ruby standard library, providing some useful tools that's
|
15
|
+
not existed in the standard library, especially for functional programming.
|
16
|
+
email:
|
17
|
+
- godfat (XD) godfat.org
|
18
|
+
executables:
|
19
19
|
- ludy
|
20
20
|
extensions: []
|
21
|
-
|
22
|
-
|
23
|
-
-
|
24
|
-
-
|
21
|
+
extra_rdoc_files:
|
22
|
+
- CHANGES
|
23
|
+
- LICENSE
|
24
|
+
- TODO
|
25
|
+
files:
|
26
|
+
- .gitignore
|
25
27
|
- CHANGES
|
26
|
-
- lib
|
27
|
-
- lib/ludy
|
28
|
-
- lib/ludy/array
|
29
|
-
- lib/ludy/class
|
30
|
-
- lib/ludy/deprecated
|
31
|
-
- lib/ludy/hash
|
32
|
-
- lib/ludy/helpers
|
33
|
-
- lib/ludy/kernel
|
34
|
-
- lib/ludy/proc
|
35
|
-
- lib/ludy/symbol
|
36
|
-
- lib/ludy/tasks
|
37
|
-
- lib/ludy/tasks/preprocess_cpp
|
38
|
-
- lib/ludy/test
|
39
|
-
- lib/puzzle_generator
|
40
28
|
- LICENSE
|
41
|
-
- ludy.gemspec
|
42
29
|
- NOTICE
|
43
30
|
- README
|
44
|
-
-
|
45
|
-
- tasks
|
46
|
-
- tasks/ann.rake
|
47
|
-
- tasks/bones.rake
|
48
|
-
- tasks/gem.rake
|
49
|
-
- tasks/git.rake
|
50
|
-
- tasks/manifest.rake
|
51
|
-
- tasks/notes.rake
|
52
|
-
- tasks/post_load.rake
|
53
|
-
- tasks/rdoc.rake
|
54
|
-
- tasks/rubyforge.rake
|
55
|
-
- tasks/spec.rake
|
56
|
-
- tasks/svn.rake
|
57
|
-
- tasks/test.rake
|
58
|
-
- test
|
59
|
-
- test/deprecated
|
60
|
-
- test/ludy
|
61
|
-
- test/multiruby.sh
|
31
|
+
- Rakefile
|
62
32
|
- TODO
|
63
|
-
files:
|
64
|
-
- bin
|
65
33
|
- bin/ludy
|
66
|
-
-
|
67
|
-
- lib
|
68
|
-
- lib/ludy
|
34
|
+
- lib/ludy.rb
|
69
35
|
- lib/ludy/all.rb
|
70
|
-
- lib/ludy/array
|
36
|
+
- lib/ludy/array.rb
|
71
37
|
- lib/ludy/array/body.rb
|
72
38
|
- lib/ludy/array/choice.rb
|
73
39
|
- lib/ludy/array/combine.rb
|
@@ -82,12 +48,9 @@ files:
|
|
82
48
|
- lib/ludy/array/product.rb
|
83
49
|
- lib/ludy/array/rotate.rb
|
84
50
|
- lib/ludy/array/tail.rb
|
85
|
-
- lib/ludy/array.rb
|
86
51
|
- lib/ludy/blackhole.rb
|
87
|
-
- lib/ludy/class
|
88
|
-
- lib/ludy/class/undef_all_methods.rb
|
89
52
|
- lib/ludy/class.rb
|
90
|
-
- lib/ludy/
|
53
|
+
- lib/ludy/class/undef_all_methods.rb
|
91
54
|
- lib/ludy/deprecated/aspect.rb
|
92
55
|
- lib/ludy/deprecated/callstack.rb
|
93
56
|
- lib/ludy/deprecated/curry.rb
|
@@ -96,12 +59,10 @@ files:
|
|
96
59
|
- lib/ludy/deprecated/untranspose.rb
|
97
60
|
- lib/ludy/deprecated/unzip.rb
|
98
61
|
- lib/ludy/dices.rb
|
99
|
-
- lib/ludy/hash
|
100
|
-
- lib/ludy/hash/reverse_merge.rb
|
101
62
|
- lib/ludy/hash.rb
|
102
|
-
- lib/ludy/
|
63
|
+
- lib/ludy/hash/reverse_merge.rb
|
103
64
|
- lib/ludy/helpers/check_box.rb
|
104
|
-
- lib/ludy/kernel
|
65
|
+
- lib/ludy/kernel.rb
|
105
66
|
- lib/ludy/kernel/deep_copy.rb
|
106
67
|
- lib/ludy/kernel/defun.rb
|
107
68
|
- lib/ludy/kernel/ergo.rb
|
@@ -112,57 +73,44 @@ files:
|
|
112
73
|
- lib/ludy/kernel/public_send.rb
|
113
74
|
- lib/ludy/kernel/singleton_method.rb
|
114
75
|
- lib/ludy/kernel/tap.rb
|
115
|
-
- lib/ludy/kernel.rb
|
116
76
|
- lib/ludy/lazy.rb
|
117
77
|
- lib/ludy/list.rb
|
118
78
|
- lib/ludy/message_dispatcher.rb
|
119
79
|
- lib/ludy/namespace.rb
|
120
80
|
- lib/ludy/paginator.rb
|
121
81
|
- lib/ludy/pattern_matcher.rb
|
122
|
-
- lib/ludy/proc
|
82
|
+
- lib/ludy/proc.rb
|
123
83
|
- lib/ludy/proc/bind.rb
|
124
84
|
- lib/ludy/proc/chain.rb
|
125
85
|
- lib/ludy/proc/compose.rb
|
126
86
|
- lib/ludy/proc/curry.rb
|
127
|
-
- lib/ludy/
|
128
|
-
- lib/ludy/symbol
|
87
|
+
- lib/ludy/symbol.rb
|
129
88
|
- lib/ludy/symbol/curry.rb
|
130
89
|
- lib/ludy/symbol/to_msg.rb
|
131
90
|
- lib/ludy/symbol/to_proc.rb
|
132
|
-
- lib/ludy/
|
133
|
-
- lib/ludy/tasks
|
91
|
+
- lib/ludy/tasks.rb
|
134
92
|
- lib/ludy/tasks/common.rb
|
135
|
-
- lib/ludy/tasks/preprocess_cpp
|
93
|
+
- lib/ludy/tasks/preprocess_cpp.rb
|
136
94
|
- lib/ludy/tasks/preprocess_cpp/attr_builder.rb
|
137
95
|
- lib/ludy/tasks/preprocess_cpp/debug_hook.rb
|
138
96
|
- lib/ludy/tasks/preprocess_cpp/header_guard.rb
|
139
97
|
- lib/ludy/tasks/preprocess_cpp/template_forward_parameters.rb
|
140
|
-
- lib/ludy/tasks/preprocess_cpp.rb
|
141
|
-
- lib/ludy/tasks.rb
|
142
|
-
- lib/ludy/test
|
143
98
|
- lib/ludy/timer.rb
|
144
99
|
- lib/ludy/variable.rb
|
145
100
|
- lib/ludy/version.rb
|
146
101
|
- lib/ludy/y_combinator.rb
|
147
102
|
- lib/ludy/z_combinator.rb
|
148
|
-
- lib/
|
149
|
-
- lib/puzzle_generator
|
103
|
+
- lib/puzzle_generator.rb
|
150
104
|
- lib/puzzle_generator/chain.rb
|
151
105
|
- lib/puzzle_generator/chained_map.rb
|
152
106
|
- lib/puzzle_generator/colored_map.rb
|
153
107
|
- lib/puzzle_generator/map.rb
|
154
108
|
- lib/puzzle_generator/misc.rb
|
155
109
|
- lib/puzzle_generator/puzzle.rb
|
156
|
-
- lib/puzzle_generator.rb
|
157
|
-
- LICENSE
|
158
110
|
- ludy.gemspec
|
159
|
-
- NOTICE
|
160
|
-
- Rakefile
|
161
|
-
- README
|
162
|
-
- spec
|
163
111
|
- spec/ludy_spec.rb
|
164
112
|
- spec/spec_helper.rb
|
165
|
-
-
|
113
|
+
- task/gemgem.rb
|
166
114
|
- tasks/ann.rake
|
167
115
|
- tasks/bones.rake
|
168
116
|
- tasks/gem.rake
|
@@ -176,8 +124,6 @@ files:
|
|
176
124
|
- tasks/spec.rake
|
177
125
|
- tasks/svn.rake
|
178
126
|
- tasks/test.rake
|
179
|
-
- test
|
180
|
-
- test/deprecated
|
181
127
|
- test/deprecated/callstack.rb
|
182
128
|
- test/deprecated/curry.rb
|
183
129
|
- test/deprecated/rambda.rb
|
@@ -186,7 +132,6 @@ files:
|
|
186
132
|
- test/deprecated/unzip_and_untranspose.rb
|
187
133
|
- test/example_puzzle.rb
|
188
134
|
- test/helper.rb
|
189
|
-
- test/ludy
|
190
135
|
- test/ludy/test_array.rb
|
191
136
|
- test/ludy/test_class.rb
|
192
137
|
- test/ludy/test_defun.rb
|
@@ -202,40 +147,34 @@ files:
|
|
202
147
|
- test/ludy/test_y_combinator.rb
|
203
148
|
- test/ludy/test_z_combinator.rb
|
204
149
|
- test/multiruby.sh
|
205
|
-
|
206
|
-
|
207
|
-
homepage: http://ludy.rubyforge.org/
|
150
|
+
homepage: http://github.com/godfat/
|
151
|
+
licenses: []
|
208
152
|
post_install_message:
|
209
|
-
rdoc_options:
|
210
|
-
- --diagram
|
211
|
-
- --charset=utf-8
|
212
|
-
- --inline-source
|
213
|
-
- --line-numbers
|
214
|
-
- --promiscuous
|
153
|
+
rdoc_options:
|
215
154
|
- --main
|
216
155
|
- README
|
217
|
-
require_paths:
|
156
|
+
require_paths:
|
218
157
|
- lib
|
219
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
158
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
159
|
+
none: false
|
160
|
+
requirements:
|
161
|
+
- - ! '>='
|
162
|
+
- !ruby/object:Gem::Version
|
163
|
+
version: '0'
|
164
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
165
|
+
none: false
|
166
|
+
requirements:
|
167
|
+
- - ! '>='
|
168
|
+
- !ruby/object:Gem::Version
|
169
|
+
version: '0'
|
231
170
|
requirements: []
|
232
|
-
|
233
|
-
|
234
|
-
rubygems_version: 1.1.1
|
171
|
+
rubyforge_project:
|
172
|
+
rubygems_version: 1.7.2
|
235
173
|
signing_key:
|
236
|
-
specification_version:
|
237
|
-
summary: Aims to extend Ruby standard library, providing some useful tools that's
|
238
|
-
|
174
|
+
specification_version: 3
|
175
|
+
summary: Aims to extend Ruby standard library, providing some useful tools that's
|
176
|
+
not existed in the standard library, especially for functional programming.
|
177
|
+
test_files:
|
239
178
|
- test/ludy/test_array.rb
|
240
179
|
- test/ludy/test_class.rb
|
241
180
|
- test/ludy/test_defun.rb
|