rom-rails 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.rspec +1 -0
  4. data/.ruby-version +1 -0
  5. data/.travis.yml +20 -0
  6. data/CHANGELOG.md +3 -0
  7. data/Gemfile +17 -0
  8. data/LICENSE +20 -0
  9. data/LICENSE.txt +22 -0
  10. data/README.md +5 -0
  11. data/Rakefile +4 -0
  12. data/lib/rom-rails.rb +8 -0
  13. data/lib/rom/rails/controller_extension.rb +13 -0
  14. data/lib/rom/rails/railtie.rb +79 -0
  15. data/lib/rom/rails/version.rb +5 -0
  16. data/lib/rom/rom-rails.rb +8 -0
  17. data/rom-rails.gemspec +24 -0
  18. data/spec/dummy/.rspec +1 -0
  19. data/spec/dummy/README.rdoc +28 -0
  20. data/spec/dummy/Rakefile +6 -0
  21. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  22. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  23. data/spec/dummy/app/controllers/users_controller.rb +7 -0
  24. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  25. data/spec/dummy/app/mailers/.keep +0 -0
  26. data/spec/dummy/app/mappers/users.rb +10 -0
  27. data/spec/dummy/app/models/.keep +0 -0
  28. data/spec/dummy/app/models/user.rb +9 -0
  29. data/spec/dummy/app/relations/users.rb +9 -0
  30. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  31. data/spec/dummy/app/views/users/index.html.erb +7 -0
  32. data/spec/dummy/bin/bundle +3 -0
  33. data/spec/dummy/bin/rails +4 -0
  34. data/spec/dummy/bin/rake +4 -0
  35. data/spec/dummy/config.ru +4 -0
  36. data/spec/dummy/config/application.rb +16 -0
  37. data/spec/dummy/config/boot.rb +4 -0
  38. data/spec/dummy/config/database.yml +7 -0
  39. data/spec/dummy/config/environment.rb +5 -0
  40. data/spec/dummy/config/environments/development.rb +19 -0
  41. data/spec/dummy/config/environments/production.rb +65 -0
  42. data/spec/dummy/config/environments/test.rb +31 -0
  43. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  44. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  45. data/spec/dummy/config/initializers/inflections.rb +16 -0
  46. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  47. data/spec/dummy/config/initializers/secret_token.rb +12 -0
  48. data/spec/dummy/config/initializers/session_store.rb +3 -0
  49. data/spec/dummy/config/initializers/wrap_parameters.rb +9 -0
  50. data/spec/dummy/config/locales/en.yml +23 -0
  51. data/spec/dummy/config/routes.rb +3 -0
  52. data/spec/dummy/db/development.sqlite3 +0 -0
  53. data/spec/dummy/db/migrate/20141110205016_add_users.rb +7 -0
  54. data/spec/dummy/db/schema.rb +20 -0
  55. data/spec/dummy/db/seeds.rb +7 -0
  56. data/spec/dummy/db/test.sqlite3 +0 -0
  57. data/spec/dummy/lib/assets/.keep +0 -0
  58. data/spec/dummy/lib/tasks/.keep +0 -0
  59. data/spec/dummy/log/.keep +0 -0
  60. data/spec/dummy/public/404.html +58 -0
  61. data/spec/dummy/public/422.html +58 -0
  62. data/spec/dummy/public/500.html +57 -0
  63. data/spec/dummy/public/favicon.ico +0 -0
  64. data/spec/dummy/public/robots.txt +5 -0
  65. data/spec/dummy/spec/features/users_spec.rb +13 -0
  66. data/spec/dummy/spec/integration/user_model_mapping_spec.rb +17 -0
  67. data/spec/dummy/vendor/assets/javascripts/.keep +0 -0
  68. data/spec/dummy/vendor/assets/stylesheets/.keep +0 -0
  69. data/spec/spec_helper.rb +19 -0
  70. metadata +212 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: dcd720e54472ff49bc3e0a5e2617367b96b759fc
4
+ data.tar.gz: 3424b02330e29163e1620478c5e19bfbafd85a3e
5
+ SHA512:
6
+ metadata.gz: f978665c485c1c8560919c20e5860e1de6d657e4e9d4182a649d53f2a92cbb229328da9c785789456e8f8b2a5e5a562a49287361cbdfca418dd1bf4c6fea1b23
7
+ data.tar.gz: e4e3388d5632740461b15f1e4d772d5925784aad4b154c261fb9bc9227c4a7ca2c12204bc9c442fe0c4132673d53c8a7d1e13de81abd5c61e2696bc7c5bb9fb5
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.1.4
data/.travis.yml ADDED
@@ -0,0 +1,20 @@
1
+ language: ruby
2
+ bundler_args: --without yard guard benchmarks
3
+ script: "RAILS_ENV=test rake app:spec"
4
+ rvm:
5
+ - 2.0
6
+ - 2.1
7
+ - rbx-2
8
+ - jruby
9
+ - ruby-head
10
+ matrix:
11
+ allow_failures:
12
+ - rvm: ruby-head
13
+ - rvm: jruby
14
+ notifications:
15
+ webhooks:
16
+ urls:
17
+ - https://webhooks.gitter.im/e/39e1225f489f38b0bd09
18
+ on_success: change
19
+ on_failure: always
20
+ on_start: false
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ # v0.0.1 2014-11-24
2
+
3
+ First public release
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'rails', '4.1.7'
6
+
7
+ gem 'sqlite3', platforms: [:mri, :rbx]
8
+ gem 'jdbc-sqlite3', platforms: :jruby
9
+
10
+ gem 'rom', git: 'https://github.com/rom-rb/rom.git', branch: 'master'
11
+ gem 'rom-sql', git: 'https://github.com/rom-rb/rom-sql.git', branch: 'master'
12
+
13
+ group :test do
14
+ gem 'rspec-rails', '~> 3.1'
15
+ gem 'database_cleaner'
16
+ gem 'capybara'
17
+ end
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Ruby Object Mapper
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Piotr Solnica
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,5 @@
1
+ [![Build Status](https://travis-ci.org/rom-rb/rom-rails.svg?branch=master)](https://travis-ci.org/rom-rb/rom-rails)
2
+
3
+ # rom-rails
4
+
5
+ Rails integration for Ruby Object Mapper
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ require 'bundler/setup'
2
+
3
+ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
4
+ load 'rails/tasks/engine.rake'
data/lib/rom-rails.rb ADDED
@@ -0,0 +1,8 @@
1
+ module Rom
2
+ module Rails
3
+ end
4
+ end
5
+
6
+ require "rom/rails/version"
7
+ require "rom/rails/railtie"
8
+ require "rom/rails/controller_extension"
@@ -0,0 +1,13 @@
1
+ module ROM
2
+ module Rails
3
+
4
+ module ControllerExtension
5
+
6
+ def rom
7
+ ::Rails.application.config.rom.env
8
+ end
9
+
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,79 @@
1
+ module ROM
2
+ module Rails
3
+
4
+ class Configuration
5
+ attr_reader :config, :setup, :env
6
+
7
+ def self.build(app)
8
+ config = rewrite_config(app)
9
+
10
+ new(config)
11
+ end
12
+
13
+ def self.rewrite_config(app)
14
+ root = app.config.root
15
+ config = app.config.database_configuration[::Rails.env].symbolize_keys
16
+
17
+ adapter = config[:adapter]
18
+ database = config[:database]
19
+
20
+ adapter = "sqlite" if adapter == "sqlite3"
21
+
22
+ { default: "#{adapter}://#{root}/#{database}" }
23
+ end
24
+
25
+ def initialize(config)
26
+ @config = config
27
+ @setup = ROM.setup(@config.symbolize_keys)
28
+ end
29
+
30
+ def finalize
31
+ @env = setup.finalize
32
+ end
33
+ end
34
+
35
+ class Railtie < ::Rails::Railtie
36
+
37
+ initializer "rom.configure" do |app|
38
+ config.rom = ROM::Rails::Configuration.build(app)
39
+ end
40
+
41
+ initializer "rom.load_schema" do |app|
42
+ require schema_file if schema_file.exist?
43
+ end
44
+
45
+ initializer "rom.load_relations" do |app|
46
+ relation_files.each { |file| require file }
47
+ end
48
+
49
+ initializer "rom.load_mappers" do |app|
50
+ mapper_files.each { |file| require file }
51
+ end
52
+
53
+ config.after_initialize do |app|
54
+ app.config.rom.finalize
55
+ ApplicationController.send(:include, ControllerExtension)
56
+ end
57
+
58
+ private
59
+
60
+ def schema_file
61
+ root.join('db/rom/schema.rb')
62
+ end
63
+
64
+ def relation_files
65
+ Dir[root.join('app/relations/**/*.rb').to_s]
66
+ end
67
+
68
+ def mapper_files
69
+ Dir[root.join('app/mappers/**/*.rb').to_s]
70
+ end
71
+
72
+ def root
73
+ ::Rails.root
74
+ end
75
+
76
+ end
77
+
78
+ end
79
+ end
@@ -0,0 +1,5 @@
1
+ module ROM
2
+ module Rails
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,8 @@
1
+ module ROM
2
+ module Rails
3
+ end
4
+ end
5
+
6
+ require "rom/rails/version"
7
+ require "rom/rails/railtie"
8
+ require "rom"
data/rom-rails.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rom/rails/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rom-rails"
8
+ spec.version = ROM::Rails::VERSION
9
+ spec.authors = ["Piotr Solnica"]
10
+ spec.email = ["piotr.solnica@gmail.com"]
11
+ spec.summary = %q{Integrate Ruby Object Mapper with Rails}
12
+ spec.homepage = ""
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_runtime_dependency 'railties', ['>= 3.0', '< 5.0']
21
+
22
+ spec.add_development_dependency "bundler"
23
+ spec.add_development_dependency "rake"
24
+ end
data/spec/dummy/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,28 @@
1
+ == README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
25
+
26
+
27
+ Please feel free to use a different markup language if you do not plan to run
28
+ <tt>rake doc:app</tt>.
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Dummy::Application.load_tasks
@@ -0,0 +1,5 @@
1
+ class ApplicationController < ActionController::Base
2
+ # Prevent CSRF attacks by raising an exception.
3
+ # For APIs, you may want to use :null_session instead.
4
+ protect_from_forgery with: :exception
5
+ end
File without changes
@@ -0,0 +1,7 @@
1
+ class UsersController < ApplicationController
2
+
3
+ def index
4
+ render locals: { users: rom.read(:users).to_a }
5
+ end
6
+
7
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
File without changes
@@ -0,0 +1,10 @@
1
+ setup = Rails.application.config.rom.setup
2
+
3
+ setup.mappers do
4
+ define(:users) do
5
+ model User
6
+
7
+ attribute :id
8
+ attribute :name
9
+ end
10
+ end
File without changes
@@ -0,0 +1,9 @@
1
+ class User
2
+ include Equalizer.new(:id, :name)
3
+
4
+ attr_reader :id, :name
5
+
6
+ def initialize(attrs)
7
+ @id, @name = attrs.values_at(:id, :name)
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ setup = Rails.application.config.rom.setup
2
+
3
+ setup.relation(:users) do
4
+
5
+ def by_name(name)
6
+ where(name: name)
7
+ end
8
+
9
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= stylesheet_link_tag "application", media: "all" %>
6
+ <%= javascript_include_tag "application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,7 @@
1
+ <ul>
2
+ <% users.each do |user| %>
3
+ <li>
4
+ <%= user.name %>
5
+ </li>
6
+ <% end %>
7
+ </ul>
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../config/boot'
3
+ require 'rake'
4
+ Rake.application.run
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run Rails.application
@@ -0,0 +1,16 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require "action_controller/railtie"
4
+ require "active_record/railtie"
5
+
6
+ Bundler.setup(:default, Rails.env)
7
+
8
+ require 'rom-sql'
9
+ require 'rom-rails'
10
+ require 'rspec-rails'
11
+
12
+ module Dummy
13
+ class Application < Rails::Application
14
+ config.assets.enabled = false
15
+ end
16
+ end
@@ -0,0 +1,4 @@
1
+ # Set up gems listed in the Gemfile.
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+
4
+ require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
@@ -0,0 +1,7 @@
1
+ development:
2
+ adapter: sqlite3
3
+ database: "db/development.sqlite3"
4
+
5
+ test:
6
+ adapter: sqlite3
7
+ database: "db/test.sqlite3"
@@ -0,0 +1,5 @@
1
+ # Load the Rails application.
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the Rails application.
5
+ Dummy::Application.initialize!
@@ -0,0 +1,19 @@
1
+ Dummy::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ # In the development environment your application's code is reloaded on
5
+ # every request. This slows down response time but is perfect for development
6
+ # since you don't have to restart the web server when you make code changes.
7
+ config.cache_classes = false
8
+
9
+ # Do not eager load code on boot.
10
+ config.eager_load = false
11
+
12
+ # Show full error reports and disable caching.
13
+ config.consider_all_requests_local = true
14
+ config.action_controller.perform_caching = false
15
+
16
+ # Print deprecation notices to the Rails logger.
17
+ config.active_support.deprecation = :log
18
+
19
+ end
@@ -0,0 +1,65 @@
1
+ Dummy::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ # Code is not reloaded between requests.
5
+ config.cache_classes = true
6
+
7
+ # Eager load code on boot. This eager loads most of Rails and
8
+ # your application in memory, allowing both thread web servers
9
+ # and those relying on copy on write to perform better.
10
+ # Rake tasks automatically ignore this option for performance.
11
+ config.eager_load = true
12
+
13
+ # Full error reports are disabled and caching is turned on.
14
+ config.consider_all_requests_local = false
15
+ config.action_controller.perform_caching = true
16
+
17
+ # Enable Rack::Cache to put a simple HTTP cache in front of your application
18
+ # Add `rack-cache` to your Gemfile before enabling this.
19
+ # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
20
+ # config.action_dispatch.rack_cache = true
21
+
22
+ # Disable Rails's static asset server (Apache or nginx will already do this).
23
+ config.serve_static_assets = false
24
+
25
+
26
+ # Specifies the header that your server uses for sending files.
27
+ # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
28
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
29
+
30
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
31
+ # config.force_ssl = true
32
+
33
+ # Set to :debug to see everything in the log.
34
+ config.log_level = :info
35
+
36
+ # Prepend all log lines with the following tags.
37
+ # config.log_tags = [ :subdomain, :uuid ]
38
+
39
+ # Use a different logger for distributed setups.
40
+ # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
41
+
42
+ # Use a different cache store in production.
43
+ # config.cache_store = :mem_cache_store
44
+
45
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
46
+ # config.action_controller.asset_host = "http://assets.example.com"
47
+
48
+
49
+ # Ignore bad email addresses and do not raise email delivery errors.
50
+ # Set this to true and configure the email server for immediate delivery to raise delivery errors.
51
+ # config.action_mailer.raise_delivery_errors = false
52
+
53
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
54
+ # the I18n.default_locale when a translation can not be found).
55
+ config.i18n.fallbacks = true
56
+
57
+ # Send deprecation notices to registered listeners.
58
+ config.active_support.deprecation = :notify
59
+
60
+ # Disable automatic flushing of the log to improve performance.
61
+ # config.autoflush_log = false
62
+
63
+ # Use default logging formatter so that PID and timestamp are not suppressed.
64
+ config.log_formatter = ::Logger::Formatter.new
65
+ end
@@ -0,0 +1,31 @@
1
+ Dummy::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ # The test environment is used exclusively to run your application's
5
+ # test suite. You never need to work with it otherwise. Remember that
6
+ # your test database is "scratch space" for the test suite and is wiped
7
+ # and recreated between test runs. Don't rely on the data there!
8
+ config.cache_classes = true
9
+
10
+ # Do not eager load code on boot. This avoids loading your whole application
11
+ # just for the purpose of running a single test. If you are using a tool that
12
+ # preloads Rails for running tests, you may have to set it to true.
13
+ config.eager_load = false
14
+
15
+ # Configure static asset server for tests with Cache-Control for performance.
16
+ config.serve_static_assets = true
17
+ config.static_cache_control = "public, max-age=3600"
18
+
19
+ # Show full error reports and disable caching.
20
+ config.consider_all_requests_local = true
21
+ config.action_controller.perform_caching = false
22
+
23
+ # Raise exceptions instead of rendering exception templates.
24
+ config.action_dispatch.show_exceptions = false
25
+
26
+ # Disable request forgery protection in test environment.
27
+ config.action_controller.allow_forgery_protection = false
28
+
29
+ # Print deprecation notices to the stderr.
30
+ config.active_support.deprecation = :stderr
31
+ end
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4
+ # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5
+
6
+ # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7
+ # Rails.backtrace_cleaner.remove_silencers!
@@ -0,0 +1,4 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Configure sensitive parameters which will be filtered from the log file.
4
+ Rails.application.config.filter_parameters += [:password]
@@ -0,0 +1,16 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new inflection rules using the following format. Inflections
4
+ # are locale specific, and you may define rules for as many different
5
+ # locales as you wish. All of these examples are active by default:
6
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
7
+ # inflect.plural /^(ox)$/i, '\1en'
8
+ # inflect.singular /^(ox)en/i, '\1'
9
+ # inflect.irregular 'person', 'people'
10
+ # inflect.uncountable %w( fish sheep )
11
+ # end
12
+
13
+ # These inflection rules are supported but not enabled by default:
14
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
15
+ # inflect.acronym 'RESTful'
16
+ # end
@@ -0,0 +1,5 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new mime types for use in respond_to blocks:
4
+ # Mime::Type.register "text/richtext", :rtf
5
+ # Mime::Type.register_alias "text/html", :iphone
@@ -0,0 +1,12 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key is used for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+
6
+ # Make sure the secret is at least 30 characters and all random,
7
+ # no regular words or you'll be exposed to dictionary attacks.
8
+ # You can use `rake secret` to generate a secure secret key.
9
+
10
+ # Make sure your secret_key_base is kept private
11
+ # if you're sharing your code publicly.
12
+ Dummy::Application.config.secret_key_base = '1f964276d8745979a6c19e6e675c59db2c43e32eba0c1455c980d78140e3da2e31ade807a416abee4b17532a8ec0af8d3dc5d46ae04b2077a882e1da79aeae4a'
@@ -0,0 +1,3 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ Dummy::Application.config.session_store :cookie_store, key: '_dummy_session'
@@ -0,0 +1,9 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # This file contains settings for ActionController::ParamsWrapper which
4
+ # is enabled by default.
5
+
6
+ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
+ ActiveSupport.on_load(:action_controller) do
8
+ wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
9
+ end
@@ -0,0 +1,23 @@
1
+ # Files in the config/locales directory are used for internationalization
2
+ # and are automatically loaded by Rails. If you want to use locales other
3
+ # than English, add the necessary files in this directory.
4
+ #
5
+ # To use the locales, use `I18n.t`:
6
+ #
7
+ # I18n.t 'hello'
8
+ #
9
+ # In views, this is aliased to just `t`:
10
+ #
11
+ # <%= t('hello') %>
12
+ #
13
+ # To use a different locale, set it with `I18n.locale`:
14
+ #
15
+ # I18n.locale = :es
16
+ #
17
+ # This would use the information in config/locales/es.yml.
18
+ #
19
+ # To learn more, please read the Rails Internationalization guide
20
+ # available at http://guides.rubyonrails.org/i18n.html.
21
+
22
+ en:
23
+ hello: "Hello world"
@@ -0,0 +1,3 @@
1
+ Dummy::Application.routes.draw do
2
+ get '/users' => 'users#index'
3
+ end
Binary file
@@ -0,0 +1,7 @@
1
+ class AddUsers < ActiveRecord::Migration
2
+ def change
3
+ create_table(:users) do |t|
4
+ t.string :name
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,20 @@
1
+ # encoding: UTF-8
2
+ # This file is auto-generated from the current state of the database. Instead
3
+ # of editing this file, please use the migrations feature of Active Record to
4
+ # incrementally modify your database, and then regenerate this schema definition.
5
+ #
6
+ # Note that this schema.rb definition is the authoritative source for your
7
+ # database schema. If you need to create the application database on another
8
+ # system, you should be using db:schema:load, not running all the migrations
9
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
11
+ #
12
+ # It's strongly recommended that you check this file into your version control system.
13
+
14
+ ActiveRecord::Schema.define(version: 20141110205016) do
15
+
16
+ create_table "users", force: true do |t|
17
+ t.string "name"
18
+ end
19
+
20
+ end
@@ -0,0 +1,7 @@
1
+ # This file should contain all the record creation needed to seed the database with its default values.
2
+ # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
3
+ #
4
+ # Examples:
5
+ #
6
+ # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
7
+ # Mayor.create(name: 'Emanuel', city: cities.first)
Binary file
File without changes
File without changes
File without changes
@@ -0,0 +1,58 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <!-- This file lives in public/404.html -->
52
+ <div class="dialog">
53
+ <h1>The page you were looking for doesn't exist.</h1>
54
+ <p>You may have mistyped the address or the page may have moved.</p>
55
+ </div>
56
+ <p>If you are the application owner check the logs for more information.</p>
57
+ </body>
58
+ </html>
@@ -0,0 +1,58 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <!-- This file lives in public/422.html -->
52
+ <div class="dialog">
53
+ <h1>The change you wanted was rejected.</h1>
54
+ <p>Maybe you tried to change something you didn't have access to.</p>
55
+ </div>
56
+ <p>If you are the application owner check the logs for more information.</p>
57
+ </body>
58
+ </html>
@@ -0,0 +1,57 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <!-- This file lives in public/500.html -->
52
+ <div class="dialog">
53
+ <h1>We're sorry, but something went wrong.</h1>
54
+ </div>
55
+ <p>If you are the application owner check the logs for more information.</p>
56
+ </body>
57
+ </html>
File without changes
@@ -0,0 +1,5 @@
1
+ # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
2
+ #
3
+ # To ban all spiders from the entire site uncomment the next two lines:
4
+ # User-agent: *
5
+ # Disallow: /
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ feature 'Users' do
4
+ background do
5
+ Rails.application.config.rom.env.relations.users.insert(name: 'Piotr')
6
+ end
7
+
8
+ scenario 'I see user list on index page' do
9
+ visit '/users'
10
+
11
+ expect(page).to have_content('Piotr')
12
+ end
13
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'User model mapping' do
4
+ let(:rom) { Rails.application.config.rom.env }
5
+
6
+ let(:users) { rom.read(:users) }
7
+
8
+ before do
9
+ rom.schema.users.insert(name: 'Piotr')
10
+ end
11
+
12
+ it 'works' do
13
+ piotr = User.new(id: 1, name: 'Piotr')
14
+
15
+ expect(users.by_name('Piotr').to_a).to eql([piotr])
16
+ end
17
+ end
File without changes
File without changes
@@ -0,0 +1,19 @@
1
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
2
+ ENV["RAILS_ENV"] ||= 'test'
3
+
4
+ require Pathname(__FILE__).dirname.join("dummy/config/environment")
5
+
6
+ require 'rspec/rails'
7
+ require 'database_cleaner'
8
+ require 'capybara/rails'
9
+
10
+ Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
11
+ ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
12
+
13
+ RSpec.configure do |config|
14
+ config.order = "random"
15
+
16
+ config.before(:all) do
17
+ DatabaseCleaner.clean_with(:truncation)
18
+ end
19
+ end
metadata ADDED
@@ -0,0 +1,212 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rom-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Piotr Solnica
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: railties
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '5.0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '3.0'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '5.0'
33
+ - !ruby/object:Gem::Dependency
34
+ name: bundler
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ description:
62
+ email:
63
+ - piotr.solnica@gmail.com
64
+ executables: []
65
+ extensions: []
66
+ extra_rdoc_files: []
67
+ files:
68
+ - ".gitignore"
69
+ - ".rspec"
70
+ - ".ruby-version"
71
+ - ".travis.yml"
72
+ - CHANGELOG.md
73
+ - Gemfile
74
+ - LICENSE
75
+ - LICENSE.txt
76
+ - README.md
77
+ - Rakefile
78
+ - lib/rom-rails.rb
79
+ - lib/rom/rails/controller_extension.rb
80
+ - lib/rom/rails/railtie.rb
81
+ - lib/rom/rails/version.rb
82
+ - lib/rom/rom-rails.rb
83
+ - rom-rails.gemspec
84
+ - spec/dummy/.rspec
85
+ - spec/dummy/README.rdoc
86
+ - spec/dummy/Rakefile
87
+ - spec/dummy/app/controllers/application_controller.rb
88
+ - spec/dummy/app/controllers/concerns/.keep
89
+ - spec/dummy/app/controllers/users_controller.rb
90
+ - spec/dummy/app/helpers/application_helper.rb
91
+ - spec/dummy/app/mailers/.keep
92
+ - spec/dummy/app/mappers/users.rb
93
+ - spec/dummy/app/models/.keep
94
+ - spec/dummy/app/models/user.rb
95
+ - spec/dummy/app/relations/users.rb
96
+ - spec/dummy/app/views/layouts/application.html.erb
97
+ - spec/dummy/app/views/users/index.html.erb
98
+ - spec/dummy/bin/bundle
99
+ - spec/dummy/bin/rails
100
+ - spec/dummy/bin/rake
101
+ - spec/dummy/config.ru
102
+ - spec/dummy/config/application.rb
103
+ - spec/dummy/config/boot.rb
104
+ - spec/dummy/config/database.yml
105
+ - spec/dummy/config/environment.rb
106
+ - spec/dummy/config/environments/development.rb
107
+ - spec/dummy/config/environments/production.rb
108
+ - spec/dummy/config/environments/test.rb
109
+ - spec/dummy/config/initializers/backtrace_silencers.rb
110
+ - spec/dummy/config/initializers/filter_parameter_logging.rb
111
+ - spec/dummy/config/initializers/inflections.rb
112
+ - spec/dummy/config/initializers/mime_types.rb
113
+ - spec/dummy/config/initializers/secret_token.rb
114
+ - spec/dummy/config/initializers/session_store.rb
115
+ - spec/dummy/config/initializers/wrap_parameters.rb
116
+ - spec/dummy/config/locales/en.yml
117
+ - spec/dummy/config/routes.rb
118
+ - spec/dummy/db/development.sqlite3
119
+ - spec/dummy/db/migrate/20141110205016_add_users.rb
120
+ - spec/dummy/db/schema.rb
121
+ - spec/dummy/db/seeds.rb
122
+ - spec/dummy/db/test.sqlite3
123
+ - spec/dummy/lib/assets/.keep
124
+ - spec/dummy/lib/tasks/.keep
125
+ - spec/dummy/log/.keep
126
+ - spec/dummy/public/404.html
127
+ - spec/dummy/public/422.html
128
+ - spec/dummy/public/500.html
129
+ - spec/dummy/public/favicon.ico
130
+ - spec/dummy/public/robots.txt
131
+ - spec/dummy/spec/features/users_spec.rb
132
+ - spec/dummy/spec/integration/user_model_mapping_spec.rb
133
+ - spec/dummy/vendor/assets/javascripts/.keep
134
+ - spec/dummy/vendor/assets/stylesheets/.keep
135
+ - spec/spec_helper.rb
136
+ homepage: ''
137
+ licenses:
138
+ - MIT
139
+ metadata: {}
140
+ post_install_message:
141
+ rdoc_options: []
142
+ require_paths:
143
+ - lib
144
+ required_ruby_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ required_rubygems_version: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ requirements: []
155
+ rubyforge_project:
156
+ rubygems_version: 2.2.2
157
+ signing_key:
158
+ specification_version: 4
159
+ summary: Integrate Ruby Object Mapper with Rails
160
+ test_files:
161
+ - spec/dummy/.rspec
162
+ - spec/dummy/README.rdoc
163
+ - spec/dummy/Rakefile
164
+ - spec/dummy/app/controllers/application_controller.rb
165
+ - spec/dummy/app/controllers/concerns/.keep
166
+ - spec/dummy/app/controllers/users_controller.rb
167
+ - spec/dummy/app/helpers/application_helper.rb
168
+ - spec/dummy/app/mailers/.keep
169
+ - spec/dummy/app/mappers/users.rb
170
+ - spec/dummy/app/models/.keep
171
+ - spec/dummy/app/models/user.rb
172
+ - spec/dummy/app/relations/users.rb
173
+ - spec/dummy/app/views/layouts/application.html.erb
174
+ - spec/dummy/app/views/users/index.html.erb
175
+ - spec/dummy/bin/bundle
176
+ - spec/dummy/bin/rails
177
+ - spec/dummy/bin/rake
178
+ - spec/dummy/config.ru
179
+ - spec/dummy/config/application.rb
180
+ - spec/dummy/config/boot.rb
181
+ - spec/dummy/config/database.yml
182
+ - spec/dummy/config/environment.rb
183
+ - spec/dummy/config/environments/development.rb
184
+ - spec/dummy/config/environments/production.rb
185
+ - spec/dummy/config/environments/test.rb
186
+ - spec/dummy/config/initializers/backtrace_silencers.rb
187
+ - spec/dummy/config/initializers/filter_parameter_logging.rb
188
+ - spec/dummy/config/initializers/inflections.rb
189
+ - spec/dummy/config/initializers/mime_types.rb
190
+ - spec/dummy/config/initializers/secret_token.rb
191
+ - spec/dummy/config/initializers/session_store.rb
192
+ - spec/dummy/config/initializers/wrap_parameters.rb
193
+ - spec/dummy/config/locales/en.yml
194
+ - spec/dummy/config/routes.rb
195
+ - spec/dummy/db/development.sqlite3
196
+ - spec/dummy/db/migrate/20141110205016_add_users.rb
197
+ - spec/dummy/db/schema.rb
198
+ - spec/dummy/db/seeds.rb
199
+ - spec/dummy/db/test.sqlite3
200
+ - spec/dummy/lib/assets/.keep
201
+ - spec/dummy/lib/tasks/.keep
202
+ - spec/dummy/log/.keep
203
+ - spec/dummy/public/404.html
204
+ - spec/dummy/public/422.html
205
+ - spec/dummy/public/500.html
206
+ - spec/dummy/public/favicon.ico
207
+ - spec/dummy/public/robots.txt
208
+ - spec/dummy/spec/features/users_spec.rb
209
+ - spec/dummy/spec/integration/user_model_mapping_spec.rb
210
+ - spec/dummy/vendor/assets/javascripts/.keep
211
+ - spec/dummy/vendor/assets/stylesheets/.keep
212
+ - spec/spec_helper.rb