flat 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: be700e7320f4e0c2d35a1650f4d08895f04da130
4
- data.tar.gz: b6c43776d503c1b5d926e7121f271d5aaa0605a1
3
+ metadata.gz: 99c7f84c4245def870567eef114988efeca938eb
4
+ data.tar.gz: bc2587ff14922dc820249b58363f35507aafc076
5
5
  SHA512:
6
- metadata.gz: ca937d39bc3cc607ef0b6d066a0d4b15ac347b3383055efee7c89192318a3d4aa105ff416f2c05d82db0aa7858b293e17cc7992926f30852a77710070fe664dc
7
- data.tar.gz: 46e3147cc64f7ddaa666a4c96e953d12c61ad348c2da8357aa2d78943fffdcb0c4aa67efcb33668e84ebc4c0d104bf8fb3f2cff75949128682b3c257f5d1c3cb
6
+ metadata.gz: 1955d8f34380cde105aa1570a84f30bffe1f22fa29a2a378cf9cdca218c1ab5b951dfbd1eca3094bfb880de914a1a14e927805706b0ed081f72d9938a03fa231
7
+ data.tar.gz: 2ba529f8cfd71e2e96770da602569824cf4ce080dd5dcedf1ce11b30215b9fe3c9af2f596fa52043540dd062bfdf43f6693c1af54133cb6caddd6d70a2f23c04
@@ -20,3 +20,30 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
20
  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
21
  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
22
  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+
24
+ ----------------------------------------
25
+ ----------------------------------------
26
+
27
+ Some portions of blank.rb are verbatim copies of software
28
+ licensed under the MIT license. That license is included below:
29
+
30
+ Copyright (c) 2005-2008 David Heinemeier Hansson
31
+
32
+ Permission is hereby granted, free of charge, to any person obtaining
33
+ a copy of this software and associated documentation files (the
34
+ "Software"), to deal in the Software without restriction, including
35
+ without limitation the rights to use, copy, modify, merge, publish,
36
+ distribute, sublicense, and/or sell copies of the Software, and to
37
+ permit persons to whom the Software is furnished to do so, subject to
38
+ the following conditions:
39
+
40
+ The above copyright notice and this permission notice shall be
41
+ included in all copies or substantial portions of the Software.
42
+
43
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
44
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
45
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
46
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
47
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
48
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
49
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -28,8 +28,6 @@ Gem::Specification.new do |spec|
28
28
  "wiki" => "https://github.com/juicyparts/flat/wiki",
29
29
  }
30
30
 
31
- spec.add_runtime_dependency "extlib", "~> 0.9.0"
32
-
33
31
  spec.add_development_dependency "bundler", ">= 1.6.2" # was "~> 1.7"
34
32
  spec.add_development_dependency "rake", "~> 10.0"
35
33
  spec.add_development_dependency "rdoc", ">= 3.12" # was "~> 4.1.0"
@@ -0,0 +1,89 @@
1
+ class Object
2
+ ##
3
+ # Returns true if the object is nil or empty (if applicable)
4
+ #
5
+ # [].blank? #=> true
6
+ # [1].blank? #=> false
7
+ # [nil].blank? #=> false
8
+ #
9
+ # @return [TrueClass, FalseClass]
10
+ #
11
+ # @api public
12
+ def blank?
13
+ nil? || (respond_to?(:empty?) && empty?)
14
+ end
15
+ end # class Object
16
+
17
+ class Numeric
18
+ ##
19
+ # Numerics are never blank
20
+ #
21
+ # 0.blank? #=> false
22
+ # 1.blank? #=> false
23
+ # 6.54321.blank? #=> false
24
+ #
25
+ # @return [FalseClass]
26
+ #
27
+ # @api public
28
+ def blank?
29
+ false
30
+ end
31
+ end # class Numeric
32
+
33
+ class NilClass
34
+ ##
35
+ # Nil is always blank
36
+ #
37
+ # nil.blank? #=> true
38
+ #
39
+ # @return [TrueClass]
40
+ #
41
+ # @api public
42
+ def blank?
43
+ true
44
+ end
45
+ end # class NilClass
46
+
47
+ class TrueClass
48
+ ##
49
+ # True is never blank.
50
+ #
51
+ # true.blank? #=> false
52
+ #
53
+ # @return [FalseClass]
54
+ #
55
+ # @api public
56
+ def blank?
57
+ false
58
+ end
59
+ end # class TrueClass
60
+
61
+ class FalseClass
62
+ ##
63
+ # False is always blank.
64
+ #
65
+ # false.blank? #=> true
66
+ #
67
+ # @return [TrueClass]
68
+ #
69
+ # @api public
70
+ def blank?
71
+ true
72
+ end
73
+ end # class FalseClass
74
+
75
+ class String
76
+ ##
77
+ # Strips out whitespace then tests if the string is empty.
78
+ #
79
+ # "".blank? #=> true
80
+ # " ".blank? #=> true
81
+ # " hey ho ".blank? #=> false
82
+ #
83
+ # @return [TrueClass, FalseClass]
84
+ #
85
+ # @api public
86
+ def blank?
87
+ strip.empty?
88
+ end
89
+ end # class String
@@ -1,8 +1,8 @@
1
- require 'extlib'
1
+ require 'extlib/blank'
2
2
 
3
3
  require 'flat/version'
4
4
  require 'flat/file'
5
5
 
6
6
  module Flat #:nodoc
7
- include Extlib
7
+
8
8
  end
@@ -20,13 +20,13 @@ module Errors #:nodoc:
20
20
 
21
21
  # = ShortRecordError
22
22
  #
23
- # The incoming line was shorter than expections defined.
23
+ # The incoming line was shorter than the defined width.
24
24
  #
25
25
  class ShortRecordError < RecordLengthError; end
26
26
 
27
27
  # = LongRecordError
28
28
  #
29
- # The incoming line was longer than expections defined.
29
+ # The incoming line was longer than the defined width.
30
30
  #
31
31
  class LongRecordError < RecordLengthError; end
32
32
 
@@ -36,7 +36,7 @@ module Field
36
36
 
37
37
  yield field_def if block_given?
38
38
 
39
- pack_format << "A#{field_def.width}"
39
+ pack_format << field_def.pack_format
40
40
  self.width += field_def.width
41
41
 
42
42
  # TODO: Add a check here to ensure the Field has a name specified; it can be a String or Symbol
@@ -85,7 +85,8 @@ module Field
85
85
  # end
86
86
  #
87
87
  class Definition #:nodoc:
88
- attr_accessor :parent, :name, :width, :padding, :aggressive
88
+ attr_reader :parent
89
+ attr_accessor :name, :width
89
90
  attr_accessor :filters, :formatters, :map_in_proc
90
91
 
91
92
  ##
@@ -120,6 +121,14 @@ module Field
120
121
  @aggressive
121
122
  end
122
123
 
124
+ #
125
+ # TODO: Find out what's capable with this pack foramat;
126
+ # String#pack, String#unpack
127
+ #
128
+ def pack_format
129
+ "A#{width}"
130
+ end
131
+
123
132
  ##
124
133
  # Add a filter. Filters are used for processing field data when a flat file is
125
134
  # being processed. For fomratting the data when writing a flat file, see
@@ -1,3 +1,3 @@
1
1
  module Flat #:nodoc:
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mel Riffe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-27 00:00:00.000000000 Z
11
+ date: 2014-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: extlib
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: 0.9.0
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: 0.9.0
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: bundler
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -189,6 +175,7 @@ files:
189
175
  - LICENSE.txt
190
176
  - README.md
191
177
  - flat.gemspec
178
+ - lib/extlib/blank.rb
192
179
  - lib/flat.rb
193
180
  - lib/flat/errors.rb
194
181
  - lib/flat/field.rb