mdb 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Mdb
2
2
 
3
- TODO: Write a gem description
3
+ Wraps [mdb-tools](https://github.com/brianb/mdbtools) for reading Microsoft Access databases
4
4
 
5
5
  ## Installation
6
6
 
@@ -18,7 +18,15 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- TODO: Write usage instructions here
21
+ ```ruby
22
+ database = Mdb.open(PATH_TO_FILE)
23
+
24
+ # list tables in the database
25
+ database.tables
26
+
27
+ # read the records in a table
28
+ database[:Movies]
29
+ ```
22
30
 
23
31
  ## Contributing
24
32
 
@@ -1,3 +1,5 @@
1
+ require 'tempfile'
2
+
1
3
  module Mdb
2
4
  class Database
3
5
 
@@ -32,7 +34,7 @@ module Mdb
32
34
 
33
35
  def read_csv(table)
34
36
  csv = execute "mdb-export -d \\| #{file_name} #{table}"
35
- if csv.blank?
37
+ if csv.empty?
36
38
  raise TableDoesNotExistError, "#{table.inspect} does not exist in #{file_name.inspect}" if !tables.member?(table.to_s)
37
39
  raise Error, "An error occurred when reading #{table.inspect} in #{file_name.inspect}"
38
40
  end
@@ -91,9 +93,12 @@ module Mdb
91
93
 
92
94
 
93
95
  def read_each(table, &block)
96
+ count = 0
94
97
  read_csv(table).each_line do |line|
95
98
  yield line.chomp
99
+ count += 1
96
100
  end
101
+ count # don't return the result of read_csv; discard it
97
102
  end
98
103
 
99
104
 
@@ -117,7 +122,7 @@ module Mdb
117
122
  stdout = `#{command} 2> #{t.path}`
118
123
  t.rewind
119
124
  stderr = t.read.strip
120
- break if stderr.blank?
125
+ break if stderr.empty?
121
126
 
122
127
  # Rails.logger.error("[mdb-tools] executed `#{command}`; got \"#{stderr}\"")
123
128
  end
@@ -1,3 +1,3 @@
1
1
  module Mdb
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
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: 2013-05-07 00:00:00.000000000 Z
12
+ date: 2013-05-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -127,7 +127,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
127
127
  version: '0'
128
128
  segments:
129
129
  - 0
130
- hash: 827409863156524609
130
+ hash: 3387175660756308767
131
131
  required_rubygems_version: !ruby/object:Gem::Requirement
132
132
  none: false
133
133
  requirements:
@@ -136,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
136
  version: '0'
137
137
  segments:
138
138
  - 0
139
- hash: 827409863156524609
139
+ hash: 3387175660756308767
140
140
  requirements: []
141
141
  rubyforge_project:
142
142
  rubygems_version: 1.8.25