From e7b405971c30d5cdbe4904cf371d86cda83398f8 Mon Sep 17 00:00:00 2001 From: Benjamin Fleischer Date: Thu, 27 Aug 2015 21:17:00 -0500 Subject: [PATCH] Clarify AMS dependencies --- Gemfile | 15 +++++----- active_model_serializers.gemspec | 49 +++++++++++++++++++++++--------- lib/active_model_serializers.rb | 24 +++++++--------- 3 files changed, 54 insertions(+), 34 deletions(-) diff --git a/Gemfile b/Gemfile index bdfff8565..2ecfb63f7 100644 --- a/Gemfile +++ b/Gemfile @@ -3,17 +3,18 @@ source 'https://rubygems.org' # Specify your gem's dependencies in active_model_serializers.gemspec gemspec -gem "minitest" +version = ENV['RAILS_VERSION'] || '4.2' -version = ENV["RAILS_VERSION"] || "4.2" - -if version == "master" - gem "rails", github: "rails/rails" +if version == 'master' + gem 'rails', github: 'rails/rails' # ugh https://github.com/rails/rails/issues/16063#issuecomment-48090125 - gem "arel", github: "rails/arel" + gem 'arel', github: 'rails/arel' else - gem "rails", "~> #{version}.0" + gem_version = "~> #{version}.0" + gem 'activemodel', gem_version + gem 'actionpack', gem_version + gem 'railties', gem_version end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem diff --git a/active_model_serializers.gemspec b/active_model_serializers.gemspec index eff27ca92..de385a97b 100644 --- a/active_model_serializers.gemspec +++ b/active_model_serializers.gemspec @@ -4,26 +4,47 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'active_model/serializer/version' Gem::Specification.new do |spec| - spec.name = "active_model_serializers" + spec.name = 'active_model_serializers' spec.version = ActiveModel::Serializer::VERSION - spec.authors = ["Steve Klabnik"] - spec.email = ["steve@steveklabnik.com"] + spec.platform = Gem::Platform::RUBY + spec.authors = ['Steve Klabnik'] + spec.email = ['steve@steveklabnik.com'] spec.summary = %q{Conventions-based JSON generation for Rails.} spec.description = %q{ActiveModel::Serializers allows you to generate your JSON in an object-oriented and convention-driven manner.} - spec.homepage = "https://github.com/rails-api/active_model_serializers" - spec.license = "MIT" + spec.homepage = 'https://github.com/rails-api/active_model_serializers' + spec.license = 'MIT' spec.files = `git ls-files -z`.split("\x0") - spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) - spec.require_paths = ["lib"] + spec.require_paths = ['lib'] - spec.add_dependency "activemodel", ">= 4.0" + spec.required_ruby_version = '>= 1.9.3' - spec.add_development_dependency "rails", ">= 4.0" - spec.add_development_dependency "bundler", "~> 1.6" - spec.add_development_dependency "timecop", ">= 0.7" - spec.add_development_dependency "rake" - spec.add_development_dependency "kaminari" - spec.add_development_dependency "will_paginate" + rails_versions = '>= 4.0' + spec.add_runtime_dependency 'activemodel', rails_versions + # 'activesupport', rails_versions + # 'builder' + + spec.add_runtime_dependency 'actionpack', rails_versions + # 'activesupport', rails_versions + # 'rack' + # 'rack-test', '~> 0.6.2' + + spec.add_runtime_dependency 'railties', rails_versions + # 'activesupport', rails_versions + # 'actionpack', rails_versions + # 'rake', '>= 0.8.7' + + # 'activesupport', rails_versions + # 'i18n, + # 'tzinfo' + # 'minitest' + # 'thread_safe' + + # Soft dependency for pagination + spec.add_development_dependency 'kaminari' + spec.add_development_dependency 'will_paginate' + + spec.add_development_dependency 'bundler', '~> 1.6' + spec.add_development_dependency 'timecop', '>= 0.7' end diff --git a/lib/active_model_serializers.rb b/lib/active_model_serializers.rb index 01c23e5f7..8b90ba7a9 100644 --- a/lib/active_model_serializers.rb +++ b/lib/active_model_serializers.rb @@ -10,22 +10,20 @@ def silence_warnings end end + require 'active_model' -require 'active_model/serializer/version' +require 'action_controller' + require 'active_model/serializer' require 'active_model/serializable_resource' +require 'active_model/serializer/version' -begin - require 'active_model/serializer/railtie' - require 'action_controller' - require 'action_controller/serialization' - - ActiveSupport.on_load(:action_controller) do - include ::ActionController::Serialization - ActionDispatch::Reloader.to_prepare do - ActiveModel::Serializer.serializers_cache.clear - end +require 'action_controller/serialization' +ActiveSupport.on_load(:action_controller) do + include ::ActionController::Serialization + ActionDispatch::Reloader.to_prepare do + ActiveModel::Serializer.serializers_cache.clear end -rescue LoadError - # rails not installed, continuing end + +require 'active_model/serializer/railtie'