slacker 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module Slacker
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
@@ -1,65 +1,73 @@
1
- # describe opens up an example group
1
+ # Method describe opens up an example group.
2
2
  describe 'My database' do
3
- # Simple example which demonstrates inline query against the database
3
+ # Simple example which demonstrates inline query against the database.
4
4
  it 'contains system tables' do
5
- # Select all system objects in the database
6
- # Whe should have at least one of those
5
+ # Select all system objects in the database.
6
+ # We should have at least one of those.
7
7
  query_result = query("select * from sysobjects where xtype = 'S';")
8
8
  query_result.count.should > 0
9
9
  end
10
10
 
11
- # The same query, this time using a SQL template
11
+ # The same query, this time using a SQL template.
12
12
  # See file sql/sample_1/sysobject.sql.erb
13
13
  it 'contains system tables (take two)' do
14
- # Every sub-folder of the sql folder appears as an sql object
15
- # and every *.sql.erb file within sql or an sql subfolder appears as a method of this object
16
- # At the root of all sql objects is the sql folder accessible through the "sql" object
14
+ # SQL templates are located in the sql folder and are accessible through the "sql" object (see below).
15
+ # Each sub-folder of the sql folder appears as a sql object contained within its parent startint at the root - the "sql" object.
16
+ # Each template file (*.sql.erb) appears as a method of the folder it appears in.
17
+ #
18
+ # For example, the file sysobjects.sql.erb is located in "sql/sample_1/",
19
+ # so it is accessible like this:
20
+ # sql.sample_1.sysobjects
21
+
17
22
  query_result = sql.sample_1.sysobjects
18
23
  query_result.count.should > 0
19
24
  end
20
25
 
21
- # This time we'll use a parameterized template
26
+ # This time we'll use a parameterized template.
22
27
  # See file sql/sample_1/sysobject_with_params.sql.erb
23
28
  it 'contains system tables (take three)' do
24
- # Every file with extension .sql.erb located in the sql folder, becomes a method of object sql
29
+ # You can pass a hash to any SQL template - this hash becomes available to the
30
+ # template through the "options" object - see file sql/sample_1/sysobject_with_params.sql.erb as an example.
25
31
  query_result = sql.sample_1.sysobjects_with_params(:xtype => 'S')
26
32
  query_result.count.should > 0
27
33
  end
28
34
 
29
- # Let's create a table and count our user objects which match this table name
30
- # We should get one
35
+ # Let's create a table and count our user objects which match this table name.
36
+ # Every "it" (example) is executed in a transaction which is rolled back once the example is complete.
37
+ # This ensures that every example starts at the same state of the database as any other example in the spec.
38
+ # No example can ever interfere witht the results of another example.
31
39
  it 'contains a user table when one is created' do
32
40
  # Use inline query to create the table
33
41
  query('create table MyTable(id int, name varchar(100));')
34
42
 
35
- # Now lookup the table by type and name using a more elaborate dynamic SQL template
43
+ # Now lookup the table by type and name using a more elaborate dynamic SQL template.
36
44
  # See template sql/sample_1/sysobject_with_params_2.sql.erb
37
45
  query_result = sql.sample_1.sysobjects_with_params_2(:xtype => 'U', :name => 'MyTable')
38
46
  query_result.count.should == 1
39
47
  end
40
48
 
41
- # SQL Templates can contain multiple statements and can return multiple resultsets
49
+ # SQL Templates can contain multiple statements and can return multiple resultsets.
42
50
  it 'can play with numbers' do
43
- # Note that we're calling the template with a block
44
- # When called with a block, a template is executed and its result is accessible
45
- # from within the block through the "results" object
51
+ # Note that this time we're calling the template with a block.
52
+ # When called with a block, a template is executed and its results are accessible
53
+ # from within the block through the "results" object.
46
54
  sql.sample_1.play_with_numbers(:x => 2, :y => 12) do
47
- # The results object contains an array of all the resultsets generated by the query script
55
+ # The results object contains an array of all the resultsets generated by the query script.
48
56
  first_resultset = results[0]
49
57
 
50
- # A resultset contains an array of records
51
- # Each record is a hash of field => value pairs
58
+ # A resultset contains an array of records.
59
+ # Each record is a hash of field => value pairs.
52
60
  first_resultset[0][:product].should == 24
53
61
 
54
- # A resultset can be matched directly against an array of hashes
62
+ # A resultset can be matched directly against an array of hashes using the "match" method.
55
63
  second_resultset = results[1]
56
64
  second_resultset.should match([{:x => 2, :y => 12, :sum => 14}])
57
65
 
58
- # Of course this works too
66
+ # Of course this works too:
59
67
  results[1].should match([{:x => 2, :y => 12, :sum => 14}])
60
68
 
61
- # Or a resultset's values can be matched one-by-one
62
- # Note that this resultset contains two records
69
+ # Or a resultset's values can be matched one-by-one.
70
+ # Note that the third resultset contains two records:
63
71
  third_resultset = results[2]
64
72
  third_resultset[0][:p].should == 2
65
73
  third_resultset[0][:s].should == 34
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: slacker
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.7
5
+ version: 0.0.8
6
6
  platform: ruby
7
7
  authors:
8
8
  - Vassil Kovatchev
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-06-23 00:00:00 Z
13
+ date: 2011-06-24 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler