import_everything 0.1.3 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/Gemfile.lock +0 -2
- data/Rakefile +17 -0
- data/VERSION +1 -1
- data/import_everything.gemspec +14 -14
- data/lib/import_everything/determine_type.rb +2 -0
- data/lib/import_everything/parsers/yaml_parser.rb +12 -0
- data/spec/{bets.html → data/bets.html} +0 -0
- data/spec/data/database.yml +23 -0
- data/spec/{howard.html → data/howard.html} +0 -0
- data/spec/{players.csv → data/players.csv} +0 -0
- data/spec/{players.sql → data/players.sql} +0 -0
- data/spec/{players.xml → data/players.xml} +0 -0
- data/spec/{csv_parser_spec.rb → parsers/csv_parser_spec.rb} +1 -1
- data/spec/{sql_parser_spec.rb → parsers/sql_parser_spec.rb} +1 -1
- data/spec/{sqlite_parser_spec.rb → parsers/sqlite_parser_spec.rb} +1 -1
- data/spec/{xml_parser_spec.rb → parsers/xml_parser_spec.rb} +2 -2
- data/spec/parsers/yaml_parser_spec.rb +15 -0
- data/spec/spec_helper.rb +1 -1
- data/vol/web_test.rb +4 -3
- metadata +15 -28
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -21,7 +21,6 @@ GEM
|
|
21
21
|
fattr
|
22
22
|
multi_json (1.5.0)
|
23
23
|
rake (10.0.3)
|
24
|
-
rcov (0.9.9)
|
25
24
|
rdoc (3.12)
|
26
25
|
json (~> 1.4)
|
27
26
|
rspec (2.8.0)
|
@@ -44,7 +43,6 @@ DEPENDENCIES
|
|
44
43
|
hpricot
|
45
44
|
jeweler (~> 1.8.4)
|
46
45
|
mharris_ext
|
47
|
-
rcov
|
48
46
|
rdoc (~> 3.12)
|
49
47
|
rspec (~> 2.8.0)
|
50
48
|
sqlite3
|
data/Rakefile
CHANGED
@@ -37,6 +37,7 @@ RSpec::Core::RakeTask.new(:rcov) do |spec|
|
|
37
37
|
end
|
38
38
|
|
39
39
|
task :default => :spec
|
40
|
+
task :test => :spec
|
40
41
|
|
41
42
|
require 'rdoc/task'
|
42
43
|
Rake::RDocTask.new do |rdoc|
|
@@ -66,6 +67,22 @@ namespace :doc do
|
|
66
67
|
end
|
67
68
|
end
|
68
69
|
|
70
|
+
namespace :rel do
|
71
|
+
task :all do
|
72
|
+
res = []
|
73
|
+
res << "bundle exec rake version:bump:patch"
|
74
|
+
res << "bundle exec rake gemspec"
|
75
|
+
res << "git add import_everything.gemspec"
|
76
|
+
res << "git commit -m gemspec"
|
77
|
+
res << "bundle exec rake install"
|
78
|
+
res << "bundle exec rake release"
|
79
|
+
res.each do |cmd|
|
80
|
+
puts cmd
|
81
|
+
puts `#{cmd}`
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
69
86
|
|
70
87
|
if false
|
71
88
|
require 'pp'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.5
|
data/import_everything.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "import_everything"
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Mike Harris"]
|
12
|
-
s.date = "2013-01-
|
12
|
+
s.date = "2013-01-10"
|
13
13
|
s.description = "import everything"
|
14
14
|
s.email = "mharris717@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -36,21 +36,24 @@ Gem::Specification.new do |s|
|
|
36
36
|
"lib/import_everything/parsers/sqlite_parser.rb",
|
37
37
|
"lib/import_everything/parsers/table_parser.rb",
|
38
38
|
"lib/import_everything/parsers/xml_parser.rb",
|
39
|
+
"lib/import_everything/parsers/yaml_parser.rb",
|
39
40
|
"lib/import_everything/preview.rb",
|
40
|
-
"spec/bets.html",
|
41
|
-
"spec/
|
41
|
+
"spec/data/bets.html",
|
42
|
+
"spec/data/database.yml",
|
43
|
+
"spec/data/howard.html",
|
44
|
+
"spec/data/players.csv",
|
45
|
+
"spec/data/players.sql",
|
46
|
+
"spec/data/players.xml",
|
42
47
|
"spec/helpers/test_db.rb",
|
43
|
-
"spec/howard.html",
|
44
48
|
"spec/import_everything_spec.rb",
|
45
49
|
"spec/junk.rb",
|
46
|
-
"spec/
|
47
|
-
"spec/
|
48
|
-
"spec/
|
50
|
+
"spec/parsers/csv_parser_spec.rb",
|
51
|
+
"spec/parsers/sql_parser_spec.rb",
|
52
|
+
"spec/parsers/sqlite_parser_spec.rb",
|
53
|
+
"spec/parsers/xml_parser_spec.rb",
|
54
|
+
"spec/parsers/yaml_parser_spec.rb",
|
49
55
|
"spec/preview_spec.rb",
|
50
56
|
"spec/spec_helper.rb",
|
51
|
-
"spec/sql_parser_spec.rb",
|
52
|
-
"spec/sqlite_parser_spec.rb",
|
53
|
-
"spec/xml_parser_spec.rb",
|
54
57
|
"vol/filename_meth.rb",
|
55
58
|
"vol/test_db_test.rb",
|
56
59
|
"vol/web_test.rb",
|
@@ -74,7 +77,6 @@ Gem::Specification.new do |s|
|
|
74
77
|
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
75
78
|
s.add_development_dependency(%q<bundler>, ["~> 1.2"])
|
76
79
|
s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
|
77
|
-
s.add_development_dependency(%q<rcov>, [">= 0"])
|
78
80
|
else
|
79
81
|
s.add_dependency(%q<mharris_ext>, [">= 0"])
|
80
82
|
s.add_dependency(%q<activesupport>, [">= 0"])
|
@@ -84,7 +86,6 @@ Gem::Specification.new do |s|
|
|
84
86
|
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
85
87
|
s.add_dependency(%q<bundler>, ["~> 1.2"])
|
86
88
|
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
87
|
-
s.add_dependency(%q<rcov>, [">= 0"])
|
88
89
|
end
|
89
90
|
else
|
90
91
|
s.add_dependency(%q<mharris_ext>, [">= 0"])
|
@@ -95,7 +96,6 @@ Gem::Specification.new do |s|
|
|
95
96
|
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
96
97
|
s.add_dependency(%q<bundler>, ["~> 1.2"])
|
97
98
|
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
98
|
-
s.add_dependency(%q<rcov>, [">= 0"])
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
@@ -16,6 +16,7 @@ module ImportEverything
|
|
16
16
|
# Get the file extension
|
17
17
|
# @return [String] file extension
|
18
18
|
fattr(:ext) { filename.split(".").last.downcase }
|
19
|
+
|
19
20
|
def method_missing(sym,*args,&b)
|
20
21
|
if sym.to_s[-1..-1] == '='
|
21
22
|
self.addl_ops[sym.to_s[0..-2]] = args.first
|
@@ -31,6 +32,7 @@ module ImportEverything
|
|
31
32
|
# Determines what parser class should be used for this file
|
32
33
|
def parser_class
|
33
34
|
h = {'sqlite' => SqliteParser, 'sqlite3' => SqliteParser, 'csv' => CsvParser, 'xml' => XmlParser, 'sql' => SqlInsertParser, 'dmp' => SqlInsertParser, 'html' => TableParser}
|
35
|
+
h = h.merge('yaml' => YamlParser, 'yml' => 'YamlParser')
|
34
36
|
h[ext].tap { |x| return x if x }
|
35
37
|
h.each do |k,klass|
|
36
38
|
return klass if ext =~ /^#{k}\d\d/
|
File without changes
|
@@ -0,0 +1,23 @@
|
|
1
|
+
development:
|
2
|
+
adapter: mysql
|
3
|
+
encoding: utf8
|
4
|
+
database: pyromaniac_development
|
5
|
+
username: root
|
6
|
+
password:
|
7
|
+
socket: /tmp/mysql.sock
|
8
|
+
|
9
|
+
test:
|
10
|
+
adapter: mysql
|
11
|
+
encoding: utf8
|
12
|
+
database: pyromaniac_test
|
13
|
+
username: root
|
14
|
+
password:
|
15
|
+
socket: /tmp/mysql.sock
|
16
|
+
|
17
|
+
production:
|
18
|
+
adapter: mysql
|
19
|
+
encoding: utf8
|
20
|
+
database: eden_production
|
21
|
+
username: root
|
22
|
+
password:
|
23
|
+
socket: /tmp/mysql.sock
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,9 +1,9 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
2
|
|
3
3
|
describe "ImportEverything" do
|
4
4
|
describe XmlParser do
|
5
5
|
before do
|
6
|
-
@parser = XmlParser.new(:filename => "
|
6
|
+
@parser = XmlParser.new(:filename => spec_file("players.xml"), :root_path => 'top', :table_paths => [['players','player'],['cities','city']])
|
7
7
|
#@parser.table_paths = nil
|
8
8
|
end
|
9
9
|
it 'smoke' do
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe "ImportEverything" do
|
4
|
+
describe YamlParser do
|
5
|
+
let(:parser) do
|
6
|
+
YamlParser.new(:filename => spec_file('database.yml'), :table => 'database')
|
7
|
+
end
|
8
|
+
it 'size' do
|
9
|
+
parser.value_hashes.should size(3)
|
10
|
+
end
|
11
|
+
it 'first root' do
|
12
|
+
parser.value_hashes[0]["root"].should == 'development'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/spec/spec_helper.rb
CHANGED
data/vol/web_test.rb
CHANGED
@@ -8,7 +8,7 @@ csv = "a,b,c
|
|
8
8
|
4,5,6"
|
9
9
|
|
10
10
|
def get_parsed(body,filename=nil)
|
11
|
-
uri = URI('http://
|
11
|
+
uri = URI('http://importeverything.herokuapp.com/get')
|
12
12
|
params = { :body => body, :filename => filename }
|
13
13
|
uri.query = URI.encode_www_form(params)
|
14
14
|
|
@@ -21,8 +21,9 @@ rows = get_parsed csv
|
|
21
21
|
puts rows.class
|
22
22
|
pp rows
|
23
23
|
|
24
|
-
sql = "insert into widgets (color,price) values ('Black',10);
|
25
|
-
|
24
|
+
sql = "insert into widgets (color,price) values ('Black',10);
|
25
|
+
insert into players (name,hr) values ('Babe',755);"
|
26
|
+
#sql = File.read("spec/players.sql")
|
26
27
|
|
27
28
|
rows = get_parsed sql, "widgets.sql"
|
28
29
|
pp rows
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: import_everything
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
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-01-
|
12
|
+
date: 2013-01-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mharris_ext
|
@@ -139,22 +139,6 @@ dependencies:
|
|
139
139
|
- - ~>
|
140
140
|
- !ruby/object:Gem::Version
|
141
141
|
version: 1.8.4
|
142
|
-
- !ruby/object:Gem::Dependency
|
143
|
-
name: rcov
|
144
|
-
requirement: !ruby/object:Gem::Requirement
|
145
|
-
none: false
|
146
|
-
requirements:
|
147
|
-
- - ! '>='
|
148
|
-
- !ruby/object:Gem::Version
|
149
|
-
version: '0'
|
150
|
-
type: :development
|
151
|
-
prerelease: false
|
152
|
-
version_requirements: !ruby/object:Gem::Requirement
|
153
|
-
none: false
|
154
|
-
requirements:
|
155
|
-
- - ! '>='
|
156
|
-
- !ruby/object:Gem::Version
|
157
|
-
version: '0'
|
158
142
|
description: import everything
|
159
143
|
email: mharris717@gmail.com
|
160
144
|
executables: []
|
@@ -182,21 +166,24 @@ files:
|
|
182
166
|
- lib/import_everything/parsers/sqlite_parser.rb
|
183
167
|
- lib/import_everything/parsers/table_parser.rb
|
184
168
|
- lib/import_everything/parsers/xml_parser.rb
|
169
|
+
- lib/import_everything/parsers/yaml_parser.rb
|
185
170
|
- lib/import_everything/preview.rb
|
186
|
-
- spec/bets.html
|
187
|
-
- spec/
|
171
|
+
- spec/data/bets.html
|
172
|
+
- spec/data/database.yml
|
173
|
+
- spec/data/howard.html
|
174
|
+
- spec/data/players.csv
|
175
|
+
- spec/data/players.sql
|
176
|
+
- spec/data/players.xml
|
188
177
|
- spec/helpers/test_db.rb
|
189
|
-
- spec/howard.html
|
190
178
|
- spec/import_everything_spec.rb
|
191
179
|
- spec/junk.rb
|
192
|
-
- spec/
|
193
|
-
- spec/
|
194
|
-
- spec/
|
180
|
+
- spec/parsers/csv_parser_spec.rb
|
181
|
+
- spec/parsers/sql_parser_spec.rb
|
182
|
+
- spec/parsers/sqlite_parser_spec.rb
|
183
|
+
- spec/parsers/xml_parser_spec.rb
|
184
|
+
- spec/parsers/yaml_parser_spec.rb
|
195
185
|
- spec/preview_spec.rb
|
196
186
|
- spec/spec_helper.rb
|
197
|
-
- spec/sql_parser_spec.rb
|
198
|
-
- spec/sqlite_parser_spec.rb
|
199
|
-
- spec/xml_parser_spec.rb
|
200
187
|
- vol/filename_meth.rb
|
201
188
|
- vol/test_db_test.rb
|
202
189
|
- vol/web_test.rb
|
@@ -216,7 +203,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
216
203
|
version: '0'
|
217
204
|
segments:
|
218
205
|
- 0
|
219
|
-
hash:
|
206
|
+
hash: 4403534682600032383
|
220
207
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
221
208
|
none: false
|
222
209
|
requirements:
|