loady 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +7 -7
- data/lib/loady.rb +7 -0
- data/lib/loady/version.rb +1 -1
- data/loady.gemspec +1 -1
- data/test/test_csv_loader.rb +2 -2
- data/test/test_helper.rb +0 -1
- metadata +3 -3
data/README.rdoc
CHANGED
@@ -2,40 +2,40 @@
|
|
2
2
|
|
3
3
|
Loady is a simple file reader and logger. Use it to quickly load a csv file, continue on error rows, and do basic logging.
|
4
4
|
|
5
|
-
|
5
|
+
It works with ruby 1.9.
|
6
6
|
|
7
7
|
== Install
|
8
8
|
|
9
9
|
gem install loady
|
10
10
|
|
11
|
-
Use
|
11
|
+
Use bundler. Include the gem in your Gemfile:
|
12
12
|
|
13
13
|
gem 'loady'
|
14
14
|
|
15
15
|
== Use
|
16
16
|
|
17
|
-
If
|
17
|
+
If an error occurs, Loady will continue reading the file, ignoring problems rows and logging a warning for each.
|
18
18
|
|
19
19
|
By default, messages are logged to the standard output.
|
20
20
|
|
21
21
|
Basic usage:
|
22
22
|
|
23
|
-
Loady
|
23
|
+
Loady.csv "/your/file.csv" do |row|
|
24
24
|
# your code to process each row goes here
|
25
25
|
puts "#{row[0]}, #{row[1]}, etc."
|
26
26
|
end
|
27
27
|
|
28
|
-
Skip first row and log to a file:
|
28
|
+
Skip the first row and log to a file:
|
29
29
|
|
30
30
|
logger = Logger.new "/your/file.log"
|
31
31
|
|
32
|
-
Loady
|
32
|
+
Loady.csv "/your/file.csv", :logger => logger, :skip_first_row => true do |row|
|
33
33
|
# do some stuff for each row
|
34
34
|
end
|
35
35
|
|
36
36
|
Name your attributes:
|
37
37
|
|
38
|
-
Loady
|
38
|
+
Loady.csv "/your/file.csv" do |row|
|
39
39
|
Monkey.create row.to_attributes [:name, :year, :mom]
|
40
40
|
end
|
41
41
|
|
data/lib/loady.rb
CHANGED
data/lib/loady/version.rb
CHANGED
data/loady.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.platform = Gem::Platform::RUBY
|
9
9
|
s.authors = ["Tee Parham"]
|
10
10
|
s.email = ["tee@stackpilot.com"]
|
11
|
-
s.homepage = ""
|
11
|
+
s.homepage = "http://github.com/stackpilot/loady"
|
12
12
|
s.summary = %q{CSV file loader with simple logging}
|
13
13
|
s.description = %q{CSV file loader with simple logging}
|
14
14
|
|
data/test/test_csv_loader.rb
CHANGED
@@ -22,7 +22,7 @@ class CsvLoaderTest < Test::Unit::TestCase
|
|
22
22
|
logger = Logger.new("/dev/null")
|
23
23
|
monkeys = []
|
24
24
|
|
25
|
-
Loady
|
25
|
+
Loady.csv "test/csv/file2.csv", :logger => logger do |row|
|
26
26
|
monkeys << row.to_attributes([:name, :year])
|
27
27
|
end
|
28
28
|
|
@@ -32,7 +32,7 @@ class CsvLoaderTest < Test::Unit::TestCase
|
|
32
32
|
assert_equal monkeys[9][:name], "King Kong", "last row name"
|
33
33
|
assert_equal monkeys[9][:year], "1933", "last row year"
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
end
|
37
37
|
|
38
38
|
end
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: loady
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Tee Parham
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-04-
|
13
|
+
date: 2011-04-18 00:00:00 -06:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -61,7 +61,7 @@ files:
|
|
61
61
|
- test/test_helper.rb
|
62
62
|
- test/test_loady.rb
|
63
63
|
has_rdoc: true
|
64
|
-
homepage:
|
64
|
+
homepage: http://github.com/stackpilot/loady
|
65
65
|
licenses: []
|
66
66
|
|
67
67
|
post_install_message:
|