constantrecord 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.rdoc +3 -3
- data/Rakefile +1 -1
- data/constantrecord.gemspec +2 -2
- data/lib/constantrecord.rb +5 -0
- data/test/constantrecord_test.rb +2 -0
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -76,9 +76,9 @@ When +data+ is a simple Array, #name is the default attribute.
|
|
76
76
|
Currency.count :all >> 5
|
77
77
|
|
78
78
|
|
79
|
-
As a matter of fact, a ConstantRecord will often be used as a select field in
|
80
|
-
HTML form. Therefore it comes with a special feature, that is not
|
81
|
-
compatible. In a Form you can use:
|
79
|
+
As a matter of fact, a ConstantRecord will often be used as a select field in
|
80
|
+
an HTML form. Therefore it comes with a special feature, that is not
|
81
|
+
ActiveRecord compatible. In a Form you can use:
|
82
82
|
|
83
83
|
<%= f.select :currency_id, Currency.options_for_select %>
|
84
84
|
|
data/Rakefile
CHANGED
@@ -3,7 +3,7 @@ require 'rubygems'
|
|
3
3
|
require 'rake'
|
4
4
|
require 'echoe'
|
5
5
|
|
6
|
-
Echoe.new('constantrecord', '0.1.
|
6
|
+
Echoe.new('constantrecord', '0.1.1') do |p|
|
7
7
|
p.description = "A tiny ActiveRecord substitute for small, never changing database tables."
|
8
8
|
p.url = "http://github.com/ChristophPetschnig/constantrecord"
|
9
9
|
p.author = "Christoph Petschnig"
|
data/constantrecord.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{constantrecord}
|
5
|
-
s.version = "0.1.
|
5
|
+
s.version = "0.1.1"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Christoph Petschnig"]
|
9
|
-
s.date = %q{2009-
|
9
|
+
s.date = %q{2009-10-21}
|
10
10
|
s.description = %q{A tiny ActiveRecord substitute for small, never changing database tables.}
|
11
11
|
s.email = %q{info@purevirtual.de}
|
12
12
|
s.extra_rdoc_files = ["lib/constantrecord.rb", "README.rdoc"]
|
data/lib/constantrecord.rb
CHANGED
@@ -108,6 +108,9 @@ module ConstantRecord #:nodoc:
|
|
108
108
|
raise TypeError.new("#{self}.find failed!\nArguments: #{args.inspect}") unless selector.kind_of?(Symbol) || selector.kind_of?(Fixnum)
|
109
109
|
|
110
110
|
if selector == :first
|
111
|
+
# no conditions given, return the first record
|
112
|
+
return self.new(1, *@data[0]) if args.size == 1
|
113
|
+
|
111
114
|
conditions = args[1][:conditions]
|
112
115
|
|
113
116
|
raise TypeError.new("#{self}.find failed!\nArguments: #{args.inspect}") unless conditions.kind_of?(Hash) && conditions.size == 1
|
@@ -129,6 +132,8 @@ module ConstantRecord #:nodoc:
|
|
129
132
|
return nil
|
130
133
|
end
|
131
134
|
|
135
|
+
return self.new(@data.size, *@data[-1]) if selector == :last
|
136
|
+
|
132
137
|
# ignore conditions on :all
|
133
138
|
return find_all if selector == :all
|
134
139
|
|
data/test/constantrecord_test.rb
CHANGED
@@ -41,6 +41,8 @@ class TestConstantRecord < Test::Unit::TestCase
|
|
41
41
|
assert_equal [ 'Lithuania', 'Latvia', 'Estonia' ], SimpleClass.find(:all).collect{|o| o.name}
|
42
42
|
assert_equal [ 1, 2, 3 ], SimpleClass.find(:all).collect{|o| o.id}
|
43
43
|
assert_equal 3, SimpleClass.count
|
44
|
+
assert_equal 'Lithuania', SimpleClass.find(:first).name
|
45
|
+
assert_equal 'Estonia', SimpleClass.find(:last).name
|
44
46
|
end
|
45
47
|
|
46
48
|
def test_simple_finder_with_custom_column_name
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: constantrecord
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christoph Petschnig
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-10-21 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|