theman 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +7 -7
- data/VERSION +1 -1
- data/lib/theman/themans_agency.rb +1 -1
- data/spec/theman_spec.rb +10 -10
- data/theman.gemspec +2 -2
- metadata +3 -3
data/README.rdoc
CHANGED
@@ -14,23 +14,23 @@ Or
|
|
14
14
|
|
15
15
|
== Basic Usage
|
16
16
|
|
17
|
-
|
18
|
-
temp_model =
|
17
|
+
my_agent = ::Theman::Agency.new 'pretty.csv'
|
18
|
+
temp_model = my_agent.instance
|
19
19
|
temp_model.count
|
20
20
|
|
21
21
|
== Advanced Usage
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
my_agent = ::Theman::Agency.new 'ugly.csv' do |agent|
|
24
|
+
agent.nulls /"N"/, /"UNKNOWN"/, /""/
|
25
|
+
agent.seds "-n -e :a -e '1,15!{P;N;D;};N;ba'"
|
26
|
+
agent.table do |t|
|
27
27
|
t.date :date
|
28
28
|
t.integer :ext_id
|
29
29
|
t.float :amount
|
30
30
|
t.boolean :exited
|
31
31
|
end
|
32
32
|
end
|
33
|
-
temp_model =
|
33
|
+
temp_model = my_agent.instance
|
34
34
|
temp_model.where(:exited => true).count
|
35
35
|
|
36
36
|
In the above example we ommitted the last 15 rows and made some things null.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2
|
@@ -75,7 +75,7 @@ module Theman
|
|
75
75
|
instance.connection.create_table(instance.table_name, :temporary => true, :id => false) do |t|
|
76
76
|
f.each_line do |line|
|
77
77
|
line.split(/,/).each do |col|
|
78
|
-
column_name =
|
78
|
+
column_name = symbolize(col)
|
79
79
|
if custom = @column_names.fetch(column_name, nil)
|
80
80
|
t.column(*custom)
|
81
81
|
else
|
data/spec/theman_spec.rb
CHANGED
@@ -31,8 +31,8 @@ end
|
|
31
31
|
describe Theman::Agency, "basic" do
|
32
32
|
before do
|
33
33
|
@csv = File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec', 'fixtures', 'temp_one.csv'))
|
34
|
-
@
|
35
|
-
@instance = @
|
34
|
+
@agent = ::Theman::Agency.new @csv
|
35
|
+
@instance = @agent.instance
|
36
36
|
end
|
37
37
|
|
38
38
|
it "should have all the records from the csv" do
|
@@ -43,10 +43,10 @@ end
|
|
43
43
|
describe Theman::Agency, "sed chomp" do
|
44
44
|
before do
|
45
45
|
@csv = File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec', 'fixtures', 'temp_two.csv'))
|
46
|
-
@
|
47
|
-
|
46
|
+
@agent = ::Theman::Agency.new @csv do |agent|
|
47
|
+
agent.seds "-n -e :a -e '1,15!{P;N;D;};N;ba'"
|
48
48
|
end
|
49
|
-
@instance = @
|
49
|
+
@instance = @agent.instance
|
50
50
|
end
|
51
51
|
|
52
52
|
it "should have all the records from the csv" do
|
@@ -57,15 +57,15 @@ end
|
|
57
57
|
describe Theman::Agency, "data types" do
|
58
58
|
before do
|
59
59
|
@csv = File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec', 'fixtures', 'temp_one.csv'))
|
60
|
-
@
|
61
|
-
|
62
|
-
|
60
|
+
@agent = ::Theman::Agency.new @csv do |agent|
|
61
|
+
agent.nulls /"N"/, /"UNKNOWN"/, /""/
|
62
|
+
agent.table do |t|
|
63
63
|
t.date :col_date
|
64
64
|
t.boolean :col_four
|
65
65
|
t.float :col_five
|
66
66
|
end
|
67
67
|
end
|
68
|
-
@instance = @
|
68
|
+
@instance = @agent.instance
|
69
69
|
end
|
70
70
|
|
71
71
|
it "should create date col" do
|
@@ -81,7 +81,7 @@ describe Theman::Agency, "data types" do
|
|
81
81
|
end
|
82
82
|
|
83
83
|
it "should have an array of nulls" do
|
84
|
-
@
|
84
|
+
@agent.null_replacements.should == [/"N"/, /"UNKNOWN"/, /""/]
|
85
85
|
end
|
86
86
|
|
87
87
|
it "should have nulls not strings" do
|
data/theman.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{theman}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Rufus Post"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-10-26}
|
13
13
|
s.description = %q{longer description of your gem}
|
14
14
|
s.email = %q{rufuspost@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 2
|
9
|
+
version: 0.0.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Rufus Post
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-10-26 00:00:00 +11:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|