christiank-turntable 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- data/turntable.rb +11 -7
- metadata +2 -2
data/turntable.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# turntable v0.5
|
2
|
+
# turntable v0.5.2
|
3
3
|
# Christian Koch <ckoch002@student.ucr.edu>
|
4
4
|
#
|
5
5
|
|
@@ -8,7 +8,7 @@ require 'ostruct'
|
|
8
8
|
|
9
9
|
class Turntable < PStore
|
10
10
|
|
11
|
-
@@version = 'v0.5'
|
11
|
+
@@version = 'v0.5.2'
|
12
12
|
|
13
13
|
# Creates a new Turntable object and corresponding PStore.
|
14
14
|
def initialize file, *columns
|
@@ -20,6 +20,7 @@ class Turntable < PStore
|
|
20
20
|
|
21
21
|
# A quick hack for loading databases
|
22
22
|
@columns = columns[0] if columns.length == 1
|
23
|
+
@columns = [@columns] if @columns.is_a?(Symbol)
|
23
24
|
end
|
24
25
|
|
25
26
|
# Loads an existing database if it exists, complains otherwise.
|
@@ -78,7 +79,8 @@ class Turntable < PStore
|
|
78
79
|
|
79
80
|
return row
|
80
81
|
end
|
81
|
-
|
82
|
+
|
83
|
+
# Custom inspect() makes working in IRB cleaner
|
82
84
|
def inspect; self.to_s; end
|
83
85
|
|
84
86
|
# The select statement. Equivalent to self.all.select() if there's a block,
|
@@ -98,8 +100,7 @@ class Turntable < PStore
|
|
98
100
|
# Prints a plain text representation of the table to STDOUT
|
99
101
|
def to_stdout
|
100
102
|
self.all.each do |row|
|
101
|
-
print
|
102
|
-
print row.id
|
103
|
+
print "|#{row.id}"
|
103
104
|
@columns.each do |column|
|
104
105
|
print '|'
|
105
106
|
print eval("row.#{column}")
|
@@ -135,8 +136,11 @@ class Row < OpenStruct
|
|
135
136
|
|
136
137
|
end
|
137
138
|
|
138
|
-
# Turntable prefers
|
139
|
-
class Array
|
139
|
+
# Turntable prefers some synonyms...
|
140
|
+
class Array
|
141
|
+
alias :contains? :include?
|
142
|
+
alias :order_by :sort_by
|
143
|
+
end
|
140
144
|
|
141
145
|
# Quick hack to shut up Object#id deprecation warnings
|
142
146
|
class Object; undef id; end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: christiank-turntable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christian Koch
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-06-
|
12
|
+
date: 2009-06-09 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|