ludy 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,5 +1,13 @@
1
1
  = ludy changes history
2
2
 
3
+ == ludy 0.1.3, 2008.01.23
4
+
5
+ * renamed next_page to next, and prev_page to prev
6
+ * added Page#page to get the page number of that page.
7
+ * added Ludy::eout to use in erb's block, see ludy/tasks/common.rb
8
+ i would extract it to erb or somewhere else someday.
9
+ * better header_guard usage, with block
10
+
3
11
  == ludy 0.1.2, 2008.01.17
4
12
 
5
13
  * aims to add functional stuffs, list comprehension is working in progress
data/Manifest.txt CHANGED
@@ -55,6 +55,7 @@ lib/ludy/symbol/curry.rb
55
55
  lib/ludy/symbol/to_msg.rb
56
56
  lib/ludy/symbol/to_proc.rb
57
57
  lib/ludy/tasks.rb
58
+ lib/ludy/tasks/common.rb
58
59
  lib/ludy/tasks/erb_cpp.rb
59
60
  lib/ludy/tasks/erb_cpp/attr_builder.rb
60
61
  lib/ludy/tasks/erb_cpp/header_guard.rb
@@ -87,7 +88,6 @@ test/deprecated/this.rb
87
88
  test/deprecated/ts_ludy.rb
88
89
  test/deprecated/unzip_and_untranspose.rb
89
90
  test/example_puzzle.rb
90
- test/test_all.rb
91
91
  test/test_array.rb
92
92
  test/test_class.rb
93
93
  test/test_defun.rb
@@ -96,6 +96,7 @@ test/test_kernel.rb
96
96
  test/test_lazy.rb
97
97
  test/test_paginator.rb
98
98
  test/test_proc.rb
99
+ test/test_require_all.rb
99
100
  test/test_symbol.rb
100
101
  test/test_variable.rb
101
102
  test/test_y_combinator.rb
data/README CHANGED
@@ -1,11 +1,11 @@
1
- = ludy 0.1.2
1
+ = ludy 0.1.3
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
5
5
  http://godfat.org
6
6
 
7
7
  == DESCRIPTION:
8
-
8
+
9
9
  Aims to extend Ruby standard library, providing some useful tools that's not existed in the standard library, especially for functional programming.
10
10
 
11
11
  == FEATURES:
@@ -93,7 +93,7 @@ paginator:
93
93
 
94
94
  pager.page(1)
95
95
  pager[1] # same as above
96
- pager.page(2).next_page.prev_page.each{|e| e} # you can enumerate
96
+ pager.page(2).next.prev.each{|e| e} # you can enumerate
97
97
  pager[3].map{|e| e*2}
98
98
  pager.size # number of pages
99
99
  pager.inject(0){|r, i| r += i.inject &:+ } # total sum of all data
@@ -106,7 +106,9 @@ header_guard:
106
106
  PROJ = 'header_sample' # remember to set project name
107
107
 
108
108
  # in utils/SimpleTest.hpp.erb
109
- <%= header_guard %>
109
+ <% header_guard do %>
110
+ class C;
111
+ <% end %>
110
112
 
111
113
  # run preprocessing task
112
114
  $ rake erb:preprocessing
@@ -114,6 +116,8 @@ header_guard:
114
116
  # produce:
115
117
  #ifndef _HEADER_SAMPLE_UTILS_SIMPLETEST_
116
118
  #define _HEADER_SAMPLE_UTILS_SIMPLETEST_
119
+ class C;
120
+ #endif
117
121
 
118
122
  attr_builder:
119
123
  require 'ludy/tasks/erb_cpp' # it would require all erb_cpp tasks.
data/Rakefile CHANGED
@@ -20,7 +20,7 @@ PROJ.description = paragraphs_of('README', 1).join("\n\n")
20
20
  PROJ.changes = paragraphs_of('CHANGES', 0..1).join("\n\n")
21
21
  PROJ.rubyforge_name = 'ludy'
22
22
 
23
- PROJ.version = '0.1.2'
23
+ PROJ.version = '0.1.3'
24
24
  PROJ.exclude << '.DS_Store' << '^tmp'
25
25
  PROJ.dependencies << 'rake'
26
26
 
data/TODO CHANGED
@@ -9,4 +9,6 @@
9
9
  * extract Array's methods to Enumerable
10
10
 
11
11
  * table showing, with pad.
12
- * rails multiple layout
12
+ * rails multiple layout
13
+
14
+ * better manifest creating
data/lib/ludy.rb CHANGED
@@ -12,7 +12,7 @@ require 'rake'
12
12
  module Ludy
13
13
 
14
14
  # :stopdoc:
15
- VERSION = '0.1.0'
15
+ VERSION = '0.1.3'
16
16
  LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
17
17
  PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
18
18
  $LOAD_PATH << LIBPATH
@@ -10,13 +10,13 @@ module Ludy
10
10
  # call Page#fetch
11
11
  class Page
12
12
  undef_method :to_a if RUBY_VERSION < '1.9.0'
13
- attr_reader :pager
13
+ attr_reader :pager, :page
14
14
  # don't create a page instance yourself unless you have to
15
15
  def initialize pager, page; @pager, @page = pager, page; end
16
16
  # return the page instance next to this page
17
- def next_page; @pager.page(@page+1); end
17
+ def next; @pager.page(@page+1); end
18
18
  # return the page instance prev to this page
19
- def prev_page; @pager.page(@page-1); end
19
+ def prev; @pager.page(@page-1); end
20
20
  # if the page numbers and the pagers are equal,
21
21
  # then the pages are equal.
22
22
  def == rhs
@@ -90,6 +90,7 @@ module Ludy
90
90
  # they would be used in find options. e.g.,
91
91
  # RailsPaginator.new Model, :order => 'created_at DESC'
92
92
  # would invoke Model.find :all, :offset => ?, :limit => ?, order => 'created_at DESC'
93
+ # TODO: conditions/options invoker...
93
94
  class RailsPaginator < Paginator
94
95
  attr_reader :model_class
95
96
  def initialize model_class, opts = {}
@@ -100,6 +101,9 @@ module Ludy
100
101
  @model_class.count
101
102
  })
102
103
  end
104
+ # it simply call super(page.to_i), so RailsPaginator also eat string.
105
+ def page page; super page.to_i; end
106
+ alias_method :[], :page
103
107
  end
104
108
  # array paginator would just simply assume your data is an array,
105
109
  # and create pages simply for your_data[offset, per_page]
@@ -0,0 +1,7 @@
1
+
2
+ module Ludy
3
+ # append erb output...
4
+ def self.eout string, binding
5
+ eval('_erbout', binding) << string
6
+ end
7
+ end
@@ -1,12 +1,17 @@
1
1
 
2
+ require 'ludy/tasks/common'
3
+
2
4
  module Kernel
3
5
 
4
6
  # C/C++ header guard generator, you shold provide the final #endif yourself,
5
7
  # and you should provide PROJ name for header guard prefix
6
- def header_guard random_suffix = nil
8
+ def header_guard random_suffix = nil, &block
7
9
  defined = "_#{PROJ.upcase}_#{@dir.upcase}_#{@class.upcase}_#{random_suffix.nil? ? '' : rand.to_s[2..-1]+'_'}"
8
- "#ifndef #{defined}
9
- #define #{defined}"
10
+
11
+ Ludy::eout "#ifndef #{defined}
12
+ #define #{defined}", block.binding
13
+ block.call
14
+ Ludy::eout '#endif', block.binding
10
15
  end
11
16
 
12
17
  end # of ludy
data/lib/ludy/variable.rb CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- require 'ludy/kernel/public_send'
2
+ require 'ludy/kernel/public_send' unless RUBY_VERSION < '1.9.0'
3
3
  require 'ludy/class/undef_all_methods'
4
4
 
5
5
  module Ludy
@@ -18,15 +18,17 @@ class TestPaginator < Test::Unit::TestCase
18
18
  assert_equal([100], pager.page(11).to_a)
19
19
  assert_nil(pager.page(12))
20
20
 
21
- assert_equal(pager[1], pager[2].prev_page)
22
- assert_equal(pager.page(11), pager[10].next_page)
23
- assert_nil(pager[1].prev_page)
24
- assert_nil(pager[10].next_page.next_page)
21
+ assert_equal(pager[1], pager[2].prev)
22
+ assert_equal(pager.page(11), pager[10].next)
23
+ assert_nil(pager[1].prev)
24
+ assert_nil(pager[10].next.next)
25
25
 
26
26
  assert_equal pager[4].data, pager[4].fetch
27
27
  assert_equal(pager[1], pager.pages.first)
28
28
  assert_equal(pager[2], pager.to_a[1])
29
29
  assert_equal(5050, pager.inject(0){|r, i| r += i.inject(&:+) })
30
+
31
+ assert_equal 4, pager[4].page
30
32
  end
31
33
  def test_basic
32
34
  pager = Ludy::Paginator.new(
File without changes
@@ -4,12 +4,22 @@ require 'ludy/variable'
4
4
 
5
5
  class TestVariable < Test::Unit::TestCase
6
6
  include Ludy
7
+ def swap a, b
8
+ a.__obj__, b.__obj__ = b.__obj__, a.__obj__
9
+ end
10
+
11
+ def test_swap
12
+ a, b = var(1), var(2)
13
+ swap a, b
14
+ assert_equal 2, a
15
+ assert_equal 1, b
16
+ end
17
+
7
18
  class Qoo
8
19
  def cool
9
20
  'cool ~~~~'
10
21
  end
11
22
  end
12
-
13
23
  def test_variable
14
24
  x = var Qoo.new
15
25
  y = x
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.2
4
+ version: 0.1.3
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-17 00:00:00 +08:00
12
+ date: 2008-01-23 00:00:00 +08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -21,7 +21,7 @@ dependencies:
21
21
  - !ruby/object:Gem::Version
22
22
  version: "0"
23
23
  version:
24
- description: "== DESCRIPTION: Aims to extend Ruby standard library, providing some useful tools that's not existed in the standard library, especially for functional programming."
24
+ description: "== DESCRIPTION:"
25
25
  email: "strip any number: 18god29fat7029 (at] godfat32 -dooot- 20org"
26
26
  executables:
27
27
  - ludy
@@ -100,6 +100,7 @@ files:
100
100
  - lib/ludy/symbol/to_msg.rb
101
101
  - lib/ludy/symbol/to_proc.rb
102
102
  - lib/ludy/tasks.rb
103
+ - lib/ludy/tasks/common.rb
103
104
  - lib/ludy/tasks/erb_cpp.rb
104
105
  - lib/ludy/tasks/erb_cpp/attr_builder.rb
105
106
  - lib/ludy/tasks/erb_cpp/header_guard.rb
@@ -132,7 +133,6 @@ files:
132
133
  - test/deprecated/ts_ludy.rb
133
134
  - test/deprecated/unzip_and_untranspose.rb
134
135
  - test/example_puzzle.rb
135
- - test/test_all.rb
136
136
  - test/test_array.rb
137
137
  - test/test_class.rb
138
138
  - test/test_defun.rb
@@ -141,6 +141,7 @@ files:
141
141
  - test/test_lazy.rb
142
142
  - test/test_paginator.rb
143
143
  - test/test_proc.rb
144
+ - test/test_require_all.rb
144
145
  - test/test_symbol.rb
145
146
  - test/test_variable.rb
146
147
  - test/test_y_combinator.rb
@@ -173,7 +174,6 @@ signing_key:
173
174
  specification_version: 2
174
175
  summary: Aims to extend Ruby standard library, providing some useful tools that's not existed in the standard library, especially for functional programming.
175
176
  test_files:
176
- - test/test_all.rb
177
177
  - test/test_array.rb
178
178
  - test/test_class.rb
179
179
  - test/test_defun.rb
@@ -182,6 +182,7 @@ test_files:
182
182
  - test/test_lazy.rb
183
183
  - test/test_paginator.rb
184
184
  - test/test_proc.rb
185
+ - test/test_require_all.rb
185
186
  - test/test_symbol.rb
186
187
  - test/test_variable.rb
187
188
  - test/test_y_combinator.rb