Carpark 18
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/Rakefile +52 -0
- data/lib/carpark.rb +30 -0
- data/tests/original_test.rb +28 -0
- data/tests/test_helper.rb +14 -0
- metadata +71 -0
- metadata.gz.sig +2 -0
data.tar.gz.sig
ADDED
Binary file
|
data/Rakefile
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
#
|
2
|
+
# Rakefile
|
3
|
+
# carpark
|
4
|
+
#
|
5
|
+
# Created by Bryce Kerley on 2006-12-31.
|
6
|
+
# Copyright (c) 2006 Bryce Kerley. All rights reserved.
|
7
|
+
#
|
8
|
+
# Subversion info:
|
9
|
+
# $Id: Rakefile 18 2007-02-06 01:41:43Z bkerley $
|
10
|
+
#
|
11
|
+
require 'rake'
|
12
|
+
require 'rake/testtask'
|
13
|
+
require 'rake/gempackagetask'
|
14
|
+
require 'rubygems'
|
15
|
+
|
16
|
+
ID = "$Id: Rakefile 18 2007-02-06 01:41:43Z bkerley $"
|
17
|
+
GEM_VERSION = ID.split[2]
|
18
|
+
|
19
|
+
#this will probably fail in win32
|
20
|
+
HOMEDIR = ENV['HOME']
|
21
|
+
|
22
|
+
Rake::TestTask.new do |t|
|
23
|
+
t.libs << 'test'
|
24
|
+
t.verbose = true
|
25
|
+
t.pattern = 'tests/**/*_test.rb'
|
26
|
+
end
|
27
|
+
|
28
|
+
task :default => :test
|
29
|
+
|
30
|
+
spec = Gem::Specification.new do |s|
|
31
|
+
s.platform = Gem::Platform::RUBY
|
32
|
+
s.summary = "car and cdr array functions"
|
33
|
+
s.name = 'Carpark'
|
34
|
+
s.author = "Bryce Kerley"
|
35
|
+
s.email = "bkerley@brycekerley.net"
|
36
|
+
s.version = GEM_VERSION
|
37
|
+
s.requirements << 'none'
|
38
|
+
s.require_path = 'lib'
|
39
|
+
s.autorequire = 'carpark'
|
40
|
+
s.files = FileList["{lib,tests}/*"].to_a + ["Rakefile"]
|
41
|
+
s.signing_key = ENV['HOME']+'/.rubygems/gem-private_key.pem'
|
42
|
+
s.cert_chain = ['bkerley-public_cert.pem']
|
43
|
+
s.description = <<EOF
|
44
|
+
Carpark provides LISP-inspired variants of car and cdr (cadr, caddar, and so on).
|
45
|
+
It uses method_missing to ensure that no matter what combination you want, it's available.
|
46
|
+
EOF
|
47
|
+
end
|
48
|
+
|
49
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
50
|
+
pkg.need_zip = true
|
51
|
+
pkg.need_tar = true
|
52
|
+
end
|
data/lib/carpark.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
#
|
2
|
+
# carpark.rb
|
3
|
+
# RubyTut
|
4
|
+
#
|
5
|
+
# Created by Bryce Kerley on 2006-11-08.
|
6
|
+
# This code is public domain.
|
7
|
+
#
|
8
|
+
# Subversion info:
|
9
|
+
# $Id: carpark.rb 177 2006-11-13 01:56:06Z bkerley $
|
10
|
+
|
11
|
+
class Array
|
12
|
+
def method_missing(m, *a)
|
13
|
+
s = m.to_s
|
14
|
+
return super.method_missing(m, a) unless s =~ /c[ad]+r/
|
15
|
+
o = s[1..-2]
|
16
|
+
|
17
|
+
return self[0].send("c#{o[0..-2]}r".to_sym) if o[-1..-1]=="a"
|
18
|
+
return self[1..-1].send("c#{o[0..-2]}r".to_sym) if o[-1..-1]=="d"
|
19
|
+
|
20
|
+
return "failed #{o}"
|
21
|
+
end
|
22
|
+
|
23
|
+
def car
|
24
|
+
return self.first
|
25
|
+
end
|
26
|
+
|
27
|
+
def cdr
|
28
|
+
return self[1..-1]
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# test.rb
|
3
|
+
# carpark
|
4
|
+
#
|
5
|
+
# Created by Bryce Kerley on 2006-12-28.
|
6
|
+
# Copyright (c) 2006 Bryce Kerley. All rights reserved.
|
7
|
+
#
|
8
|
+
# Subversion info:
|
9
|
+
# $Id: original_test.rb 1 2007-01-01 19:20:16Z bkerley $
|
10
|
+
require File.join(File.dirname(__FILE__), 'test_helper')
|
11
|
+
|
12
|
+
class CarparkTest < Test::Unit::TestCase
|
13
|
+
def test_car
|
14
|
+
assert_equal [1, 2, 3].car, 1
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_cdr
|
18
|
+
assert_equal [1, 2, 3].cdr, [2, 3]
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_cadr
|
22
|
+
assert_equal [1, 2, 3].cadr, 2
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_cdar
|
26
|
+
assert_equal [[1, 2], 3].cdar, [2]
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
#
|
2
|
+
# test_helper.rb
|
3
|
+
# carpark
|
4
|
+
#
|
5
|
+
# Created by Bryce Kerley on 2006-12-31.
|
6
|
+
# Copyright (c) 2006 Bryce Kerley. All rights reserved.
|
7
|
+
#
|
8
|
+
# Subversion info:
|
9
|
+
# $Id: test_helper.rb 1 2007-01-01 19:20:16Z bkerley $
|
10
|
+
|
11
|
+
$:.unshift File.dirname(__FILE__)
|
12
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
13
|
+
require 'test/unit'
|
14
|
+
require 'lib/carpark.rb'
|
metadata
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.9.0
|
3
|
+
specification_version: 1
|
4
|
+
name: Carpark
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: "18"
|
7
|
+
date: 2007-02-05 00:00:00 -05:00
|
8
|
+
summary: car and cdr array functions
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email: bkerley@brycekerley.net
|
12
|
+
homepage:
|
13
|
+
rubyforge_project:
|
14
|
+
description: Carpark provides LISP-inspired variants of car and cdr (cadr, caddar, and so on). It uses method_missing to ensure that no matter what combination you want, it's available.
|
15
|
+
autorequire: carpark
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: false
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
24
|
+
version:
|
25
|
+
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
28
|
+
- |
|
29
|
+
-----BEGIN CERTIFICATE-----
|
30
|
+
MIIDPDCCAiSgAwIBAgIBADANBgkqhkiG9w0BAQUFADBEMRAwDgYDVQQDDAdia2Vy
|
31
|
+
bGV5MRswGQYKCZImiZPyLGQBGRYLYnJ5Y2VrZXJsZXkxEzARBgoJkiaJk/IsZAEZ
|
32
|
+
FgNuZXQwHhcNMDcwMjAzMjAzNzQ2WhcNMDgwMjAzMjAzNzQ2WjBEMRAwDgYDVQQD
|
33
|
+
DAdia2VybGV5MRswGQYKCZImiZPyLGQBGRYLYnJ5Y2VrZXJsZXkxEzARBgoJkiaJ
|
34
|
+
k/IsZAEZFgNuZXQwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCXCWYY
|
35
|
+
oQUSXonkSEg3bsMSPWwYiibFHvxJVxcnxAR0HtYY3ihOnH6s3+LaC60Qa5dTmVG3
|
36
|
+
MkORtm7LN99TM8k2hM1P1eJhyHdxr8d8Lgww6dNZoY8a89gp6I5zCUhkLNLXcVyV
|
37
|
+
dBhF+m/mQZrqodtS1UQNZ0gaaAfCEBw+ymk7ULNgOuxh0VywwmXa04y73+ZCQN4g
|
38
|
+
9N2mmenmBXvf4ySzPQXGRkznD4+DT8H3WDlX45bKOklsTuPMkirk50x/yuLQpyee
|
39
|
+
X6dMkxVxptjrfTd4AoSMYba2YU+RGCcU4biUoPVmsmXyNLvcLBwQnfAjmkd2ESYq
|
40
|
+
YzMWepwjedNr8hNHAgMBAAGjOTA3MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0G
|
41
|
+
A1UdDgQWBBRImfX5pqtStkvfEEJ/4MyVLy8mTTANBgkqhkiG9w0BAQUFAAOCAQEA
|
42
|
+
gwP2ItVfPM80S6yR+b+rFlMVFVOvm+uZyYDyJUA8EFmbdkbHoSUvUpRBYmWCfglC
|
43
|
+
d+JjumoRplylrau9sK6tbsbfE2Lr7H4A6KO/jQJs0uKBCXGKCXkRvu2b1BTYHeOV
|
44
|
+
sWsZCTQtADRcJRve9yRJayM8YEkqzdwHnzvyPVShV8OzepbxCGkT/o/8++OYVgAH
|
45
|
+
OY5Lj1IDyG55Hb8Iw3gdPzQQATySNG6BFkcUFbWHsEBGIcZjiltEz661msnbaJj6
|
46
|
+
+nino5jISVrYg5xJYSE92FTDGqNzTYedfNF2Cb+aKlY6pioSjk5XNILq+ksqAKJF
|
47
|
+
YEW6Ol4DMyXi5G4pZ297gw==
|
48
|
+
-----END CERTIFICATE-----
|
49
|
+
|
50
|
+
post_install_message:
|
51
|
+
authors:
|
52
|
+
- Bryce Kerley
|
53
|
+
files:
|
54
|
+
- lib/carpark.rb
|
55
|
+
- tests/original_test.rb
|
56
|
+
- tests/test_helper.rb
|
57
|
+
- Rakefile
|
58
|
+
test_files: []
|
59
|
+
|
60
|
+
rdoc_options: []
|
61
|
+
|
62
|
+
extra_rdoc_files: []
|
63
|
+
|
64
|
+
executables: []
|
65
|
+
|
66
|
+
extensions: []
|
67
|
+
|
68
|
+
requirements:
|
69
|
+
- none
|
70
|
+
dependencies: []
|
71
|
+
|
metadata.gz.sig
ADDED