SimpleCSVUploder 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/SimpleCSVUploder/version.rb +1 -1
- data/lib/SimpleCSVUploder.rb +12 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e0dc6cb8b3be93731c01718cb6440a0ea721b9c
|
4
|
+
data.tar.gz: c2de4dc049c7f2d7131598da3069cc44ddb541e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0dec33292f0f849b21cb7e942c77625b444e0c55e4912b293e8f1e221f32e2e41685a181ee72af8e452d034818f1230728c5b689a7a151b1d75c6353853b375f
|
7
|
+
data.tar.gz: 411d38f691b5e7ddede05e1ecf6829eb470a75e4a27a7204f7e49fa0c01d9892ff11bc3fbbb2d5073a0004546267fa868cd83d525bd85587e645f493172a8c72
|
data/lib/SimpleCSVUploder.rb
CHANGED
@@ -11,12 +11,24 @@ module SimpleCSVUploder
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
+
def upload_local
|
15
|
+
path = "#{Rails.root}/public/uploads/csv"
|
16
|
+
FileUtils.mkdir_p(path) unless File.exists?(path)
|
17
|
+
FileUtils.copy(@file.tempfile, path)
|
18
|
+
end
|
19
|
+
|
14
20
|
private
|
15
21
|
|
16
22
|
def sanitize_filename(filename)
|
17
23
|
return File.basename(filename)
|
18
24
|
end
|
19
25
|
|
26
|
+
def csv_file_format
|
27
|
+
if self.content_type != "text/csv"
|
28
|
+
errors.add(:file, 'File format should be only CSV.')
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
20
32
|
NUM_BYTES_IN_MEGABYTE = 1048576
|
21
33
|
def file_size_under_one_mb
|
22
34
|
if (@file.size.to_f / NUM_BYTES_IN_MEGABYTE) > 1
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: SimpleCSVUploder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- saroar
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-09-
|
11
|
+
date: 2017-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|