ludy 0.1.10 → 0.1.11

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,5 +1,12 @@
1
1
  = ludy changes history
2
2
 
3
+ == ludy 0.1.11, 2008-03-25
4
+
5
+ * fixed tasks function into private method of Kernel.
6
+ * fixed version comparison.
7
+ * fixed encoding using # -*- coding: utf-8 -*- instead of $KCODE
8
+ * updated tasks/preprocess_cpp/debug_hook from std::cerr to std::clog.
9
+
3
10
  == ludy 0.1.10, 2008.02.07
4
11
 
5
12
  * fixed an offset bug in paginator. if the offset was equal to the count,
data/Manifest.txt CHANGED
@@ -51,6 +51,7 @@ lib/ludy/kernel/tap.rb
51
51
  lib/ludy/lazy.rb
52
52
  lib/ludy/list.rb
53
53
  lib/ludy/message_dispatcher.rb
54
+ lib/ludy/namespace.rb
54
55
  lib/ludy/paginator.rb
55
56
  lib/ludy/pattern_matcher.rb
56
57
  lib/ludy/proc.rb
@@ -71,6 +72,7 @@ lib/ludy/tasks/preprocess_cpp/header_guard.rb
71
72
  lib/ludy/tasks/preprocess_cpp/template_forward_parameters.rb
72
73
  lib/ludy/timer.rb
73
74
  lib/ludy/variable.rb
75
+ lib/ludy/version.rb
74
76
  lib/ludy/y_combinator.rb
75
77
  lib/ludy/z_combinator.rb
76
78
  lib/puzzle_generator.rb
@@ -82,7 +84,9 @@ lib/puzzle_generator/misc.rb
82
84
  lib/puzzle_generator/puzzle.rb
83
85
  spec/ludy_spec.rb
84
86
  spec/spec_helper.rb
87
+ tasks/ann.rake
85
88
  tasks/annotations.rake
89
+ tasks/bones.rake
86
90
  tasks/doc.rake
87
91
  tasks/gem.rake
88
92
  tasks/manifest.rake
data/README CHANGED
@@ -1,4 +1,4 @@
1
- = ludy 0.1.10
1
+ = ludy 0.1.11
2
2
  by Lin Jen-Shin (a.k.a. godfat-真常[http://godfat.org])
3
3
  strip any number: 18god29fat7029 (at] godfat32 -dooot- 20org
4
4
  * rdoc[http://ludy.rubyforge.org]
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
+ # -*- coding: utf-8 -*-
1
2
  # Look in the tasks/setup.rb file for the various options that can be
2
3
  # configured in this Rakefile. The .rake files in the tasks directory
3
4
  # are where the options are used.
4
-
5
5
  load 'tasks/setup.rb'
6
6
 
7
7
  ensure_in_path 'lib'
@@ -16,7 +16,7 @@ task :default do
16
16
  end
17
17
 
18
18
  PROJ.name = 'ludy'
19
- PROJ.authors = "Lin Jen-Shin (a.k.a. godfat \347\234\237\345\270\270)"
19
+ PROJ.authors = 'Lin Jen-Shin (a.k.a. godfat 真常)'
20
20
  PROJ.email = 'strip any number: 18god29fat7029 (at] godfat32 -dooot- 20org'
21
21
  PROJ.url = 'http://ludy.rubyforge.org/'
22
22
  PROJ.description = PROJ.summary = paragraphs_of('README', 'description').join("\n\n")
data/TODO CHANGED
@@ -17,3 +17,5 @@
17
17
 
18
18
  * refactor tasks...
19
19
  * make switch between template engine easier
20
+
21
+ * rails paginator, change model class, change opts...
data/lib/ludy.rb CHANGED
@@ -3,13 +3,14 @@
3
3
  # Equivalent to a header guard in C/C++
4
4
  # Used to prevent the class/module from being loaded more than once
5
5
  unless defined? LudyHeaderGuard
6
+
6
7
  module LudyHeaderGuard # :nodoc:
7
8
  end
8
9
 
9
10
  module Ludy
10
11
 
11
12
  # :stopdoc:
12
- VERSION = '0.1.10'
13
+ VERSION = '0.1.11'
13
14
  LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
14
15
  PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
15
16
  $LOAD_PATH << LIBPATH
@@ -53,7 +54,7 @@ module Ludy
53
54
  # require all files in the dir, only work for ludy.
54
55
  # i.e., Ludy.require_all_in 'proc' => require 'ludy/proc/*.rb'
55
56
  def self.require_all_in dir
56
- require 'rubygems' if RUBY_VERSION < '1.9.0'
57
+ require 'rubygems'
57
58
  require 'rake'
58
59
  Dir.glob("#{LIBPATH}ludy/#{dir}/*.rb").each{ |i|
59
60
  require(if dir == '.'
@@ -1,9 +1,11 @@
1
1
 
2
+ require 'ludy/version'
3
+
2
4
  class Array
3
5
  # it would be defined if RUBY_VERSION < '1.9.0', see rdoc in ruby 1.9
4
6
  def choice
5
7
  self[rand(size)]
6
- end if RUBY_VERSION < '1.9.0'
8
+ end if Ludy::ruby_before '1.9.0'
7
9
  # the choosen element would be deleted. return the choosen
8
10
  def choice!
9
11
  i = rand size
@@ -1,5 +1,5 @@
1
1
 
2
- require 'ludy/symbol/to_proc' if RUBY_VERSION < '1.9.0'
2
+ require 'ludy/symbol/to_proc'
3
3
 
4
4
  class Array
5
5
  # example:
@@ -1,8 +1,10 @@
1
1
 
2
+ require 'ludy/version'
3
+
2
4
  class Array
3
- if RUBY_VERSION < '1.9.0'
5
+ if Ludy::ruby_before '1.9.0'
4
6
  require 'ludy/array/foldr'
5
- require 'ludy/symbol/to_proc' if RUBY_VERSION < '1.9.0'
7
+ require 'ludy/symbol/to_proc' if Ludy::ruby_before '1.9.0'
6
8
  # for each combos
7
9
  # [[0,1],[2,3]].combos
8
10
  # => [[0,2],[0,3],[1,2],[1,3]]
@@ -1,7 +1,9 @@
1
1
 
2
+ require 'ludy/version'
3
+
2
4
  class Array
3
5
  # it would be defined if RUBY_VERSION < '1.9.0', see rdoc in ruby 1.9
4
6
  def count t
5
7
  inject(0){|r,i| i==t ? r+=1 : r}
6
8
  end
7
- end if RUBY_VERSION < '1.9.0'
9
+ end if Ludy::ruby_before '1.9.0'
@@ -1,5 +1,7 @@
1
1
 
2
- if RUBY_VERSION < '1.9.0'
2
+ require 'ludy/version'
3
+
4
+ if Ludy::ruby_before '1.9.0'
3
5
  begin
4
6
  require 'facets/enumerable/combos'
5
7
  rescue LoadError
@@ -1,6 +1,8 @@
1
1
 
2
+ require 'ludy/version'
3
+
2
4
  module Kernel
3
- undef_method :id if RUBY_VERSION < '1.9.0'
5
+ undef_method :id if Ludy::ruby_before '1.9.0'
4
6
  # id returns self
5
7
  def id a = nil; a.nil? ? self : a; end
6
8
  end
@@ -1,5 +1,7 @@
1
1
 
2
- if RUBY_VERSION < '1.9.0'
2
+ require 'ludy/version'
3
+
4
+ if Ludy::ruby_before '1.9.0'
3
5
  module Kernel
4
6
  # it would be defined if RUBY_VERSION < '1.9.0', see rdoc in ruby 1.9
5
7
  def public_send msg, *args, &block
@@ -1,6 +1,8 @@
1
1
 
2
+ require 'ludy/version'
3
+
2
4
  module Kernel
3
- if RUBY_VERSION < '1.9.0'
5
+ if Ludy::ruby_before '1.9.0'
4
6
  # it would be defined if RUBY_VERSION < '1.9.0', see rdoc in ruby 1.9
5
7
  def define_singleton_method msg, &block
6
8
  self.class.__send__ :define_method, msg, &block
@@ -1,6 +1,8 @@
1
1
 
2
+ require 'ludy/version'
3
+
2
4
  module Kernel
3
- if RUBY_VERSION < '1.9.0'
5
+ if Ludy::ruby_before '1.9.0'
4
6
  # it would be defined if RUBY_VERSION < '1.9.0', see rdoc in ruby 1.9
5
7
  def tap
6
8
  yield self
@@ -1,8 +1,6 @@
1
1
 
2
2
  require 'ludy/pattern_matcher'
3
- if RUBY_VERSION < '1.9.0'
4
- require 'ludy/kernel/singleton_method'
5
- end
3
+ require 'ludy/kernel/singleton_method'
6
4
 
7
5
  module Ludy
8
6
 
@@ -0,0 +1,71 @@
1
+
2
+ # module Ludy
3
+ # def use_module mod
4
+ # user = self.class
5
+ # mod.constants.each{ |const|
6
+ # target = mod.const_get const
7
+ # if user.const_defined? const
8
+ # origin = user.const_get const
9
+ # if origin.kind_of? Class and target.kind_of? Class
10
+ # # TODO: don't just override it!
11
+ # target.instance_methods.sort.each{ |method|
12
+ # origin.class.module_eval do
13
+ # # define_method method, target.instance_method(method)
14
+ # end
15
+ # }
16
+ # else
17
+ # # TODO: don't just override it!
18
+ # user.__send__ :remove_const, const
19
+ # user.const_set const, target
20
+ # end
21
+ # else
22
+ # user.const_set const, target
23
+ # end
24
+ # }
25
+ # end
26
+ # def unuse_module mod
27
+ # mod.constants.each{ |const|
28
+ # self.class.__send__ :remove_const, const
29
+ # }
30
+ # end
31
+ # end
32
+ #
33
+ # module Std
34
+ # N = 29
35
+ # class Array
36
+ # def orz
37
+ # puts 'orz'
38
+ # end
39
+ # end
40
+ # end
41
+ #
42
+ # # module M
43
+ # # Ludy::using_module Std
44
+ # # end
45
+ #
46
+ # require 'test/unit'
47
+ # class ContantsTest < Test::Unit::TestCase
48
+ # include Ludy
49
+ # def test_a_global
50
+ # assert_raise NameError do
51
+ # N
52
+ # end
53
+ # end
54
+ # def test_b_std
55
+ # assert_equal 29, Std::N
56
+ # end
57
+ # def test_c_using_std
58
+ # use_module Std
59
+ # assert_equal 29, N
60
+ # assert [].respond_to?(:orz)
61
+ # end
62
+ # def test_d_using_nil
63
+ # unuse_module Std
64
+ # assert 29, Std::N
65
+ # end
66
+ # def test_e_global
67
+ # assert_raise NameError do
68
+ # N
69
+ # end
70
+ # end
71
+ # end
@@ -1,5 +1,6 @@
1
1
 
2
- require 'ludy/kernel/public_send' if RUBY_VERSION < '1.9.0'
2
+ require 'ludy/version'
3
+ require 'ludy/kernel/public_send'
3
4
 
4
5
  module Ludy
5
6
  # which was produced by Paginator#page / Paginator#[],
@@ -9,7 +10,7 @@ module Ludy
9
10
  # was fetched, it won't fetch again. it you need refetch,
10
11
  # call Page#fetch
11
12
  class Page
12
- undef_method :to_a if RUBY_VERSION < '1.9.0'
13
+ undef_method :to_a if Ludy::ruby_before '1.9.0'
13
14
  # pager to get the original pager; page to get the number of this page
14
15
  attr_reader :pager, :page
15
16
  # don't create a page instance yourself unless you have to
@@ -1,39 +1,42 @@
1
1
 
2
- require 'ludy/kernel/public_send'
2
+ require 'ludy/version'
3
3
 
4
- class Proc
5
- def __curry__ *pre # :nodoc:
6
- lambda{ |*post| self[*(pre + post)] }
7
- end
4
+ if Ludy::ruby_before '1.9.0'
5
+ require 'ludy/kernel/public_send'
6
+ class Proc
7
+ def __curry__ *pre # :nodoc:
8
+ lambda{ |*post| self[*(pre + post)] }
9
+ end
8
10
 
9
- # make the caller be a curried function
10
- # lambda{|a,b,c| [a,b,c]}.curry[1][2][3]
11
- # => [1,2,3]
12
- def curry
13
- class << self
14
- alias_method :__call__, :call
15
- def call *args, &block # :nodoc:
16
- if self.arity == -1
17
- begin # let's try if arguments are ready
18
- # is there any better way to determine this?
19
- # it's hard to detect correct arity value when
20
- # Symbol#to_proc happened
21
- # e.g., :message_that_you_never_know.to_proc.arity => ?
22
- # i'd tried put hacks in Symbol#to_proc, but it's
23
- # difficult to implement in correct way
24
- # i would try it again in other day
11
+ # make the caller be a curried function
12
+ # lambda{|a,b,c| [a,b,c]}.curry[1][2][3]
13
+ # => [1,2,3]
14
+ def curry
15
+ class << self
16
+ alias_method :__call__, :call
17
+ def call *args, &block # :nodoc:
18
+ if self.arity == -1
19
+ begin # let's try if arguments are ready
20
+ # is there any better way to determine this?
21
+ # it's hard to detect correct arity value when
22
+ # Symbol#to_proc happened
23
+ # e.g., :message_that_you_never_know.to_proc.arity => ?
24
+ # i'd tried put hacks in Symbol#to_proc, but it's
25
+ # difficult to implement in correct way
26
+ # i would try it again in other day
27
+ self.public_send :__call__, *args, &block
28
+ rescue ArgumentError # oops, let's curry it
29
+ method(:call).to_proc.public_send :__curry__, *args
30
+ end
31
+ elsif args.size == self.arity
25
32
  self.public_send :__call__, *args, &block
26
- rescue ArgumentError # oops, let's curry it
33
+ else
27
34
  method(:call).to_proc.public_send :__curry__, *args
28
35
  end
29
- elsif args.size == self.arity
30
- self.public_send :__call__, *args, &block
31
- else
32
- method(:call).to_proc.public_send :__curry__, *args
33
36
  end
37
+ alias_method :[], :call
34
38
  end
35
- alias_method :[], :call
39
+ self
36
40
  end
37
- self
38
41
  end
39
42
  end
@@ -1,5 +1,7 @@
1
1
 
2
- if RUBY_VERSION < '1.9.0'
2
+ require 'ludy/version'
3
+
4
+ if Ludy::ruby_before '1.9.0'
3
5
  class Symbol
4
6
  # it would be defined if RUBY_VERSION < '1.9.0', see rdoc in ruby 1.9
5
7
  def to_proc; lambda{ |*args| args.shift.__send__ self, *args }; end
@@ -35,7 +35,7 @@ namespace :preprocess do
35
35
 
36
36
  erb_inputs.zip(erb_outputs).each{ |input, output|
37
37
  file output => input do
38
- preprocess lambda{|input| ERB.new input}, input, output
38
+ preprocess lambda{|input_str| ERB.new input_str}, input, output
39
39
  end
40
40
  }
41
41
 
@@ -1,6 +1,6 @@
1
1
 
2
2
  module Kernel
3
-
3
+ private
4
4
  # just like attr_accessor for c++
5
5
  def accessor type, *pros
6
6
  (reader_only type, *pros) +
@@ -46,4 +46,4 @@ def member_only type, *pros
46
46
  result << "#{@prefix}#{@indent}#{type} #{pros.map{|p|"#{p}_"}.join(", ")};\n"
47
47
  end
48
48
 
49
- end # of ludy
49
+ end # of Kernel
@@ -2,6 +2,7 @@
2
2
  require 'ludy/tasks/common'
3
3
 
4
4
  module Kernel
5
+ private
5
6
  # it simply output:
6
7
  # #ifndef NDEBUG
7
8
  # #include <iostream>
@@ -28,8 +29,8 @@ module Kernel
28
29
  block.call
29
30
  Ludy::erbout "
30
31
  #ifndef NDEBUG
31
- std::cerr << \"method #{name} called, for \" << this << \" at #{@file}: #{eval '__LINE__', block.binding}\\n\";
32
+ std::clog << \"method #{name} called, for \" << this << \" at #{@file}: #{eval '__LINE__', block.binding}\\n\";
32
33
  #endif
33
34
  ", block.binding
34
35
  end
35
- end
36
+ end # of Kernel
@@ -2,7 +2,7 @@
2
2
  require 'ludy/tasks/common'
3
3
 
4
4
  module Kernel
5
-
5
+ private
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
@@ -14,4 +14,4 @@ def header_guard random_suffix = nil, &block
14
14
  Ludy::erbout '#endif', block.binding
15
15
  end
16
16
 
17
- end # of ludy
17
+ end # of Kernel
@@ -4,7 +4,7 @@ require 'ludy/array/map_with_index'
4
4
  require 'ludy/array/tail'
5
5
 
6
6
  module Kernel
7
-
7
+ private
8
8
  # forward template functions' generator
9
9
  def for_template_parameters_within range, modifiers = ['volatile', 'const volatile']
10
10
  modifiers = ['', 'const'] + modifiers
@@ -42,4 +42,4 @@ def arguments args_list
42
42
  }.join(', ')
43
43
  end
44
44
 
45
- end # of ludy
45
+ end # of Kernel
data/lib/ludy/variable.rb CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- require 'ludy/kernel/public_send' unless RUBY_VERSION < '1.9.0'
2
+ require 'ludy/kernel/public_send'
3
3
  require 'ludy/class/undef_all_methods'
4
4
 
5
5
  module Ludy
@@ -0,0 +1,9 @@
1
+
2
+ require 'rubygems'
3
+ module Ludy
4
+ GEM_RUBY_VERSION = Gem::Version.new(::RUBY_VERSION)
5
+ module_function
6
+ def ruby_before ver
7
+ GEM_RUBY_VERSION < Gem::Version.new(ver)
8
+ end
9
+ end
@@ -7,7 +7,7 @@ require 'ludy/kernel/deep_copy'
7
7
  require 'ludy/array/combine'
8
8
  require 'ludy/array/rotate'
9
9
  require 'ludy/array/choice' # for Array#choice!
10
- require 'ludy/array/product' if RUBY_VERSION < '1.9.0'
10
+ require 'ludy/array/product'
11
11
 
12
12
  module PuzzleGenerator
13
13
 
@@ -3,8 +3,8 @@ require 'puzzle_generator/misc'
3
3
  require 'puzzle_generator/chain'
4
4
 
5
5
  require 'ludy/kernel/maybe'
6
- require 'ludy/array/count' if RUBY_VERSION < '1.9.0'
7
- require 'ludy/array/product' if RUBY_VERSION < '1.9.0'
6
+ require 'ludy/array/count'
7
+ require 'ludy/array/product'
8
8
 
9
9
  module PuzzleGenerator
10
10
 
data/tasks/ann.rake ADDED
@@ -0,0 +1,76 @@
1
+ # $Id$
2
+
3
+ begin
4
+ require 'bones/smtp_tls'
5
+ rescue LoadError
6
+ require 'net/smtp'
7
+ end
8
+ require 'time'
9
+
10
+ namespace :ann do
11
+
12
+ file PROJ.ann_file do
13
+ puts "Generating #{PROJ.ann_file}"
14
+ File.open(PROJ.ann_file,'w') do |fd|
15
+ fd.puts("#{PROJ.name} version #{PROJ.version}")
16
+ fd.puts(" by #{Array(PROJ.authors).first}") if PROJ.authors
17
+ fd.puts(" #{PROJ.url}") if PROJ.url
18
+ fd.puts(" (the \"#{PROJ.release_name}\" release)") if PROJ.release_name
19
+ fd.puts
20
+ fd.puts("== DESCRIPTION")
21
+ fd.puts
22
+ fd.puts(PROJ.description)
23
+ fd.puts
24
+ fd.puts(PROJ.changes.sub(%r/^.*$/, '== CHANGES'))
25
+ fd.puts
26
+ PROJ.ann_paragraphs.each do |p|
27
+ fd.puts "== #{p.upcase}"
28
+ fd.puts
29
+ fd.puts paragraphs_of(PROJ.readme_file, p).join("\n\n")
30
+ fd.puts
31
+ end
32
+ fd.puts PROJ.ann_text if PROJ.ann_text
33
+ end
34
+ end
35
+
36
+ desc "Create an announcement file"
37
+ task :announcement => PROJ.ann_file
38
+
39
+ desc "Send an email announcement"
40
+ task :email => PROJ.ann_file do
41
+ from = PROJ.ann_email[:from] || PROJ.email
42
+ to = Array(PROJ.ann_email[:to])
43
+
44
+ ### build a mail header for RFC 822
45
+ rfc822msg = "From: #{from}\n"
46
+ rfc822msg << "To: #{to.join(',')}\n"
47
+ rfc822msg << "Subject: [ANN] #{PROJ.name} #{PROJ.version}"
48
+ rfc822msg << " (#{PROJ.release_name})" if PROJ.release_name
49
+ rfc822msg << "\n"
50
+ rfc822msg << "Date: #{Time.new.rfc822}\n"
51
+ rfc822msg << "Message-Id: "
52
+ rfc822msg << "<#{"%.8f" % Time.now.to_f}@#{PROJ.ann_email[:domain]}>\n\n"
53
+ rfc822msg << File.read(PROJ.ann_file)
54
+
55
+ params = [:server, :port, :domain, :acct, :passwd, :authtype].map do |key|
56
+ PROJ.ann_email[key]
57
+ end
58
+
59
+ params[3] = PROJ.email if params[3].nil?
60
+
61
+ if params[4].nil?
62
+ STDOUT.write "Please enter your e-mail password (#{params[3]}): "
63
+ params[4] = STDIN.gets.chomp
64
+ end
65
+
66
+ ### send email
67
+ Net::SMTP.start(*params) {|smtp| smtp.sendmail(rfc822msg, from, to)}
68
+ end
69
+ end # namespace :ann
70
+
71
+ desc 'Alias to ann:announcement'
72
+ task :ann => 'ann:announcement'
73
+
74
+ CLOBBER << PROJ.ann_file
75
+
76
+ # EOF
@@ -5,23 +5,15 @@ if HAVE_BONES
5
5
  desc "Enumerate all annotations"
6
6
  task :notes do
7
7
  Bones::AnnotationExtractor.enumerate(
8
- PROJ, "OPTIMIZE|FIXME|TODO", :tag => true)
8
+ PROJ, PROJ.annotation_tags.join('|'), :tag => true)
9
9
  end
10
10
 
11
11
  namespace :notes do
12
- desc "Enumerate all OPTIMIZE annotations"
13
- task :optimize do
14
- Bones::AnnotationExtractor.enumerate(PROJ, "OPTIMIZE")
15
- end
16
-
17
- desc "Enumerate all FIXME annotations"
18
- task :fixme do
19
- Bones::AnnotationExtractor.enumerate(PROJ, "FIXME")
20
- end
21
-
22
- desc "Enumerate all TODO annotations"
23
- task :todo do
24
- Bones::AnnotationExtractor.enumerate(PROJ, "TODO")
12
+ PROJ.annotation_tags.each do |tag|
13
+ desc "Enumerate all #{tag} annotations"
14
+ task tag.downcase.to_sym do
15
+ Bones::AnnotationExtractor.enumerate(PROJ, tag)
16
+ end
25
17
  end
26
18
  end
27
19
 
data/tasks/bones.rake ADDED
@@ -0,0 +1,40 @@
1
+ # $Id$
2
+
3
+ require 'pp'
4
+ require 'stringio'
5
+
6
+ namespace :bones do
7
+
8
+ desc 'Show the PROJ open struct'
9
+ task :debug do |t|
10
+ atr = if ARGV.length == 2
11
+ t.application.top_level_tasks.pop
12
+ end
13
+ sio = StringIO.new
14
+ sep = "\n" + ' '*27
15
+ fmt = "%23s => %s"
16
+
17
+ if atr
18
+ PP.pp(PROJ.send(atr.to_sym), sio, 49)
19
+ sio.seek 0
20
+ val = sio.read
21
+ val = val.split("\n").join(sep)
22
+
23
+ puts fmt % [atr, val]
24
+ else
25
+ h = PROJ.instance_variable_get(:@table)
26
+ h.keys.map {|k| k.to_s}.sort.each do |k|
27
+ sio.truncate 0
28
+ PP.pp(h[k.to_sym], sio, 49)
29
+ sio.seek 0
30
+ val = sio.read
31
+ val = val.split("\n").join(sep)
32
+
33
+ puts fmt % [k, val]
34
+ end
35
+ end
36
+ end
37
+
38
+ end # namespace :bones
39
+
40
+ # EOF
data/tasks/doc.rake CHANGED
@@ -31,7 +31,6 @@ namespace :doc do
31
31
  sh "#{RDOC} --ri -o ri ."
32
32
  end
33
33
 
34
- desc 'Remove ri products'
35
34
  task :clobber_ri do
36
35
  rm_r 'ri' rescue nil
37
36
  end
@@ -44,6 +43,6 @@ task :doc => 'doc:rdoc'
44
43
  desc 'Remove all build products'
45
44
  task :clobber => %w(doc:clobber_rdoc doc:clobber_ri)
46
45
 
47
- remove_desc_for_task %w(doc:clobber_rdoc doc:clobber_ri)
46
+ remove_desc_for_task %w(doc:clobber_rdoc)
48
47
 
49
48
  # EOF
data/tasks/gem.rake CHANGED
@@ -12,6 +12,7 @@ namespace :gem do
12
12
  s.email = PROJ.email
13
13
  s.homepage = Array(PROJ.url).first
14
14
  s.rubyforge_project = PROJ.rubyforge_name
15
+ s.post_install_message = PROJ.post_install_message
15
16
 
16
17
  s.description = PROJ.description
17
18
 
@@ -62,9 +63,29 @@ namespace :gem do
62
63
  puts PROJ.spec.to_ruby
63
64
  end
64
65
 
65
- Rake::GemPackageTask.new(PROJ.spec) do |pkg|
66
+ pkg = Rake::PackageTask.new(PROJ.name, PROJ.version) do |pkg|
66
67
  pkg.need_tar = PROJ.need_tar
67
68
  pkg.need_zip = PROJ.need_zip
69
+ pkg.package_files += PROJ.spec.files
70
+ end
71
+ Rake::Task['gem:package'].instance_variable_set(:@full_comment, nil)
72
+
73
+ gem_file = if PROJ.spec.platform == Gem::Platform::RUBY
74
+ "#{pkg.package_name}.gem"
75
+ else
76
+ "#{pkg.package_name}-#{PROJ.spec.platform}.gem"
77
+ end
78
+
79
+ desc "Build the gem file #{gem_file}"
80
+ task :package => "#{pkg.package_dir}/#{gem_file}"
81
+
82
+ file "#{pkg.package_dir}/#{gem_file}" => [pkg.package_dir] + PROJ.spec.files do
83
+ when_writing("Creating GEM") {
84
+ Gem::Builder.new(PROJ.spec).build
85
+ verbose(true) {
86
+ mv gem_file, "#{pkg.package_dir}/#{gem_file}"
87
+ }
88
+ }
68
89
  end
69
90
 
70
91
  desc 'Install the gem'
@@ -74,9 +95,15 @@ namespace :gem do
74
95
 
75
96
  desc 'Uninstall the gem'
76
97
  task :uninstall do
77
- sh "#{SUDO} #{GEM} uninstall -v '#{PROJ.version}' -x #{PROJ.name}"
98
+ installed_list = Gem.source_index.find_name(PROJ.name)
99
+ if installed_list and installed_list.collect { |s| s.version.to_s}.include?(PROJ.version) then
100
+ sh "#{SUDO} #{GEM} uninstall -v '#{PROJ.version}' -i -x #{PROJ.name}"
101
+ end
78
102
  end
79
103
 
104
+ desc 'Reinstall the gem'
105
+ task :reinstall => [:uninstall, :install]
106
+
80
107
  end # namespace :gem
81
108
 
82
109
  desc 'Alias to gem:package'
data/tasks/manifest.rake CHANGED
@@ -6,18 +6,11 @@ namespace :manifest do
6
6
 
7
7
  desc 'Verify the manifest'
8
8
  task :check do
9
- fn = 'Manifest.tmp'
10
- files = []
11
- exclude = Regexp.new(PROJ.exclude.join('|'))
12
- Find.find '.' do |path|
13
- path.sub! %r/^(\.\/|\/)/o, ''
14
- next unless test ?f, path
15
- next if path =~ exclude
16
- files << path
17
- end
9
+ fn = PROJ.manifest_file + '.tmp'
10
+ files = manifest_files
18
11
 
19
- File.open(fn, 'w') {|fp| fp.puts files.sort}
20
- lines = %x(#{DIFF} -du Manifest.txt #{fn}).split("\n")
12
+ File.open(fn, 'w') {|fp| fp.puts files}
13
+ lines = %x(#{DIFF} -du #{PROJ.manifest_file} #{fn}).split("\n")
21
14
  if HAVE_FACETS_ANSICODE and ENV.has_key?('TERM')
22
15
  lines.map! do |line|
23
16
  case line
@@ -34,19 +27,20 @@ namespace :manifest do
34
27
 
35
28
  desc 'Create a new manifest'
36
29
  task :create do
37
- fn = 'Manifest.txt'
38
- files = []
39
- exclude = Regexp.new(PROJ.exclude.join('|'))
40
- Find.find '.' do |path|
41
- path.sub! %r/^(\.\/|\/)/o, ''
42
- next unless test ?f, path
43
- next if path =~ exclude
44
- files << path
30
+ files = manifest_files
31
+ unless test(?f, PROJ.manifest_file)
32
+ files << PROJ.manifest_file
33
+ files.sort!
45
34
  end
35
+ File.open(PROJ.manifest_file, 'w') {|fp| fp.puts files}
36
+ end
46
37
 
47
- files << fn unless test ?f, fn
48
- File.open(fn, 'w') {|fp| fp.puts files.sort}
38
+ task :assert do
39
+ files = manifest_files
40
+ manifest = File.read(PROJ.manifest_file).split($/)
41
+ raise "ERROR: #{PROJ.manifest_file} is out of date" unless files == manifest
49
42
  end
43
+
50
44
  end # namespace :manifest
51
45
 
52
46
  desc 'Alias to manifest:check'
data/tasks/post_load.rake CHANGED
@@ -3,16 +3,30 @@
3
3
  # This file does not define any rake tasks. It is used to load some project
4
4
  # settings if they are not defined by the user.
5
5
 
6
- unless PROJ.changes
7
- PROJ.changes = paragraphs_of('History.txt', 0..1).join("\n\n")
8
- end
6
+ PROJ.rdoc_exclude << "^#{Regexp.escape(PROJ.manifest_file)}$"
7
+ PROJ.exclude << "^#{Regexp.escape(PROJ.ann_file)}$"
9
8
 
10
- unless PROJ.description
11
- PROJ.description = paragraphs_of('README.txt', 'description').join("\n\n")
9
+ PROJ.instance_variable_get(:@table).each do |key,val|
10
+ next unless val.instance_of? Array
11
+ next if key == :dependencies
12
+ val.flatten!
12
13
  end
13
14
 
14
- unless PROJ.summary
15
- PROJ.summary = PROJ.description.split('.').first
16
- end
15
+ PROJ.changes ||= paragraphs_of(PROJ.history_file, 0..1).join("\n\n")
16
+
17
+ PROJ.description ||= paragraphs_of(PROJ.readme_file, 'description').join("\n\n")
18
+
19
+ PROJ.summary ||= PROJ.description.split('.').first
20
+
21
+ PROJ.files ||=
22
+ if test(?f, PROJ.manifest_file)
23
+ files = File.readlines(PROJ.manifest_file).map {|fn| fn.chomp.strip}
24
+ files.delete ''
25
+ files
26
+ else [] end
27
+
28
+ PROJ.executables ||= PROJ.files.find_all {|fn| fn =~ %r/^bin/}
29
+
30
+ PROJ.rdoc_main ||= PROJ.readme_file
17
31
 
18
32
  # EOF
data/tasks/setup.rb CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'rubygems'
4
4
  require 'rake'
5
+ require 'rake/clean'
5
6
  require 'fileutils'
6
7
  require 'ostruct'
7
8
 
@@ -17,6 +18,10 @@ PROJ.url = nil
17
18
  PROJ.version = ENV['VERSION'] || '0.0.0'
18
19
  PROJ.rubyforge_name = nil
19
20
  PROJ.exclude = %w(tmp$ bak$ ~$ CVS .svn/ ^pkg/ ^doc/)
21
+ PROJ.release_name = ENV['RELEASE']
22
+ PROJ.history_file = 'History.txt'
23
+ PROJ.manifest_file = 'Manifest.txt'
24
+ PROJ.readme_file = 'README.txt'
20
25
 
21
26
  # Rspec
22
27
  PROJ.specs = FileList['spec/**/*_spec.rb']
@@ -28,13 +33,16 @@ PROJ.test_file = 'test/all.rb'
28
33
  PROJ.test_opts = []
29
34
 
30
35
  # Rcov
31
- PROJ.rcov_opts = ['--sort', 'coverage', '-T']
36
+ PROJ.rcov_dir = 'coverage'
37
+ PROJ.rcov_opts = %w[--sort coverage -T]
38
+ PROJ.rcov_threshold = 90.0
39
+ PROJ.rcov_threshold_exact = false
32
40
 
33
41
  # Rdoc
34
42
  PROJ.rdoc_opts = []
35
43
  PROJ.rdoc_include = %w(^lib/ ^bin/ ^ext/ .txt$)
36
- PROJ.rdoc_exclude = %w(extconf.rb$ ^Manifest.txt$)
37
- PROJ.rdoc_main = 'README.txt'
44
+ PROJ.rdoc_exclude = %w(extconf.rb$)
45
+ PROJ.rdoc_main = nil
38
46
  PROJ.rdoc_dir = 'doc'
39
47
  PROJ.rdoc_remote_dir = nil
40
48
 
@@ -45,20 +53,17 @@ PROJ.libs = []
45
53
  %w(lib ext).each {|dir| PROJ.libs << dir if test ?d, dir}
46
54
 
47
55
  # Gem Packaging
48
- PROJ.files =
49
- if test ?f, 'Manifest.txt'
50
- files = File.readlines('Manifest.txt').map {|fn| fn.chomp.strip}
51
- files.delete ''
52
- files
53
- else [] end
54
- PROJ.executables = PROJ.files.find_all {|fn| fn =~ %r/^bin/}
56
+ PROJ.files = nil
57
+ PROJ.executables = nil
55
58
  PROJ.dependencies = []
56
59
  PROJ.need_tar = true
57
60
  PROJ.need_zip = false
61
+ PROJ.post_install_message = nil
58
62
 
59
63
  # File Annotations
60
- PROJ.annotation_exclude = []
64
+ PROJ.annotation_exclude = %w(^tasks/setup.rb$)
61
65
  PROJ.annotation_extensions = %w(.txt .rb .erb) << ''
66
+ PROJ.annotation_tags = %w(FIXME OPTIMIZE TODO)
62
67
 
63
68
  # Subversion Repository
64
69
  PROJ.svn = false
@@ -67,6 +72,21 @@ PROJ.svn_trunk = 'trunk'
67
72
  PROJ.svn_tags = 'tags'
68
73
  PROJ.svn_branches = 'branches'
69
74
 
75
+ # Announce
76
+ PROJ.ann_file = 'announcement.txt'
77
+ PROJ.ann_text = nil
78
+ PROJ.ann_paragraphs = []
79
+ PROJ.ann_email = {
80
+ :from => nil,
81
+ :to => %w(ruby-talk@ruby-lang.org),
82
+ :server => 'localhost',
83
+ :port => 25,
84
+ :domain => ENV['HOSTNAME'],
85
+ :acct => nil,
86
+ :passwd => nil,
87
+ :authtype => :plain
88
+ }
89
+
70
90
  # Load the other rake files in the tasks folder
71
91
  rakefiles = Dir.glob('tasks/*.rake').sort
72
92
  rakefiles.unshift(rakefiles.delete('tasks/post_load.rake')).compact!
@@ -99,8 +119,8 @@ SUDO = if WIN32 then ''
99
119
  else '' end
100
120
  end
101
121
 
102
- RCOV = WIN32 ? 'rcov.cmd' : 'rcov'
103
- GEM = WIN32 ? 'gem.cmd' : 'gem'
122
+ RCOV = WIN32 ? 'rcov.bat' : 'rcov'
123
+ GEM = WIN32 ? 'gem.bat' : 'gem'
104
124
 
105
125
  %w(rcov spec/rake/spectask rubyforge bones facets/ansicode).each do |lib|
106
126
  begin
@@ -149,7 +169,10 @@ def depend_on( name, version = nil )
149
169
  spec = Gem.source_index.find_name(name).last
150
170
  version = spec.version.to_s if version.nil? and !spec.nil?
151
171
 
152
- PROJ.dependencies << (version.nil? ? [name] : [name, ">= #{version}"])
172
+ PROJ.dependencies << case version
173
+ when nil; [name]
174
+ when %r/^\d/; [name, ">= #{version}"]
175
+ else [name, version] end
153
176
  end
154
177
 
155
178
  # Adds the given arguments to the include path if they are not already there
@@ -186,4 +209,19 @@ def in_directory( dir, &block )
186
209
  end
187
210
  end
188
211
 
212
+ # Scans the current working directory and creates a list of files that are
213
+ # candidates to be in the manifest.
214
+ #
215
+ def manifest_files
216
+ files = []
217
+ exclude = Regexp.new(PROJ.exclude.join('|'))
218
+ Find.find '.' do |path|
219
+ path.sub! %r/^(\.\/|\/)/o, ''
220
+ next unless test ?f, path
221
+ next if path =~ exclude
222
+ files << path
223
+ end
224
+ files.sort!
225
+ end
226
+
189
227
  # EOF
data/tasks/spec.rake CHANGED
@@ -1,11 +1,13 @@
1
1
  # $Id$
2
2
 
3
3
  if HAVE_SPEC_RAKE_SPECTASK
4
+ require 'spec/rake/verify_rcov'
4
5
 
5
6
  namespace :spec do
6
7
 
7
8
  desc 'Run all specs with basic output'
8
9
  Spec::Rake::SpecTask.new(:run) do |t|
10
+ t.ruby_opts = PROJ.ruby_opts
9
11
  t.spec_opts = PROJ.spec_opts
10
12
  t.spec_files = PROJ.specs
11
13
  t.libs += PROJ.libs
@@ -13,6 +15,7 @@ namespace :spec do
13
15
 
14
16
  desc 'Run all specs with text output'
15
17
  Spec::Rake::SpecTask.new(:specdoc) do |t|
18
+ t.ruby_opts = PROJ.ruby_opts
16
19
  t.spec_opts = PROJ.spec_opts + ['--format', 'specdoc']
17
20
  t.spec_files = PROJ.specs
18
21
  t.libs += PROJ.libs
@@ -21,12 +24,22 @@ namespace :spec do
21
24
  if HAVE_RCOV
22
25
  desc 'Run all specs with RCov'
23
26
  Spec::Rake::SpecTask.new(:rcov) do |t|
27
+ t.ruby_opts = PROJ.ruby_opts
24
28
  t.spec_opts = PROJ.spec_opts
25
29
  t.spec_files = PROJ.specs
26
30
  t.libs += PROJ.libs
27
31
  t.rcov = true
32
+ t.rcov_dir = PROJ.rcov_dir
28
33
  t.rcov_opts = PROJ.rcov_opts + ['--exclude', 'spec']
29
34
  end
35
+
36
+ RCov::VerifyTask.new(:verify) do |t|
37
+ t.threshold = PROJ.rcov_threshold
38
+ t.index_html = File.join(PROJ.rcov_dir, 'index.html')
39
+ t.require_exact_threshold = PROJ.rcov_threshold_exact
40
+ end
41
+
42
+ task :verify => :rcov
30
43
  end
31
44
 
32
45
  end # namespace :spec
data/tasks/test.rake CHANGED
@@ -6,7 +6,7 @@ namespace :test do
6
6
 
7
7
  Rake::TestTask.new(:run) do |t|
8
8
  t.libs = PROJ.libs
9
- t.test_files = if test ?f, PROJ.test_file then [PROJ.test_file]
9
+ t.test_files = if test(?f, PROJ.test_file) then [PROJ.test_file]
10
10
  else PROJ.tests end
11
11
  t.ruby_opts += PROJ.ruby_opts
12
12
  t.ruby_opts += PROJ.test_opts
@@ -15,14 +15,14 @@ namespace :test do
15
15
  if HAVE_RCOV
16
16
  desc 'Run rcov on the unit tests'
17
17
  task :rcov => :clobber_rcov do
18
- opts = PROJ.rcov_opts.join(' ')
19
- files = if test ?f, PROJ.test_file then [PROJ.test_file]
18
+ opts = PROJ.rcov_opts.dup << '-o' << PROJ.rcov_dir
19
+ opts = opts.join(' ')
20
+ files = if test(?f, PROJ.test_file) then [PROJ.test_file]
20
21
  else PROJ.tests end
21
22
  files = files.join(' ')
22
23
  sh "#{RCOV} #{files} #{opts}"
23
24
  end
24
25
 
25
- desc 'Remove rcov products'
26
26
  task :clobber_rcov do
27
27
  rm_r 'coverage' rescue nil
28
28
  end
@@ -35,6 +35,4 @@ task :test => 'test:run'
35
35
 
36
36
  task :clobber => 'test:clobber_rcov' if HAVE_RCOV
37
37
 
38
- remove_desc_for_task %w(test:clobber_rcov)
39
-
40
38
  # EOF
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.10
4
+ version: 0.1.11
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-02-07 00:00:00 +08:00
12
+ date: 2008-03-25 00:00:00 +08:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -26,7 +26,9 @@ extra_rdoc_files:
26
26
  - README
27
27
  - TODO
28
28
  - bin/ludy
29
+ - tasks/ann.rake
29
30
  - tasks/annotations.rake
31
+ - tasks/bones.rake
30
32
  - tasks/doc.rake
31
33
  - tasks/gem.rake
32
34
  - tasks/manifest.rake
@@ -90,6 +92,7 @@ files:
90
92
  - lib/ludy/lazy.rb
91
93
  - lib/ludy/list.rb
92
94
  - lib/ludy/message_dispatcher.rb
95
+ - lib/ludy/namespace.rb
93
96
  - lib/ludy/paginator.rb
94
97
  - lib/ludy/pattern_matcher.rb
95
98
  - lib/ludy/proc.rb
@@ -110,6 +113,7 @@ files:
110
113
  - lib/ludy/tasks/preprocess_cpp/template_forward_parameters.rb
111
114
  - lib/ludy/timer.rb
112
115
  - lib/ludy/variable.rb
116
+ - lib/ludy/version.rb
113
117
  - lib/ludy/y_combinator.rb
114
118
  - lib/ludy/z_combinator.rb
115
119
  - lib/puzzle_generator.rb
@@ -121,7 +125,9 @@ files:
121
125
  - lib/puzzle_generator/puzzle.rb
122
126
  - spec/ludy_spec.rb
123
127
  - spec/spec_helper.rb
128
+ - tasks/ann.rake
124
129
  - tasks/annotations.rake
130
+ - tasks/bones.rake
125
131
  - tasks/doc.rake
126
132
  - tasks/gem.rake
127
133
  - tasks/manifest.rake