serialism 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/Guardfile +43 -0
- data/LICENSE.txt +22 -0
- data/README.md +81 -0
- data/Rakefile +2 -0
- data/lib/serialism/collection.rb +94 -0
- data/lib/serialism/serializer.rb +59 -0
- data/lib/serialism/version.rb +3 -0
- data/lib/serialism.rb +6 -0
- data/serialism.gemspec +27 -0
- data/spec/lib/serialism/collection_spec.rb +113 -0
- data/spec/lib/serialism/serializer_spec.rb +40 -0
- data/spec/spec_helper.rb +63 -0
- metadata +146 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3a8da01fff2518ac843e20e413b6316fde7ac376
|
4
|
+
data.tar.gz: 9ce3c2b30174352c5347510ae20bf1a0fe5774bf
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bf44d446ca14577c76edcaec7154eaa8dad1cdc32b34a7b409b19fd7ae06c69f6c5ff79a25420c58f55d0fe63d4dcbeb0fedbbb77bd2cce8338fda158e522fb3
|
7
|
+
data.tar.gz: 8319e027cc4e276bab9e6073819ac17cc42d124ff41d396923bd384ce01327f0c037d7e44ebc58230deec06b70f552c3641a47980c490ad1c07303d9112f83e3
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
## Uncomment and set this to only include directories you want to watch
|
5
|
+
# directories %w(app lib config test spec features) \
|
6
|
+
# .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
|
7
|
+
|
8
|
+
## Note: if you are using the `directories` clause above and you are not
|
9
|
+
## watching the project directory ('.'), then you will want to move
|
10
|
+
## the Guardfile to a watched dir and symlink it back, e.g.
|
11
|
+
#
|
12
|
+
# $ mkdir config
|
13
|
+
# $ mv Guardfile config/
|
14
|
+
# $ ln -s config/Guardfile .
|
15
|
+
#
|
16
|
+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
17
|
+
|
18
|
+
# Note: The cmd option is now required due to the increasing number of ways
|
19
|
+
# rspec may be run, below are examples of the most common uses.
|
20
|
+
# * bundler: 'bundle exec rspec'
|
21
|
+
# * bundler binstubs: 'bin/rspec'
|
22
|
+
# * spring: 'bin/rspec' (This will use spring if running and you have
|
23
|
+
# installed the spring binstubs per the docs)
|
24
|
+
# * zeus: 'zeus rspec' (requires the server to be started separately)
|
25
|
+
# * 'just' rspec: 'rspec'
|
26
|
+
|
27
|
+
guard :rspec, cmd: "bundle exec rspec" do
|
28
|
+
require "guard/rspec/dsl"
|
29
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
30
|
+
|
31
|
+
# Feel free to open issues for suggestions and improvements
|
32
|
+
|
33
|
+
# RSpec files
|
34
|
+
rspec = dsl.rspec
|
35
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
36
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
37
|
+
watch(rspec.spec_files)
|
38
|
+
|
39
|
+
# Ruby files
|
40
|
+
ruby = dsl.ruby
|
41
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
42
|
+
|
43
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Alex Dean
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
# Serialism
|
2
|
+
|
3
|
+
Kinda like (and inspired by) [ActiveModel::Serializer](https://github.com/rails-api/active_model_serializers),
|
4
|
+
but with a smaller/simpler feature set and not JSON-centric.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'serialism'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install serialism
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
# A class you want to serialize instances of.
|
26
|
+
class Foo
|
27
|
+
attr_accessor :id
|
28
|
+
|
29
|
+
def initialize(id)
|
30
|
+
@id = id
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# A class describing how you want to serialize instances of Foo.
|
35
|
+
class FooSerializer < Serialism::Serializer
|
36
|
+
|
37
|
+
# These properties will be present in each serialized record.
|
38
|
+
attributes :id, :computed
|
39
|
+
|
40
|
+
# Methods have access to the `Foo` instance they're working on via `object`.
|
41
|
+
def computed
|
42
|
+
"computed - #{object.id}"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
items = [
|
47
|
+
Foo.new(1),
|
48
|
+
Foo.new(2),
|
49
|
+
Foo.new(3)
|
50
|
+
]
|
51
|
+
|
52
|
+
serializer = FooSerializer.new(items[0])
|
53
|
+
serializer.render
|
54
|
+
# => {:id=>1, :computed=>"computed - 1"}
|
55
|
+
|
56
|
+
collection = Serialism::Collection.new(items, serializer: FooSerializer)
|
57
|
+
|
58
|
+
puts collection.to_csv
|
59
|
+
# id,computed
|
60
|
+
# 1,computed - 1
|
61
|
+
# 2,computed - 2
|
62
|
+
# 3,computed - 3
|
63
|
+
|
64
|
+
puts collection.to_json
|
65
|
+
# [
|
66
|
+
# {
|
67
|
+
# "id": 1,
|
68
|
+
# "computed": "computed - 1"
|
69
|
+
# },
|
70
|
+
# {
|
71
|
+
# "id": 2,
|
72
|
+
# "computed": "computed - 2"
|
73
|
+
# },
|
74
|
+
# {
|
75
|
+
# "id": 3,
|
76
|
+
# "computed": "computed - 3"
|
77
|
+
# }
|
78
|
+
# ]
|
79
|
+
|
80
|
+
|
81
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
module Serialism
|
2
|
+
|
3
|
+
# Combines a set of items and a serializer class.
|
4
|
+
#
|
5
|
+
# Example:
|
6
|
+
#
|
7
|
+
# class Foo
|
8
|
+
# attr_accessor :id
|
9
|
+
# end
|
10
|
+
#
|
11
|
+
# class FooSerializer < Serialism::Serializer
|
12
|
+
# attributes :id
|
13
|
+
# end
|
14
|
+
#
|
15
|
+
# Serialism::Collection.new(a_bunch_of_foo_instances, serializer: FooSerializer).to_csv
|
16
|
+
# #=> returns a CSV string
|
17
|
+
class Collection
|
18
|
+
|
19
|
+
attr_reader :items
|
20
|
+
|
21
|
+
# create a new collection
|
22
|
+
#
|
23
|
+
# @param[Enumerable] items
|
24
|
+
# A collection of items.
|
25
|
+
# All member items should be encodable by `serializer`.
|
26
|
+
# @param[Serialism::Serializer] serializer
|
27
|
+
# The serializer class used to encode members of `items`.
|
28
|
+
def initialize(items=[], serializer:)
|
29
|
+
if ! serializer.respond_to?(:attributes)
|
30
|
+
raise ArgumentError, "serializer must implement a class-level :attributes method"
|
31
|
+
end
|
32
|
+
if ! serializer.instance_methods.include?(:render)
|
33
|
+
raise ArgumentError, "serializer must implement an instance-level :render method"
|
34
|
+
end
|
35
|
+
@serializer = serializer
|
36
|
+
|
37
|
+
self.items = items
|
38
|
+
end
|
39
|
+
|
40
|
+
# Set the items in the collection.
|
41
|
+
#
|
42
|
+
# Replaces any previous items already in the collection.
|
43
|
+
#
|
44
|
+
# @param [#each] items an enumerable collection of items
|
45
|
+
# @return [CsvCollection]
|
46
|
+
def items=(items)
|
47
|
+
raise ArgumentError, "argument must respond_to :each" if ! items.respond_to?(:each)
|
48
|
+
raise ArgumentError, "argument must respond_to :map" if ! items.respond_to?(:map)
|
49
|
+
|
50
|
+
@items = items
|
51
|
+
self
|
52
|
+
end
|
53
|
+
|
54
|
+
# return the attributes for the collection
|
55
|
+
#
|
56
|
+
# @return [Array]
|
57
|
+
def attributes
|
58
|
+
return [] if items.size == 0
|
59
|
+
|
60
|
+
@serializer.attributes
|
61
|
+
end
|
62
|
+
|
63
|
+
# Generate a csv string for the collection
|
64
|
+
#
|
65
|
+
# When members of the array returned by the serializer are themselves arrays,
|
66
|
+
# these sub-arrays will be joined using "," prior to being added to the main
|
67
|
+
# CSV.
|
68
|
+
#
|
69
|
+
# @return [String]
|
70
|
+
def to_csv
|
71
|
+
require 'csv'
|
72
|
+
|
73
|
+
CSV.generate do |csv|
|
74
|
+
csv << attributes
|
75
|
+
items.each do |t|
|
76
|
+
|
77
|
+
row = @serializer.new(t).render.values.map do |cell|
|
78
|
+
# convert complex cells to comma-separated strings
|
79
|
+
cell.is_a?(Array) ? cell.join(',') : cell
|
80
|
+
end
|
81
|
+
|
82
|
+
csv << row
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def to_json
|
88
|
+
require 'json'
|
89
|
+
|
90
|
+
JSON.dump(items.map {|t| @serializer.new(t).render })
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module Serialism
|
2
|
+
|
3
|
+
# Base class for concrete serializers to inherit from.
|
4
|
+
#
|
5
|
+
# Example:
|
6
|
+
#
|
7
|
+
# class Foo
|
8
|
+
# attr_accessor :id
|
9
|
+
# end
|
10
|
+
#
|
11
|
+
# class FooSerializer < Serialism::Serializer
|
12
|
+
# attributes :id, :computed
|
13
|
+
#
|
14
|
+
# def computed
|
15
|
+
# "computed - #{object.id}"
|
16
|
+
# end
|
17
|
+
# end
|
18
|
+
#
|
19
|
+
# item = Foo.new
|
20
|
+
# item.id = 12
|
21
|
+
#
|
22
|
+
# serializer = FooSerializer.new(item)
|
23
|
+
# serializer.render
|
24
|
+
# # => {id: 12, computed: "computed - 12"}
|
25
|
+
class Serializer
|
26
|
+
|
27
|
+
attr_reader :object
|
28
|
+
|
29
|
+
@attributes = []
|
30
|
+
def self.attributes(*attrs)
|
31
|
+
if attrs.size > 0
|
32
|
+
@attributes = attrs
|
33
|
+
end
|
34
|
+
@attributes
|
35
|
+
end
|
36
|
+
|
37
|
+
def initialize(object)
|
38
|
+
@object = object
|
39
|
+
end
|
40
|
+
|
41
|
+
# Transform `object` using rules defined by the serializer.
|
42
|
+
#
|
43
|
+
# @return [Hash] Keys are defined by the classes `attributes`.
|
44
|
+
def render
|
45
|
+
self.class.attributes.inject({}) do |memo,attr|
|
46
|
+
if respond_to?(attr)
|
47
|
+
memo[attr] = self.send(attr)
|
48
|
+
elsif object.respond_to?(attr)
|
49
|
+
memo[attr] = object.send(attr)
|
50
|
+
else
|
51
|
+
raise ArgumentError, "Unknown attribute :#{attr}"
|
52
|
+
end
|
53
|
+
memo
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
data/lib/serialism.rb
ADDED
data/serialism.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'serialism/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "serialism"
|
8
|
+
spec.version = Serialism::VERSION
|
9
|
+
spec.authors = ["Alex Dean"]
|
10
|
+
spec.email = ["alex@crackpot.org"]
|
11
|
+
spec.summary = %q{Like ActiveModel::Serializer but smaller and not JSON-centric.}
|
12
|
+
spec.homepage = ""
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
21
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
22
|
+
spec.add_development_dependency "rspec", "~> 3.0.0"
|
23
|
+
spec.add_development_dependency "guard-rspec"
|
24
|
+
spec.add_development_dependency "ruby_gntp"
|
25
|
+
spec.add_development_dependency "ci_reporter_rspec"
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Serialism::Collection, type: :model do
|
4
|
+
|
5
|
+
# a serializer class
|
6
|
+
let(:serializer) do
|
7
|
+
Class.new(Serialism::Serializer) do
|
8
|
+
attributes :id, :computed
|
9
|
+
|
10
|
+
def computed
|
11
|
+
"computed - #{object.id}"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# a class being serialized
|
17
|
+
let(:serialized) do
|
18
|
+
Struct.new(:id)
|
19
|
+
end
|
20
|
+
|
21
|
+
let(:items) do
|
22
|
+
3.times.map do |i|
|
23
|
+
serialized.new(i)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
let(:collection) do
|
28
|
+
Serialism::Collection.new(items, serializer: serializer)
|
29
|
+
end
|
30
|
+
|
31
|
+
describe 'initialize' do
|
32
|
+
it 'should require serializer to implement class-level attributes' do
|
33
|
+
invalid_serializer = Class.new
|
34
|
+
|
35
|
+
expect {
|
36
|
+
Serialism::Collection.new([], serializer: invalid_serializer)
|
37
|
+
}.to raise_error(ArgumentError, 'serializer must implement a class-level :attributes method')
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should require serializer to implement instance-level render' do
|
41
|
+
invalid_serializer = Class.new do
|
42
|
+
def self.attributes
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
expect {
|
47
|
+
Serialism::Collection.new([], serializer: invalid_serializer)
|
48
|
+
}.to raise_error(ArgumentError, 'serializer must implement an instance-level :render method')
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should succeed when given a valid serializer' do
|
52
|
+
serializer = Class.new do
|
53
|
+
def self.attributes
|
54
|
+
end
|
55
|
+
|
56
|
+
def render
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
expect {
|
61
|
+
Serialism::Collection.new([], serializer: serializer)
|
62
|
+
}.not_to raise_error
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe 'items=' do
|
67
|
+
it 'should require argument to respond_to :each' do
|
68
|
+
expect {
|
69
|
+
collection.items = :blat
|
70
|
+
}.to raise_error(ArgumentError, 'argument must respond_to :each')
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe 'attributes' do
|
75
|
+
it 'should return array of attributes' do
|
76
|
+
expect(collection.attributes).to eq serializer.attributes
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe 'to_csv' do
|
81
|
+
it 'should generate a csv string' do
|
82
|
+
|
83
|
+
expected = <<-EOF
|
84
|
+
id,computed
|
85
|
+
0,computed - 0
|
86
|
+
1,computed - 1
|
87
|
+
2,computed - 2
|
88
|
+
EOF
|
89
|
+
expect(collection.to_csv).to eq expected
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'should encode complex cells as csv strings' do
|
93
|
+
collection.items = [
|
94
|
+
serialized.new([1,2,3]),
|
95
|
+
serialized.new([4,5,6])
|
96
|
+
]
|
97
|
+
|
98
|
+
expected = <<-EOF
|
99
|
+
id,computed
|
100
|
+
"1,2,3","computed - [1, 2, 3]"
|
101
|
+
"4,5,6","computed - [4, 5, 6]"
|
102
|
+
EOF
|
103
|
+
expect(collection.to_csv).to eq expected
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
describe 'to_json' do
|
108
|
+
it 'should generate json' do
|
109
|
+
expect(collection.to_json).to eq '[{"id":0,"computed":"computed - 0"},{"id":1,"computed":"computed - 1"},{"id":2,"computed":"computed - 2"}]'
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Serialism::Serializer, type: :model do
|
4
|
+
|
5
|
+
let(:subject) do
|
6
|
+
Class.new(Serialism::Serializer) do
|
7
|
+
attributes :id, :computed
|
8
|
+
|
9
|
+
def computed
|
10
|
+
"computed by serializer - #{object.id}"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '.attributes' do
|
16
|
+
it 'should allow attributes to be set and retrieved' do
|
17
|
+
subject.attributes(:a, :b)
|
18
|
+
|
19
|
+
expect(subject.attributes).to eq([:a, :b])
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#render' do
|
24
|
+
let(:item) do
|
25
|
+
item_class = Struct.new(:id, :computed)
|
26
|
+
item_class.new(1, "'computed' defined in item")
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should prefer attribute implementations in the serializer' do
|
30
|
+
values = subject.new(item).render
|
31
|
+
expect(values[:computed]).to eq "computed by serializer - 1"
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should use attribute implementation in the object if not defined explicitly in serializer' do
|
35
|
+
values = subject.new(item).render
|
36
|
+
expect(values[:id]).to eq 1
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
require_relative '../lib/serialism'
|
2
|
+
|
3
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
4
|
+
RSpec.configure do |config|
|
5
|
+
|
6
|
+
# These two settings work together to allow you to limit a spec run
|
7
|
+
# to individual examples or groups you care about by tagging them with
|
8
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
9
|
+
# get run.
|
10
|
+
config.filter_run :focus
|
11
|
+
config.run_all_when_everything_filtered = true
|
12
|
+
|
13
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
14
|
+
# file, and it's useful to allow more verbose output when running an
|
15
|
+
# individual spec file.
|
16
|
+
if config.files_to_run.one?
|
17
|
+
# Use the documentation formatter for detailed output,
|
18
|
+
# unless a formatter has already been configured
|
19
|
+
# (e.g. via a command-line flag).
|
20
|
+
config.default_formatter = 'doc'
|
21
|
+
end
|
22
|
+
|
23
|
+
# Print the 10 slowest examples and example groups at the
|
24
|
+
# end of the spec run, to help surface which specs are running
|
25
|
+
# particularly slow.
|
26
|
+
# config.profile_examples = 10
|
27
|
+
|
28
|
+
# Run specs in random order to surface order dependencies. If you find an
|
29
|
+
# order dependency and want to debug it, you can fix the order by providing
|
30
|
+
# the seed, which is printed after each run.
|
31
|
+
# --seed 1234
|
32
|
+
config.order = :random
|
33
|
+
|
34
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
35
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
36
|
+
# test failures related to randomization by passing the same `--seed` value
|
37
|
+
# as the one that triggered the failure.
|
38
|
+
Kernel.srand config.seed
|
39
|
+
|
40
|
+
# rspec-expectations config goes here. You can use an alternate
|
41
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
42
|
+
# assertions if you prefer.
|
43
|
+
config.expect_with :rspec do |expectations|
|
44
|
+
# Enable only the newer, non-monkey-patching expect syntax.
|
45
|
+
# For more details, see:
|
46
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
47
|
+
expectations.syntax = :expect
|
48
|
+
end
|
49
|
+
|
50
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
51
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
52
|
+
config.mock_with :rspec do |mocks|
|
53
|
+
# Enable only the newer, non-monkey-patching expect syntax.
|
54
|
+
# For more details, see:
|
55
|
+
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
56
|
+
mocks.syntax = :expect
|
57
|
+
|
58
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
59
|
+
# a real object. This is generally recommended.
|
60
|
+
mocks.verify_partial_doubles = true
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
metadata
ADDED
@@ -0,0 +1,146 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: serialism
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alex Dean
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-08-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 3.0.0
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.0.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: guard-rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: ruby_gntp
|
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: ci_reporter_rspec
|
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
|
+
description:
|
98
|
+
email:
|
99
|
+
- alex@crackpot.org
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- ".rspec"
|
106
|
+
- Gemfile
|
107
|
+
- Guardfile
|
108
|
+
- LICENSE.txt
|
109
|
+
- README.md
|
110
|
+
- Rakefile
|
111
|
+
- lib/serialism.rb
|
112
|
+
- lib/serialism/collection.rb
|
113
|
+
- lib/serialism/serializer.rb
|
114
|
+
- lib/serialism/version.rb
|
115
|
+
- serialism.gemspec
|
116
|
+
- spec/lib/serialism/collection_spec.rb
|
117
|
+
- spec/lib/serialism/serializer_spec.rb
|
118
|
+
- spec/spec_helper.rb
|
119
|
+
homepage: ''
|
120
|
+
licenses:
|
121
|
+
- MIT
|
122
|
+
metadata: {}
|
123
|
+
post_install_message:
|
124
|
+
rdoc_options: []
|
125
|
+
require_paths:
|
126
|
+
- lib
|
127
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0'
|
137
|
+
requirements: []
|
138
|
+
rubyforge_project:
|
139
|
+
rubygems_version: 2.4.3
|
140
|
+
signing_key:
|
141
|
+
specification_version: 4
|
142
|
+
summary: Like ActiveModel::Serializer but smaller and not JSON-centric.
|
143
|
+
test_files:
|
144
|
+
- spec/lib/serialism/collection_spec.rb
|
145
|
+
- spec/lib/serialism/serializer_spec.rb
|
146
|
+
- spec/spec_helper.rb
|