NCIRLFileUploader 0.0.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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/ncirl_file_uploader.rb +27 -0
  3. metadata +43 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4077a0fa70e49cbc166456f36ee58091b2a43514
4
+ data.tar.gz: 82c815628079e37e5845d7870767d91be049186f
5
+ SHA512:
6
+ metadata.gz: f761b1807a47668ed4ba549473b324d421f0ba691e7e538e9839341956068564f7c4572cc5c90b762652203b27a11d96f798bcbeea3f8d58c74e298c0786d625
7
+ data.tar.gz: baf15fdd4b79a539f176f2e0e4d5a7368230f833722d9b3d090203dfe18a90d7be14d60501a44bbae8adf9ca23a7f425492dee24d18f2505ba1754ed23e82ecf
@@ -0,0 +1,27 @@
1
+ require 'csv'
2
+ class NCIRLFileUploader
3
+
4
+ def self.upload(file, type)
5
+ @uploaded = file
6
+ File.open("fromimporter.csv", 'wb') do |file|
7
+ file.write(@uploaded.read)
8
+ end
9
+
10
+ if type == "Room"
11
+ CSV.foreach('fromimporter.csv', headers: true) do |row|
12
+ Room.create(row.to_h)
13
+ end
14
+ end
15
+ if type == "Course"
16
+ CSV.foreach('fromimporter.csv', headers: true) do |row|
17
+ Course.create(row.to_h)
18
+ end
19
+ end
20
+
21
+ if type == "Subject"
22
+ CSV.foreach('fromimporter.csv', headers: true) do |row|
23
+ Subject.create(row.to_h)
24
+ end
25
+ end
26
+ end
27
+ end
metadata ADDED
@@ -0,0 +1,43 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: NCIRLFileUploader
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - '13127390'
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-12-01 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: For loading CSV files into the Timetable Application
14
+ email: 13127390@noreply.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - ncirl_file_uploader.rb
20
+ homepage: http://rubygems.org/gems/ncirlfileuploader
21
+ licenses: []
22
+ metadata: {}
23
+ post_install_message:
24
+ rdoc_options: []
25
+ require_paths:
26
+ - lib
27
+ required_ruby_version: !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: '0'
32
+ required_rubygems_version: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ requirements: []
38
+ rubyforge_project:
39
+ rubygems_version: 2.6.14
40
+ signing_key:
41
+ specification_version: 4
42
+ summary: CSV File Loader
43
+ test_files: []