morph 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +2 -0
- data/lib/morph.rb +11 -9
- data/morph.gemspec +1 -1
- metadata +3 -3
data/CHANGELOG
CHANGED
data/lib/morph.rb
CHANGED
@@ -1,12 +1,5 @@
|
|
1
1
|
if RUBY_VERSION >= "1.9"
|
2
2
|
require 'csv'
|
3
|
-
else
|
4
|
-
begin
|
5
|
-
require 'fastercsv'
|
6
|
-
rescue LoadError
|
7
|
-
puts "\nYou need to install the fastercsv gem to use Morph.from_csv with Ruby 1.8"
|
8
|
-
puts " sudo gem install fastercsv\n"
|
9
|
-
end
|
10
3
|
end
|
11
4
|
begin
|
12
5
|
# require 'active_support'
|
@@ -25,7 +18,7 @@ rescue Exception => e
|
|
25
18
|
end
|
26
19
|
|
27
20
|
module Morph
|
28
|
-
VERSION = "0.3.
|
21
|
+
VERSION = "0.3.1"
|
29
22
|
|
30
23
|
class << self
|
31
24
|
def generate_migrations object, options={}
|
@@ -38,7 +31,16 @@ module Morph
|
|
38
31
|
|
39
32
|
def from_csv csv, class_name, namespace=Morph
|
40
33
|
objects = []
|
41
|
-
|
34
|
+
if !(RUBY_VERSION >= "1.9")
|
35
|
+
begin
|
36
|
+
require 'fastercsv'
|
37
|
+
rescue LoadError
|
38
|
+
puts "\nYou need to install the fastercsv gem to use Morph.from_csv() with Ruby 1.8"
|
39
|
+
puts " gem install fastercsv\n"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
csv_utility = (RUBY_VERSION >= "1.9") ? CSV : 'FasterCSV'.constantize
|
42
44
|
csv_utility.parse(csv, { :headers => true }) do |row|
|
43
45
|
object = object_from_name class_name, namespace
|
44
46
|
row.each do |key, value|
|
data/morph.gemspec
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: morph
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 1
|
10
|
+
version: 0.3.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Rob McKinnon
|