excel_validator 0.0.1 → 0.0.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 +7 -0
- data/.gitignore +17 -17
- data/Gemfile +4 -4
- data/LICENSE.txt +22 -22
- data/README.md +82 -83
- data/Rakefile +5 -5
- data/excel_validator.gemspec +26 -26
- data/lib/excel_validator.rb +107 -107
- data/lib/excel_validator/version.rb +3 -3
- metadata +13 -23
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 33099e03a7c11ca16a7b3454c551653e37aedebe
|
4
|
+
data.tar.gz: 366f422739e2f0b7537be1df3d80d23a1ddb1755
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 21e08e804cf0692da465095502557407c09a71fb8390b44ca686ed0ca63f5cc3590750d16ce075a4cacba67ca7ff1d2da26c3e733045c719247173435d10f471
|
7
|
+
data.tar.gz: de66ede59e230ec711a789159022439c4b5edf5a63c616da9dcc4a5b38470b89fdb91f157fe06eb3333d14795807419cefaea518bdfc0277c9cc6d1edea039e1
|
data/.gitignore
CHANGED
@@ -1,17 +1,17 @@
|
|
1
|
-
*.gem
|
2
|
-
*.rbc
|
3
|
-
.bundle
|
4
|
-
.config
|
5
|
-
.yardoc
|
6
|
-
Gemfile.lock
|
7
|
-
InstalledFiles
|
8
|
-
_yardoc
|
9
|
-
coverage
|
10
|
-
doc/
|
11
|
-
lib/bundler/man
|
12
|
-
pkg
|
13
|
-
rdoc
|
14
|
-
spec/reports
|
15
|
-
test/tmp
|
16
|
-
test/version_tmp
|
17
|
-
tmp
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
data/Gemfile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
# Specify your gem's dependencies in excel_validator.gemspec
|
4
|
-
gemspec
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in excel_validator.gemspec
|
4
|
+
gemspec
|
data/LICENSE.txt
CHANGED
@@ -1,22 +1,22 @@
|
|
1
|
-
Copyright (c) 2014 Aaditi Jain
|
2
|
-
|
3
|
-
MIT License
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
a copy of this software and associated documentation files (the
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
the following conditions:
|
12
|
-
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
included in all copies or substantial portions of the Software.
|
15
|
-
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
1
|
+
Copyright (c) 2014 Aaditi Jain
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,83 +1,82 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
5. Create new Pull Request
|
1
|
+
[](http://badge.fury.io/rb/excel_validator)
|
2
|
+
# ExcelValidator
|
3
|
+
|
4
|
+
provides methods to validate the content of an excel(xls/xlsx) file
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
`gem 'excel_validator'`
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
`$ bundle`
|
13
|
+
|
14
|
+
Or install it yourself as:
|
15
|
+
`$ gem install excel_validator`
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
**require 'excel_validator'**
|
19
|
+
|
20
|
+
**f = ExcelValidator::ValidateFile.new(file_name, file_path)**
|
21
|
+
|
22
|
+
1) **f.number_of_sheets_is?(5)**
|
23
|
+
|
24
|
+
#returns true if the number of sheets in the file is 5.
|
25
|
+
|
26
|
+
2) **f.names_of_sheets_are?({1: 'Banks', 2: 'Countries', 3: 'Metrics'})**
|
27
|
+
|
28
|
+
#returns true if the names of the sheets at each position is as specified. If the names are case sensitive , do f.names_of_sheets_are?({1: 'Banks', 2: 'Countries', 3: 'Metrics'}, true)
|
29
|
+
|
30
|
+
|
31
|
+
3) **f.first_row_is?(2, 5)**
|
32
|
+
|
33
|
+
#returns true if the first non-empty row of 2nd sheet in the file is 12
|
34
|
+
|
35
|
+
|
36
|
+
4) **f.last_row_is?(2,100)**
|
37
|
+
|
38
|
+
#returns true if the first non-empty row of 2nd sheet in the file is 100
|
39
|
+
|
40
|
+
|
41
|
+
5) **f.first_column_is?(2, 'B')**
|
42
|
+
|
43
|
+
#returns true if the first non-empty row of 2nd sheet in the file is 'B'
|
44
|
+
|
45
|
+
|
46
|
+
6) **f.last_column_is?(2, 'CK')**
|
47
|
+
|
48
|
+
#returns true if the first non-empty row of 2nd sheet in the file is 'CK'
|
49
|
+
|
50
|
+
|
51
|
+
7) **f.column_is_empty?(2, 'B')**
|
52
|
+
|
53
|
+
#returns true if the 'B' column of 2nd sheet in the file is completely empty
|
54
|
+
|
55
|
+
|
56
|
+
8) **f.row_is_empty?(2, 12)**
|
57
|
+
|
58
|
+
#returns true if the 12th row of 2nd sheet in the file is completely empty
|
59
|
+
|
60
|
+
|
61
|
+
9) **f.content_of_cell_is?(2, 3, 'C', 'Location', true)**
|
62
|
+
|
63
|
+
#returns true if at 2nd sheet in the file Row3, Column C, content is 'Location'. If the content is case sensitive , do
|
64
|
+
|
65
|
+
|
66
|
+
10) **f.empty_sheets_present?**
|
67
|
+
|
68
|
+
#returns true if there are empty sheets present in the file.
|
69
|
+
|
70
|
+
|
71
|
+
11) **f.keyword_present?(2, 'ClassA')**
|
72
|
+
|
73
|
+
#returns true if keyword 'ClassA' is present the 2nd sheet of the file. If the keyword is case sensitive, do f.keyword_present?(2, 'ClassA', true)
|
74
|
+
|
75
|
+
|
76
|
+
## Contributing
|
77
|
+
|
78
|
+
1. Fork it
|
79
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
80
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
81
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
82
|
+
5. Create new Pull Request
|
data/Rakefile
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
require "bundler/gem_tasks"
|
2
|
-
require "rspec/core/rake_task"
|
3
|
-
|
4
|
-
RSpec::Core::RakeTask.new
|
5
|
-
task test: :spec
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rspec/core/rake_task"
|
3
|
+
|
4
|
+
RSpec::Core::RakeTask.new
|
5
|
+
task test: :spec
|
data/excel_validator.gemspec
CHANGED
@@ -1,26 +1,26 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'excel_validator/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "excel_validator"
|
8
|
-
spec.version = ExcelValidator::VERSION
|
9
|
-
spec.authors = ["Aaditi Jain"]
|
10
|
-
spec.email = ["aaditi2290@gmail.com"]
|
11
|
-
spec.description = %q{provides methods to
|
12
|
-
spec.summary = %q{provides methods to
|
13
|
-
spec.homepage = "https://github.com/Aaditi/excel_validator.git"
|
14
|
-
spec.license = "MIT"
|
15
|
-
|
16
|
-
spec.files = `git ls-files`.split($/)
|
17
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = ["lib"]
|
20
|
-
|
21
|
-
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
-
spec.add_development_dependency "rake"
|
23
|
-
spec.add_development_dependency "rspec"
|
24
|
-
|
25
|
-
spec.add_runtime_dependency "roo", "~> 1.13.2"
|
26
|
-
end
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'excel_validator/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "excel_validator"
|
8
|
+
spec.version = ExcelValidator::VERSION
|
9
|
+
spec.authors = ["Aaditi Jain"]
|
10
|
+
spec.email = ["aaditi2290@gmail.com"]
|
11
|
+
spec.description = %q{provides methods to validate the content of an excel(xls/xlsx) file}
|
12
|
+
spec.summary = %q{provides methods to validate the content of an excel(xls/xlsx) file}
|
13
|
+
spec.homepage = "https://github.com/Aaditi/excel_validator.git"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "rspec"
|
24
|
+
|
25
|
+
spec.add_runtime_dependency "roo", "~> 1.13.2"
|
26
|
+
end
|
data/lib/excel_validator.rb
CHANGED
@@ -1,107 +1,107 @@
|
|
1
|
-
require "excel_validator/version"
|
2
|
-
module ExcelValidator
|
3
|
-
class ValidateFile
|
4
|
-
require "roo"
|
5
|
-
|
6
|
-
def initialize(file_name,file_path)
|
7
|
-
case File.extname(file_name)
|
8
|
-
when ".xls"
|
9
|
-
@file = Roo::Excel.new(file_path)
|
10
|
-
when ".xlsx"
|
11
|
-
@file = Roo::Excelx.new(file_path)
|
12
|
-
else raise "Not a Excel / Excelx File"
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
#counts the number of sheets in the file.
|
17
|
-
#sheet_number: should be an integer
|
18
|
-
def number_of_sheets_is?(sheet_number)
|
19
|
-
@file.sheets.count == sheet_number ? true : false
|
20
|
-
end
|
21
|
-
|
22
|
-
#checks the names of the sheets in the file
|
23
|
-
#sheets_hash: should be a hash with key, value as position, name respectively. Example: {1: 'Bank', 2: 'Metric', 7: 'Country'}
|
24
|
-
def names_of_sheets_are?(sheets_hash, case_sensitive = false)
|
25
|
-
sheets_hash.each do |key, value|
|
26
|
-
if ( case_sensitive ? (@file.sheets[(key.to_i - 1)] != value) : (@file.sheets[(key.to_i - 1)].to_s.downcase != value.to_s.downcase ))
|
27
|
-
return false
|
28
|
-
end
|
29
|
-
end
|
30
|
-
true
|
31
|
-
end
|
32
|
-
|
33
|
-
#checks that the first non_empty row in the sheet is as specified
|
34
|
-
def first_row_is?(sheet_number, row_number)
|
35
|
-
set_default_sheet(sheet_number)
|
36
|
-
@file.first_row == row_number ? true : false
|
37
|
-
end
|
38
|
-
|
39
|
-
#checks that the last non_empty row in the sheet is as specified
|
40
|
-
def last_row_is?(sheet_number, row_number)
|
41
|
-
set_default_sheet(sheet_number)
|
42
|
-
@file.last_row == row_number ? true : false
|
43
|
-
end
|
44
|
-
|
45
|
-
#checks that the first non_empty column in the sheet is as specified
|
46
|
-
def first_column_is?(sheet_number, column_number)
|
47
|
-
set_default_sheet(sheet_number)
|
48
|
-
@file.first_column_as_letter == column_number ? true : false
|
49
|
-
end
|
50
|
-
|
51
|
-
#checks that the last non_empty column in the sheet is as specified
|
52
|
-
def last_column_is?(sheet_number, column_number)
|
53
|
-
set_default_sheet(sheet_number)
|
54
|
-
@file.last_column_as_letter == column_number ? true : false
|
55
|
-
end
|
56
|
-
|
57
|
-
#checks if the content at the specified row and column is as required
|
58
|
-
def content_of_cell_is?(sheet_number, row, column, content, case_sensitive=false)
|
59
|
-
set_default_sheet(sheet_number)
|
60
|
-
return ( (case_sensitive) ? (@file.cell(row,column).to_s == content.to_s) : (@file.cell(row,column).to_s.downcase == content.to_s.downcase))
|
61
|
-
end
|
62
|
-
|
63
|
-
|
64
|
-
#checks if the specified column is empty
|
65
|
-
def column_is_empty?(sheet_number, column)
|
66
|
-
set_default_sheet(sheet_number)
|
67
|
-
@file.first_row.upto @file.last_row do |row|
|
68
|
-
return false if @file.cell(row,column).nil? != true
|
69
|
-
end
|
70
|
-
true
|
71
|
-
end
|
72
|
-
|
73
|
-
#checks if the specified row is empty
|
74
|
-
def row_is_empty?(sheet_number, row)
|
75
|
-
@file.first_column.upto @file.last_column do |column|
|
76
|
-
return false if @file.cell(row,column).nil? != true
|
77
|
-
end
|
78
|
-
true
|
79
|
-
end
|
80
|
-
|
81
|
-
#Returns true if there is an empty sheet in the file
|
82
|
-
def empty_sheets_present?
|
83
|
-
@file.sheets.count.times do |sheet_number|
|
84
|
-
set_default_sheet(sheet_number + 1)
|
85
|
-
@file.first_row ? next : (return true)
|
86
|
-
end
|
87
|
-
false
|
88
|
-
end
|
89
|
-
|
90
|
-
#Checks if a keyword is present in the sheet
|
91
|
-
def keyword_present?(sheet_number, keyword, case_sensitive=false )
|
92
|
-
set_default_sheet(sheet_number)
|
93
|
-
@file.first_row.upto @file.last_row do |row|
|
94
|
-
@file.first_column.upto @file.last_column do |column|
|
95
|
-
return true if ( (case_sensitive) ? @file.cell(row, column) == keyword : @file.cell(row, column).to_s.downcase == keyword.to_s.downcase )
|
96
|
-
end
|
97
|
-
end
|
98
|
-
false
|
99
|
-
end
|
100
|
-
|
101
|
-
private
|
102
|
-
def set_default_sheet(sheet_number)
|
103
|
-
@file.default_sheet = @file.sheets[sheet_number - 1]
|
104
|
-
end
|
105
|
-
|
106
|
-
end #class end
|
107
|
-
end #module end
|
1
|
+
require "excel_validator/version"
|
2
|
+
module ExcelValidator
|
3
|
+
class ValidateFile
|
4
|
+
require "roo"
|
5
|
+
|
6
|
+
def initialize(file_name,file_path)
|
7
|
+
case File.extname(file_name)
|
8
|
+
when ".xls"
|
9
|
+
@file = Roo::Excel.new(file_path)
|
10
|
+
when ".xlsx"
|
11
|
+
@file = Roo::Excelx.new(file_path)
|
12
|
+
else raise "Not a Excel / Excelx File"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
#counts the number of sheets in the file.
|
17
|
+
#sheet_number: should be an integer
|
18
|
+
def number_of_sheets_is?(sheet_number)
|
19
|
+
@file.sheets.count == sheet_number ? true : false
|
20
|
+
end
|
21
|
+
|
22
|
+
#checks the names of the sheets in the file
|
23
|
+
#sheets_hash: should be a hash with key, value as position, name respectively. Example: {1: 'Bank', 2: 'Metric', 7: 'Country'}
|
24
|
+
def names_of_sheets_are?(sheets_hash, case_sensitive = false)
|
25
|
+
sheets_hash.each do |key, value|
|
26
|
+
if ( case_sensitive ? (@file.sheets[(key.to_i - 1)] != value) : (@file.sheets[(key.to_i - 1)].to_s.downcase != value.to_s.downcase ))
|
27
|
+
return false
|
28
|
+
end
|
29
|
+
end
|
30
|
+
true
|
31
|
+
end
|
32
|
+
|
33
|
+
#checks that the first non_empty row in the sheet is as specified
|
34
|
+
def first_row_is?(sheet_number, row_number)
|
35
|
+
set_default_sheet(sheet_number)
|
36
|
+
@file.first_row == row_number ? true : false
|
37
|
+
end
|
38
|
+
|
39
|
+
#checks that the last non_empty row in the sheet is as specified
|
40
|
+
def last_row_is?(sheet_number, row_number)
|
41
|
+
set_default_sheet(sheet_number)
|
42
|
+
@file.last_row == row_number ? true : false
|
43
|
+
end
|
44
|
+
|
45
|
+
#checks that the first non_empty column in the sheet is as specified
|
46
|
+
def first_column_is?(sheet_number, column_number)
|
47
|
+
set_default_sheet(sheet_number)
|
48
|
+
@file.first_column_as_letter == column_number ? true : false
|
49
|
+
end
|
50
|
+
|
51
|
+
#checks that the last non_empty column in the sheet is as specified
|
52
|
+
def last_column_is?(sheet_number, column_number)
|
53
|
+
set_default_sheet(sheet_number)
|
54
|
+
@file.last_column_as_letter == column_number ? true : false
|
55
|
+
end
|
56
|
+
|
57
|
+
#checks if the content at the specified row and column is as required
|
58
|
+
def content_of_cell_is?(sheet_number, row, column, content, case_sensitive=false)
|
59
|
+
set_default_sheet(sheet_number)
|
60
|
+
return ( (case_sensitive) ? (@file.cell(row,column).to_s == content.to_s) : (@file.cell(row,column).to_s.downcase == content.to_s.downcase))
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
#checks if the specified column is empty
|
65
|
+
def column_is_empty?(sheet_number, column)
|
66
|
+
set_default_sheet(sheet_number)
|
67
|
+
@file.first_row.upto @file.last_row do |row|
|
68
|
+
return false if @file.cell(row,column).nil? != true
|
69
|
+
end
|
70
|
+
true
|
71
|
+
end
|
72
|
+
|
73
|
+
#checks if the specified row is empty
|
74
|
+
def row_is_empty?(sheet_number, row)
|
75
|
+
@file.first_column.upto @file.last_column do |column|
|
76
|
+
return false if @file.cell(row,column).nil? != true
|
77
|
+
end
|
78
|
+
true
|
79
|
+
end
|
80
|
+
|
81
|
+
#Returns true if there is an empty sheet in the file
|
82
|
+
def empty_sheets_present?
|
83
|
+
@file.sheets.count.times do |sheet_number|
|
84
|
+
set_default_sheet(sheet_number + 1)
|
85
|
+
@file.first_row ? next : (return true)
|
86
|
+
end
|
87
|
+
false
|
88
|
+
end
|
89
|
+
|
90
|
+
#Checks if a keyword is present in the sheet
|
91
|
+
def keyword_present?(sheet_number, keyword, case_sensitive=false )
|
92
|
+
set_default_sheet(sheet_number)
|
93
|
+
@file.first_row.upto @file.last_row do |row|
|
94
|
+
@file.first_column.upto @file.last_column do |column|
|
95
|
+
return true if ( (case_sensitive) ? @file.cell(row, column) == keyword : @file.cell(row, column).to_s.downcase == keyword.to_s.downcase )
|
96
|
+
end
|
97
|
+
end
|
98
|
+
false
|
99
|
+
end
|
100
|
+
|
101
|
+
private
|
102
|
+
def set_default_sheet(sheet_number)
|
103
|
+
@file.default_sheet = @file.sheets[sheet_number - 1]
|
104
|
+
end
|
105
|
+
|
106
|
+
end #class end
|
107
|
+
end #module end
|
@@ -1,3 +1,3 @@
|
|
1
|
-
module ExcelValidator
|
2
|
-
VERSION = "0.0.
|
3
|
-
end
|
1
|
+
module ExcelValidator
|
2
|
+
VERSION = "0.0.2"
|
3
|
+
end
|
metadata
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: excel_validator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Aaditi Jain
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-19 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: bundler
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -22,7 +20,6 @@ dependencies:
|
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ~>
|
28
25
|
- !ruby/object:Gem::Version
|
@@ -30,39 +27,34 @@ dependencies:
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rake
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - '>='
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - '>='
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: rspec
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - '>='
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - '>='
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: roo
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
59
|
- - ~>
|
68
60
|
- !ruby/object:Gem::Version
|
@@ -70,12 +62,11 @@ dependencies:
|
|
70
62
|
type: :runtime
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
66
|
- - ~>
|
76
67
|
- !ruby/object:Gem::Version
|
77
68
|
version: 1.13.2
|
78
|
-
description: provides methods to
|
69
|
+
description: provides methods to validate the content of an excel(xls/xlsx) file
|
79
70
|
email:
|
80
71
|
- aaditi2290@gmail.com
|
81
72
|
executables: []
|
@@ -96,28 +87,27 @@ files:
|
|
96
87
|
homepage: https://github.com/Aaditi/excel_validator.git
|
97
88
|
licenses:
|
98
89
|
- MIT
|
90
|
+
metadata: {}
|
99
91
|
post_install_message:
|
100
92
|
rdoc_options: []
|
101
93
|
require_paths:
|
102
94
|
- lib
|
103
95
|
required_ruby_version: !ruby/object:Gem::Requirement
|
104
|
-
none: false
|
105
96
|
requirements:
|
106
|
-
- -
|
97
|
+
- - '>='
|
107
98
|
- !ruby/object:Gem::Version
|
108
99
|
version: '0'
|
109
100
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
|
-
none: false
|
111
101
|
requirements:
|
112
|
-
- -
|
102
|
+
- - '>='
|
113
103
|
- !ruby/object:Gem::Version
|
114
104
|
version: '0'
|
115
105
|
requirements: []
|
116
106
|
rubyforge_project:
|
117
|
-
rubygems_version:
|
107
|
+
rubygems_version: 2.0.14
|
118
108
|
signing_key:
|
119
|
-
specification_version:
|
120
|
-
summary: provides methods to
|
109
|
+
specification_version: 4
|
110
|
+
summary: provides methods to validate the content of an excel(xls/xlsx) file
|
121
111
|
test_files:
|
122
112
|
- spec/fixtures/test_excel.xlsx
|
123
113
|
- spec/lib/excel_validator_spec.rb
|