necromancy 0.1.0 → 0.1.1

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/README.rst CHANGED
@@ -41,6 +41,7 @@ their arguments are given into that function each time.
41
41
 
42
42
  Rich extensions.
43
43
  ________________________________________________________________________________
44
+
44
45
  If you want, you can use extensions by clojuring up the evil spirit.
45
46
 
46
47
  .. code:: ruby
@@ -48,13 +49,20 @@ If you want, you can use extensions by clojuring up the evil spirit.
48
49
  M = Necromancy.Alternative.new
49
50
  M.x | M.y == ->(o) { o.x || o.y }
50
51
 
52
+ No core extensions.
53
+ ________________________________________________________________________________
54
+
55
+ Open classes is evil unless that is need really!
56
+ Necromancy isn't. All methods are defining at local modules,
57
+ and you can call their methods by sending some messages to a Necromancy object.
58
+
51
59
  Examples
52
60
  --------------------------------------------------------------------------------
53
61
 
54
62
  Simple Function composion
55
63
  ________________________________________________________________________________
56
64
 
57
- First, your create a `Necromancy` object.
65
+ First, you create a `Necromancy` object.
58
66
  it is immutable, you can save it to any variable you like.
59
67
  for example, that is constant, global varibale, instance variable, class variable, local variable, etc.
60
68
 
@@ -102,7 +110,7 @@ ________________________________________________________________________________
102
110
 
103
111
  .. code:: ruby
104
112
 
105
- N = Necromancy.Alternative.using(:>> => :then).new
113
+ N = Necromancy.Alternative[:>> => :then].new
106
114
  str_or_nil = ["foo", nil].sample
107
115
  str_or_nil.tap &(N.then N.upcase!) # => nil or "FOO"
108
116
 
@@ -119,7 +127,7 @@ ________________________________________________________________________________
119
127
 
120
128
  .. code:: ruby
121
129
 
122
- N = Necromancy.Alternative.(:>>).new
130
+ N = Necromancy.Alternative(:>>).new
123
131
  str_or_nil = ["foo", nil].sample
124
132
  str_or_nil.tap &N >> N.upcase! # => nil or "FOO"
125
133
  (1..5).map &N ** 2 # => [1, 4, 9, 16, 25]
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
data/examples/fizzbuzz.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'necromancy'
2
2
 
3
- L = Necromancy.Alternative.new
4
- puts (1..100).map &(L%15).zero? >> proc{"FizzBuzz"} |
5
- (L%3).zero? >> proc{"Fizz"} |
6
- (L%5).zero? >> proc{"Buzz"} |
7
- L
3
+ N = Necromancy.Alternative.new
4
+ puts (1..100).map &(N%15).zero? >> proc{"FizzBuzz"} |
5
+ (N%3).zero? >> proc{"Fizz"} |
6
+ (N%5).zero? >> proc{"Buzz"} |
7
+ N
@@ -1,8 +1,8 @@
1
1
  require 'necromancy'
2
2
 
3
- L = Necromancy.Alternative.using(:<< => :if,
4
- :>> => :then,
5
- :| => :else).new
6
- puts (1..100).map &( (L%15).zero? .then(proc{"FizzBuzz"}) .else \
7
- (L%3).zero? .then(proc{"Fizz"}) .else \
8
- (L%5).zero? .then(proc{"Buzz"}) .else L )
3
+ N = Necromancy.Alternative[:<< => :if,
4
+ :>> => :then,
5
+ :| => :else].new
6
+ puts (1..100).map &( (N%15).zero? .then(proc{"FizzBuzz"}) .else \
7
+ (N%3).zero? .then(proc{"Fizz"}) .else \
8
+ (N%5).zero? .then(proc{"Buzz"}) .else N )
@@ -1,6 +1,6 @@
1
1
  require 'necromancy'
2
2
 
3
- L = Necromancy.Alternative.hiding(:*, :**).new
3
+ N = Necromancy.Alternative.hiding(:*, :**).new
4
4
 
5
5
  ary = [1, nil, 2, nil, 3]
6
- p ary.map &(L | proc{0}) * 10 # => [10, 0, 20, 0, 3]
6
+ p ary.map &(N | proc{0}) * 10 # => [10, 0, 20, 0, 3]
@@ -15,10 +15,22 @@ module Necromancy
15
15
  private :branch
16
16
 
17
17
  def call(*targets)
18
- branch { protected *instance_methods }.using(*targets)
18
+ warn <<EOF
19
+ Necromancy.Hoge.() deprecated.
20
+ Use Necromancy.Hoge().
21
+ EOF
22
+ branch { protected *instance_methods }[*targets]
19
23
  end
20
24
 
21
25
  def using(*targets)
26
+ warn <<EOF
27
+ Necromancy.Hoge.using() deprecated.
28
+ Use Necromancy.Hoge[].
29
+ EOF
30
+ self[*targets]
31
+ end
32
+
33
+ def [](*targets)
22
34
  names = targets.select { |t| t.is_a? Symbol }
23
35
  aliases = targets.select { |t| t.is_a? Hash }.inject(:merge) || {}
24
36
  branch do
@@ -38,7 +50,13 @@ module Necromancy
38
50
  def method_missing(name, *args, &block)
39
51
  super unless ('A'..'Z').include? name[0]
40
52
  if ::Necromancy::Control.const_defined? name
41
- branch { include ::Necromancy::Control.const_get(name) }
53
+ mod = ::Necromancy::Control.const_get(name)
54
+
55
+ if args.empty?
56
+ branch { include mod }
57
+ else
58
+ branch { include mod; protected *mod.instance_methods }[*args, &block]
59
+ end
42
60
  else
43
61
  super
44
62
  end
@@ -1,4 +1,4 @@
1
1
  module Necromancy
2
2
 
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: necromancy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-06 00:00:00.000000000 Z
12
+ date: 2013-04-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec