filetype_validation 0.1.1 → 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 +4 -4
- data/README.md +16 -2
- data/lib/filetype_validation/csv_validator.rb +3 -0
- data/lib/filetype_validation/version.rb +1 -1
- 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: 4c6578f287b418d2cdccabc34cf642f5e5eb0f9c
|
4
|
+
data.tar.gz: 5e1bfcd8bbb364d0862290c014438ba661a59fc1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 756803e9a16fe5d26531584d6f095ed5dc1be4ea78c65130f885e1ac93c8853c550b87c950c37dcb9f2b0139dfeef2d8dc70e11cb1c2255958a37c1efcf09a16
|
7
|
+
data.tar.gz: a197045fd4679828ddbb433fa67c99b0bcaf5615f4d47ffbf7f87a6a5750b532452421d4447eb0b3691ec7705abfadca51e772e3327d0e77ad43c0eb92fa0e66
|
data/README.md
CHANGED
@@ -20,7 +20,7 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
-
The gem currently supports csv file validation
|
23
|
+
The gem currently supports csv file validation:
|
24
24
|
|
25
25
|
```ruby
|
26
26
|
FiletypeValidation.csv?(file, options)
|
@@ -33,6 +33,20 @@ This specifies how many lines of the file the validator will use to decide wheth
|
|
33
33
|
* `:headers`
|
34
34
|
This expects either `true` or `false` to denote whether the csv file's header will be included in the validation.
|
35
35
|
|
36
|
+
* `:skip_extension_check`
|
37
|
+
If true, the gem will exclude the check for a '.csv' extension on the filepath
|
38
|
+
|
39
|
+
The gem also supports plaintext file validation:
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
FiletypeValidation.plaintext?(file, options)
|
43
|
+
```
|
44
|
+
|
45
|
+
In this call, `file` is either a `String` representing the file path or the file itself and `options` is a `Hash` that enables the user to customize their call. The `options` parameter currently supports these customizations:
|
46
|
+
|
47
|
+
* `:bytes_to_read`
|
48
|
+
This specifies how many bytes of the start of the given file the gem will use to determine whether or not it's plaintext.
|
49
|
+
|
36
50
|
## Development
|
37
51
|
|
38
52
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -41,7 +55,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
41
55
|
|
42
56
|
## Contributing
|
43
57
|
|
44
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
58
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/optoro/filetype_validation. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
45
59
|
|
46
60
|
|
47
61
|
## License
|
@@ -18,9 +18,12 @@ module FiletypeValidation
|
|
18
18
|
private
|
19
19
|
|
20
20
|
# Checks if the file has a .csv extension
|
21
|
+
# Check is bypassed if :skip_extension_check flag is passed
|
21
22
|
#
|
22
23
|
# @return [Boolean] true if the file has a csv extension
|
23
24
|
def csv_extension?
|
25
|
+
return true if options[:skip_extension_check]
|
26
|
+
|
24
27
|
'.csv'.casecmp(File.extname(file.path))
|
25
28
|
.zero?
|
26
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: filetype_validation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joe Jacob
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|