oat 0.5.1 → 0.5.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
  SHA1:
3
- metadata.gz: b2d910f58530d5cbf88e106998c333704b15237f
4
- data.tar.gz: 4aeb7c7638228de5debc7fdfca5adf68e7b311ea
3
+ metadata.gz: e91756d324b28991b10b9b78aad3dac169ff75ef
4
+ data.tar.gz: 64cb4030b9179913f78b575848f4f80a919f26e1
5
5
  SHA512:
6
- metadata.gz: 61302f48f109b9f6d354b858aff022d06e5df6d182d7c51f423e9d3b05990b1b677e5917661784bb57fcebdc683cfbf1b581402b7e5bb9eb6a936a8cd535d264
7
- data.tar.gz: 43bcffc5b42c3782246f2b388cacb9bbe1ac733d16d19150701dbad4b7f95f32451e7b3e901e4d11a6714286490c1c102d66e8edb1aabb27325b4bacfdf860ad
6
+ metadata.gz: '08264457ae25d020fa01992d7854945d1c553d0e6c8fd5be02cb0641a3daa03195f182bf0bf15ee047e571f11dfe1c18637ee9711b16513eee8195daebdc16fa'
7
+ data.tar.gz: 4e96b9fcf7bf646a289ff692f7fb7e5b70e4c8becb57258b65e24790327c87b0dc3477f8a4961da17bc24c1375a8a3bdd39b55cea513a02126a368637ea6c164
data/CHANGELOG.md CHANGED
@@ -1,8 +1,7 @@
1
1
  # Change Log
2
2
 
3
- ## [Unreleased](https://github.com/ismasan/oat/tree/HEAD)
4
-
5
- [Full Changelog](https://github.com/ismasan/oat/compare/v0.5.0...HEAD)
3
+ ## [v0.5.1](https://github.com/ismasan/oat/tree/v0.5.1) (2017-06-06)
4
+ [Full Changelog](https://github.com/ismasan/oat/compare/v0.5.0...v0.5.1)
6
5
 
7
6
  **Merged pull requests:**
8
7
 
@@ -1,12 +1,4 @@
1
1
  # http://jsonapi.org/format/#url-based-json-api
2
- require 'active_support/inflector'
3
- require 'active_support/core_ext/string/inflections'
4
- unless defined?(String.new.pluralize)
5
- class String
6
- include ActiveSupport::CoreExtensions::String::Inflections
7
- end
8
- end
9
-
10
2
  module Oat
11
3
  module Adapters
12
4
 
@@ -24,7 +16,7 @@ module Oat
24
16
  end
25
17
 
26
18
  def type(*types)
27
- @root_name = types.first.to_s.pluralize.to_sym
19
+ @root_name = pluralize(types.first.to_s).to_sym
28
20
  end
29
21
 
30
22
  def link(rel, opts = {})
@@ -74,7 +66,7 @@ module Oat
74
66
  if ent
75
67
  ent_hash = ent.to_hash
76
68
  _name = entity_name(name)
77
- link_name = _name.to_s.pluralize.to_sym
69
+ link_name = pluralize(_name.to_s).to_sym
78
70
  data[:links][_name] = ent_hash[:id]
79
71
 
80
72
  entity_hash[link_name] ||= []
@@ -87,7 +79,7 @@ module Oat
87
79
  def entities(name, collection, serializer_class = nil, context_options = {}, &block)
88
80
  return if collection.nil? || collection.empty?
89
81
  _name = entity_name(name)
90
- link_name = _name.to_s.pluralize.to_sym
82
+ link_name = pluralize(_name.to_s).to_sym
91
83
  data[:links][link_name] = []
92
84
 
93
85
  collection.each do |obj|
@@ -155,6 +147,15 @@ module Oat
155
147
  ent.to_hash.values.first.first if ent
156
148
  end
157
149
 
150
+ PLURAL = /s$/
151
+
152
+ def pluralize(str)
153
+ if str =~ PLURAL
154
+ str
155
+ else
156
+ "#{str}s"
157
+ end
158
+ end
158
159
  end
159
160
  end
160
161
  end
@@ -2,7 +2,7 @@ require 'support/class_attribute'
2
2
 
3
3
  module Oat
4
4
  class Serializer
5
-
5
+ extend ClassAttribute
6
6
  class_attribute :_adapter, :logger, :schemas, :schema_methods
7
7
 
8
8
  self.schemas = []
data/lib/oat/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Oat
2
- VERSION = "0.5.1"
2
+ VERSION = "0.5.2"
3
3
  end
@@ -1,66 +1,37 @@
1
- begin
2
- require 'active_support/core_ext/class/attribute'
3
- rescue LoadError
4
- module Kernel
5
- # Returns the object's singleton class.
6
- def singleton_class
7
- class << self
8
- self
9
- end
10
- end unless respond_to?(:singleton_class) # exists in 1.9.2
11
-
12
- # class_eval on an object acts like singleton_class.class_eval.
13
- def class_eval(*args, &block)
14
- singleton_class.class_eval(*args, &block)
15
- end
16
- end
17
-
18
- class Module
19
- def remove_possible_method(method)
20
- if method_defined?(method) || private_method_defined?(method)
21
- remove_method(method)
22
- end
23
- rescue NameError
24
- # If the requested method is defined on a superclass or included module,
25
- # method_defined? returns true but remove_method throws a NameError.
26
- # Ignore this.
27
- end
28
-
29
- def redefine_method(method, &block)
30
- remove_possible_method(method)
31
- define_method(method, &block)
32
- end
33
- end
34
-
35
- class Class
1
+ module Oat
2
+ module ClassAttribute
36
3
  def class_attribute(*attrs)
37
4
  attrs.each do |name|
38
5
  class_eval <<-RUBY, __FILE__, __LINE__ + 1
39
- def self.#{name}() nil end
40
- def self.#{name}?() !!#{name} end
6
+ def self.#{name}() nil end
41
7
 
42
- def self.#{name}=(val)
43
- singleton_class.class_eval do
44
- remove_possible_method(:#{name})
45
- define_method(:#{name}) { val }
46
- end
8
+ def self.#{name}=(val)
9
+ singleton_class.class_eval do
10
+ define_method(:#{name}) { val }
11
+ end
47
12
 
48
- if singleton_class?
49
- class_eval do
50
- remove_possible_method(:#{name})
51
- def #{name}
52
- defined?(@#{name}) ? @#{name} : singleton_class.#{name}
13
+ if singleton_class?
14
+ class_eval do
15
+ def #{name}
16
+ defined?(@#{name}) ? @#{name} : singleton_class.#{name}
17
+ end
53
18
  end
54
19
  end
20
+ val
55
21
  end
56
- val
57
- end
58
22
  RUBY
59
23
 
60
24
  end
61
25
  end
62
26
 
63
27
  private
28
+
29
+ def singleton_class
30
+ class << self
31
+ self
32
+ end
33
+ end unless respond_to?(:singleton_class) # exists in 1.9.2
34
+
64
35
  def singleton_class?
65
36
  ancestors.first != self
66
37
  end
data/oat.gemspec CHANGED
@@ -18,7 +18,6 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency "activesupport"
22
21
  spec.add_development_dependency "bundler", "~> 1.3"
23
22
  spec.add_development_dependency "rake"
24
23
  spec.add_development_dependency "rspec", ">= 3.0"
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ismael Celis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-06 00:00:00.000000000 Z
11
+ date: 2018-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: activesupport
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: bundler
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -97,13 +83,6 @@ files:
97
83
  - LICENSE
98
84
  - README.md
99
85
  - Rakefile
100
- - gemfiles/Gemfile.as-1.4.4
101
- - gemfiles/Gemfile.as-2.3.x
102
- - gemfiles/Gemfile.as-3.0.x
103
- - gemfiles/Gemfile.as-3.1.x
104
- - gemfiles/Gemfile.as-3.2.x
105
- - gemfiles/Gemfile.as-4.0.x
106
- - gemfiles/Gemfile.as-4.1.x
107
86
  - lib/oat.rb
108
87
  - lib/oat/adapter.rb
109
88
  - lib/oat/adapters/hal.rb
@@ -140,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
119
  version: '0'
141
120
  requirements: []
142
121
  rubyforge_project:
143
- rubygems_version: 2.5.1
122
+ rubygems_version: 2.6.13
144
123
  signing_key:
145
124
  specification_version: 4
146
125
  summary: Adapters-based serializers with Hypermedia support
@@ -1,6 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in oat.gemspec
4
- gem 'activesupport', '1.4.4'
5
- gem 'rake', '< 10.2'
6
- gemspec :path => "../"
@@ -1,6 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in oat.gemspec
4
- gem 'activesupport', '~>2.3.18'
5
- gem 'rake', '< 10.2'
6
- gemspec :path => "../"
@@ -1,7 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in oat.gemspec
4
- gem 'i18n', '0.6.9'
5
- gem 'activesupport', '~>3.0.20'
6
- gem 'rake', '< 10.2'
7
- gemspec :path => "../"
@@ -1,7 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in oat.gemspec
4
- gem 'i18n', '0.6.9'
5
- gem 'activesupport', '~>3.1.12'
6
- gem 'rake', '< 10.2'
7
- gemspec :path => "../"
@@ -1,7 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in oat.gemspec
4
- gem 'i18n', '0.6.9'
5
- gem 'activesupport', '~>3.2.16'
6
- gem 'rake', '< 10.2'
7
- gemspec :path => "../"
@@ -1,5 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in oat.gemspec
4
- gem 'activesupport', '~>4.0.2'
5
- gemspec :path => "../"
@@ -1,5 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in oat.gemspec
4
- gem 'activesupport', '~>4.1.4'
5
- gemspec :path => "../"