sequel 1.4.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +56 -0
- data/README +257 -154
- data/Rakefile +8 -16
- data/lib/sequel_model.rb +15 -257
- data/lib/sequel_model/associations.rb +70 -33
- data/lib/sequel_model/base.rb +80 -35
- data/lib/sequel_model/caching.rb +3 -3
- data/lib/sequel_model/deprecated.rb +81 -0
- data/lib/sequel_model/eager_loading.rb +303 -43
- data/lib/sequel_model/hooks.rb +29 -25
- data/lib/sequel_model/inflections.rb +112 -0
- data/lib/sequel_model/inflector.rb +279 -0
- data/lib/sequel_model/plugins.rb +15 -14
- data/lib/sequel_model/record.rb +87 -75
- data/lib/sequel_model/schema.rb +2 -0
- data/lib/sequel_model/validations.rb +300 -2
- data/spec/associations_spec.rb +175 -9
- data/spec/base_spec.rb +37 -18
- data/spec/caching_spec.rb +7 -4
- data/spec/deprecated_relations_spec.rb +3 -43
- data/spec/eager_loading_spec.rb +295 -7
- data/spec/hooks_spec.rb +7 -4
- data/spec/inflector_spec.rb +34 -0
- data/spec/model_spec.rb +30 -53
- data/spec/record_spec.rb +191 -33
- data/spec/spec_helper.rb +17 -2
- data/spec/validations_spec.rb +414 -15
- metadata +7 -22
- data/lib/sequel_model/pretty_table.rb +0 -73
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
|
|
3
3
|
specification_version: 1
|
4
4
|
name: sequel
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.
|
7
|
-
date: 2008-04-
|
6
|
+
version: 1.5.0
|
7
|
+
date: 2008-04-29 00:00:00 -07:00
|
8
8
|
summary: "The Database Toolkit for Ruby: Model Classes"
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -32,7 +32,6 @@ files:
|
|
32
32
|
- COPYING
|
33
33
|
- README
|
34
34
|
- Rakefile
|
35
|
-
- doc/rdoc
|
36
35
|
- spec/associations_spec.rb
|
37
36
|
- spec/base_spec.rb
|
38
37
|
- spec/caching_spec.rb
|
@@ -47,6 +46,7 @@ files:
|
|
47
46
|
- spec/spec.opts
|
48
47
|
- spec/spec_helper.rb
|
49
48
|
- spec/validations_spec.rb
|
49
|
+
- spec/inflector_spec.rb
|
50
50
|
- lib/sequel.rb
|
51
51
|
- lib/sequel_model.rb
|
52
52
|
- lib/sequel_model
|
@@ -56,27 +56,21 @@ files:
|
|
56
56
|
- lib/sequel_model/eager_loading.rb
|
57
57
|
- lib/sequel_model/hooks.rb
|
58
58
|
- lib/sequel_model/plugins.rb
|
59
|
-
- lib/sequel_model/pretty_table.rb
|
60
59
|
- lib/sequel_model/record.rb
|
61
60
|
- lib/sequel_model/schema.rb
|
62
61
|
- lib/sequel_model/validations.rb
|
62
|
+
- lib/sequel_model/deprecated.rb
|
63
|
+
- lib/sequel_model/inflections.rb
|
64
|
+
- lib/sequel_model/inflector.rb
|
63
65
|
- CHANGELOG
|
64
66
|
test_files: []
|
65
67
|
|
66
68
|
rdoc_options:
|
67
69
|
- --quiet
|
68
|
-
- --title
|
69
|
-
- "Sequel: The Database Toolkit for Ruby"
|
70
|
-
- --opname
|
71
|
-
- index.html
|
72
70
|
- --line-numbers
|
73
|
-
- --main
|
74
|
-
- README
|
75
71
|
- --inline-source
|
76
72
|
- --exclude
|
77
73
|
- ^(examples|extras)/
|
78
|
-
- --exclude
|
79
|
-
- lib/sequel_model.rb
|
80
74
|
extra_rdoc_files:
|
81
75
|
- README
|
82
76
|
- CHANGELOG
|
@@ -88,15 +82,6 @@ extensions: []
|
|
88
82
|
requirements: []
|
89
83
|
|
90
84
|
dependencies:
|
91
|
-
- !ruby/object:Gem::Dependency
|
92
|
-
name: assistance
|
93
|
-
version_requirement:
|
94
|
-
version_requirements: !ruby/object:Gem::Version::Requirement
|
95
|
-
requirements:
|
96
|
-
- - ">="
|
97
|
-
- !ruby/object:Gem::Version
|
98
|
-
version: 0.1.2
|
99
|
-
version:
|
100
85
|
- !ruby/object:Gem::Dependency
|
101
86
|
name: sequel_core
|
102
87
|
version_requirement:
|
@@ -104,5 +89,5 @@ dependencies:
|
|
104
89
|
requirements:
|
105
90
|
- - "="
|
106
91
|
- !ruby/object:Gem::Version
|
107
|
-
version: 1.
|
92
|
+
version: 1.5.0
|
108
93
|
version:
|
@@ -1,73 +0,0 @@
|
|
1
|
-
module Sequel
|
2
|
-
# Prints nice-looking plain-text tables
|
3
|
-
# +--+-------+
|
4
|
-
# |id|name |
|
5
|
-
# |--+-------|
|
6
|
-
# |1 |fasdfas|
|
7
|
-
# |2 |test |
|
8
|
-
# +--+-------+
|
9
|
-
module PrettyTable
|
10
|
-
def self.records_columns(records)
|
11
|
-
columns = []
|
12
|
-
records.each do |r|
|
13
|
-
if Array === r && (k = r.keys)
|
14
|
-
return k
|
15
|
-
elsif Hash === r
|
16
|
-
r.keys.each {|k| columns << k unless columns.include?(k)}
|
17
|
-
end
|
18
|
-
end
|
19
|
-
columns
|
20
|
-
end
|
21
|
-
|
22
|
-
def self.column_sizes(records, columns)
|
23
|
-
sizes = Hash.new {0}
|
24
|
-
columns.each do |c|
|
25
|
-
s = c.to_s.size
|
26
|
-
sizes[c.to_sym] = s if s > sizes[c.to_sym]
|
27
|
-
end
|
28
|
-
records.each do |r|
|
29
|
-
columns.each do |c|
|
30
|
-
s = r[c].to_s.size
|
31
|
-
sizes[c.to_sym] = s if s > sizes[c.to_sym]
|
32
|
-
end
|
33
|
-
end
|
34
|
-
sizes
|
35
|
-
end
|
36
|
-
|
37
|
-
def self.separator_line(columns, sizes)
|
38
|
-
l = ''
|
39
|
-
'+' + columns.map {|c| '-' * sizes[c]}.join('+') + '+'
|
40
|
-
end
|
41
|
-
|
42
|
-
def self.format_cell(size, v)
|
43
|
-
case v
|
44
|
-
when Bignum, Fixnum
|
45
|
-
"%#{size}d" % v
|
46
|
-
when Float
|
47
|
-
"%#{size}g" % v
|
48
|
-
else
|
49
|
-
"%-#{size}s" % v.to_s
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def self.data_line(columns, sizes, record)
|
54
|
-
'|' + columns.map {|c| format_cell(sizes[c], record[c])}.join('|') + '|'
|
55
|
-
end
|
56
|
-
|
57
|
-
def self.header_line(columns, sizes)
|
58
|
-
'|' + columns.map {|c| "%-#{sizes[c]}s" % c.to_s}.join('|') + '|'
|
59
|
-
end
|
60
|
-
|
61
|
-
def self.print(records, columns = nil) # records is an array of hashes
|
62
|
-
columns ||= records_columns(records)
|
63
|
-
sizes = column_sizes(records, columns)
|
64
|
-
|
65
|
-
puts separator_line(columns, sizes)
|
66
|
-
puts header_line(columns, sizes)
|
67
|
-
puts separator_line(columns, sizes)
|
68
|
-
records.each {|r| puts data_line(columns, sizes, r)}
|
69
|
-
puts separator_line(columns, sizes)
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|