imparcial 0.0.5 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/README.txt +26 -20
- data/Rakefile +15 -1
- data/lib/imparcial.rb +1 -1
- metadata +1 -1
data/README.txt
CHANGED
@@ -3,7 +3,7 @@ Imparcial, Database Abstraction Layer
|
|
3
3
|
|
4
4
|
== DESCRIPTION:
|
5
5
|
|
6
|
-
|
6
|
+
Imparcial is a Database Abstraction Layer for Ruby. It's designed not only to
|
7
7
|
be a connection and result-set wrapping, one can also manipulate databases'
|
8
8
|
mechanisms with ruby structures as well as by using SQL syntaxes.
|
9
9
|
Furthermore, Imparcial is primarly intented to be a library for developing
|
@@ -22,47 +22,53 @@ needs an abstraction layer.
|
|
22
22
|
== USAGE:
|
23
23
|
|
24
24
|
* Initializing the adapter:
|
25
|
-
|
25
|
+
|
26
|
+
adapter = Imparcial::Initializer.adapter(:mysql) do |config|
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
config.username = 'batman'
|
29
|
+
config.password = 'joker_suckz'
|
30
|
+
config.database = 'batcave'
|
31
|
+
config.logger = Logger.new(STDERR)
|
31
32
|
|
32
|
-
|
33
|
+
end
|
33
34
|
|
34
|
-
|
35
|
+
adapter.connect
|
35
36
|
|
36
37
|
And that's all. You may also specify :port, :host
|
37
38
|
|
38
39
|
* Getting Tables from a specific database:
|
39
40
|
abstract_adapter
|
40
41
|
|
41
|
-
|
42
|
+
adapter.get_tables # => ['person', 'invoice', 'product', 'supplier']
|
42
43
|
|
43
44
|
* Creating a Table
|
44
|
-
|
45
|
+
|
46
|
+
adapter.create_table :table_name => 'user', :fields => [{:name => :id, :type => :integer},
|
45
47
|
{:name => :name, :type => :string}]
|
46
48
|
|
47
49
|
adapter.table_exists? :table_name => 'user' # => true
|
48
50
|
|
49
51
|
* Inserting Records
|
50
|
-
|
51
|
-
|
52
|
+
|
53
|
+
adapter.insert :table_name => 'user', :values => {:id => 1, :name => 'robin'}
|
54
|
+
adapter.insert :table_name => 'user', :values => {:id => 2, :name => 'penguim'}
|
52
55
|
|
53
56
|
* Deleting Records
|
54
|
-
|
57
|
+
|
58
|
+
adapter.delete :table_name => 'user', :conditions => ['id = ?', 1]
|
55
59
|
|
56
60
|
* Selecting Records
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
61
|
+
|
62
|
+
adapter.select :table_name => 'user'
|
63
|
+
adapter.result.each do |id, name|
|
64
|
+
puts 'displaying info:'
|
65
|
+
puts "#{id.column_name} = #{id.column_value}"
|
66
|
+
puts "#{name.column_name} = "#{name.column_value}"
|
67
|
+
end
|
63
68
|
|
64
69
|
* Dropping a Table
|
65
|
-
|
70
|
+
|
71
|
+
adapter.drop_table :table_name => 'user'
|
66
72
|
|
67
73
|
Make sure to check the API for more features!
|
68
74
|
|
data/Rakefile
CHANGED
@@ -29,6 +29,8 @@ require 'rubygems'
|
|
29
29
|
require 'hoe'
|
30
30
|
$:.unshift(File.dirname(__FILE__) + '/lib')
|
31
31
|
require 'imparcial'
|
32
|
+
require 'rake/rdoctask'
|
33
|
+
|
32
34
|
|
33
35
|
Hoe.new('imparcial', Imparcial::VERSION) do |s|
|
34
36
|
|
@@ -42,10 +44,22 @@ Hoe.new('imparcial', Imparcial::VERSION) do |s|
|
|
42
44
|
s.email = 'antonio@gmail.com'
|
43
45
|
|
44
46
|
s.extra_deps << 'facets' << 'rake' << 'hoe'
|
45
|
-
s.remote_rdoc_dir = ''
|
47
|
+
s.remote_rdoc_dir = 'rdoc'
|
46
48
|
s.changes = s.paragraphs_of('History.txt', 0..1).join("\n\n")
|
47
49
|
|
48
50
|
end
|
51
|
+
|
52
|
+
desc "Generating RDOC"
|
53
|
+
Rake::RDocTask.new(:rdoc) do |r|
|
54
|
+
|
55
|
+
r.title = 'imparcial'
|
56
|
+
files = ['README.txt','lib/**/*.rb']
|
57
|
+
r.rdoc_files.add(files)
|
58
|
+
r.main = 'README.txt'
|
59
|
+
r.options << '--inline-source' << '--line-numbers'
|
60
|
+
r.rdoc_dir = 'doc'
|
61
|
+
|
62
|
+
end
|
49
63
|
|
50
64
|
task :repubdoc => [:release, :publish_docs]
|
51
65
|
|
data/lib/imparcial.rb
CHANGED