pikelet 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.coveralls.yml +1 -0
- data/.travis.yml +14 -0
- data/lib/pikelet/field_definition.rb +3 -1
- data/lib/pikelet/version.rb +1 -1
- data/pikelet.gemspec +3 -0
- data/spec/pikelet_spec.rb +152 -0
- data/spec/spec_helper.rb +84 -0
- metadata +50 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba77b8ff8d09025491cbe13b0cd6f18f735a3b84
|
4
|
+
data.tar.gz: 4949556c8adee37a5d0370d02a2bd1c1a3a1f544
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c0afce709436d65d47d6234abbf8cc94dfbe61870a5c171bfa8b2314488cdfb3ce907a901767a3f3f95ad74cc8f251223c554eaa0a081aba663c7d2b8607c9e
|
7
|
+
data.tar.gz: 60432f02988c999c97d33c73418523997f58f2a0133707435a8fe61d749f5683a76d0c5dfb986fc446b0a76b39e2a130dc8536b10258272607edb567cba58580
|
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_name: travis-ci
|
data/.travis.yml
ADDED
data/lib/pikelet/version.rb
CHANGED
data/pikelet.gemspec
CHANGED
@@ -25,4 +25,7 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.add_development_dependency "bundler", "~> 1.5"
|
26
26
|
spec.add_development_dependency "rake"
|
27
27
|
spec.add_development_dependency "rspec"
|
28
|
+
spec.add_development_dependency "rspec-its"
|
29
|
+
spec.add_development_dependency "rspec-collection_matchers"
|
30
|
+
spec.add_development_dependency "coveralls"
|
28
31
|
end
|
@@ -0,0 +1,152 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "pikelet"
|
3
|
+
require "csv"
|
4
|
+
|
5
|
+
describe Pikelet do
|
6
|
+
RSpec::Matchers.define :match_hash do |expected|
|
7
|
+
match do |actual|
|
8
|
+
actual.to_h == expected
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:records) { definition.parse(data).to_a }
|
13
|
+
|
14
|
+
subject { records }
|
15
|
+
|
16
|
+
describe "a simple flat file" do
|
17
|
+
let(:definition) do
|
18
|
+
Pikelet.define do
|
19
|
+
name 0... 4
|
20
|
+
number 4...13
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
let(:data) do
|
25
|
+
<<-FILE.gsub(/^\s*/, "").split(/[\r\n]+/)
|
26
|
+
John012345678
|
27
|
+
Sue 087654321
|
28
|
+
FILE
|
29
|
+
end
|
30
|
+
|
31
|
+
it { is_expected.to have(2).records }
|
32
|
+
|
33
|
+
its(:first) { is_expected.to match_hash(name: "John", number: "012345678") }
|
34
|
+
its(:last) { is_expected.to match_hash(name: "Sue", number: "087654321") }
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "a file with heterogeneous records" do
|
38
|
+
let(:definition) do
|
39
|
+
Pikelet.define do
|
40
|
+
type_signature 0...1
|
41
|
+
|
42
|
+
record 'A' do
|
43
|
+
name 1... 5
|
44
|
+
number 5...14
|
45
|
+
end
|
46
|
+
|
47
|
+
record 'B' do
|
48
|
+
number 1...10
|
49
|
+
name 10...14
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
let(:data) do
|
55
|
+
<<-FILE.gsub(/^\s*/, "").split(/[\r\n]+/)
|
56
|
+
AJohn012345678
|
57
|
+
B087654321Sue
|
58
|
+
FILE
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
it { is_expected.to have(2).records }
|
63
|
+
|
64
|
+
its(:first) { is_expected.to match_hash(name: "John", number: "012345678", type_signature: "A") }
|
65
|
+
its(:last) { is_expected.to match_hash(name: "Sue", number: "087654321", type_signature: "B") }
|
66
|
+
end
|
67
|
+
|
68
|
+
describe "a CSV file" do
|
69
|
+
let(:definition) do
|
70
|
+
Pikelet.define do
|
71
|
+
name 0
|
72
|
+
number 1
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
let(:data) do
|
77
|
+
CSV.parse <<-FILE.gsub(/^\s*/, "")
|
78
|
+
John,012345678
|
79
|
+
Sue,087654321
|
80
|
+
FILE
|
81
|
+
end
|
82
|
+
|
83
|
+
it { is_expected.to have(2).records }
|
84
|
+
|
85
|
+
its(:first) { is_expected.to match_hash(name: "John", number: "012345678") }
|
86
|
+
its(:last) { is_expected.to match_hash(name: "Sue", number: "087654321") }
|
87
|
+
end
|
88
|
+
|
89
|
+
describe "inheritance" do
|
90
|
+
let(:definition) do
|
91
|
+
Pikelet.define do
|
92
|
+
type_signature 0...6
|
93
|
+
|
94
|
+
record 'SIMPLE' do
|
95
|
+
name 6...10
|
96
|
+
|
97
|
+
record 'FANCY' do
|
98
|
+
number 10...19
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
let(:data) do
|
105
|
+
<<-FILE.gsub(/^\s*/, "").split(/[\r\n]+/)
|
106
|
+
SIMPLEJohn012345678
|
107
|
+
FANCY Sue 087654321
|
108
|
+
FILE
|
109
|
+
end
|
110
|
+
|
111
|
+
it { is_expected.to have(2).records }
|
112
|
+
|
113
|
+
its(:first) { is_expected.to match_hash(name: "John", type_signature: "SIMPLE") }
|
114
|
+
its(:last) { is_expected.to match_hash(name: "Sue", number: "087654321", type_signature: "FANCY") }
|
115
|
+
end
|
116
|
+
|
117
|
+
describe "integer fields" do
|
118
|
+
let(:definition) do
|
119
|
+
Pikelet.define do
|
120
|
+
value 0...4, type: :integer
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
let(:data) do
|
125
|
+
<<-FILE.gsub(/^\s*/, "").split(/[\r\n]+/)
|
126
|
+
5637
|
127
|
+
FILE
|
128
|
+
end
|
129
|
+
|
130
|
+
subject { records.first }
|
131
|
+
|
132
|
+
its(:value) { is_expected.to eq 5637 }
|
133
|
+
end
|
134
|
+
|
135
|
+
describe "overpunch fields" do
|
136
|
+
let(:definition) do
|
137
|
+
Pikelet.define do
|
138
|
+
value 0...4, type: :overpunch
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
let(:data) do
|
143
|
+
<<-FILE.gsub(/^\s*/, "").split(/[\r\n]+/)
|
144
|
+
563J
|
145
|
+
FILE
|
146
|
+
end
|
147
|
+
|
148
|
+
subject { records.first }
|
149
|
+
|
150
|
+
its(:value) { is_expected.to eq -5631 }
|
151
|
+
end
|
152
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause this
|
4
|
+
# file to always be loaded, without a need to explicitly require it in any files.
|
5
|
+
#
|
6
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
7
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
8
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
9
|
+
# individual file that may not need all of that loaded. Instead, make a
|
10
|
+
# separate helper file that requires this one and then use it only in the specs
|
11
|
+
# that actually need it.
|
12
|
+
#
|
13
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
14
|
+
# users commonly want.
|
15
|
+
#
|
16
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
17
|
+
RSpec.configure do |config|
|
18
|
+
require "rspec/its"
|
19
|
+
require "rspec/collection_matchers"
|
20
|
+
|
21
|
+
# Coveralls
|
22
|
+
require "coveralls"
|
23
|
+
|
24
|
+
Coveralls.wear! do
|
25
|
+
add_filter 'spec'
|
26
|
+
end
|
27
|
+
|
28
|
+
# These two settings work together to allow you to limit a spec run
|
29
|
+
# to individual examples or groups you care about by tagging them with
|
30
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
31
|
+
# get run.
|
32
|
+
# config.filter_run :focus
|
33
|
+
# config.run_all_when_everything_filtered = true
|
34
|
+
|
35
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
36
|
+
# file, and it's useful to allow more verbose output when running an
|
37
|
+
# individual spec file.
|
38
|
+
if config.files_to_run.one?
|
39
|
+
# Use the documentation formatter for detailed output,
|
40
|
+
# unless a formatter has already been configured
|
41
|
+
# (e.g. via a command-line flag).
|
42
|
+
config.default_formatter = 'doc'
|
43
|
+
end
|
44
|
+
|
45
|
+
# Print the 10 slowest examples and example groups at the
|
46
|
+
# end of the spec run, to help surface which specs are running
|
47
|
+
# particularly slow.
|
48
|
+
config.profile_examples = 10
|
49
|
+
|
50
|
+
# Run specs in random order to surface order dependencies. If you find an
|
51
|
+
# order dependency and want to debug it, you can fix the order by providing
|
52
|
+
# the seed, which is printed after each run.
|
53
|
+
# --seed 1234
|
54
|
+
config.order = :random
|
55
|
+
|
56
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
57
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
58
|
+
# test failures related to randomization by passing the same `--seed` value
|
59
|
+
# as the one that triggered the failure.
|
60
|
+
Kernel.srand config.seed
|
61
|
+
|
62
|
+
# rspec-expectations config goes here. You can use an alternate
|
63
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
64
|
+
# assertions if you prefer.
|
65
|
+
config.expect_with :rspec do |expectations|
|
66
|
+
# Enable only the newer, non-monkey-patching expect syntax.
|
67
|
+
# For more details, see:
|
68
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
69
|
+
expectations.syntax = :expect
|
70
|
+
end
|
71
|
+
|
72
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
73
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
74
|
+
config.mock_with :rspec do |mocks|
|
75
|
+
# Enable only the newer, non-monkey-patching expect syntax.
|
76
|
+
# For more details, see:
|
77
|
+
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
78
|
+
mocks.syntax = :expect
|
79
|
+
|
80
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
81
|
+
# a real object. This is generally recommended.
|
82
|
+
mocks.verify_partial_doubles = true
|
83
|
+
end
|
84
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pikelet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Carney
|
@@ -66,6 +66,48 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec-its
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec-collection_matchers
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: coveralls
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
69
111
|
description: Pikelet is a type of small pancake popular in Australia and New Zealand.
|
70
112
|
Also, a flat-file database parser capable of dealing with heterogeneous records.
|
71
113
|
email:
|
@@ -74,9 +116,11 @@ executables: []
|
|
74
116
|
extensions: []
|
75
117
|
extra_rdoc_files: []
|
76
118
|
files:
|
119
|
+
- ".coveralls.yml"
|
77
120
|
- ".gitignore"
|
78
121
|
- ".ruby-gemset"
|
79
122
|
- ".ruby-version"
|
123
|
+
- ".travis.yml"
|
80
124
|
- Gemfile
|
81
125
|
- LICENSE.txt
|
82
126
|
- README.md
|
@@ -87,6 +131,8 @@ files:
|
|
87
131
|
- lib/pikelet/record_definition.rb
|
88
132
|
- lib/pikelet/version.rb
|
89
133
|
- pikelet.gemspec
|
134
|
+
- spec/pikelet_spec.rb
|
135
|
+
- spec/spec_helper.rb
|
90
136
|
homepage: ''
|
91
137
|
licenses:
|
92
138
|
- MIT
|
@@ -111,4 +157,6 @@ rubygems_version: 2.2.2
|
|
111
157
|
signing_key:
|
112
158
|
specification_version: 4
|
113
159
|
summary: A simple flat-file database parser.
|
114
|
-
test_files:
|
160
|
+
test_files:
|
161
|
+
- spec/pikelet_spec.rb
|
162
|
+
- spec/spec_helper.rb
|