adacosta-labilerecord 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +5 -1
- data/README.rdoc +10 -9
- data/lib/labilerecord.rb +3 -3
- metadata +1 -1
data/History.txt
CHANGED
data/README.rdoc
CHANGED
@@ -15,19 +15,20 @@
|
|
15
15
|
|
16
16
|
== SYNOPSIS:
|
17
17
|
|
18
|
-
require 'rubygems'
|
19
18
|
require 'labilerecord'
|
20
19
|
|
21
20
|
LabileRecord::Base.connection = {:dbname => 'postgres', :user => user,
|
22
21
|
:pass => pass, :host => host, :port => port}
|
23
22
|
|
24
|
-
|
23
|
+
databases = LabileRecord::Query.new("SELECT * FROM pg_database")
|
25
24
|
# execute the query
|
26
|
-
|
27
|
-
# inspect
|
28
|
-
|
29
|
-
#inspect fields (columns)
|
30
|
-
|
25
|
+
databases.exec!
|
26
|
+
# inspect rows
|
27
|
+
puts databases.rows.inspect
|
28
|
+
# inspect fields (columns)
|
29
|
+
puts databases.fields.inspect
|
30
|
+
# inspect specific row and column of data set
|
31
|
+
puts datases.rows[0].datname
|
31
32
|
|
32
33
|
== REQUIREMENTS:
|
33
34
|
|
@@ -35,8 +36,8 @@
|
|
35
36
|
|
36
37
|
== INSTALL:
|
37
38
|
|
38
|
-
|
39
|
-
|
39
|
+
gem sources -a http://gems.github.com
|
40
|
+
sudo gem install adacosta-labilerecord
|
40
41
|
|
41
42
|
== LICENSE:
|
42
43
|
|
data/lib/labilerecord.rb
CHANGED
@@ -18,7 +18,7 @@ module LabileRecord
|
|
18
18
|
end
|
19
19
|
|
20
20
|
class Query < LabileRecord::Base
|
21
|
-
attr_reader :
|
21
|
+
attr_reader :rows
|
22
22
|
attr_reader :result
|
23
23
|
attr_reader :fields
|
24
24
|
attr_reader :string
|
@@ -27,7 +27,7 @@ module LabileRecord
|
|
27
27
|
@string = query_string
|
28
28
|
end
|
29
29
|
|
30
|
-
def exec
|
30
|
+
def exec!
|
31
31
|
@result = connection.exec(@string)
|
32
32
|
parse_fields
|
33
33
|
parse_result_data
|
@@ -46,7 +46,7 @@ module LabileRecord
|
|
46
46
|
end
|
47
47
|
rows << row
|
48
48
|
end
|
49
|
-
@
|
49
|
+
@rows = rows
|
50
50
|
end
|
51
51
|
|
52
52
|
def parse_fields
|