import_everything_rails 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.rdoc +18 -0
- data/app/models/dataload.rb +85 -0
- data/lib/import_everything_rails/engine.rb +7 -0
- data/lib/import_everything_rails.rb +3 -0
- data/spec/import_everything_rails_spec.rb +7 -0
- data/spec/spec_helper.rb +9 -0
- metadata +70 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Mike Harris
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
= import_everything_rails
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Note on Patches/Pull Requests
|
6
|
+
|
7
|
+
* Fork the project.
|
8
|
+
* Make your feature addition or bug fix.
|
9
|
+
* Add tests for it. This is important so I don't break it in a
|
10
|
+
future version unintentionally.
|
11
|
+
* Commit, do not mess with rakefile, version, or history.
|
12
|
+
(if you want to have your own version, that is fine but
|
13
|
+
bump version in a commit by itself I can ignore when I pull)
|
14
|
+
* Send me a pull request. Bonus points for topic branches.
|
15
|
+
|
16
|
+
== Copyright
|
17
|
+
|
18
|
+
Copyright (c) 2010 Mike Harris. See LICENSE for details.
|
@@ -0,0 +1,85 @@
|
|
1
|
+
# class MockFile
|
2
|
+
# attr_accessor :filename, :read
|
3
|
+
# include FromHash
|
4
|
+
# end
|
5
|
+
|
6
|
+
class Dataload
|
7
|
+
include MongoMapper::Document
|
8
|
+
plugin Joint
|
9
|
+
attachment :file
|
10
|
+
key :coll_name
|
11
|
+
belongs_to :workspace
|
12
|
+
end
|
13
|
+
|
14
|
+
class Dataload
|
15
|
+
key :addl_ops, Hash
|
16
|
+
def method_missing(sym,*args,&b)
|
17
|
+
if sym.to_s[-1..-1] == '='
|
18
|
+
self.addl_ops[sym.to_s[0..-2]] = args.first
|
19
|
+
else
|
20
|
+
super
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# class Dataload
|
26
|
+
# attr_accessor :coll, :data, :url, :file, :workspace, :actual
|
27
|
+
# include FromHash
|
28
|
+
# fattr(:addl_ops) { {} }
|
29
|
+
# def import_ops
|
30
|
+
# {:file => get_file}.merge(addl_ops)
|
31
|
+
# end
|
32
|
+
# def save!
|
33
|
+
# ImportEverything.each_table_and_rows(:file => get_file) do |table,rows|
|
34
|
+
# c = workspace.get_or_create_coll(table.to_s)
|
35
|
+
# rows.each { |row| c.save(row) }
|
36
|
+
# c.invalidate_cache!
|
37
|
+
# end
|
38
|
+
# end
|
39
|
+
# fattr(:get_file) do
|
40
|
+
# if url.present?
|
41
|
+
# require 'open-uri'
|
42
|
+
# MockFile.new(:filename => url, :read => open(url, 'rb') { |f| f.read })
|
43
|
+
# elsif file.present?
|
44
|
+
# file
|
45
|
+
# else
|
46
|
+
# data
|
47
|
+
# end
|
48
|
+
# end
|
49
|
+
# fattr(:preview) { ImportEverything.preview(import_ops) }
|
50
|
+
# def to_json
|
51
|
+
# #save! if preview.ready?
|
52
|
+
# mylog "dataload", :ready => preview.ready?, :actual => actual
|
53
|
+
# if preview.ready?
|
54
|
+
# if actual
|
55
|
+
# save!
|
56
|
+
# {:ran => true}
|
57
|
+
# else
|
58
|
+
# mylog 'dataload', :stuff => 'ready not actual'
|
59
|
+
# res = {:addl_required_fields => preview.addl_required_fields, :result => true, :tables => preview.tables.map { |x| x.to_hash }}
|
60
|
+
# mylog 'dataload', :stuff => 'ready not actual 2'
|
61
|
+
# res
|
62
|
+
# end
|
63
|
+
# else
|
64
|
+
# {:addl_required_fields => preview.addl_required_fields, :result => false}
|
65
|
+
# end
|
66
|
+
# end
|
67
|
+
# def method_missing(sym,*args,&b)
|
68
|
+
# if sym.to_s[-1..-1] == '='
|
69
|
+
# self.addl_ops[sym.to_s[0..-2]] = args.first
|
70
|
+
# else
|
71
|
+
# super
|
72
|
+
# end
|
73
|
+
# end
|
74
|
+
# end
|
75
|
+
#
|
76
|
+
#
|
77
|
+
# class Dataload
|
78
|
+
# extend ActiveModel::Naming
|
79
|
+
# def to_key
|
80
|
+
# nil
|
81
|
+
# end
|
82
|
+
# def persisted?
|
83
|
+
# false
|
84
|
+
# end
|
85
|
+
# end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: import_everything_rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mike Harris
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-05-12 00:00:00 -04:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rspec
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
description: import_everything_rails
|
26
|
+
email: mharris717@gmail.com
|
27
|
+
executables: []
|
28
|
+
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files:
|
32
|
+
- LICENSE
|
33
|
+
- README.rdoc
|
34
|
+
files:
|
35
|
+
- app/models/dataload.rb
|
36
|
+
- lib/import_everything_rails.rb
|
37
|
+
- lib/import_everything_rails/engine.rb
|
38
|
+
- LICENSE
|
39
|
+
- README.rdoc
|
40
|
+
has_rdoc: true
|
41
|
+
homepage: http://github.com/mharris717/import_everything_rails
|
42
|
+
licenses: []
|
43
|
+
|
44
|
+
post_install_message:
|
45
|
+
rdoc_options:
|
46
|
+
- --charset=UTF-8
|
47
|
+
require_paths:
|
48
|
+
- lib
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: "0"
|
54
|
+
version:
|
55
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: "0"
|
60
|
+
version:
|
61
|
+
requirements: []
|
62
|
+
|
63
|
+
rubyforge_project:
|
64
|
+
rubygems_version: 1.3.5
|
65
|
+
signing_key:
|
66
|
+
specification_version: 3
|
67
|
+
summary: import_everything_rails
|
68
|
+
test_files:
|
69
|
+
- spec/import_everything_rails_spec.rb
|
70
|
+
- spec/spec_helper.rb
|