t12n 0.2.1 → 0.2.2

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
  SHA256:
3
- metadata.gz: ef2dec0bbe62bca0a96adb8dbbbcb8f34247685e1732c6da2c12b2f60a2b3ac2
4
- data.tar.gz: c97270db164e850355428fd019c80b9f6c3343509544e0203b47aa28cbd9903c
3
+ metadata.gz: 2c352df68907d196975b7f76bdd6f6c457100926153034ed88ea295ae1b09081
4
+ data.tar.gz: 2ddc1c2ae840b0bb34db467f70c940d9c3b7a3c81d84bb4393d7e6c8628dd94f
5
5
  SHA512:
6
- metadata.gz: 0501cb657af60da6ef6a3cf217fa5c3e206664eb4f5e5346f5c34c2c2054849d105ddb7127ca16e14a3c45b52b5b212540fd59112f4b78ce021b3d2f08a197c1
7
- data.tar.gz: e557b6371029d851dcb9f9eff37617706abcb8fe395a66bc759fd4671764e825bd711a6150f8e826b373d9c46497a7646cd69edb89ce5fefcfb9095f9c9571b6
6
+ metadata.gz: 063dc527c987a30e6afe6bb427960b3253c4f52eceb7a4b1c75d008aaba6e0ffa61385a8275e4d4e69642538ac7b096e1adb04290646176681f5bd7fed913d18
7
+ data.tar.gz: 336f0a9a15dc36470b2d8cd1e9f492753b3453b0a8a140a66cc26e3ed85d2933a010e4a29b0892b50d444d298b9d132f5c98f64c82bed4ff06aef813c6d65440
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- t12n (0.1.0)
4
+ t12n (0.2.2)
5
5
  ivo (~> 0.5)
6
6
  zeitwerk (~> 2.4)
7
7
 
data/README.md CHANGED
@@ -4,35 +4,19 @@
4
4
 
5
5
  Create schemas describing data transformations.
6
6
 
7
- ## Installation
8
-
9
- Add this line to your application's Gemfile:
10
-
11
- ```ruby
12
- gem 't12n'
13
- ```
14
-
15
- And then execute:
16
-
17
- $ bundle install
18
-
19
- Or install it yourself as:
20
-
21
- $ gem install t12n
22
-
23
7
  ## Usage
24
8
 
25
- See specs for usage.
9
+ See [spec/examples](spec/examples). The examples run as tests to ensure accuracy.
26
10
 
27
11
  ## Development
28
12
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
13
+ After checking out the repo, run `bundle install` to install dependencies. Then, run `rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
14
 
31
15
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
16
 
33
17
  ## Contributing
34
18
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/t12n. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/t12n/blob/master/CODE_OF_CONDUCT.md).
19
+ Bug reports and pull requests are welcome on GitHub at https://github.com/austinthecoder/t12n. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/austinthecoder/t12n/blob/master/CODE_OF_CONDUCT.md).
36
20
 
37
21
  ## License
38
22
 
@@ -40,4 +24,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
40
24
 
41
25
  ## Code of Conduct
42
26
 
43
- Everyone interacting in the T12n project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/t12n/blob/master/CODE_OF_CONDUCT.md).
27
+ Everyone interacting in the T12n project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/austinthecoder/t12n/blob/master/CODE_OF_CONDUCT.md).
@@ -3,9 +3,19 @@
3
3
  module T12n
4
4
  Interface = Ivo.new(:schema_store) do
5
5
  def define_schema(name, &block)
6
+ raise ArgumentError, "No block given" unless block
7
+
8
+ raise ArgumentError, "Unexpected proc arity: #{block.arity}" if block.arity > 1
9
+
6
10
  builder = SchemaBuilder.new(self)
7
- builder.instance_exec(&block)
8
- schema = Schema.new(name.to_s, builder.schema_attrs, builder.context_blocks)
11
+
12
+ if block.arity == 1
13
+ block.call(builder)
14
+ else
15
+ builder.instance_exec(&block)
16
+ end
17
+
18
+ schema = Schema.new(name, builder.schema_attrs, builder.context_blocks)
9
19
  schema_store.save(schema)
10
20
  :ok
11
21
  end
@@ -20,6 +20,8 @@ module T12n
20
20
  end
21
21
 
22
22
  def define_attr(name, &block)
23
+ raise ArgumentError, "No block given" unless block
24
+
23
25
  schema_attrs << Attr.new(name.to_s, Serializer.from_proc(block))
24
26
  :ok
25
27
  end
@@ -12,7 +12,7 @@ module T12n
12
12
  end
13
13
 
14
14
  def fetch(name)
15
- schema_by_name[name.to_s]
15
+ schema_by_name[name]
16
16
  end
17
17
 
18
18
  private
data/lib/t12n/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module T12n
4
- VERSION = "0.2.1"
4
+ VERSION = "0.2.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: t12n
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Austin Schneider
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-22 00:00:00.000000000 Z
11
+ date: 2021-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: zeitwerk
@@ -56,7 +56,6 @@ files:
56
56
  - README.md
57
57
  - Rakefile
58
58
  - bin/console
59
- - bin/setup
60
59
  - exe/t12n
61
60
  - lib/t12n.rb
62
61
  - lib/t12n/interface.rb
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here