rom-rails 0.0.1 → 0.0.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: dcd720e54472ff49bc3e0a5e2617367b96b759fc
4
- data.tar.gz: 3424b02330e29163e1620478c5e19bfbafd85a3e
3
+ metadata.gz: e3973d28b785258452fa186c82b218bb7d49b2e5
4
+ data.tar.gz: 7cb178d38de10564cd0c2a33e5968e907774b6d3
5
5
  SHA512:
6
- metadata.gz: f978665c485c1c8560919c20e5860e1de6d657e4e9d4182a649d53f2a92cbb229328da9c785789456e8f8b2a5e5a562a49287361cbdfca418dd1bf4c6fea1b23
7
- data.tar.gz: e4e3388d5632740461b15f1e4d772d5925784aad4b154c261fb9bc9227c4a7ca2c12204bc9c442fe0c4132673d53c8a7d1e13de81abd5c61e2696bc7c5bb9fb5
6
+ metadata.gz: a4708a692ac5821630b2f4459cb3a8b7e3b6c31aa2f4ef79d19d509e4e11a12f751a044bcfc9be4aeb1313c7a00f6723dca94bb09b952586db36ef5a8e544bd2
7
+ data.tar.gz: b4650efa04ae9afb73f49dc96a4e0f814563b8e2f6e1bc52e11297ec837471fcc303930b6984ea5254811fbf2c5c34354c54aeea6a811aca987215f4fc2e1477
data/.gitignore CHANGED
@@ -15,3 +15,6 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ spec/dummy/db/*.sqlite3
19
+ spec/dummy/tmp
20
+ spec/dummy/log
data/.travis.yml CHANGED
@@ -1,6 +1,8 @@
1
1
  language: ruby
2
2
  bundler_args: --without yard guard benchmarks
3
- script: "RAILS_ENV=test rake app:spec"
3
+ env:
4
+ - CODECLIMATE_REPO_TOKEN=87c9080bda25bce8e63a294f99312345c144c0f6d5eedf400fd753356fbf7dcf
5
+ script: "RAILS_ENV=test rake app:db:schema:load app:spec"
4
6
  rvm:
5
7
  - 2.0
6
8
  - 2.1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
- # v0.0.1 2014-11-24
1
+ # Change log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ ## v0.0.2 2014-11-25
6
+
7
+ ### Added
8
+
9
+ * Support for username and password in database.yml (solnic)
10
+ * Support for more db schemes (solnic)
11
+ * Missing runtime dep on rom gem (solnic)
12
+
13
+ [Compare v0.0.1...v0.0.2](https://github.com/rom-rb/rom-rails/compare/v0.0.1...v0.0.2)
14
+
15
+ ## v0.0.1 2014-11-24
2
16
 
3
17
  First public release
data/Gemfile CHANGED
@@ -7,11 +7,10 @@ gem 'rails', '4.1.7'
7
7
  gem 'sqlite3', platforms: [:mri, :rbx]
8
8
  gem 'jdbc-sqlite3', platforms: :jruby
9
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
10
  group :test do
11
+ gem 'rom-sql'
14
12
  gem 'rspec-rails', '~> 3.1'
13
+ gem 'codeclimate-test-reporter', require: nil
15
14
  gem 'database_cleaner'
16
15
  gem 'capybara'
17
16
  end
data/README.md CHANGED
@@ -1,5 +1,74 @@
1
- [![Build Status](https://travis-ci.org/rom-rb/rom-rails.svg?branch=master)](https://travis-ci.org/rom-rb/rom-rails)
1
+ [![Gem Version](https://badge.fury.io/rb/rom-rails.svg)][gem]
2
+ [![Build Status](https://travis-ci.org/rom-rb/rom-rails.svg?branch=master)][travis]
3
+ [![Dependency Status](https://gemnasium.com/rom-rb/rom-rails.png)][gemnasium]
4
+ [![Code Climate](https://codeclimate.com/github/rom-rb/rom-rails/badges/gpa.svg)][codeclimate]
5
+ [![Test Coverage](https://codeclimate.com/github/rom-rb/rom-rails/badges/coverage.svg)][codeclimate]
6
+ [![Inline docs](http://inch-ci.org/github/rom-rb/rom-rails.svg?branch=master)][inchpages]
7
+
8
+ [gem]: https://rubygems.org/gems/rom-rails
9
+ [travis]: https://travis-ci.org/rom-rb/rom-rails
10
+ [gemnasium]: https://gemnasium.com/rom-rb/rom-rails
11
+ [codeclimate]: https://codeclimate.com/github/rom-rb/rom-rails
12
+ [coveralls]: https://coveralls.io/r/rom-rb/rom-rails
13
+ [inchpages]: http://inch-ci.org/github/rom-rb/rom-rails
2
14
 
3
15
  # rom-rails
4
16
 
5
- Rails integration for Ruby Object Mapper
17
+ Rails integration for [Ruby Object Mapper](https://github.com/rom-rb/rom).
18
+
19
+ ## Installation and setup
20
+
21
+ In your Gemfile:
22
+
23
+ ```
24
+ gem 'rom'
25
+ gem 'rom-rails'
26
+ ```
27
+
28
+ ## Schema
29
+
30
+ Defining schema is only required for adapters that don't support inferring schema
31
+ automatically. This means if you're using `rom-sql` you don't have to define the schema.
32
+ In other cases the railtie expects the schema to be in `db/rom/schema.rb` which
33
+ is loaded before relations and mappers.
34
+
35
+ ## Relations and mappers
36
+
37
+ The railtie automatically loads relations and mappers from `app/relations` and
38
+ `app/mappers` and finalizes the environment afterwards. During the booting process
39
+ rom's setup object is available via `Rails.application.config.rom.setup`.
40
+
41
+ ## Relations in controllers
42
+
43
+ Currently the railtie simply adds `#rom` method to your controllers which returns
44
+ the whole environment. This is **a temporary solution** which is not meant to be final.
45
+
46
+ Eventually ROM will expose relations to the controller layer (thus view layer too)
47
+ that are already loaded into memory and **there will be no database interactions**
48
+ taking place in those layers. This means that effectively database **query interface
49
+ will not be available in controllers, views, helpers or anywhere outside of the
50
+ relation definitions**.
51
+
52
+ This means your Rails application will work with arrays of domain objects rather
53
+ than ad-hoc database queries scattered across your entire codebase and there will
54
+ be *a single place* where you define all the relations and object mapping.
55
+
56
+ ## Status
57
+
58
+ This project is still in alpha state. For examples of usage please take a look
59
+ at `spec/dummy` app.
60
+
61
+ Proper documentation will be added once the interface is stable.
62
+
63
+ ## Roadmap
64
+
65
+ Please refer to [issues](https://github.com/rom-rb/rom-rails/issues).
66
+
67
+ ## Community
68
+
69
+ * [![Gitter chat](https://badges.gitter.im/rom-rb/chat.png)](https://gitter.im/rom-rb/chat)
70
+ * [Ruby Object Mapper](https://groups.google.com/forum/#!forum/rom-rb) mailing list
71
+
72
+ ## License
73
+
74
+ See `LICENSE` file.
@@ -5,21 +5,37 @@ module ROM
5
5
  attr_reader :config, :setup, :env
6
6
 
7
7
  def self.build(app)
8
- config = rewrite_config(app)
8
+ root = app.config.root
9
+ db_config = app.config.database_configuration[::Rails.env].symbolize_keys
10
+
11
+ config = rewrite_config(root, db_config)
9
12
 
10
13
  new(config)
11
14
  end
12
15
 
13
- def self.rewrite_config(app)
14
- root = app.config.root
15
- config = app.config.database_configuration[::Rails.env].symbolize_keys
16
-
16
+ def self.rewrite_config(root, config)
17
17
  adapter = config[:adapter]
18
18
  database = config[:database]
19
+ password = config[:password]
20
+ username = config[:username]
21
+ hostname = config.fetch(:hostname) { 'localhost' }
19
22
 
20
23
  adapter = "sqlite" if adapter == "sqlite3"
21
24
 
22
- { default: "#{adapter}://#{root}/#{database}" }
25
+ path =
26
+ if adapter == "sqlite"
27
+ "#{root}/#{database}"
28
+ else
29
+ db_path = [hostname, database].join('/')
30
+
31
+ if username && password
32
+ [[username, password].join(':'), db_path].join('@')
33
+ else
34
+ db_path
35
+ end
36
+ end
37
+
38
+ { default: "#{adapter}://#{path}" }
23
39
  end
24
40
 
25
41
  def initialize(config)
@@ -1,5 +1,5 @@
1
1
  module ROM
2
2
  module Rails
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
data/rom-rails.gemspec CHANGED
@@ -17,6 +17,7 @@ Gem::Specification.new do |spec|
17
17
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
18
  spec.require_paths = ["lib"]
19
19
 
20
+ spec.add_runtime_dependency 'rom', '~> 0.3', '>= 0.3.1'
20
21
  spec.add_runtime_dependency 'railties', ['>= 3.0', '< 5.0']
21
22
 
22
23
  spec.add_development_dependency "bundler"
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,11 @@
1
1
  # This file is copied to spec/ when you run 'rails generate rspec:install'
2
2
  ENV["RAILS_ENV"] ||= 'test'
3
3
 
4
+ if RUBY_ENGINE == 'rbx'
5
+ require "codeclimate-test-reporter"
6
+ CodeClimate::TestReporter.start
7
+ end
8
+
4
9
  require Pathname(__FILE__).dirname.join("dummy/config/environment")
5
10
 
6
11
  require 'rspec/rails'
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+
3
+ describe ROM::Rails::Configuration do
4
+ let(:root) { '/somewhere' }
5
+
6
+ describe '.rewrite_config' do
7
+ it 'rewrites database config hash to a URI for sqlite' do
8
+ db_config = { adapter: 'sqlite', database: 'testing.sqlite' }
9
+
10
+ config = ROM::Rails::Configuration.rewrite_config(root, db_config)
11
+
12
+ expect(config).to eql(default: "sqlite:///somewhere/testing.sqlite")
13
+ end
14
+
15
+ it 'rewrites database config hash to a URI for postgres' do
16
+ db_config = {
17
+ adapter: 'postgres',
18
+ database: 'testing',
19
+ username: 'piotr',
20
+ hostname: 'localhost',
21
+ password: 'secret'
22
+ }
23
+
24
+ config = ROM::Rails::Configuration.rewrite_config(root, db_config)
25
+
26
+ expect(config).to eql(default: "postgres://piotr:secret@localhost/testing")
27
+
28
+ db_config = {
29
+ adapter: 'postgres',
30
+ database: 'testing'
31
+ }
32
+
33
+ config = ROM::Rails::Configuration.rewrite_config(root, db_config)
34
+
35
+ expect(config).to eql(default: "postgres://localhost/testing")
36
+ end
37
+ end
38
+
39
+ end
metadata CHANGED
@@ -1,15 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rom-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Solnica
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-24 00:00:00.000000000 Z
11
+ date: 2014-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rom
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.3'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.3.1
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '0.3'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 0.3.1
13
33
  - !ruby/object:Gem::Dependency
14
34
  name: railties
15
35
  requirement: !ruby/object:Gem::Requirement
@@ -115,11 +135,9 @@ files:
115
135
  - spec/dummy/config/initializers/wrap_parameters.rb
116
136
  - spec/dummy/config/locales/en.yml
117
137
  - spec/dummy/config/routes.rb
118
- - spec/dummy/db/development.sqlite3
119
138
  - spec/dummy/db/migrate/20141110205016_add_users.rb
120
139
  - spec/dummy/db/schema.rb
121
140
  - spec/dummy/db/seeds.rb
122
- - spec/dummy/db/test.sqlite3
123
141
  - spec/dummy/lib/assets/.keep
124
142
  - spec/dummy/lib/tasks/.keep
125
143
  - spec/dummy/log/.keep
@@ -133,6 +151,7 @@ files:
133
151
  - spec/dummy/vendor/assets/javascripts/.keep
134
152
  - spec/dummy/vendor/assets/stylesheets/.keep
135
153
  - spec/spec_helper.rb
154
+ - spec/unit/configuration_spec.rb
136
155
  homepage: ''
137
156
  licenses:
138
157
  - MIT
@@ -192,11 +211,9 @@ test_files:
192
211
  - spec/dummy/config/initializers/wrap_parameters.rb
193
212
  - spec/dummy/config/locales/en.yml
194
213
  - spec/dummy/config/routes.rb
195
- - spec/dummy/db/development.sqlite3
196
214
  - spec/dummy/db/migrate/20141110205016_add_users.rb
197
215
  - spec/dummy/db/schema.rb
198
216
  - spec/dummy/db/seeds.rb
199
- - spec/dummy/db/test.sqlite3
200
217
  - spec/dummy/lib/assets/.keep
201
218
  - spec/dummy/lib/tasks/.keep
202
219
  - spec/dummy/log/.keep
@@ -210,3 +227,4 @@ test_files:
210
227
  - spec/dummy/vendor/assets/javascripts/.keep
211
228
  - spec/dummy/vendor/assets/stylesheets/.keep
212
229
  - spec/spec_helper.rb
230
+ - spec/unit/configuration_spec.rb
Binary file
Binary file