transcriber 0.0.25 → 0.0.26

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. data/examples/all.rb +1 -1
  2. data/examples/to_input/serializables.rb +23 -0
  3. data/lib/transcriber.rb +29 -37
  4. data/lib/transcriber/configuration.rb +25 -1
  5. data/lib/transcriber/resource/builder.rb +24 -5
  6. data/lib/transcriber/resource/input_parser.rb +8 -2
  7. data/lib/transcriber/resource/key/embeddable.rb +4 -2
  8. data/lib/transcriber/resource/{builder/embeddables.rb → key/embeddable/builder.rb} +2 -2
  9. data/lib/transcriber/resource/{parser/embeddable.rb → key/embeddable/parser.rb} +3 -3
  10. data/lib/transcriber/resource/{response/embeddable.rb → key/embeddable/response.rb} +2 -2
  11. data/lib/transcriber/resource/key/href.rb +2 -1
  12. data/lib/transcriber/resource/{response/href.rb → key/href/response.rb} +2 -2
  13. data/lib/transcriber/resource/key/property.rb +4 -2
  14. data/lib/transcriber/resource/{builder/properties.rb → key/property/builder.rb} +2 -2
  15. data/lib/transcriber/resource/{parser/property.rb → key/property/parser.rb} +23 -9
  16. data/lib/transcriber/resource/{response/property.rb → key/property/response.rb} +2 -2
  17. data/lib/transcriber/resource/key/relation.rb +2 -1
  18. data/lib/transcriber/resource/{builder/relations.rb → key/relation/builder.rb} +2 -2
  19. data/lib/transcriber/resource/{response/relation.rb → key/relation/response.rb} +2 -2
  20. data/lib/transcriber/resource/serialization/boolean.rb +13 -0
  21. data/lib/transcriber/resource/serialization/date.rb +8 -0
  22. data/lib/transcriber/resource/serialization/enumerable.rb +5 -0
  23. data/lib/transcriber/resource/serialization/float.rb +6 -0
  24. data/lib/transcriber/resource/serialization/integer.rb +6 -0
  25. data/lib/transcriber/resource/serialization/string.rb +4 -0
  26. data/lib/transcriber/version.rb +1 -1
  27. data/spec/unit/resource/builder/embeddables_spec.rb +1 -1
  28. data/spec/unit/resource/builder/properties_spec.rb +1 -1
  29. data/spec/unit/resource/builder/relations_spec.rb +1 -1
  30. data/spec/unit/resource/parser/embeddable_spec.rb +1 -1
  31. data/spec/unit/resource/parser/property_spec.rb +1 -1
  32. data/spec/unit/resource/response/embeddable_spec.rb +1 -1
  33. data/spec/unit/resource/response/property_spec.rb +1 -1
  34. metadata +24 -25
  35. data/lib/transcriber/resource/builder/keys.rb +0 -21
  36. data/lib/transcriber/resource/builder/summarizations.rb +0 -14
data/examples/all.rb CHANGED
@@ -1,4 +1,4 @@
1
- $:.push 'lib'; require 'transcriber'
1
+ $:.push 'lib'; puts ": #{$:}"; require 'transcriber'
2
2
 
3
3
  Dir["examples/*/**.rb"].each do |file|
4
4
  [:Root, :Item, :Customer, :Entry, :Service].each do |klass|
@@ -0,0 +1,23 @@
1
+ $:.push 'lib'; require 'transcriber'
2
+
3
+ Transcriber.configure do |c|
4
+ c.true_value = "X"
5
+ c.false_value = ""
6
+ c.date_format = "%Y%m%d"
7
+ end
8
+
9
+ class Customer < Transcriber::Resource
10
+ property :login
11
+ property :age, type: Integer
12
+ property :birth, type: Date
13
+ property :active, type: Boolean
14
+ property :services, type: Enumerable
15
+ property :balance, type: Float
16
+ end
17
+
18
+ @root = Customer.new({login: 'jackiechan2010', age: 22, birth: "1990-07-04", active: true, services: ["Hosting", "Email"], balance: 200.00})
19
+
20
+ puts "root.to_input: #{@root.to_input}"
21
+
22
+ puts "root: #{@root.inspect}"
23
+ puts "resource: #{@root.resource}"
data/lib/transcriber.rb CHANGED
@@ -1,42 +1,34 @@
1
- require 'date'
2
- require 'active_support/inflector'
3
- require 'active_support/concern'
4
- require 'active_support/core_ext/class/attribute_accessors'
5
- require 'active_support/core_ext/object/try'
6
- require 'active_support/core_ext/array/wrap'
7
- require 'active_support/core_ext/hash/slice'
1
+ require "date"
2
+ require "active_support/inflector"
3
+ require "active_support/concern"
4
+ require "active_support/core_ext/class/attribute_accessors"
5
+ require "active_support/core_ext/object/try"
6
+ require "active_support/core_ext/array/wrap"
7
+ require "active_support/core_ext/hash/slice"
8
8
  require "active_support/core_ext/hash/indifferent_access"
9
9
 
10
- require 'transcriber/resource/input_path'
11
- require 'transcriber/resource/input_parser'
12
- require 'transcriber/resource/parser'
13
- require 'transcriber/resource/response'
14
- require 'transcriber/resource/serialization/boolean'
15
- require 'transcriber/resource/serialization/date'
16
- require 'transcriber/resource/serialization/enumerable'
17
- require 'transcriber/resource/serialization/float'
18
- require 'transcriber/resource/serialization/integer'
19
- require 'transcriber/resource/serialization/string'
20
- require 'transcriber/resource/key'
21
- require 'transcriber/resource/parser/property'
22
- require 'transcriber/resource/parser/embeddable'
23
- require 'transcriber/resource/response/property'
24
- require 'transcriber/resource/response/embeddable'
25
- require 'transcriber/resource/response/relation'
26
- require 'transcriber/resource/response/href'
27
- require 'transcriber/resource/key/property'
28
- require 'transcriber/resource/key/association'
29
- require 'transcriber/resource/key/relation'
30
- require 'transcriber/resource/key/embeddable'
31
- require 'transcriber/resource/key/href'
32
- require 'transcriber/resource/builder/keys'
33
- require 'transcriber/resource/builder/relations'
34
- require 'transcriber/resource/builder/embeddables'
35
- require 'transcriber/resource/builder/properties'
36
- require 'transcriber/resource/builder/summarizations'
37
- require 'transcriber/resource/builder'
38
- require 'transcriber/resource'
39
- require 'transcriber/configuration'
10
+ require "transcriber/resource/input_path"
11
+ require "transcriber/resource/input_parser"
12
+ require "transcriber/resource/parser"
13
+ require "transcriber/resource/response"
14
+ require "transcriber/resource/serialization/boolean"
15
+ require "transcriber/resource/serialization/date"
16
+ require "transcriber/resource/serialization/enumerable"
17
+ require "transcriber/resource/serialization/float"
18
+ require "transcriber/resource/serialization/integer"
19
+ require "transcriber/resource/serialization/string"
20
+ require "transcriber/resource/key"
21
+ require "transcriber/resource/key/property"
22
+ require "transcriber/resource/key/property/builder"
23
+ require "transcriber/resource/key/association"
24
+ require "transcriber/resource/key/relation"
25
+ require "transcriber/resource/key/relation/builder"
26
+ require "transcriber/resource/key/embeddable"
27
+ require "transcriber/resource/key/embeddable/builder"
28
+ require "transcriber/resource/key/href"
29
+ require "transcriber/resource/builder"
30
+ require "transcriber/resource"
31
+ require "transcriber/configuration"
40
32
 
41
33
  module Transcriber
42
34
  def self.configuration
@@ -2,7 +2,7 @@ module Transcriber
2
2
  class Configuration
3
3
  attr_accessor :host
4
4
 
5
- DefaultHandler = lambda {|keys| keys}
5
+ DefaultHandler = proc {|keys| keys}
6
6
 
7
7
  def convert_input_keys
8
8
  @convert_input_keys || DefaultHandler
@@ -11,5 +11,29 @@ module Transcriber
11
11
  def convert_input_keys=(converter)
12
12
  @convert_input_keys = converter
13
13
  end
14
+
15
+ def true_value
16
+ @true || true
17
+ end
18
+
19
+ def true_value=(value)
20
+ @true = value
21
+ end
22
+
23
+ def false_value
24
+ @false || false
25
+ end
26
+
27
+ def false_value=(value)
28
+ @false = value
29
+ end
30
+
31
+ def date_format
32
+ @date_format
33
+ end
34
+
35
+ def date_format=(format)
36
+ @date_format = format
37
+ end
14
38
  end
15
39
  end
@@ -1,11 +1,30 @@
1
1
  module Transcriber
2
2
  class Resource
3
3
  module Builder
4
- include Keys
5
- include Relations
6
- include Embeddables
7
- include Properties
8
- include Summarizations
4
+ include Relation::Builder
5
+ include Embeddable::Builder
6
+ include Property::Builder
7
+
8
+ def key(key)
9
+ fail "you can't define a key with name '#{key.name}'" if not_allowed?(key)
10
+ key.model = self
11
+ attr_accessor key.name
12
+ self.keys << key
13
+ self.id_key = key if key.options[:id]
14
+ end
15
+
16
+ def summarizes(*args)
17
+ args.each do |name|
18
+ key = keys.find {|key| key.name == name}
19
+ summarized_keys << key if key
20
+ end
21
+ end
22
+
23
+ private
24
+
25
+ def not_allowed?(key)
26
+ Resource.not_allowed_names.include?(key.name.to_s)
27
+ end
9
28
  end
10
29
  end
11
30
  end
@@ -1,13 +1,19 @@
1
1
  module Transcriber
2
2
  class Resource
3
3
  module InputParser
4
+ def to_input!(options = {})
5
+ to_input(options.merge(fail: true))
6
+ end
7
+
4
8
  def to_input(options = {})
5
9
  input = {}
10
+ propagatable_options = {without_nil: options[:without_nil],
11
+ fail: options[:fail]}
6
12
 
7
13
  keys_to_input(options).each do |key|
8
14
  value = __send__(key.name)
9
- key_options = options.fetch(key.name, {without_nil: options[:without_nil]})
10
- input.merge! key.to_input(value, self, key_options)
15
+ key_options = options.fetch(key.name, {}).merge(propagatable_options)
16
+ input.merge! key.to_input!(value, self, key_options)
11
17
  end
12
18
 
13
19
  input.with_indifferent_access
@@ -1,8 +1,10 @@
1
1
  module Transcriber
2
2
  class Resource
3
3
  class Embeddable < Association
4
- include Parser::Embeddable
5
- include Response::Embeddable
4
+ autoload :Parser, "transcriber/resource/key/embeddable/parser"
5
+ autoload :Response, "transcriber/resource/key/embeddable/response"
6
+ include Parser
7
+ include Response
6
8
 
7
9
  attr_accessor :fields
8
10
 
@@ -1,7 +1,7 @@
1
1
  module Transcriber
2
2
  class Resource
3
- module Builder
4
- module Embeddables
3
+ class Embeddable
4
+ module Builder
5
5
  def embeds(name, options = {})
6
6
  key Embeddable.new(name, options)
7
7
  end
@@ -1,7 +1,7 @@
1
1
  module Transcriber
2
2
  class Resource
3
- module Parser
4
- module Embeddable
3
+ class Embeddable
4
+ module Parser
5
5
  def parse(item, resource = nil)
6
6
  return parse_fields(item) if fields
7
7
  value = digg(item)
@@ -21,7 +21,7 @@ module Transcriber
21
21
  raw? ? attrs : super
22
22
  end
23
23
 
24
- def to_input(value, resource, options = {})
24
+ def to_input!(value, resource, options = {})
25
25
  return {} if value.nil?
26
26
  fields ? to_multiple_input(value, options)
27
27
  : to_single_input(value, options)
@@ -1,7 +1,7 @@
1
1
  module Transcriber
2
2
  class Resource
3
- module Response
4
- module Embeddable
3
+ class Embeddable
4
+ module Response
5
5
  def to_resource(parent)
6
6
  return {} unless visible?(parent)
7
7
  resource = nil
@@ -1,7 +1,8 @@
1
1
  module Transcriber
2
2
  class Resource
3
3
  class Href < Key
4
- include Response::Href
4
+ autoload :Response, "transcriber/resource/key/href/response"
5
+ include Response
5
6
 
6
7
  def initialize
7
8
  super(:href)
@@ -1,7 +1,7 @@
1
1
  module Transcriber
2
2
  class Resource
3
- module Response
4
- module Href
3
+ class Href
4
+ module Response
5
5
  def to_resource(parent)
6
6
  id_key = parent.class.id_key.name
7
7
  {name => "#{Transcriber.host}/#{parent.class.resource_name}/#{parent.send(id_key)}"}
@@ -1,8 +1,10 @@
1
1
  module Transcriber
2
2
  class Resource
3
3
  class Property < Key
4
- include Parser::Property
5
- include Response::Property
4
+ autoload :Parser, "transcriber/resource/key/property/parser"
5
+ autoload :Response, "transcriber/resource/key/property/response"
6
+ include Parser
7
+ include Response
6
8
 
7
9
  attr_accessor :serializer, :translations
8
10
 
@@ -1,7 +1,7 @@
1
1
  module Transcriber
2
2
  class Resource
3
- module Builder
4
- module Properties
3
+ class Property
4
+ module Builder
5
5
  def property(name, options = {})
6
6
  key Property.new(name, options)
7
7
  end
@@ -1,7 +1,7 @@
1
1
  module Transcriber
2
2
  class Resource
3
- module Parser
4
- module Property
3
+ class Property
4
+ module Parser
5
5
  def parse(item, resource = nil)
6
6
  value = digg(item)
7
7
  translate_from_input(serializer.serialize(value), resource)
@@ -14,16 +14,19 @@ module Transcriber
14
14
  def translate_from_input(value, resource)
15
15
  case translations
16
16
  when nil then value
17
- when Hash then translations.key(value)
18
17
  when Proc then resource.instance_eval(&translations)
18
+ when Hash
19
+ fail "from input error" unless translations.has_value?(value)
20
+ translations.key(value)
19
21
  end
20
22
  end
21
23
 
22
24
  def translate_to_input(value, resource)
23
25
  case translations
24
- when nil then value
25
- when Hash then translations[value]
26
26
  when Proc then resource.instance_eval(&translations)
27
+ when Hash
28
+ fail "to input error" unless translations.has_key?(value)
29
+ translations[value]
27
30
  end
28
31
  end
29
32
 
@@ -31,17 +34,28 @@ module Transcriber
31
34
  value
32
35
  end
33
36
 
34
- def to_input(value, resource, options = {});
35
- value = translate_to_input(value, resource)
37
+ def to_input!(value, resource, options = {})
38
+ input_value = nil
39
+
40
+ begin
41
+ if translations
42
+ input_value = translate_to_input(value, resource)
43
+ else
44
+ input_value = serializer.desserialize(value)
45
+ end
46
+ rescue => exception
47
+ raise exception if options[:fail]
48
+ end
49
+
36
50
  input = {}
37
51
  path = input_path
38
52
 
39
53
  if path.any?
40
54
  last = path.pop
41
55
  key_input = path.inject(input) {|buffer, key| buffer[key] = {}; buffer[key]}
42
- key_input[last] = value
56
+ key_input[last] = input_value
43
57
  else
44
- input.merge!(value)
58
+ input.merge!(input_value)
45
59
  end
46
60
 
47
61
  input
@@ -1,7 +1,7 @@
1
1
  module Transcriber
2
2
  class Resource
3
- module Response
4
- module Property
3
+ class Property
4
+ module Response
5
5
  def to_resource(parent)
6
6
  visible?(parent) ? {name => parent.__send__(name)} : {}
7
7
  end
@@ -1,7 +1,8 @@
1
1
  module Transcriber
2
2
  class Resource
3
3
  class Relation < Association
4
- include Response::Relation
4
+ autoload :Response, "transcriber/resource/key/relation/response"
5
+ include Response
5
6
 
6
7
  def initialize(name, options = {})
7
8
  super
@@ -1,7 +1,7 @@
1
1
  module Transcriber
2
2
  class Resource
3
- module Builder
4
- module Relations
3
+ class Relation
4
+ module Builder
5
5
  def relation(name, options = {})
6
6
  key Relation.new(name, options)
7
7
  end
@@ -1,7 +1,7 @@
1
1
  module Transcriber
2
2
  class Resource
3
- module Response
4
- module Relation
3
+ class Relation
4
+ module Response
5
5
  def to_resource(parent)
6
6
  included = parent.__send__(name)
7
7
  return {} unless visible?(parent) and included
@@ -31,6 +31,19 @@ module Transcriber
31
31
  fail "value not serializable: #{value}" if bool.nil?
32
32
  end
33
33
  end
34
+
35
+ def self.desserialize(value)
36
+ fail unless boolean?(value)
37
+
38
+ value ? Transcriber.configuration.true_value
39
+ : Transcriber.configuration.false_value
40
+ end
41
+
42
+ private
43
+
44
+ def self.boolean?(value)
45
+ !!value == value
46
+ end
34
47
  end
35
48
  end
36
49
  end
@@ -7,6 +7,14 @@ module Transcriber
7
7
  rescue ArgumentError
8
8
  raise "value not serializable: #{value}"
9
9
  end
10
+
11
+ def self.desserialize(value)
12
+ date = value.kind_of?(::Date) ? value : ::Date.parse(value)
13
+ format = Transcriber.configuration.date_format
14
+ format ? date.strftime(format) : date.to_s
15
+ rescue ArgumentError
16
+ raise "value not desserializable: #{value}"
17
+ end
10
18
  end
11
19
  end
12
20
  end
@@ -6,6 +6,11 @@ module Transcriber
6
6
  fail "value not serializable: #{value}" unless value.kind_of?(::Enumerable)
7
7
  value
8
8
  end
9
+
10
+ def self.desserialize(value)
11
+ fail "value not desserializable: #{value}" unless value.kind_of?(::Enumerable)
12
+ value
13
+ end
9
14
  end
10
15
  end
11
16
  end
@@ -7,6 +7,12 @@ module Transcriber
7
7
  rescue ArgumentError
8
8
  raise "value not serializable: #{value}"
9
9
  end
10
+
11
+ def self.desserialize(value)
12
+ Float(value)
13
+ rescue ArgumentError
14
+ raise "value not desserializable: #{value}"
15
+ end
10
16
  end
11
17
  end
12
18
  end
@@ -7,6 +7,12 @@ module Transcriber
7
7
  rescue ArgumentError
8
8
  raise "value not serializable: #{value}"
9
9
  end
10
+
11
+ def self.desserialize(value)
12
+ Integer(value)
13
+ rescue ArgumentError
14
+ raise "value not desserializable: #{value}"
15
+ end
10
16
  end
11
17
  end
12
18
  end
@@ -5,6 +5,10 @@ module Transcriber
5
5
  def self.serialize(value)
6
6
  value.nil? ? nil : value.to_s
7
7
  end
8
+
9
+ def self.serialize(value)
10
+ value.nil? ? nil : value.to_s
11
+ end
8
12
  end
9
13
  end
10
14
  end
@@ -1,3 +1,3 @@
1
1
  module Transcriber
2
- VERSION = "0.0.25"
2
+ VERSION = "0.0.26"
3
3
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
  require 'unit/resource/builder/shared_example_for_association'
3
3
 
4
- describe Resource::Builder::Embeddables do
4
+ describe Resource::Embeddable::Builder do
5
5
  before do
6
6
  class Example < Transcriber::Resource
7
7
  embeds_one :contract, some_option: 'contract options'
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Resource::Builder::Properties do
3
+ describe Resource::Property::Builder do
4
4
  shared_examples_for "a property" do
5
5
  it "defines an attr_accessor with property name" do
6
6
  Example.new.tap do |example|
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
  require 'unit/resource/builder/shared_example_for_association'
3
3
 
4
- describe Resource::Builder::Relations do
4
+ describe Resource::Relation::Builder do
5
5
  describe ".has_one" do
6
6
  before do
7
7
  class Example < Transcriber::Resource
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Resource::Parser::Embeddable do
3
+ describe Resource::Embeddable::Parser do
4
4
  context "when it embeds one" do
5
5
  before do
6
6
  class ExampleChild < Resource
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Resource::Parser::Property do
3
+ describe Resource::Property::Parser do
4
4
  subject {Resource::Property.new(:login)}
5
5
 
6
6
  let(:item) {{login: "jackiechan2010"}}
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Resource::Response::Embeddable do
3
+ describe Resource::Embeddable::Response do
4
4
  before do
5
5
  class ExampleChild < Resource
6
6
  property :id
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Resource::Response::Property do
3
+ describe Resource::Property::Response do
4
4
  class Customer
5
5
  attr_accessor :login
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: transcriber
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.25
4
+ version: 0.0.26
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,11 +11,11 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2011-09-26 00:00:00.000000000Z
14
+ date: 2011-10-04 00:00:00.000000000Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activesupport
18
- requirement: &70247910656520 !ruby/object:Gem::Requirement
18
+ requirement: &70153480625580 !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
21
  - - ~>
@@ -23,10 +23,10 @@ dependencies:
23
23
  version: '3.0'
24
24
  type: :runtime
25
25
  prerelease: false
26
- version_requirements: *70247910656520
26
+ version_requirements: *70153480625580
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: i18n
29
- requirement: &70247910656020 !ruby/object:Gem::Requirement
29
+ requirement: &70153480624980 !ruby/object:Gem::Requirement
30
30
  none: false
31
31
  requirements:
32
32
  - - ! '>='
@@ -34,10 +34,10 @@ dependencies:
34
34
  version: '0.5'
35
35
  type: :runtime
36
36
  prerelease: false
37
- version_requirements: *70247910656020
37
+ version_requirements: *70153480624980
38
38
  - !ruby/object:Gem::Dependency
39
39
  name: rspec
40
- requirement: &70247899184700 !ruby/object:Gem::Requirement
40
+ requirement: &70153480616320 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
43
  - - ~>
@@ -45,10 +45,10 @@ dependencies:
45
45
  version: '2.6'
46
46
  type: :development
47
47
  prerelease: false
48
- version_requirements: *70247899184700
48
+ version_requirements: *70153480616320
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: guard
51
- requirement: &70247899184240 !ruby/object:Gem::Requirement
51
+ requirement: &70153480615520 !ruby/object:Gem::Requirement
52
52
  none: false
53
53
  requirements:
54
54
  - - ~>
@@ -56,10 +56,10 @@ dependencies:
56
56
  version: '0.5'
57
57
  type: :development
58
58
  prerelease: false
59
- version_requirements: *70247899184240
59
+ version_requirements: *70153480615520
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: guard-rspec
62
- requirement: &70247899183780 !ruby/object:Gem::Requirement
62
+ requirement: &70153480614880 !ruby/object:Gem::Requirement
63
63
  none: false
64
64
  requirements:
65
65
  - - ~>
@@ -67,10 +67,10 @@ dependencies:
67
67
  version: '0.4'
68
68
  type: :development
69
69
  prerelease: false
70
- version_requirements: *70247899183780
70
+ version_requirements: *70153480614880
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: growl
73
- requirement: &70247899183320 !ruby/object:Gem::Requirement
73
+ requirement: &70153480614320 !ruby/object:Gem::Requirement
74
74
  none: false
75
75
  requirements:
76
76
  - - ~>
@@ -78,7 +78,7 @@ dependencies:
78
78
  version: '1.0'
79
79
  type: :development
80
80
  prerelease: false
81
- version_requirements: *70247899183320
81
+ version_requirements: *70153480614320
82
82
  description: ''
83
83
  email:
84
84
  - victorcrodrigues@gmail.com
@@ -128,6 +128,7 @@ files:
128
128
  - examples/to_input/embeds_one.rb
129
129
  - examples/to_input/embeds_one_without_key.rb
130
130
  - examples/to_input/flattened.rb
131
+ - examples/to_input/serializables.rb
131
132
  - examples/to_input/simple.rb
132
133
  - examples/to_input/with_field.rb
133
134
  - examples/to_input/with_field_path.rb
@@ -138,27 +139,25 @@ files:
138
139
  - lib/transcriber/configuration.rb
139
140
  - lib/transcriber/resource.rb
140
141
  - lib/transcriber/resource/builder.rb
141
- - lib/transcriber/resource/builder/embeddables.rb
142
- - lib/transcriber/resource/builder/keys.rb
143
- - lib/transcriber/resource/builder/properties.rb
144
- - lib/transcriber/resource/builder/relations.rb
145
- - lib/transcriber/resource/builder/summarizations.rb
146
142
  - lib/transcriber/resource/input_parser.rb
147
143
  - lib/transcriber/resource/input_path.rb
148
144
  - lib/transcriber/resource/key.rb
149
145
  - lib/transcriber/resource/key/association.rb
150
146
  - lib/transcriber/resource/key/embeddable.rb
147
+ - lib/transcriber/resource/key/embeddable/builder.rb
148
+ - lib/transcriber/resource/key/embeddable/parser.rb
149
+ - lib/transcriber/resource/key/embeddable/response.rb
151
150
  - lib/transcriber/resource/key/href.rb
151
+ - lib/transcriber/resource/key/href/response.rb
152
152
  - lib/transcriber/resource/key/property.rb
153
+ - lib/transcriber/resource/key/property/builder.rb
154
+ - lib/transcriber/resource/key/property/parser.rb
155
+ - lib/transcriber/resource/key/property/response.rb
153
156
  - lib/transcriber/resource/key/relation.rb
157
+ - lib/transcriber/resource/key/relation/builder.rb
158
+ - lib/transcriber/resource/key/relation/response.rb
154
159
  - lib/transcriber/resource/parser.rb
155
- - lib/transcriber/resource/parser/embeddable.rb
156
- - lib/transcriber/resource/parser/property.rb
157
160
  - lib/transcriber/resource/response.rb
158
- - lib/transcriber/resource/response/embeddable.rb
159
- - lib/transcriber/resource/response/href.rb
160
- - lib/transcriber/resource/response/property.rb
161
- - lib/transcriber/resource/response/relation.rb
162
161
  - lib/transcriber/resource/serialization/boolean.rb
163
162
  - lib/transcriber/resource/serialization/date.rb
164
163
  - lib/transcriber/resource/serialization/enumerable.rb
@@ -1,21 +0,0 @@
1
- module Transcriber
2
- class Resource
3
- module Builder
4
- module Keys
5
- def key(key)
6
- fail "you can't define a key with name '#{key.name}'" if not_allowed?(key)
7
- key.model = self
8
- attr_accessor key.name
9
- self.keys << key
10
- self.id_key = key if key.options[:id]
11
- end
12
-
13
- private
14
-
15
- def not_allowed?(key)
16
- Resource.not_allowed_names.include?(key.name.to_s)
17
- end
18
- end
19
- end
20
- end
21
- end
@@ -1,14 +0,0 @@
1
- module Transcriber
2
- class Resource
3
- module Builder
4
- module Summarizations
5
- def summarizes(*args)
6
- args.each do |name|
7
- key = keys.find {|key| key.name == name}
8
- summarized_keys << key if key
9
- end
10
- end
11
- end
12
- end
13
- end
14
- end