import_everything 0.1.0 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,20 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "rspec", "~> 2.8.0"
10
+ gem "rdoc", "~> 3.12"
11
+ gem "bundler", "~> 1.2"
12
+ gem "jeweler", "~> 1.8.4"
13
+ gem "rcov", ">= 0"
14
+ end
15
+
16
+ gem "mharris_ext"
17
+ gem "activesupport"
18
+ gem 'hpricot'
19
+ gem 'sqlite3'
20
+ gem 'yard'
data/Gemfile.lock ADDED
@@ -0,0 +1,51 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ activesupport (3.2.9)
5
+ i18n (~> 0.6)
6
+ multi_json (~> 1.0)
7
+ diff-lcs (1.1.3)
8
+ facets (2.9.3)
9
+ fattr (2.2.1)
10
+ git (1.2.5)
11
+ hpricot (0.8.4)
12
+ i18n (0.6.1)
13
+ jeweler (1.8.4)
14
+ bundler (~> 1.0)
15
+ git (>= 1.2.5)
16
+ rake
17
+ rdoc
18
+ json (1.7.6)
19
+ mharris_ext (1.6.0)
20
+ facets
21
+ fattr
22
+ multi_json (1.5.0)
23
+ rake (10.0.3)
24
+ rcov (0.9.9)
25
+ rdoc (3.12)
26
+ json (~> 1.4)
27
+ rspec (2.8.0)
28
+ rspec-core (~> 2.8.0)
29
+ rspec-expectations (~> 2.8.0)
30
+ rspec-mocks (~> 2.8.0)
31
+ rspec-core (2.8.0)
32
+ rspec-expectations (2.8.0)
33
+ diff-lcs (~> 1.1.2)
34
+ rspec-mocks (2.8.0)
35
+ sqlite3 (1.3.6)
36
+ yard (0.8.3)
37
+
38
+ PLATFORMS
39
+ ruby
40
+
41
+ DEPENDENCIES
42
+ activesupport
43
+ bundler (~> 1.2)
44
+ hpricot
45
+ jeweler (~> 1.8.4)
46
+ mharris_ext
47
+ rcov
48
+ rdoc (~> 3.12)
49
+ rspec (~> 2.8.0)
50
+ sqlite3
51
+ yard
data/Rakefile CHANGED
@@ -1,49 +1,101 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
2
12
  require 'rake'
3
13
 
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "import_everything"
8
- gem.summary = %Q{import everything}
9
- gem.description = %Q{import everything}
10
- gem.email = "mharris717@gmail.com"
11
- gem.homepage = "http://github.com/mharris717/import_everything"
12
- gem.authors = ["Mike Harris"]
13
- gem.add_development_dependency "rspec"
14
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
- end
16
- Jeweler::GemcutterTasks.new
17
- rescue LoadError
18
- puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "import_everything"
18
+ gem.homepage = "http://github.com/mharris717/import_everything"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{import everything}
21
+ gem.description = %Q{import everything}
22
+ gem.email = "mharris717@gmail.com"
23
+ gem.authors = ["Mike Harris"]
24
+ # dependencies defined in Gemfile
19
25
  end
26
+ Jeweler::RubygemsDotOrgTasks.new
20
27
 
21
- require 'spec/rake/spectask'
22
- Spec::Rake::SpecTask.new(:spec) do |spec|
23
- spec.libs << 'lib' << 'spec'
24
- spec.spec_files = FileList['spec/**/*_spec.rb']
28
+ require 'rspec/core'
29
+ require 'rspec/core/rake_task'
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList['spec/**/*_spec.rb']
25
32
  end
26
33
 
27
- Spec::Rake::SpecTask.new(:rcov) do |spec|
28
- spec.libs << 'lib' << 'spec'
34
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
29
35
  spec.pattern = 'spec/**/*_spec.rb'
30
36
  spec.rcov = true
31
37
  end
32
38
 
33
- task :spec => :check_dependencies
34
-
35
39
  task :default => :spec
36
40
 
37
- require 'rake/rdoctask'
41
+ require 'rdoc/task'
38
42
  Rake::RDocTask.new do |rdoc|
39
- if File.exist?('VERSION')
40
- version = File.read('VERSION')
41
- else
42
- version = ""
43
- end
43
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
44
44
 
45
45
  rdoc.rdoc_dir = 'rdoc'
46
46
  rdoc.title = "import_everything #{version}"
47
47
  rdoc.rdoc_files.include('README*')
48
48
  rdoc.rdoc_files.include('lib/**/*.rb')
49
49
  end
50
+
51
+
52
+
53
+ require 'yard'
54
+ YARD::Rake::YardocTask.new do |t|
55
+ #t.files = ['lib/**/*.rb', OTHER_PATHS] # optional
56
+ #t.options = ['--any', '--extra', '--opts'] # optional
57
+ t.options = ["--reload"]
58
+ end
59
+
60
+ namespace :doc do
61
+ task :generate do
62
+ puts `yardoc -e yard_ext.rb`
63
+ end
64
+ task :server do
65
+ puts `yard server -e yard_ext.rb --reload`
66
+ end
67
+ end
68
+
69
+
70
+ if false
71
+ require 'pp'
72
+ File.open("test.txt","w") do |f|
73
+ f << "Statement\n"
74
+ PP.pp(statement,f)
75
+ f << "\n\n"
76
+
77
+ modname = statement[0].source
78
+ mod = register ModuleObject.new(namespace, modname)
79
+ parse_block(statement[1], :namespace => mod)
80
+
81
+ f << "modname\n"
82
+ PP.pp(modname,f)
83
+ f << "\n\n"
84
+
85
+ f << "namespace\n"
86
+ PP.pp(namespace,f)
87
+ f << "\n\n"
88
+
89
+ f << "Statement[0]\n"
90
+ PP.pp(statement[0],f)
91
+ f << "\n\n"
92
+
93
+ f << "Statement[1]\n"
94
+ PP.pp(statement[1],f)
95
+ f << "\n\n"
96
+
97
+
98
+ end
99
+ exit
100
+ end
101
+
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.2
@@ -0,0 +1,104 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "import_everything"
8
+ s.version = "0.1.2"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Mike Harris"]
12
+ s.date = "2013-01-08"
13
+ s.description = "import everything"
14
+ s.email = "mharris717@gmail.com"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ "Gemfile",
22
+ "Gemfile.lock",
23
+ "LICENSE",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "import_everything.gemspec",
28
+ "lib/import_everything.rb",
29
+ "lib/import_everything/determine_type.rb",
30
+ "lib/import_everything/ext.rb",
31
+ "lib/import_everything/parser/line_parser.rb",
32
+ "lib/import_everything/parser/module_methods.rb",
33
+ "lib/import_everything/parser/parser.rb",
34
+ "lib/import_everything/parsers/csv_parser.rb",
35
+ "lib/import_everything/parsers/sql_parser.rb",
36
+ "lib/import_everything/parsers/sqlite_parser.rb",
37
+ "lib/import_everything/parsers/table_parser.rb",
38
+ "lib/import_everything/parsers/xml_parser.rb",
39
+ "lib/import_everything/preview.rb",
40
+ "spec/bets.html",
41
+ "spec/csv_parser_spec.rb",
42
+ "spec/helpers/test_db.rb",
43
+ "spec/howard.html",
44
+ "spec/import_everything_spec.rb",
45
+ "spec/junk.rb",
46
+ "spec/players.csv",
47
+ "spec/players.sql",
48
+ "spec/players.xml",
49
+ "spec/preview_spec.rb",
50
+ "spec/spec_helper.rb",
51
+ "spec/sql_parser_spec.rb",
52
+ "spec/sqlite_parser_spec.rb",
53
+ "spec/xml_parser_spec.rb",
54
+ "vol/filename_meth.rb",
55
+ "vol/test_db_test.rb",
56
+ "vol/web_test.rb",
57
+ "yard_ext.rb"
58
+ ]
59
+ s.homepage = "http://github.com/mharris717/import_everything"
60
+ s.licenses = ["MIT"]
61
+ s.require_paths = ["lib"]
62
+ s.rubygems_version = "1.8.23"
63
+ s.summary = "import everything"
64
+
65
+ if s.respond_to? :specification_version then
66
+ s.specification_version = 3
67
+
68
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
69
+ s.add_runtime_dependency(%q<mharris_ext>, [">= 0"])
70
+ s.add_runtime_dependency(%q<activesupport>, [">= 0"])
71
+ s.add_runtime_dependency(%q<hpricot>, [">= 0"])
72
+ s.add_runtime_dependency(%q<sqlite3>, [">= 0"])
73
+ s.add_runtime_dependency(%q<yard>, [">= 0"])
74
+ s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
75
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
76
+ s.add_development_dependency(%q<bundler>, ["~> 1.2"])
77
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
78
+ s.add_development_dependency(%q<rcov>, [">= 0"])
79
+ else
80
+ s.add_dependency(%q<mharris_ext>, [">= 0"])
81
+ s.add_dependency(%q<activesupport>, [">= 0"])
82
+ s.add_dependency(%q<hpricot>, [">= 0"])
83
+ s.add_dependency(%q<sqlite3>, [">= 0"])
84
+ s.add_dependency(%q<yard>, [">= 0"])
85
+ s.add_dependency(%q<rspec>, ["~> 2.8.0"])
86
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
87
+ s.add_dependency(%q<bundler>, ["~> 1.2"])
88
+ s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
89
+ s.add_dependency(%q<rcov>, [">= 0"])
90
+ end
91
+ else
92
+ s.add_dependency(%q<mharris_ext>, [">= 0"])
93
+ s.add_dependency(%q<activesupport>, [">= 0"])
94
+ s.add_dependency(%q<hpricot>, [">= 0"])
95
+ s.add_dependency(%q<sqlite3>, [">= 0"])
96
+ s.add_dependency(%q<yard>, [">= 0"])
97
+ s.add_dependency(%q<rspec>, ["~> 2.8.0"])
98
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
99
+ s.add_dependency(%q<bundler>, ["~> 1.2"])
100
+ s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
101
+ s.add_dependency(%q<rcov>, [">= 0"])
102
+ end
103
+ end
104
+
@@ -8,8 +8,13 @@ module ImportEverything
8
8
  file.first_responding(:original_filename, :filename, :path, :name)
9
9
  end
10
10
  end
11
+
12
+
11
13
  fattr(:filename) { self.class.get_filename(file) }
12
14
  fattr(:file) { open(filename) }
15
+
16
+ # Get the file extension
17
+ # @return [String] file extension
13
18
  fattr(:ext) { filename.split(".").last.downcase }
14
19
  def method_missing(sym,*args,&b)
15
20
  if sym.to_s[-1..-1] == '='
@@ -18,8 +23,12 @@ module ImportEverything
18
23
  super
19
24
  end
20
25
  end
26
+
27
+ # Store addl ops
21
28
  fattr(:addl_ops) { {} }
22
29
  fattr(:parser_ops) { {:file => file}.merge(addl_ops) }
30
+
31
+ # Determines what parser class should be used for this file
23
32
  def parser_class
24
33
  h = {'sqlite' => SqliteParser, 'sqlite3' => SqliteParser, 'csv' => CsvParser, 'xml' => XmlParser, 'sql' => SqlInsertParser, 'dmp' => SqlInsertParser, 'html' => TableParser}
25
34
  h[ext].tap { |x| return x if x }
@@ -28,9 +37,21 @@ module ImportEverything
28
37
  end
29
38
  raise "no parser found for #{ext}"
30
39
  end
40
+
41
+ # Creates the parser
31
42
  def parser
32
- # puts "parser ops is #{parser_ops.inspect}"
33
43
  parser_class.new(parser_ops)
34
44
  end
45
+
46
+ module Include
47
+ fattr(:dt) do
48
+ DetermineType.new
49
+ end
50
+
51
+ %w(filename file).each do |m|
52
+ define_method(m) { dt.send(m) }
53
+ define_method("#{m}=") { |v| dt.send("#{m}=",v) }
54
+ end
55
+ end
35
56
  end
36
57
  end
@@ -10,22 +10,28 @@ module ImportEverything
10
10
  {:table => row_hash[:table], :values => row_hash[:values].cleaned_hash_values}
11
11
  end
12
12
  end
13
-
14
- fattr(:value_hashes) do
15
- parsers.map { |x| x.value_hashes }.flatten
16
- end
13
+
17
14
  fattr(:row_hashes) do
18
- if respond_to?(:parsers)
19
- parsers.map { |x| x.row_hashes }.flatten
20
- else
21
- value_hashes.map { |x| {:table => table, :values => x} }
22
- end
15
+ value_hashes.map { |x| {:table => table, :values => x} }
16
+ end
17
+
18
+ def value_hashes
19
+ raise NotImplementedError.new("value_hashes in #{self.class}")
23
20
  end
24
- def line_parsers; parsers; end
25
- fattr(:filename) { ImportEverything::DetermineType.get_filename(file) }
26
- fattr(:file) { open(filename) }
27
- fattr(:str) { file.read }
28
21
 
22
+ include DetermineType::Include
23
+
24
+ fattr(:str) { file.read }
25
+ end
26
+ module ParserPreviewMod
27
+ fattr(:addl_required_fields) do
28
+ required_fields.select do |x|
29
+ send(x).to_s.blank?
30
+ end
31
+ end
32
+ fattr(:required_fields) { [] }
33
+ end
34
+ module IterationHelpers
29
35
  def each_row
30
36
  each_table_and_rows do |table,rows|
31
37
  rows.each { |row| yield(table,row) }
@@ -43,13 +49,23 @@ module ImportEverything
43
49
  res
44
50
  end
45
51
  end
46
- module ParserPreviewMod
47
- fattr(:addl_required_fields) do
48
- required_fields.select do |x|
49
- send(x).to_s.blank?
52
+ Parser.send(:include,ParserPreviewMod)
53
+ Parser.send(:include,IterationHelpers)
54
+
55
+ class Parser
56
+ class ImpParsers < Parser
57
+ # subclass must implement parsers or value_hashes
58
+ # if implemented, should return an array of line parsers
59
+ def parsers
60
+ raise NotImplementedError.new("parsers")
61
+ end
62
+ def line_parsers; parsers; end
63
+ fattr(:value_hashes) do
64
+ parsers.map { |x| x.value_hashes }.flatten
65
+ end
66
+ fattr(:row_hashes) do
67
+ parsers.map { |x| x.row_hashes }.flatten
50
68
  end
51
69
  end
52
- fattr(:required_fields) { [] }
53
70
  end
54
- Parser.send(:include,ParserPreviewMod)
55
71
  end
@@ -1,6 +1,8 @@
1
1
  module ImportEverything
2
2
  class CsvParser < Parser
3
3
  fattr(:delimiter) { "," }
4
+
5
+ # Generates the value hashes
4
6
  def value_hashes
5
7
  require 'csv'
6
8
  res = []
@@ -1,5 +1,5 @@
1
1
  module ImportEverything
2
- class SqlInsertParser < Parser
2
+ class SqlInsertParser < Parser::ImpParsers
3
3
  fattr(:lines) do
4
4
  str.split(/\n|;/).map { |x| x.strip }.select { |x| x.present? }
5
5
  end
@@ -1,5 +1,5 @@
1
1
  module ImportEverything
2
- class SqliteParser < Parser
2
+ class SqliteParser < Parser::ImpParsers
3
3
  fattr(:filfename) do
4
4
  f = Tempfile.new('somedb.sqlite3')
5
5
  f.binmode
@@ -7,12 +7,8 @@ module ImportEverything
7
7
  f.path
8
8
  end
9
9
  fattr(:db) do
10
- gem 'sqlite3-ruby'
11
10
  require 'sqlite3'
12
- #raise "#{filename} #{file.local_methods.inspect}"
13
- res = SQLite3::Database.new(filename)
14
- #get_raw_tables(res)
15
- #res
11
+ SQLite3::Database.new(filename)
16
12
  end
17
13
  def get_raw_tables(db)
18
14
  sql = "SELECT name FROM sqlite_master WHERE type='table' ORDER BY name;"
@@ -1,5 +1,5 @@
1
1
  module ImportEverything
2
- class XmlParser < Parser
2
+ class XmlParser < Parser::ImpParsers
3
3
  attr_accessor :root_path, :table_paths, :xyz
4
4
  #fattr(:table_paths) { [['players','player'],['cities','city']] }
5
5
  #fattr(:root_path) { 'top' }
@@ -15,7 +15,7 @@ module ImportEverything
15
15
  [:root_path,:table_paths]
16
16
  end
17
17
 
18
- class TableParser < Parser
18
+ class TableParser < Parser::ImpParsers
19
19
  attr_accessor :doc, :table, :row_path
20
20
  include FromHash
21
21
  def row_docs
@@ -17,8 +17,7 @@ module ImportEverything
17
17
  end
18
18
  end
19
19
  def rows
20
- #mylog "display_table", :rows => @rows
21
- @rows
20
+ @rows
22
21
  end
23
22
  def to_hash
24
23
  {:keys => keys, :row_arrays => row_value_arrays, :table => table}
@@ -5,5 +5,6 @@ require 'active_support'
5
5
  this_path = File.expand_path(File.dirname(__FILE__))
6
6
  require "#{this_path}/import_everything/ext"
7
7
  paths = Dir["#{this_path}/import_everything/**/*.rb"]
8
- paths = paths.make_first { |path| %w(parser.rb line_parser.rb).include?(File.basename(path)) }
9
- paths.each { |x| require x }
8
+ paths = paths.make_first { |path| %w(determine_type.rb parser.rb line_parser.rb).include?(File.basename(path)) }
9
+ paths.each { |x| require x }
10
+
@@ -0,0 +1,31 @@
1
+ class TestDB
2
+ class << self
3
+ fattr(:instance) { new }
4
+ end
5
+ fattr(:filename) { "/Code/wheeeee.sqlite3" }
6
+ fattr(:db_inner) do
7
+ require 'sqlite3'
8
+ SQLite3::Database.new(filename)
9
+ #SQLite3::Database.new(open("http://localhost:3000/wheeeee.sqlite3") { |f| f.read })
10
+ end
11
+ fattr(:create) do
12
+ `rm -f #{filename}`
13
+ db = db_inner
14
+ db.execute("CREATE TABLE cities ( name varchar(255) )")
15
+ db.execute("CREATE TABLE players ( first varchar(255), last varchar(255), age integer)")
16
+ #raise db.execute("SELECT name FROM sqlite_master WHERE type='table' ORDER BY name;").inspect
17
+ db.execute("INSERT into players (first,last,age) VALUES ('Albert','Pujols',29)")
18
+ db.execute("INSERT into players (first,last,age) VALUES ('David','Wright',26)")
19
+ db.execute("INSERT into players (first,last,age) VALUES ('Hanley','Ramirez',27)")
20
+ db.execute("INSERT into cities (name) VALUES ('Madison')")
21
+ raise "foo" unless db.execute("select count(*) from players").flatten.first.to_i == 3
22
+ end
23
+ fattr(:db) do
24
+ create
25
+ db_inner
26
+ end
27
+ #def create; end
28
+ end
29
+ def create_test_db!
30
+
31
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,10 +1,10 @@
1
1
  $LOAD_PATH.unshift(File.dirname(__FILE__))
2
2
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
3
  require 'import_everything'
4
- require 'spec'
5
- require 'spec/autorun'
4
+ #require 'spec'
5
+ #require 'spec/autorun'
6
6
 
7
- Spec::Runner.configure do |config|
7
+ RSpec.configure do |config|
8
8
 
9
9
  end
10
10
 
@@ -14,7 +14,7 @@ def mit(name,&b)
14
14
  it(name,&b) #if name == 'parses values'
15
15
  end
16
16
 
17
- Spec::Matchers.define :size do |exp_size|
17
+ RSpec::Matchers.define :size do |exp_size|
18
18
  match do |arr|
19
19
  arr.size == exp_size
20
20
  end
@@ -1,32 +1,6 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
- class TestDB
4
- class << self
5
- fattr(:instance) { new }
6
- end
7
- fattr(:filename) { "/Code/wheeeee.sqlite3" }
8
- fattr(:db) do
9
- gem 'sqlite3-ruby'
10
- require 'sqlite3'
11
- SQLite3::Database.new(filename)
12
- #SQLite3::Database.new(open("http://localhost:3000/wheeeee.sqlite3") { |f| f.read })
13
- end
14
- fattr(:crefate) do
15
- `rm -f #{filename}`
16
- db.execute("CREATE TABLE cities ( name varchar(255) )")
17
- db.execute("CREATE TABLE players ( first varchar(255), last varchar(255), age integer)")
18
- #raise db.execute("SELECT name FROM sqlite_master WHERE type='table' ORDER BY name;").inspect
19
- db.execute("INSERT into players (first,last,age) VALUES ('Albert','Pujols',29)")
20
- db.execute("INSERT into players (first,last,age) VALUES ('David','Wright',26)")
21
- db.execute("INSERT into players (first,last,age) VALUES ('Hanley','Ramirez',27)")
22
- db.execute("INSERT into cities (name) VALUES ('Madison')")
23
- raise "foo" unless db.execute("select count(*) from players").flatten.first.to_i == 3
24
- end
25
- def create; end
26
- end
27
- def create_test_db!
28
-
29
- end
3
+ load "spec/helpers/test_db.rb"
30
4
 
31
5
  # raise TestDB.instance.db.execute2("SELECT name FROM sqlite_master WHERE type='table' ORDER BY name;").flatten.inspect
32
6
 
@@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
3
3
  describe "ImportEverything" do
4
4
  describe XmlParser do
5
5
  before do
6
- @parser = XmlParser.new(:filename => "/Code/import_everything/spec/players.xml", :root_path => 'top', :table_paths => [['players','player'],['cities','city']])
6
+ @parser = XmlParser.new(:filename => "/Code/orig/import_everything_all/import_everything/spec/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,4 @@
1
+ load "lib/import_everything.rb"
2
+
3
+ p = ImportEverything::CsvParser.new
4
+ p.filename = "abc"
@@ -0,0 +1,4 @@
1
+ load "lib/import_everything.rb"
2
+ load "spec/helpers/test_db.rb"
3
+
4
+ db = TestDB.instance.db
data/vol/web_test.rb ADDED
@@ -0,0 +1,38 @@
1
+ require 'json'
2
+ require 'pp'
3
+ require 'net/http'
4
+ load "lib/import_everything.rb"
5
+
6
+ csv = "a,b,c
7
+ 1,2,3
8
+ 4,5,6"
9
+
10
+ def get_parsed(body,filename=nil)
11
+ uri = URI('http://localhost:4000/get')
12
+ params = { :body => body, :filename => filename }
13
+ uri.query = URI.encode_www_form(params)
14
+
15
+ res = Net::HTTP.get_response(uri)
16
+ rows = JSON.parse(res.body)
17
+ end
18
+
19
+
20
+ rows = get_parsed csv
21
+ puts rows.class
22
+ pp rows
23
+
24
+ sql = "insert into widgets (color,price) values ('Black',10);"
25
+ sql = File.read("spec/players.sql")
26
+
27
+ rows = get_parsed sql, "widgets.sql"
28
+ pp rows
29
+
30
+ if false
31
+
32
+
33
+ parser = ImportEverything::SqlInsertParser::LineParser.new(:line => sql)
34
+ puts parser.value_hash.inspect
35
+
36
+ parser = ImportEverything::SqlInsertParser.new(:str => sql, :filename => "abc.sql", :file => nil)
37
+ puts parser.value_hashes.inspect
38
+ end
data/yard_ext.rb ADDED
@@ -0,0 +1,18 @@
1
+ require 'yard'
2
+ class FattrHandler < YARD::Handlers::Ruby::AttributeHandler
3
+ handles method_call(:fattr)
4
+ namespace_only
5
+
6
+ def process
7
+ name = statement.parameters.first.jump(:tstring_content, :ident).source
8
+ object = YARD::CodeObjects::MethodObject.new(namespace, name)
9
+ register(object)
10
+ parse_block(statement.last.last, :owner => object)
11
+
12
+ # modify the object
13
+ object.dynamic = true
14
+
15
+ # add custom metadata to the object
16
+ object['custom_field'] = 'Generated by Fattr'
17
+ end
18
+ end
metadata CHANGED
@@ -1,64 +1,207 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: import_everything
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 1
8
- - 0
9
- version: 0.1.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Mike Harris
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2010-05-18 00:00:00 -04:00
18
- default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2013-01-08 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: mharris_ext
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: activesupport
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: hpricot
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: sqlite3
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: yard
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
21
95
  name: rspec
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: 2.8.0
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: 2.8.0
110
+ - !ruby/object:Gem::Dependency
111
+ name: rdoc
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: '3.12'
118
+ type: :development
22
119
  prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- segments:
28
- - 0
29
- version: "0"
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ version: '3.12'
126
+ - !ruby/object:Gem::Dependency
127
+ name: bundler
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ~>
132
+ - !ruby/object:Gem::Version
133
+ version: '1.2'
30
134
  type: :development
31
- version_requirements: *id001
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ~>
140
+ - !ruby/object:Gem::Version
141
+ version: '1.2'
142
+ - !ruby/object:Gem::Dependency
143
+ name: jeweler
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ~>
148
+ - !ruby/object:Gem::Version
149
+ version: 1.8.4
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: 1.8.4
158
+ - !ruby/object:Gem::Dependency
159
+ name: rcov
160
+ requirement: !ruby/object:Gem::Requirement
161
+ none: false
162
+ requirements:
163
+ - - ! '>='
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ type: :development
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - ! '>='
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
32
174
  description: import everything
33
175
  email: mharris717@gmail.com
34
176
  executables: []
35
-
36
177
  extensions: []
37
-
38
- extra_rdoc_files:
178
+ extra_rdoc_files:
39
179
  - LICENSE
40
180
  - README.rdoc
41
- files:
181
+ files:
42
182
  - .document
43
- - .gitignore
183
+ - Gemfile
184
+ - Gemfile.lock
44
185
  - LICENSE
45
186
  - README.rdoc
46
187
  - Rakefile
47
188
  - VERSION
189
+ - import_everything.gemspec
48
190
  - lib/import_everything.rb
191
+ - lib/import_everything/determine_type.rb
49
192
  - lib/import_everything/ext.rb
193
+ - lib/import_everything/parser/line_parser.rb
194
+ - lib/import_everything/parser/module_methods.rb
195
+ - lib/import_everything/parser/parser.rb
50
196
  - lib/import_everything/parsers/csv_parser.rb
51
- - lib/import_everything/parsers/determine_type.rb
52
- - lib/import_everything/parsers/line_parser.rb
53
- - lib/import_everything/parsers/module_methods.rb
54
- - lib/import_everything/parsers/parser.rb
55
- - lib/import_everything/parsers/preview.rb
56
197
  - lib/import_everything/parsers/sql_parser.rb
57
198
  - lib/import_everything/parsers/sqlite_parser.rb
58
199
  - lib/import_everything/parsers/table_parser.rb
59
200
  - lib/import_everything/parsers/xml_parser.rb
201
+ - lib/import_everything/preview.rb
60
202
  - spec/bets.html
61
203
  - spec/csv_parser_spec.rb
204
+ - spec/helpers/test_db.rb
62
205
  - spec/howard.html
63
206
  - spec/import_everything_spec.rb
64
207
  - spec/junk.rb
@@ -70,42 +213,36 @@ files:
70
213
  - spec/sql_parser_spec.rb
71
214
  - spec/sqlite_parser_spec.rb
72
215
  - spec/xml_parser_spec.rb
73
- has_rdoc: true
216
+ - vol/filename_meth.rb
217
+ - vol/test_db_test.rb
218
+ - vol/web_test.rb
219
+ - yard_ext.rb
74
220
  homepage: http://github.com/mharris717/import_everything
75
- licenses: []
76
-
221
+ licenses:
222
+ - MIT
77
223
  post_install_message:
78
- rdoc_options:
79
- - --charset=UTF-8
80
- require_paths:
224
+ rdoc_options: []
225
+ require_paths:
81
226
  - lib
82
- required_ruby_version: !ruby/object:Gem::Requirement
83
- requirements:
84
- - - ">="
85
- - !ruby/object:Gem::Version
86
- segments:
87
- - 0
88
- version: "0"
89
- required_rubygems_version: !ruby/object:Gem::Requirement
90
- requirements:
91
- - - ">="
92
- - !ruby/object:Gem::Version
93
- segments:
227
+ required_ruby_version: !ruby/object:Gem::Requirement
228
+ none: false
229
+ requirements:
230
+ - - ! '>='
231
+ - !ruby/object:Gem::Version
232
+ version: '0'
233
+ segments:
94
234
  - 0
95
- version: "0"
235
+ hash: 4495039761905964226
236
+ required_rubygems_version: !ruby/object:Gem::Requirement
237
+ none: false
238
+ requirements:
239
+ - - ! '>='
240
+ - !ruby/object:Gem::Version
241
+ version: '0'
96
242
  requirements: []
97
-
98
243
  rubyforge_project:
99
- rubygems_version: 1.3.6
244
+ rubygems_version: 1.8.23
100
245
  signing_key:
101
246
  specification_version: 3
102
247
  summary: import everything
103
- test_files:
104
- - spec/csv_parser_spec.rb
105
- - spec/import_everything_spec.rb
106
- - spec/junk.rb
107
- - spec/preview_spec.rb
108
- - spec/spec_helper.rb
109
- - spec/sql_parser_spec.rb
110
- - spec/sqlite_parser_spec.rb
111
- - spec/xml_parser_spec.rb
248
+ test_files: []
data/.gitignore DELETED
@@ -1,5 +0,0 @@
1
- *.sw?
2
- .DS_Store
3
- coverage
4
- rdoc
5
- pkg