rom-rails 1.2.0 → 2.0.0

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
  SHA256:
3
- metadata.gz: e5acc8ec1307f8d3d91dc9918bff1e25d359685d57525ec3ddfbed5296ce38b2
4
- data.tar.gz: 688d949fe6d60bebb5e48162370a62694a6aa8f6f965696952252c9e044a008f
3
+ metadata.gz: 68fc37fe8b9ca646395ffd02e68f29b774d7330e9513bf1de8a27771d5393896
4
+ data.tar.gz: 90159fa988c5fbe590516e2d4112483ab35752264c771352bdfc0a63f14168d2
5
5
  SHA512:
6
- metadata.gz: 47bdcf5a66ae1f5dbcf683cdf7d8a8873a23a12bd9cd0029bd2881ee1c68e9b26aeffb271c80e132a7587a07e10db767d9bd5dd63e097979a4be3e89b5d5b688
7
- data.tar.gz: 7ac28d31ef0a9c86b3a49104cce96c9b46c2302e3a063c7e9d7fd53ed3ac39483dc1fa1f893fcff826a4123d55a073af57c9d0e61e3f78d8874651febd361e82
6
+ metadata.gz: fb112f2f9c27a973262ed39133ae9befe1adbaf91aed42470d28a46776c73d02f17f22318863d9d2623e0f30caf65fafac40168ed050785a94261006a2c64fd4
7
+ data.tar.gz: e7e53cbb6139f0df6d748c3ead2c1e153ceba72f9dcb3bf69df11cb2d8b50b7cc7a99824d2d13ad75884270ae07711c7eb10e54ad1aedaeb63223ae55f0ed4fa
@@ -4,17 +4,19 @@ cache: bundler
4
4
  bundler_args: --without yard guard benchmarks
5
5
  script: "RAILS_ENV=test bundle exec rake app:db:reset app:spec"
6
6
  rvm:
7
- - 2.3.1
8
- - 2.4.1
9
- - jruby-9.1.13.0
7
+ - 2.4.6
8
+ - 2.5.5
9
+ - 2.6.3
10
+ - jruby-9.2.7.0
10
11
  env:
11
- - RAILS_VERSION=5.1.0
12
- - RAILS_VERSION=5.0.0
13
- - RAILS_VERSION=4.2.0
12
+ - RAILS_VERSION=5.2
13
+ - RAILS_VERSION=5.1
14
+ - RAILS_VERSION=5.0
15
+ - RAILS_VERSION=4.2
14
16
  notifications:
15
17
  webhooks:
16
18
  urls:
17
- - https://webhooks.gitter.im/e/39e1225f489f38b0bd09
19
+ - https://rom-rb.zulipchat.com/api/v1/external/travis?api_key=S1S2GRkXHlzlaCGyUwm7o4lg50IZrwCH&stream=notifications&topic=ci
18
20
  on_success: change
19
21
  on_failure: always
20
22
  on_start: false
@@ -1,6 +1,29 @@
1
+ ## v2.0.0 2019-04-27
2
+
3
+ ### Changed
4
+
5
+ * Updated to depend on rom-* 5.0
6
+ * Repository generator creates a `by_id` method (cflipse)
7
+
8
+ [Compare v1.3.0...v2.0.0](https://github.com/rom-rb/rom-rails/compare/v1.3.0...v2.0.0)
9
+
10
+ ## v1.3.0 2018-11-26
11
+
12
+ ### Changed
13
+
14
+ * Rake task automatically attempts to include `rom-sql`'s tasks (cflipse)
15
+ * Escape special characters in username & password from parsed database.yml (Cervajz)
16
+
17
+ ### Fixed
18
+
19
+ * do not double log when ActiveRecord is present (Cervajz)
20
+ * running the install generator no longer results in a broken app if `DATABASE_URL` is not set (cflipse)
21
+
22
+ [Compare v1.2.0...v1.3.0](https://github.com/rom-rb/rom-rails/compare/v1.2.0...v1.3.0)
23
+
1
24
  ## v1.2.0 2018-10-20
2
25
 
3
- ## Changed
26
+ ### Changed
4
27
 
5
28
  * ROM output is broadcast to STDOUT during rails console (radar)
6
29
  * Generators default to same adapter as the default gateway (cflipse)
@@ -11,7 +34,7 @@
11
34
 
12
35
  ## v1.1.1 2018-04-17
13
36
 
14
- ### Changed
37
+ ### Fixedd
15
38
 
16
39
  * Fix Rails.logger lookup bug (cflipse)
17
40
 
data/Gemfile CHANGED
@@ -17,7 +17,6 @@ gem 'rom', git: 'https://github.com/rom-rb/rom', branch: 'master' do
17
17
  gem 'rom-repository', group: :tools
18
18
  end
19
19
 
20
- gem 'rom-http'
21
20
  gem 'rom-sql', github: 'rom-rb/rom-sql', branch: 'master'
22
21
 
23
22
  platforms :jruby do
data/README.md CHANGED
@@ -1,6 +1,5 @@
1
1
  [gem]: https://rubygems.org/gems/rom-rails
2
2
  [travis]: https://travis-ci.org/rom-rb/rom-rails
3
- [gemnasium]: https://gemnasium.com/rom-rb/rom-rails
4
3
  [codeclimate]: https://codeclimate.com/github/rom-rb/rom-rails
5
4
  [coveralls]: https://coveralls.io/r/rom-rb/rom-rails
6
5
  [inchpages]: http://inch-ci.org/github/rom-rb/rom-rails
@@ -9,7 +8,6 @@
9
8
 
10
9
  [![Gem Version](https://badge.fury.io/rb/rom-rails.svg)][gem]
11
10
  [![Build Status](https://travis-ci.org/rom-rb/rom-rails.svg?branch=master)][travis]
12
- [![Dependency Status](https://gemnasium.com/rom-rb/rom-rails.svg)][gemnasium]
13
11
  [![Code Climate](https://codeclimate.com/github/rom-rb/rom-rails/badges/gpa.svg)][codeclimate]
14
12
  [![Test Coverage](https://codeclimate.com/github/rom-rb/rom-rails/badges/coverage.svg)][codeclimate]
15
13
  [![Inline docs](http://inch-ci.org/github/rom-rb/rom-rails.svg?branch=master)][inchpages]
@@ -1,4 +1,4 @@
1
- require 'types'
1
+ require "types"
2
2
 
3
3
  class ApplicationModel < ROM::Struct
4
4
  def self.inherited(base)
@@ -1,3 +1,3 @@
1
1
  ROM::Rails::Railtie.configure do |config|
2
- config.gateways[:default] = [:<%= adapter %>, ENV.fetch('DATABASE_URL')]
2
+ # config.gateways[:default] = [:<%= adapter %>, ENV.fetch('DATABASE_URL')]
3
3
  end
@@ -1,4 +1,4 @@
1
- require 'dry/types'
1
+ require "dry/types"
2
2
 
3
3
  module Types
4
4
  include Dry::Types.module
@@ -4,4 +4,12 @@ class <%= model_name %>Repository < ROM::Repository::Root
4
4
  commands :create, update: :by_pk, delete: :by_pk
5
5
 
6
6
  struct_namespace <%= struct_namespace %>
7
+
8
+ def by_id(id)
9
+ root.by_pk(id).one
10
+ end
11
+
12
+ def all
13
+ root.to_a
14
+ end
7
15
  end
@@ -86,8 +86,8 @@ module ROM
86
86
  def self.generic_uri(config)
87
87
  build_uri(
88
88
  scheme: config.fetch(:scheme),
89
- user: config[:username],
90
- password: config[:password],
89
+ user: escape_option(config[:username]),
90
+ password: escape_option(config[:password]),
91
91
  host: config[:host],
92
92
  port: config[:port],
93
93
  path: config[:database]
@@ -97,6 +97,10 @@ module ROM
97
97
  def self.build_uri(attrs)
98
98
  Addressable::URI.new(attrs).to_s
99
99
  end
100
+
101
+ def self.escape_option(option)
102
+ option.nil? ? option : CGI.escape(option)
103
+ end
100
104
  end
101
105
  end
102
106
  end
@@ -46,10 +46,7 @@ module ROM
46
46
  end
47
47
 
48
48
  console do |_app|
49
- unless ActiveSupport::Logger.logger_outputs_to?(::Rails.logger, STDERR, STDOUT)
50
- console = ActiveSupport::Logger.new(STDERR)
51
- ::Rails.logger.extend ActiveSupport::Logger.broadcast console
52
- end
49
+ Railtie.configure_console_logger
53
50
  end
54
51
 
55
52
  # Behaves like `Railtie#configure` if the given block does not take any
@@ -137,6 +134,19 @@ module ROM
137
134
  def active_record?
138
135
  defined?(::ActiveRecord)
139
136
  end
137
+
138
+ # @api private
139
+ def std_err_out_logger?
140
+ ActiveSupport::Logger.logger_outputs_to?(::Rails.logger, STDERR, STDOUT)
141
+ end
142
+
143
+ # @api private
144
+ def configure_console_logger
145
+ return if active_record? || std_err_out_logger?
146
+
147
+ console = ActiveSupport::Logger.new(STDERR)
148
+ ::Rails.logger.extend ActiveSupport::Logger.broadcast console
149
+ end
140
150
  end
141
151
  end
142
152
  end
@@ -1,3 +1,9 @@
1
+ begin
2
+ require "rom/sql/rake_task"
3
+ rescue LoadError
4
+ # rom-sql is optional
5
+ end
6
+
1
7
  namespace :db do
2
8
  desc 'Set up ROM gateways'
3
9
  task :setup do
@@ -1,5 +1,5 @@
1
1
  module ROM
2
2
  module Rails
3
- VERSION = '1.2.0'.freeze
3
+ VERSION = '2.0.0'.freeze
4
4
  end
5
5
  end
@@ -5,8 +5,8 @@ require 'rom/rails/version'
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "rom-rails"
7
7
  spec.version = ROM::Rails::VERSION.dup
8
- spec.authors = ["Piotr Solnica"]
9
- spec.email = ["piotr.solnica@gmail.com"]
8
+ spec.authors = ["Chris Flipse", "Piotr Solnica"]
9
+ spec.email = ["cflipse@gmail.com", "piotr.solnica@gmail.com"]
10
10
  spec.summary = 'Integrate Ruby Object Mapper with Rails'
11
11
  spec.homepage = "http://rom-rb.org"
12
12
  spec.license = "MIT"
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
  spec.add_runtime_dependency 'dry-core', '~> 0.3'
21
21
  spec.add_runtime_dependency 'dry-equalizer', '~> 0.2'
22
22
  spec.add_runtime_dependency 'railties', '>= 3.0', '< 6.0'
23
- spec.add_runtime_dependency 'rom', '~> 4.0'
23
+ spec.add_runtime_dependency 'rom', '~> 5.0'
24
24
 
25
25
  spec.add_development_dependency "bundler"
26
26
  spec.add_development_dependency "rake"
@@ -1,6 +1,6 @@
1
1
  ROM::Rails::Railtie.configure do |config|
2
2
  scheme = RUBY_ENGINE == 'jruby' ? 'jdbc:sqlite' : 'sqlite'
3
- config.gateways[:arro] = [:http, uri: 'http://example.org' ]
3
+ config.gateways[:arro] = [:test_adapter, uri: 'http://example.org' ]
4
4
  config.gateways[:sql] = [:sql, "#{scheme}://#{Rails.root}/db/#{Rails.env}.sqlite3"]
5
5
  config.gateways[:default] = [:test_adapter, foo: :bar]
6
6
  config.auto_registration_paths += [Rails.root.join('lib', 'additional_app', 'persistence')]
@@ -112,6 +112,22 @@ RSpec.describe ROM::Rails::ActiveRecord::Configuration do
112
112
 
113
113
  expect(read(config)).to eq uri: expected_uri, options: { pool: 5 }
114
114
  end
115
+
116
+ it 'handles special characters in username and password' do
117
+ config = {
118
+ pool: 5,
119
+ adapter: 'mysql2',
120
+ username: 'r@o%ot',
121
+ password: 'p@ssw0rd#',
122
+ database: 'database',
123
+ host: 'example.com'
124
+ }
125
+
126
+ expected_uri = 'mysql2://r%40o%25ot:p%40ssw0rd%23@example.com/database'
127
+ expected_uri = "jdbc:#{expected_uri}" if RUBY_ENGINE == 'jruby'
128
+
129
+ expect(read(config)).to eq uri: expected_uri, options: { pool: 5 }
130
+ end
115
131
  end
116
132
  end
117
133
  end
@@ -16,7 +16,7 @@ RSpec.describe ROM::Generators::InstallGenerator, type: :generator do
16
16
  file 'rom.rb' do
17
17
  contains <<-CONTENT.strip_heredoc
18
18
  ROM::Rails::Railtie.configure do |config|
19
- config.gateways[:default] = [:sql, ENV.fetch('DATABASE_URL')]
19
+ # config.gateways[:default] = [:sql, ENV.fetch('DATABASE_URL')]
20
20
  end
21
21
  CONTENT
22
22
  end
@@ -39,7 +39,7 @@ RSpec.describe ROM::Generators::InstallGenerator, type: :generator do
39
39
  directory "lib" do
40
40
  file "types.rb" do
41
41
  contains <<-CONTENT.strip_heredoc
42
- require 'dry/types'
42
+ require "dry/types"
43
43
 
44
44
  module Types
45
45
  include Dry::Types.module
@@ -63,7 +63,7 @@ RSpec.describe ROM::Generators::InstallGenerator, type: :generator do
63
63
  directory "models" do
64
64
  file "application_model.rb" do
65
65
  contains <<-CONTENT.strip_heredoc
66
- require 'types'
66
+ require "types"
67
67
 
68
68
  class ApplicationModel < ROM::Struct
69
69
  def self.inherited(base)
@@ -22,6 +22,14 @@ RSpec.describe ROM::Generators::RepositoryGenerator, type: :generator do
22
22
  commands :create, update: :by_pk, delete: :by_pk
23
23
 
24
24
  struct_namespace Dummy
25
+
26
+ def by_id(id)
27
+ root.by_pk(id).one
28
+ end
29
+
30
+ def all
31
+ root.to_a
32
+ end
25
33
  end
26
34
  CONTENT
27
35
  end
@@ -44,6 +52,14 @@ RSpec.describe ROM::Generators::RepositoryGenerator, type: :generator do
44
52
  commands :create, update: :by_pk, delete: :by_pk
45
53
 
46
54
  struct_namespace Dummy
55
+
56
+ def by_id(id)
57
+ root.by_pk(id).one
58
+ end
59
+
60
+ def all
61
+ root.to_a
62
+ end
47
63
  end
48
64
  CONTENT
49
65
  end
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rom-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
+ - Chris Flipse
7
8
  - Piotr Solnica
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2018-10-20 00:00:00.000000000 Z
12
+ date: 2019-04-27 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: addressable
@@ -78,14 +79,14 @@ dependencies:
78
79
  requirements:
79
80
  - - "~>"
80
81
  - !ruby/object:Gem::Version
81
- version: '4.0'
82
+ version: '5.0'
82
83
  type: :runtime
83
84
  prerelease: false
84
85
  version_requirements: !ruby/object:Gem::Requirement
85
86
  requirements:
86
87
  - - "~>"
87
88
  - !ruby/object:Gem::Version
88
- version: '4.0'
89
+ version: '5.0'
89
90
  - !ruby/object:Gem::Dependency
90
91
  name: bundler
91
92
  requirement: !ruby/object:Gem::Requirement
@@ -144,6 +145,7 @@ dependencies:
144
145
  version: '0.50'
145
146
  description:
146
147
  email:
148
+ - cflipse@gmail.com
147
149
  - piotr.solnica@gmail.com
148
150
  executables: []
149
151
  extensions: []