data_slicer 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.document +5 -5
- data/.rspec +1 -1
- data/.travis.yml +4 -0
- data/Gemfile +14 -14
- data/LICENSE.txt +20 -20
- data/README.rdoc +19 -19
- data/Rakefile +44 -49
- data/VERSION +1 -1
- data/data_slicer.gemspec +63 -0
- data/lib/data_slicer.rb +11 -11
- data/spec/data_slicer_spec.rb +21 -21
- data/spec/spec_helper.rb +14 -14
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ab5c07db38862a96835032dbbb5a2b3d61fe19e
|
4
|
+
data.tar.gz: 9f99ac9b5d49ae22db93a801eeff2a2088ecb82f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b74a8c076717ef05ff357fe51ef8367dcbd76be06868ce16a3c4ef26aebcf2d3ffa49a33133e5795bd2277ca9d5a63af286200d84ebc66b416b58ebbb8b58d37
|
7
|
+
data.tar.gz: 384a86b85a6a41862ebbcb56be1f67f2c798ee3e46c73fb3e434cba16242bb2d995e07bc7fe0ffb31170b7de0624bf67d62b3c3b43ec0d40079b06cf61dd0cf2
|
data/.document
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
lib/**/*.rb
|
2
|
-
bin/*
|
3
|
-
-
|
4
|
-
features/**/*.feature
|
5
|
-
LICENSE.txt
|
1
|
+
lib/**/*.rb
|
2
|
+
bin/*
|
3
|
+
-
|
4
|
+
features/**/*.feature
|
5
|
+
LICENSE.txt
|
data/.rspec
CHANGED
@@ -1 +1 @@
|
|
1
|
-
--color
|
1
|
+
--color
|
data/.travis.yml
ADDED
data/Gemfile
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
source "http://rubygems.org"
|
2
|
-
# Add dependencies required to use your gem here.
|
3
|
-
# Example:
|
4
|
-
# gem "activesupport", ">= 2.3.5"
|
5
|
-
|
6
|
-
# Add dependencies to develop your gem here.
|
7
|
-
# Include everything needed to run rake, tests, features, etc.
|
8
|
-
group :development do
|
9
|
-
gem "rspec", "~> 2.
|
10
|
-
gem "rdoc", "~> 3.12"
|
11
|
-
gem "bundler", "~> 1.0"
|
12
|
-
gem "jeweler", "~> 2.0.0"
|
13
|
-
gem "simplecov", ">= 0"
|
14
|
-
end
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
group :development do
|
9
|
+
gem "rspec", "~> 2.14"
|
10
|
+
gem "rdoc", "~> 3.12"
|
11
|
+
gem "bundler", "~> 1.0"
|
12
|
+
gem "jeweler", "~> 2.0.0"
|
13
|
+
gem "simplecov", ">= 0"
|
14
|
+
end
|
data/LICENSE.txt
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
-
Copyright (c) 2014 Craig Hills
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
1
|
+
Copyright (c) 2014 Craig Hills
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
CHANGED
@@ -1,19 +1,19 @@
|
|
1
|
-
= data_slicer
|
2
|
-
|
3
|
-
String extension for slicing fixed length data strings into their individual parts.
|
4
|
-
|
5
|
-
== Contributing to data_slicer
|
6
|
-
|
7
|
-
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
8
|
-
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
9
|
-
* Fork the project.
|
10
|
-
* Start a feature/bugfix branch.
|
11
|
-
* Commit and push until you are happy with your contribution.
|
12
|
-
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
-
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
-
|
15
|
-
== Copyright
|
16
|
-
|
17
|
-
Copyright (c) 2014 Craig Hills. See LICENSE.txt for
|
18
|
-
further details.
|
19
|
-
|
1
|
+
= data_slicer
|
2
|
+
|
3
|
+
String extension for slicing fixed length data strings into their individual parts.
|
4
|
+
|
5
|
+
== Contributing to data_slicer
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
9
|
+
* Fork the project.
|
10
|
+
* Start a feature/bugfix branch.
|
11
|
+
* Commit and push until you are happy with your contribution.
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2014 Craig Hills. See LICENSE.txt for
|
18
|
+
further details.
|
19
|
+
|
data/Rakefile
CHANGED
@@ -1,49 +1,44 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require 'bundler'
|
5
|
-
begin
|
6
|
-
Bundler.setup(:default, :development)
|
7
|
-
rescue Bundler::BundlerError => e
|
8
|
-
$stderr.puts e.message
|
9
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
-
exit e.status_code
|
11
|
-
end
|
12
|
-
require 'rake'
|
13
|
-
|
14
|
-
require 'jeweler'
|
15
|
-
Jeweler::Tasks.new do |gem|
|
16
|
-
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
-
gem.name = "data_slicer"
|
18
|
-
gem.homepage = "http://github.com/chills42/data_slicer"
|
19
|
-
gem.license = "MIT"
|
20
|
-
gem.summary = %Q{allows slicing of fixed length string data}
|
21
|
-
gem.description = %Q{allows slicing of fixed length string data}
|
22
|
-
gem.email = "chills@gmail.com"
|
23
|
-
gem.authors = ["Craig Hills"]
|
24
|
-
# dependencies defined in Gemfile
|
25
|
-
end
|
26
|
-
Jeweler::RubygemsDotOrgTasks.new
|
27
|
-
|
28
|
-
require 'rspec/core'
|
29
|
-
require 'rspec/core/rake_task'
|
30
|
-
RSpec::Core::RakeTask.new(:spec) do |spec|
|
31
|
-
spec.pattern = FileList['spec/**/*_spec.rb']
|
32
|
-
end
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
rdoc.rdoc_dir = 'rdoc'
|
46
|
-
rdoc.title = "data_slicer #{version}"
|
47
|
-
rdoc.rdoc_files.include('README*')
|
48
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
49
|
-
end
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "data_slicer"
|
18
|
+
gem.homepage = "http://github.com/chills42/data_slicer"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{allows slicing of fixed length string data}
|
21
|
+
gem.description = %Q{allows slicing of fixed length string data}
|
22
|
+
gem.email = "chills@gmail.com"
|
23
|
+
gem.authors = ["Craig Hills"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rspec/core'
|
29
|
+
require 'rspec/core/rake_task'
|
30
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
31
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
32
|
+
end
|
33
|
+
|
34
|
+
task :default => :spec
|
35
|
+
|
36
|
+
require 'rdoc/task'
|
37
|
+
Rake::RDocTask.new do |rdoc|
|
38
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
39
|
+
|
40
|
+
rdoc.rdoc_dir = 'rdoc'
|
41
|
+
rdoc.title = "data_slicer #{version}"
|
42
|
+
rdoc.rdoc_files.include('README*')
|
43
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
44
|
+
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/data_slicer.gemspec
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "data_slicer"
|
8
|
+
s.version = "0.1.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Craig Hills"]
|
12
|
+
s.date = "2014-01-16"
|
13
|
+
s.description = "allows slicing of fixed length string data"
|
14
|
+
s.email = "chills@gmail.com"
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".rspec",
|
22
|
+
".travis.yml",
|
23
|
+
"Gemfile",
|
24
|
+
"LICENSE.txt",
|
25
|
+
"README.rdoc",
|
26
|
+
"Rakefile",
|
27
|
+
"VERSION",
|
28
|
+
"data_slicer.gemspec",
|
29
|
+
"lib/data_slicer.rb",
|
30
|
+
"spec/data_slicer_spec.rb",
|
31
|
+
"spec/spec_helper.rb"
|
32
|
+
]
|
33
|
+
s.homepage = "http://github.com/chills42/data_slicer"
|
34
|
+
s.licenses = ["MIT"]
|
35
|
+
s.require_paths = ["lib"]
|
36
|
+
s.rubygems_version = "2.0.3"
|
37
|
+
s.summary = "allows slicing of fixed length string data"
|
38
|
+
|
39
|
+
if s.respond_to? :specification_version then
|
40
|
+
s.specification_version = 4
|
41
|
+
|
42
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
43
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.14"])
|
44
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
45
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0"])
|
46
|
+
s.add_development_dependency(%q<jeweler>, ["~> 2.0.0"])
|
47
|
+
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
48
|
+
else
|
49
|
+
s.add_dependency(%q<rspec>, ["~> 2.14"])
|
50
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
51
|
+
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
52
|
+
s.add_dependency(%q<jeweler>, ["~> 2.0.0"])
|
53
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
54
|
+
end
|
55
|
+
else
|
56
|
+
s.add_dependency(%q<rspec>, ["~> 2.14"])
|
57
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
58
|
+
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
59
|
+
s.add_dependency(%q<jeweler>, ["~> 2.0.0"])
|
60
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
data/lib/data_slicer.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
# monkey-patching to add a data_slice string extension method
|
2
|
-
class String
|
3
|
-
def data_slice(*args)
|
4
|
-
index = 0
|
5
|
-
args.map do |length|
|
6
|
-
start = index
|
7
|
-
index += length
|
8
|
-
slice(start, length).strip
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
1
|
+
# monkey-patching to add a data_slice string extension method
|
2
|
+
class String
|
3
|
+
def data_slice(*args)
|
4
|
+
index = 0
|
5
|
+
args.map do |length|
|
6
|
+
start = index
|
7
|
+
index += length
|
8
|
+
slice(start, length).strip
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
data/spec/data_slicer_spec.rb
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
describe 'String' do
|
4
|
-
it 'has a data_slice method' do
|
5
|
-
''.data_slice
|
6
|
-
end
|
7
|
-
it 'should return an array' do
|
8
|
-
expect(''.data_slice).to be_kind_of(Array)
|
9
|
-
end
|
10
|
-
it 'slices the specified lengths, starting at index 0' do
|
11
|
-
expect('asdf'.data_slice(2, 2)).to eq(%w[as df])
|
12
|
-
end
|
13
|
-
it 'trims leading and trailing whitespace from the field' do
|
14
|
-
expect('a b '.data_slice(4, 4)).to eq(%w[a b])
|
15
|
-
end
|
16
|
-
it 'can handle several different field widths' do
|
17
|
-
example = 'MATH2010Calculus I 4Smith '
|
18
|
-
expected_array = ['MATH', '2010', 'Calculus I', '4', 'Smith']
|
19
|
-
expect(example.data_slice(4, 4, 20, 1, 16)).to eq(expected_array)
|
20
|
-
end
|
21
|
-
end
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe 'String' do
|
4
|
+
it 'has a data_slice method' do
|
5
|
+
''.data_slice
|
6
|
+
end
|
7
|
+
it 'should return an array' do
|
8
|
+
expect(''.data_slice).to be_kind_of(Array)
|
9
|
+
end
|
10
|
+
it 'slices the specified lengths, starting at index 0' do
|
11
|
+
expect('asdf'.data_slice(2, 2)).to eq(%w[as df])
|
12
|
+
end
|
13
|
+
it 'trims leading and trailing whitespace from the field' do
|
14
|
+
expect('a b '.data_slice(4, 4)).to eq(%w[a b])
|
15
|
+
end
|
16
|
+
it 'can handle several different field widths' do
|
17
|
+
example = 'MATH2010Calculus I 4Smith '
|
18
|
+
expected_array = ['MATH', '2010', 'Calculus I', '4', 'Smith']
|
19
|
+
expect(example.data_slice(4, 4, 20, 1, 16)).to eq(expected_array)
|
20
|
+
end
|
21
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
-
require 'simplecov'
|
4
|
-
SimpleCov.start
|
5
|
-
|
6
|
-
require 'rspec'
|
7
|
-
require 'data_slicer'
|
8
|
-
|
9
|
-
# Requires supporting files with custom matchers and macros, etc,
|
10
|
-
# in ./support/ and its subdirectories.
|
11
|
-
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
12
|
-
|
13
|
-
RSpec.configure do |config|
|
14
|
-
end
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'simplecov'
|
4
|
+
SimpleCov.start
|
5
|
+
|
6
|
+
require 'rspec'
|
7
|
+
require 'data_slicer'
|
8
|
+
|
9
|
+
# Requires supporting files with custom matchers and macros, etc,
|
10
|
+
# in ./support/ and its subdirectories.
|
11
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
12
|
+
|
13
|
+
RSpec.configure do |config|
|
14
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: data_slicer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Craig Hills
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.
|
19
|
+
version: '2.14'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.
|
26
|
+
version: '2.14'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rdoc
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -90,11 +90,13 @@ extra_rdoc_files:
|
|
90
90
|
files:
|
91
91
|
- .document
|
92
92
|
- .rspec
|
93
|
+
- .travis.yml
|
93
94
|
- Gemfile
|
94
95
|
- LICENSE.txt
|
95
96
|
- README.rdoc
|
96
97
|
- Rakefile
|
97
98
|
- VERSION
|
99
|
+
- data_slicer.gemspec
|
98
100
|
- lib/data_slicer.rb
|
99
101
|
- spec/data_slicer_spec.rb
|
100
102
|
- spec/spec_helper.rb
|