fast_xls_to_hash 0.1.2

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 77a106fe2833d8484cf1769ba40cd009e7feb2c1
4
+ data.tar.gz: c844d5b0f2a67dd957eaa9ae4659bfc44495aa0c
5
+ SHA512:
6
+ metadata.gz: c76f9a9f2a29a9014e8627cf3a9f2733c4be169b2d35f9cb7f4d1f26fd0d78f511ec06b97224c24cf4656fe970b88b1c33f108e8d12a8929c7c543277fa42dec
7
+ data.tar.gz: 016ffa016bade7d988c31a0e295c1705a31be5c5253d9cf2f2bc661abba83deaef72d236aca4e40adb95fcd5300bf3617eba7f23c5da9068bb0e8a487ce50c99
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/fast_xls_to_hash'
4
+
5
+ module FastXlsToHash
6
+ ERROR = 'I need xls file path'
7
+
8
+ dir = ARGV[0] ? ARGV[0] : return p ERROR
9
+ ParseXls.to_hash(dir)
10
+ end
11
+
@@ -0,0 +1,3 @@
1
+ module FastXlsToHash
2
+ VERSION = "0.1.2"
3
+ end
@@ -0,0 +1,42 @@
1
+ module FastXlsToHash
2
+
3
+ class ParseXls
4
+
5
+ FORMULA_ERROR = 'Error'
6
+
7
+ def self.to_hash(file)
8
+ book = Spreadsheet.open(file)
9
+
10
+ hash = Hash.new{ |hash, key| hash[key] = {} }
11
+ book.worksheets.each do |sheet|
12
+ sheet.each_with_index do |row, row_index|
13
+ hash[sheet.name.to_sym]["row_#{row_index + 1}".to_sym] = {}
14
+ row.each_with_index do |val, index|
15
+ if val.class == Spreadsheet::Formula
16
+ if val.value.class == Spreadsheet::Excel::Error
17
+ hash[sheet.name.to_sym]["row_#{row_index + 1}".to_sym]["column_#{index + 1}".to_sym] = FORMULA_ERROR
18
+ next
19
+ end
20
+ hash[sheet.name.to_sym]["row_#{row_index + 1}".to_sym]["column_#{index + 1}".to_sym] = val.value
21
+ else
22
+ hash[sheet.name.to_sym]["row_#{row_index + 1}".to_sym]["column_#{index + 1}".to_sym] = val
23
+ end
24
+ end
25
+ end
26
+ end
27
+
28
+ kill(book)
29
+
30
+ hash
31
+ end
32
+
33
+ private
34
+
35
+ def kill(object)
36
+ object = nil
37
+ GC.start
38
+ end
39
+
40
+ end
41
+
42
+ end
@@ -0,0 +1,5 @@
1
+ require "fast_xls_to_hash/version"
2
+ require "fast_xls_to_hash/xls/parse"
3
+
4
+ module FastXlsToHash
5
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe FastXlsToHash do
4
+ it 'has a version number' do
5
+ expect(FastXlsToHash::VERSION).not_to be nil
6
+ end
7
+
8
+ it 'does something useful' do
9
+ expect(false).to eq(true)
10
+ end
11
+ end
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'fast_xls_to_hash'
metadata ADDED
@@ -0,0 +1,123 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fast_xls_to_hash
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - woodcrust
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-06-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: spreadsheet
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.12'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.12'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: byebug
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Fast parsing xls to the hash
84
+ email:
85
+ - roboucrop@gmail.com
86
+ executables:
87
+ - fast_xls_to_hash
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - bin/fast_xls_to_hash
92
+ - lib/fast_xls_to_hash.rb
93
+ - lib/fast_xls_to_hash/version.rb
94
+ - lib/fast_xls_to_hash/xls/parse.rb
95
+ - spec/fast_xls_to_hash_spec.rb
96
+ - spec/spec_helper.rb
97
+ homepage: https://github.com/woodcrust/fast_xls_to_hash
98
+ licenses:
99
+ - MIT
100
+ metadata: {}
101
+ post_install_message:
102
+ rdoc_options: []
103
+ require_paths:
104
+ - lib
105
+ required_ruby_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ required_rubygems_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ requirements: []
116
+ rubyforge_project:
117
+ rubygems_version: 2.5.1
118
+ signing_key:
119
+ specification_version: 4
120
+ summary: This is xls parser
121
+ test_files:
122
+ - spec/fast_xls_to_hash_spec.rb
123
+ - spec/spec_helper.rb