danmunk-fixed_fields 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.
- data/Rakefile +1 -1
- data/fixed_fields.gemspec +2 -2
- data/lib/fixed_fields.rb +16 -5
- metadata +2 -2
data/Rakefile
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
2
2
|
require 'rake'
|
3
3
|
require 'echoe'
|
4
4
|
|
5
|
-
Echoe.new('fixed_fields', '0.1.
|
5
|
+
Echoe.new('fixed_fields', '0.1.2') do |f|
|
6
6
|
f.description = 'Helps map fields from fixed length record to an active record instance'
|
7
7
|
f.url = 'http://www.github.com/danmunk/fixed_fields'
|
8
8
|
f.author = 'Dan Munk'
|
data/fixed_fields.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{fixed_fields}
|
5
|
-
s.version = "0.1.
|
5
|
+
s.version = "0.1.2"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Dan Munk"]
|
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.description = %q{Helps map fields from fixed length record to an active record instance}
|
11
11
|
s.email = %q{danmunk@gmail.com}
|
12
12
|
s.extra_rdoc_files = ["lib/fixed_fields.rb", "README.rdoc"]
|
13
|
-
s.files = ["fixed_fields.gemspec", "github_test.rb", "init.rb", "lib/fixed_fields.rb", "Rakefile", "README.rdoc"
|
13
|
+
s.files = ["fixed_fields.gemspec", "github_test.rb", "init.rb", "lib/fixed_fields.rb", "Manifest", "Rakefile", "README.rdoc"]
|
14
14
|
s.has_rdoc = true
|
15
15
|
s.homepage = %q{http://www.github.com/danmunk/fixed_fields}
|
16
16
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Fixed_fields", "--main", "README.rdoc"]
|
data/lib/fixed_fields.rb
CHANGED
@@ -1,24 +1,35 @@
|
|
1
1
|
module FixedFields
|
2
|
-
|
3
2
|
def self.included(base)
|
4
3
|
base.extend FieldMethods
|
5
4
|
end
|
6
5
|
|
7
6
|
module FieldMethods
|
8
|
-
def
|
7
|
+
def fixed_field(attribute, options={})
|
9
8
|
unless included_modules.include? InstanceMethods
|
10
9
|
extend ClassMethods
|
11
10
|
include InstanceMethods
|
11
|
+
|
12
|
+
class_eval { cattr_accessor :field_info }
|
13
|
+
self.field_info = {}
|
12
14
|
end
|
15
|
+
|
16
|
+
options[:width] = options[:end] - options[:begin] if options[:width].blank?
|
17
|
+
self.field_info[attribute] = options
|
13
18
|
end
|
14
19
|
end
|
15
20
|
|
16
21
|
module ClassMethods
|
17
|
-
|
22
|
+
def read_fields(record)
|
23
|
+
instance = self.new
|
24
|
+
self.field_info.each do |key, options|
|
25
|
+
instance[key] = record[options[:begin], options[:width]]
|
26
|
+
end
|
27
|
+
|
28
|
+
instance
|
29
|
+
end
|
18
30
|
end
|
19
31
|
|
20
|
-
module InstanceMethods
|
21
|
-
|
32
|
+
module InstanceMethods
|
22
33
|
end
|
23
34
|
end
|
24
35
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: danmunk-fixed_fields
|
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
|
- Dan Munk
|
@@ -27,9 +27,9 @@ files:
|
|
27
27
|
- github_test.rb
|
28
28
|
- init.rb
|
29
29
|
- lib/fixed_fields.rb
|
30
|
+
- Manifest
|
30
31
|
- Rakefile
|
31
32
|
- README.rdoc
|
32
|
-
- Manifest
|
33
33
|
has_rdoc: true
|
34
34
|
homepage: http://www.github.com/danmunk/fixed_fields
|
35
35
|
post_install_message:
|