csv_record 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +3 -0
- data/README.md +7 -3
- data/csv_record.gemspec +1 -1
- data/lib/csv_record/version.rb +1 -1
- data/lib/csv_record/writer.rb +2 -2
- data/test/csv_record/reader_test.rb +31 -14
- metadata +4 -3
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# CsvRecord
|
2
2
|
|
3
|
+
[![Build Status](https://secure.travis-ci.org/lukasalexandre/csv_record.png)](http://travis-ci.org/lukasalexandre/csv_record) [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/lukasalexandre/csv_record)
|
4
|
+
|
3
5
|
CSV Record connects classes to CSV documents database to establish an almost zero-configuration persistence layer for applications.
|
4
6
|
|
5
7
|
## Installation
|
@@ -25,6 +27,8 @@ $ gem install csv_record
|
|
25
27
|
## Usage
|
26
28
|
|
27
29
|
```ruby
|
30
|
+
requite 'csv_record'
|
31
|
+
|
28
32
|
class Car
|
29
33
|
include CsvRecord::Document
|
30
34
|
end
|
@@ -49,10 +53,10 @@ car.destroy # removes the record from the database
|
|
49
53
|
|
50
54
|
car.new_record? # checks if the record is new
|
51
55
|
|
52
|
-
|
56
|
+
Car.all # retrieves all saved records
|
53
57
|
|
54
|
-
|
55
|
-
|
58
|
+
Car.find car.id # find through its id
|
59
|
+
Car.find car # find through the record
|
56
60
|
|
57
61
|
Car.count # returns the amount of records in the database
|
58
62
|
```
|
data/csv_record.gemspec
CHANGED
@@ -3,7 +3,7 @@ require File.expand_path('../lib/csv_record/version', __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.authors = ["Lukas Alexandre"]
|
6
|
-
gem.email = ["
|
6
|
+
gem.email = ["lukasalexandre@gmail.com"]
|
7
7
|
gem.description = %q{CSV Object-relational mapping}
|
8
8
|
gem.summary = %q{CSV Record connects classes to CSV documents database to establish an almost zero-configuration persistence layer for applications.}
|
9
9
|
gem.homepage = "https://github.com/lukasalexandre/csv_record"
|
data/lib/csv_record/version.rb
CHANGED
data/lib/csv_record/writer.rb
CHANGED
@@ -51,24 +51,41 @@ describe CsvRecord::Reader do
|
|
51
51
|
Car.count.must_equal 2
|
52
52
|
end
|
53
53
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
54
|
+
describe 'simple query' do
|
55
|
+
it 'querying by id' do
|
56
|
+
cars = []
|
57
|
+
3.times do
|
58
|
+
cars << car.clone
|
59
|
+
cars.last.save
|
60
|
+
end
|
61
|
+
Car.find(cars.first.id).wont_be_nil
|
62
|
+
Car.find(cars.first.id).must_be_instance_of Car
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'querying by object' do
|
66
|
+
cars = []
|
67
|
+
3.times do
|
68
|
+
cars << car.clone
|
69
|
+
cars.last.save
|
70
|
+
end
|
71
|
+
Car.find(cars.first).wont_be_nil
|
72
|
+
Car.find(cars.first.id).must_be_instance_of Car
|
59
73
|
end
|
60
|
-
Car.find(cars.first.id).wont_be_nil
|
61
|
-
Car.find(cars.first.id).must_be_instance_of Car
|
62
74
|
end
|
63
75
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
76
|
+
describe 'complex queries' do
|
77
|
+
it 'with params' do
|
78
|
+
car.save
|
79
|
+
second_car.save
|
80
|
+
Car.find(
|
81
|
+
year: 1997,
|
82
|
+
make: 'Ford'
|
83
|
+
)
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'dinamyc finders' do
|
87
|
+
|
69
88
|
end
|
70
|
-
Car.find(cars.first).wont_be_nil
|
71
|
-
Car.find(cars.first.id).must_be_instance_of Car
|
72
89
|
end
|
73
90
|
end
|
74
91
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: csv_record
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-11-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -61,12 +61,13 @@ dependencies:
|
|
61
61
|
version: '0'
|
62
62
|
description: CSV Object-relational mapping
|
63
63
|
email:
|
64
|
-
-
|
64
|
+
- lukasalexandre@gmail.com
|
65
65
|
executables: []
|
66
66
|
extensions: []
|
67
67
|
extra_rdoc_files: []
|
68
68
|
files:
|
69
69
|
- .gitignore
|
70
|
+
- .travis.yml
|
70
71
|
- Gemfile
|
71
72
|
- LICENSE
|
72
73
|
- README.md
|