lab419_core 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,10 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2012 Robert Dober
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10
+
data/README.md ADDED
@@ -0,0 +1,9 @@
1
+ # Lab419, Programmers' Best Friend
2
+
3
+ ## Core
4
+
5
+ This is pushed to rubygems for dependency reasons.
6
+
7
+ No stable API can be assumed.
8
+
9
+
@@ -0,0 +1,5 @@
1
+ class Array
2
+ def flatten_once
3
+ inject([]){ |a,e| [*a] + [*e] }
4
+ end
5
+ end # class Array
@@ -0,0 +1,20 @@
1
+ require 'lab419/core/array/flatten_once'
2
+ class Hash
3
+ def hmap &blk
4
+ Hash[ *map(&blk).flatten_once ]
5
+ end
6
+
7
+ def only *keys
8
+ keys.inject Hash.new do | h, k |
9
+ has_key?( k ) ? h.merge( k => self[k] ) : h
10
+ end
11
+ end
12
+
13
+ def without *keys
14
+ dup.tap do | h |
15
+ keys.each do | k |
16
+ h.delete k
17
+ end
18
+ end
19
+ end
20
+ end # class Hash
@@ -0,0 +1,4 @@
1
+ class Integer
2
+ alias_method :inc, :succ
3
+ alias_method :dec, :pred
4
+ end # class Integer
@@ -0,0 +1,36 @@
1
+ class Integer
2
+ class << self
3
+ def pred
4
+ lambda{ |a| a.pred }
5
+ end
6
+ def succ
7
+ lambda{ |a| a.succ }
8
+ end
9
+ def sum
10
+ -> *args do
11
+ args.reduce{ |a,b| a + b }
12
+ end
13
+ end
14
+ def diff
15
+ -> a, b do
16
+ a - b
17
+ end
18
+ end
19
+ def prod
20
+ -> *args do
21
+ args.reduce{ |a,b| a * b }
22
+ end
23
+ end
24
+ def div
25
+ -> a, b do
26
+ a / b
27
+ end
28
+ end
29
+ def mod
30
+ -> a, b do
31
+ a % b
32
+ end
33
+ end
34
+ end # class << self
35
+ end # class Proc
36
+
@@ -0,0 +1,2 @@
1
+ require 'lab419/core/integer/instance_methods'
2
+ require 'lab419/core/integer/operators'
@@ -0,0 +1,25 @@
1
+ module Kernel
2
+
3
+ def applyto *args
4
+ msg_or_lambda = args.shift
5
+ case msg_or_lambda
6
+ when String, Symbol
7
+ -> *a do
8
+ send( msg_or_lambda, *(args + a) )
9
+ end
10
+ when Proc
11
+ -> *a do
12
+ msg_or_lambda.( *(args + a) )
13
+ end
14
+ else
15
+ raise ArgumentError, "need a message (str or sym) or a lambda to be applied to"
16
+ end
17
+ end
18
+
19
+ def sendmsg *args, &blk
20
+ -> receiver do
21
+ receiver.send( *args, &blk )
22
+ end
23
+ end
24
+ end # module Kernel
25
+
@@ -0,0 +1,3 @@
1
+ class Object
2
+ def identity; self end
3
+ end # class Object
@@ -0,0 +1,7 @@
1
+ class Proc
2
+ class << self
3
+ def identity
4
+ new{ |x| x }
5
+ end
6
+ end # class << self
7
+ end # class Proc
@@ -0,0 +1,5 @@
1
+ module Lab419
2
+ module Core
3
+ VERSION = "0.0.1"
4
+ end # module Core
5
+ end # module Lab419
metadata ADDED
@@ -0,0 +1,112 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lab419_core
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Robert Dober
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-04-09 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: ruby-debug19
16
+ requirement: &83956320 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '0.11'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *83956320
25
+ - !ruby/object:Gem::Dependency
26
+ name: rake
27
+ requirement: &83956020 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 0.9.2.2
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *83956020
36
+ - !ruby/object:Gem::Dependency
37
+ name: rspec
38
+ requirement: &83955730 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 2.9.0
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *83955730
47
+ - !ruby/object:Gem::Dependency
48
+ name: maruku
49
+ requirement: &83955380 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 0.6.0
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *83955380
58
+ - !ruby/object:Gem::Dependency
59
+ name: wirble
60
+ requirement: &83955000 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ~>
64
+ - !ruby/object:Gem::Version
65
+ version: 0.1.3
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *83955000
69
+ description: Coming Soon
70
+ email: robert.dober@gmail.com
71
+ executables: []
72
+ extensions: []
73
+ extra_rdoc_files: []
74
+ files:
75
+ - lib/lab419/core/object.rb
76
+ - lib/lab419/core/array/flatten_once.rb
77
+ - lib/lab419/core/integer/operators.rb
78
+ - lib/lab419/core/integer/instance_methods.rb
79
+ - lib/lab419/core/kernel.rb
80
+ - lib/lab419/core/proc.rb
81
+ - lib/lab419/core/hash.rb
82
+ - lib/lab419/core/version.rb
83
+ - lib/lab419/core/integer.rb
84
+ - LICENSE
85
+ - README.md
86
+ homepage: https://github.com/RobertDober/lab419
87
+ licenses:
88
+ - MIT
89
+ post_install_message:
90
+ rdoc_options: []
91
+ require_paths:
92
+ - lib
93
+ required_ruby_version: !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: 1.9.2
99
+ required_rubygems_version: !ruby/object:Gem::Requirement
100
+ none: false
101
+ requirements:
102
+ - - ! '>='
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirements: []
106
+ rubyforge_project:
107
+ rubygems_version: 1.8.11
108
+ signing_key:
109
+ specification_version: 3
110
+ summary: Making Ruby's Core more powerfull and convinient
111
+ test_files: []
112
+ has_rdoc: