ivy-serializers-rails 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 223c377f7969b7bde8b5d281bd69941a79100343
4
+ data.tar.gz: 0c64797097a46a1589b8d1cea0f20e4d48c25dd9
5
+ SHA512:
6
+ metadata.gz: 7394a529a72464fcada031b5e2b0ad9c6ffc09c73a21f9eb9a4ac3c028aa947eaa0b31d1ffbc68f367aec9a4852cf339addf4282bdd70b1ad8aa39a4e48b675f
7
+ data.tar.gz: 02cc0b6465347dc774a45d015760c25f4989cd796eff5064fe657f065027f3eab3dfc1d4d915b0bc6a738f9ad2555ebaa556b581990c956444eb29a4dca08b1d
@@ -0,0 +1,12 @@
1
+ *.log
2
+ *.sqlite
3
+ /.bundle/
4
+ /.yardoc
5
+ /Gemfile.lock
6
+ /_yardoc/
7
+ /coverage/
8
+ /doc/
9
+ /gemfiles/*.lock
10
+ /pkg/
11
+ /spec/reports/
12
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,18 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 2.2.2
5
+ - 1.9.3
6
+
7
+ cache: bundler
8
+
9
+ before_install: gem install bundler -v 1.9.4
10
+
11
+ gemfile:
12
+ - gemfiles/rails_3.x.gemfile
13
+ - gemfiles/rails_4.x.gemfile
14
+
15
+ notifications:
16
+ email:
17
+ on_success: change
18
+ on_failure: always
@@ -0,0 +1,8 @@
1
+ appraise "rails-3.x" do
2
+ gem "test-unit", "~> 3.0"
3
+ gem "rails", "~> 3.2"
4
+ end
5
+
6
+ appraise "rails-4.x" do
7
+ gem "rails", "~> 4.0"
8
+ end
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,73 @@
1
+ # ivy-serializers-rails
2
+
3
+ [![Build Status](https://travis-ci.org/IvyApp/ivy-serializers-rails.svg?branch=master)](https://travis-ci.org/IvyApp/ivy-serializers-rails)
4
+
5
+ Rails integration for
6
+ [ivy-serializers](https://github.com/ivyapp/ivy-serializers).
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'ivy-serializers-rails'
14
+ ```
15
+
16
+ And then execute:
17
+
18
+ ```sh
19
+ bundle
20
+ ```
21
+
22
+ Or install it yourself with:
23
+
24
+ ```sh
25
+ gem install ivy-serializers-rails
26
+ ```
27
+
28
+ ## Usage
29
+
30
+ See the [ivy-serializers docs](https://github.com/IvyApp/ivy-serializers/blob/master/README.md#usage)
31
+ for how to define a serializer. Once you've done that, set up your
32
+ controller(s) to use your serializer:
33
+
34
+ ```ruby
35
+ class ApplicationController < ActionController::Base
36
+ self.serializer = MySerializer
37
+ end
38
+ ```
39
+
40
+ Note that you're not limited to a single serializer. If you have multiple
41
+ serialization formats, such as one for admin and one for public-facing, you can
42
+ define alternate serializers in `app/serializers` and use them as well.
43
+
44
+ ### Alternate Output Formats
45
+
46
+ By default the ActiveModel::Serializers output format is used. If you'd rather
47
+ use JSON-API (or a custom format), you can do so by setting
48
+ `serialization_format` in your controller. For instance, to use JSON-API:
49
+
50
+ ```ruby
51
+ class ApplicationController < ActionController::Base
52
+ self.serialization_format = Ivy::Serializers::Formats::JSONAPI
53
+ end
54
+ ```
55
+
56
+ ## Development
57
+
58
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run
59
+ `bin/console` for an interactive prompt that will allow you to experiment.
60
+
61
+ To install this gem onto your local machine, run `bundle exec rake install`. To
62
+ release a new version, update the version number in `version.rb`, and then run
63
+ `bundle exec rake release` to create a git tag for the version, push git
64
+ commits and tags, and push the `.gem` file to
65
+ [rubygems.org](https://rubygems.org).
66
+
67
+ ## Contributing
68
+
69
+ 1. Fork it ( https://github.com/[my-github-username]/ivy-serializers-rails/fork )
70
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
71
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
72
+ 4. Push to the branch (`git push origin my-new-feature`)
73
+ 5. Create a new Pull Request
@@ -0,0 +1,7 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ desc 'Default: run specs.'
7
+ task :default => :spec
@@ -0,0 +1,7 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+
4
+ Bundler.require :default, :development
5
+
6
+ Combustion.initialize! :all
7
+ run Combustion::Application
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "test-unit", "~> 3.0"
6
+ gem "rails", "~> 3.2"
7
+
8
+ gemspec :path => "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 4.0"
6
+
7
+ gemspec :path => "../"
@@ -0,0 +1,29 @@
1
+ require File.expand_path('../lib/ivy/serializers/rails/version', __FILE__)
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = 'ivy-serializers-rails'
5
+ spec.version = Ivy::Serializers::Rails::VERSION
6
+ spec.authors = ['Dray Lacy']
7
+ spec.email = ['dray@envylabs.com']
8
+
9
+ spec.summary = 'Rails integration for ivy-serializers.'
10
+ spec.homepage = 'https://github.com/IvyApp/ivy-serializers-rails'
11
+
12
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
13
+ spec.bindir = 'exe'
14
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
15
+ spec.require_paths = ['lib']
16
+
17
+ spec.add_dependency 'ivy-serializers', '~> 0.2'
18
+ spec.add_dependency 'railties', '>= 3.2.6', '< 5'
19
+
20
+ spec.add_development_dependency 'appraisal', '~> 2.0'
21
+ spec.add_development_dependency 'bundler', '~> 1.9'
22
+ spec.add_development_dependency 'combustion', '~> 0.5.3'
23
+ spec.add_development_dependency 'json-schema-rspec'
24
+ spec.add_development_dependency 'rails', '~> 4.2.1'
25
+ spec.add_development_dependency 'rake', '~> 10.0'
26
+ spec.add_development_dependency 'rspec-rails', '~> 3.2.1'
27
+ spec.add_development_dependency 'simplecov', '~> 0.10.0'
28
+ spec.add_development_dependency 'sqlite3', '~> 1.3.10'
29
+ end
@@ -0,0 +1,2 @@
1
+ require 'ivy/serializers/rails/version'
2
+ require 'ivy/serializers/rails/railtie'
@@ -0,0 +1,39 @@
1
+ require 'active_support'
2
+
3
+ module Ivy
4
+ module Serializers
5
+ module Rails
6
+ module ActionController
7
+ module SerializationSupport
8
+ extend ActiveSupport::Concern
9
+
10
+ class SerializerNotFound < ::StandardError
11
+ end
12
+
13
+ included do
14
+ class_attribute :serializer, :instance_writer => false
15
+ class_attribute :serialization_format, :instance_writer => false
16
+ self.serialization_format = ::Ivy::Serializers::Formats::ActiveModelSerializers
17
+ end
18
+
19
+ private
20
+
21
+ %w[ _render_option_json _render_with_renderer_json ].each do |renderer_method|
22
+ define_method(renderer_method) do |resource, options|
23
+ unless serializer
24
+ raise SerializerNotFound, "No serializer found in #{self.class.name}"
25
+ end
26
+
27
+ unless resource.kind_of?(::Hash)
28
+ resource = ::Ivy::Serializers::Documents.create(serializer, controller_name, resource)
29
+ resource = options.fetch(:serialization_format) { self.class.serialization_format }.new(resource)
30
+ end
31
+
32
+ super(resource, options)
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,17 @@
1
+ require 'ivy/serializers'
2
+ require 'ivy/serializers/rails/action_controller/serialization_support'
3
+ require 'rails'
4
+
5
+ module Ivy
6
+ module Serializers
7
+ module Rails
8
+ class Railtie < ::Rails::Railtie
9
+ initializer 'ivy.serializers.controllers' do
10
+ ActiveSupport.on_load(:action_controller) do
11
+ include ::Ivy::Serializers::Rails::ActionController::SerializationSupport
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,7 @@
1
+ module Ivy
2
+ module Serializers
3
+ module Rails
4
+ VERSION = '0.1.0'
5
+ end
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,218 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ivy-serializers-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Dray Lacy
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-05-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ivy-serializers
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: railties
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 3.2.6
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: '5'
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 3.2.6
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: '5'
47
+ - !ruby/object:Gem::Dependency
48
+ name: appraisal
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '2.0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '2.0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: bundler
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '1.9'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '1.9'
75
+ - !ruby/object:Gem::Dependency
76
+ name: combustion
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: 0.5.3
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: 0.5.3
89
+ - !ruby/object:Gem::Dependency
90
+ name: json-schema-rspec
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ - !ruby/object:Gem::Dependency
104
+ name: rails
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: 4.2.1
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: 4.2.1
117
+ - !ruby/object:Gem::Dependency
118
+ name: rake
119
+ requirement: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - "~>"
122
+ - !ruby/object:Gem::Version
123
+ version: '10.0'
124
+ type: :development
125
+ prerelease: false
126
+ version_requirements: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - "~>"
129
+ - !ruby/object:Gem::Version
130
+ version: '10.0'
131
+ - !ruby/object:Gem::Dependency
132
+ name: rspec-rails
133
+ requirement: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - "~>"
136
+ - !ruby/object:Gem::Version
137
+ version: 3.2.1
138
+ type: :development
139
+ prerelease: false
140
+ version_requirements: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - "~>"
143
+ - !ruby/object:Gem::Version
144
+ version: 3.2.1
145
+ - !ruby/object:Gem::Dependency
146
+ name: simplecov
147
+ requirement: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - "~>"
150
+ - !ruby/object:Gem::Version
151
+ version: 0.10.0
152
+ type: :development
153
+ prerelease: false
154
+ version_requirements: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - "~>"
157
+ - !ruby/object:Gem::Version
158
+ version: 0.10.0
159
+ - !ruby/object:Gem::Dependency
160
+ name: sqlite3
161
+ requirement: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - "~>"
164
+ - !ruby/object:Gem::Version
165
+ version: 1.3.10
166
+ type: :development
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ requirements:
170
+ - - "~>"
171
+ - !ruby/object:Gem::Version
172
+ version: 1.3.10
173
+ description:
174
+ email:
175
+ - dray@envylabs.com
176
+ executables: []
177
+ extensions: []
178
+ extra_rdoc_files: []
179
+ files:
180
+ - ".gitignore"
181
+ - ".rspec"
182
+ - ".travis.yml"
183
+ - Appraisals
184
+ - Gemfile
185
+ - README.md
186
+ - Rakefile
187
+ - config.ru
188
+ - gemfiles/rails_3.x.gemfile
189
+ - gemfiles/rails_4.x.gemfile
190
+ - ivy-serializers-rails.gemspec
191
+ - lib/ivy/serializers/rails.rb
192
+ - lib/ivy/serializers/rails/action_controller/serialization_support.rb
193
+ - lib/ivy/serializers/rails/railtie.rb
194
+ - lib/ivy/serializers/rails/version.rb
195
+ homepage: https://github.com/IvyApp/ivy-serializers-rails
196
+ licenses: []
197
+ metadata: {}
198
+ post_install_message:
199
+ rdoc_options: []
200
+ require_paths:
201
+ - lib
202
+ required_ruby_version: !ruby/object:Gem::Requirement
203
+ requirements:
204
+ - - ">="
205
+ - !ruby/object:Gem::Version
206
+ version: '0'
207
+ required_rubygems_version: !ruby/object:Gem::Requirement
208
+ requirements:
209
+ - - ">="
210
+ - !ruby/object:Gem::Version
211
+ version: '0'
212
+ requirements: []
213
+ rubyforge_project:
214
+ rubygems_version: 2.4.6
215
+ signing_key:
216
+ specification_version: 4
217
+ summary: Rails integration for ivy-serializers.
218
+ test_files: []