taps 0.2.7 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +1 -1
- data/lib/taps/client_session.rb +26 -10
- data/lib/taps/progress_bar.rb +1 -1
- data/lib/taps/schema.rb +3 -1
- data/spec/client_session_spec.rb +3 -3
- data/spec/schema_spec.rb +1 -0
- metadata +5 -5
data/VERSION.yml
CHANGED
data/lib/taps/client_session.rb
CHANGED
@@ -74,27 +74,32 @@ class ClientSession
|
|
74
74
|
end
|
75
75
|
|
76
76
|
def cmd_send_indexes
|
77
|
-
puts "Sending
|
77
|
+
puts "Sending indexes"
|
78
78
|
|
79
79
|
index_data = `#{File.dirname(__FILE__)}/../../bin/schema indexes #{database_url}`
|
80
80
|
session_resource['indexes'].post(index_data, :taps_version => Taps.version)
|
81
81
|
end
|
82
82
|
|
83
83
|
def cmd_send_schema
|
84
|
-
puts "Sending schema
|
84
|
+
puts "Sending schema"
|
85
85
|
|
86
86
|
schema_data = `#{File.dirname(__FILE__)}/../../bin/schema dump #{database_url}`
|
87
87
|
session_resource['schema'].post(schema_data, :taps_version => Taps.version)
|
88
88
|
end
|
89
89
|
|
90
90
|
def cmd_send_reset_sequences
|
91
|
-
puts "Resetting
|
91
|
+
puts "Resetting sequences"
|
92
92
|
|
93
93
|
session_resource["reset_sequences"].post('', :taps_version => Taps.version)
|
94
94
|
end
|
95
95
|
|
96
96
|
def cmd_send_data
|
97
|
-
puts "Sending
|
97
|
+
puts "Sending data"
|
98
|
+
|
99
|
+
tables_with_counts, record_count = fetch_tables_info
|
100
|
+
|
101
|
+
puts "#{tables_with_counts.size} tables, #{format_number(record_count)} records"
|
102
|
+
|
98
103
|
|
99
104
|
db.tables.each do |table_name|
|
100
105
|
table = db[table_name]
|
@@ -135,6 +140,17 @@ class ClientSession
|
|
135
140
|
end
|
136
141
|
end
|
137
142
|
|
143
|
+
def fetch_tables_info
|
144
|
+
record_count = 0
|
145
|
+
tables = db.tables
|
146
|
+
tables_with_counts = tables.inject({}) do |accum, table|
|
147
|
+
accum[table] = db[table].count
|
148
|
+
record_count += accum[table]
|
149
|
+
end
|
150
|
+
|
151
|
+
[ tables_with_counts, record_count ]
|
152
|
+
end
|
153
|
+
|
138
154
|
def cmd_receive
|
139
155
|
verify_server
|
140
156
|
cmd_receive_schema
|
@@ -144,9 +160,9 @@ class ClientSession
|
|
144
160
|
end
|
145
161
|
|
146
162
|
def cmd_receive_data
|
147
|
-
puts "Receiving data
|
163
|
+
puts "Receiving data"
|
148
164
|
|
149
|
-
tables_with_counts, record_count =
|
165
|
+
tables_with_counts, record_count = fetch_remote_tables_info
|
150
166
|
|
151
167
|
puts "#{tables_with_counts.size} tables, #{format_number(record_count)} records"
|
152
168
|
|
@@ -194,7 +210,7 @@ class ClientSession
|
|
194
210
|
[chunksize, rows]
|
195
211
|
end
|
196
212
|
|
197
|
-
def
|
213
|
+
def fetch_remote_tables_info
|
198
214
|
retries = 0
|
199
215
|
max_retries = 1
|
200
216
|
begin
|
@@ -211,7 +227,7 @@ class ClientSession
|
|
211
227
|
end
|
212
228
|
|
213
229
|
def cmd_receive_schema
|
214
|
-
puts "Receiving schema
|
230
|
+
puts "Receiving schema"
|
215
231
|
|
216
232
|
schema_data = session_resource['schema'].get(:taps_version => Taps.version)
|
217
233
|
output = Taps::Utils.load_schema(database_url, schema_data)
|
@@ -219,7 +235,7 @@ class ClientSession
|
|
219
235
|
end
|
220
236
|
|
221
237
|
def cmd_receive_indexes
|
222
|
-
puts "Receiving
|
238
|
+
puts "Receiving indexes"
|
223
239
|
|
224
240
|
index_data = session_resource['indexes'].get(:taps_version => Taps.version)
|
225
241
|
|
@@ -228,7 +244,7 @@ class ClientSession
|
|
228
244
|
end
|
229
245
|
|
230
246
|
def cmd_reset_sequences
|
231
|
-
puts "Resetting
|
247
|
+
puts "Resetting sequences"
|
232
248
|
|
233
249
|
output = `#{File.dirname(__FILE__)}/../../bin/schema reset_db_sequences #{database_url}`
|
234
250
|
puts output if output
|
data/lib/taps/progress_bar.rb
CHANGED
@@ -127,7 +127,7 @@ class ProgressBar
|
|
127
127
|
data = [0, 0, 0, 0].pack("SSSS")
|
128
128
|
if @out.ioctl(tiocgwinsz, data) >= 0 then
|
129
129
|
rows, cols, xpixels, ypixels = data.unpack("SSSS")
|
130
|
-
if cols
|
130
|
+
if cols > 0 then cols else default_width end
|
131
131
|
else
|
132
132
|
default_width
|
133
133
|
end
|
data/lib/taps/schema.rb
CHANGED
@@ -27,7 +27,9 @@ module Schema
|
|
27
27
|
|
28
28
|
def sqlite_config(url)
|
29
29
|
m = %r{(sqlite3?)://(.+)}.match(url)
|
30
|
-
|
30
|
+
database = m[2]
|
31
|
+
database, q = database.split('?')
|
32
|
+
{ 'adapter' => 'sqlite3', 'database' => database }
|
31
33
|
end
|
32
34
|
|
33
35
|
def connection(database_url)
|
data/spec/client_session_spec.rb
CHANGED
@@ -49,7 +49,7 @@ describe Taps::ClientSession do
|
|
49
49
|
@progressbar.stubs(:inc)
|
50
50
|
@progressbar.stubs(:finish)
|
51
51
|
@mytable = mock('mytable')
|
52
|
-
@client.expects(:
|
52
|
+
@client.expects(:fetch_remote_tables_info).returns([ { :mytable => 2 }, 2 ])
|
53
53
|
@client.stubs(:db).returns(mock('db'))
|
54
54
|
@client.db.stubs(:[]).with(:mytable).returns(@mytable)
|
55
55
|
@client.expects(:fetch_table_rows).with(:mytable, 1000, 0).returns([ 1000, { :header => [:x, :y], :data => [[1, 2], [3, 4]] } ])
|
@@ -59,11 +59,11 @@ describe Taps::ClientSession do
|
|
59
59
|
lambda { @client.cmd_receive_data }.should.not.raise
|
60
60
|
end
|
61
61
|
|
62
|
-
it "fetches tables info from taps server" do
|
62
|
+
it "fetches remote tables info from taps server" do
|
63
63
|
@marshal_data = Marshal.dump({ :mytable => 2 })
|
64
64
|
@client.session_resource.stubs(:[]).with('tables').returns(mock('tables'))
|
65
65
|
@client.session_resource['tables'].stubs(:get).with(:taps_version => Taps.version).returns(@marshal_data)
|
66
|
-
@client.
|
66
|
+
@client.fetch_remote_tables_info.should == [ { :mytable => 2 }, 2 ]
|
67
67
|
end
|
68
68
|
|
69
69
|
it "fetches table rows given a chunksize and offset from taps server" do
|
data/spec/schema_spec.rb
CHANGED
@@ -25,6 +25,7 @@ describe Taps::Schema do
|
|
25
25
|
it "translates sqlite database path" do
|
26
26
|
Taps::Schema.create_config("sqlite://pathtodb/mydb")['database'].should == 'pathtodb/mydb'
|
27
27
|
Taps::Schema.create_config("sqlite:///pathtodb/mydb")['database'].should == '/pathtodb/mydb'
|
28
|
+
Taps::Schema.create_config("sqlite:///pathtodb/mydb?encoding=utf8")['database'].should == '/pathtodb/mydb'
|
28
29
|
end
|
29
30
|
|
30
31
|
it "connects activerecord to the database" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: taps
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ricardo Chimal, Jr.
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-03-
|
13
|
+
date: 2009-03-16 00:00:00 -07:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -89,16 +89,16 @@ files:
|
|
89
89
|
- spec/client_session_spec.rb
|
90
90
|
- spec/schema_spec.rb
|
91
91
|
- lib/taps/db_session.rb
|
92
|
-
- lib/taps/client_session.rb
|
93
92
|
- lib/taps/progress_bar.rb
|
93
|
+
- lib/taps/server.rb
|
94
94
|
- lib/taps/cli.rb
|
95
95
|
- lib/taps/adapter_hacks.rb
|
96
96
|
- lib/taps/adapter_hacks/invalid_text_limit.rb
|
97
97
|
- lib/taps/adapter_hacks/non_rails_schema_dump.rb
|
98
|
-
- lib/taps/server.rb
|
99
98
|
- lib/taps/schema.rb
|
100
|
-
- lib/taps/
|
99
|
+
- lib/taps/client_session.rb
|
101
100
|
- lib/taps/utils.rb
|
101
|
+
- lib/taps/config.rb
|
102
102
|
- README.rdoc
|
103
103
|
- LICENSE
|
104
104
|
- VERSION.yml
|