rom-roda 0.0.2 → 0.1.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
  SHA1:
3
- metadata.gz: b79451fcdd3bf53763133acc8216c43f4f5d1386
4
- data.tar.gz: a24b5388bfce4bd2019d086056fe07110e7a56ae
3
+ metadata.gz: 2128db69a23bdec4354929eb16503e7225070236
4
+ data.tar.gz: 63042a8f762c8120bb1f298dcbb56c2e054e0a47
5
5
  SHA512:
6
- metadata.gz: a5d79c48d12b5364f4287798e316646673b858fc4586dd15df91f4e56fb79565f7f67a5b3f99c0aef21b8e16ed3c51c8a95830eea60f89f787566cb4bc327cbf
7
- data.tar.gz: 6dbc547ab0c0fd44ac5de06d92914960a786f3b1c58e2578c3ee2a91e2193532c69a2bd02cd029975ba77a9c73c8e6af4d97679949afa0e90d4520558617246c
6
+ metadata.gz: 29f5291600465d9262a948cacf5b803098bdd9e0322ec9f1423e24947ef39d1a149aa6d2131940cce7f4f417f3b600dfd2963d9b78dc9a9f8ee9b68903346657
7
+ data.tar.gz: be4f75dc86917ebd56a08031390e484bfce2e60d9556b1263ecb5ba49b33dfa02de16fecca21cdbdfd37aa9d52de7d48a7f92aff5312512924a70e50f752571e
@@ -0,0 +1,20 @@
1
+ language: ruby
2
+ sudo: false
3
+ cache: bundler
4
+ bundler_args: --without sql benchmarks console tools
5
+ script: "bundle exec rspec"
6
+ rvm:
7
+ - 2.0
8
+ - 2.1
9
+ - 2.2
10
+ - rbx-2
11
+ - jruby
12
+ - ruby-head
13
+ - jruby-head
14
+ env:
15
+ global:
16
+ - JRUBY_OPTS='--dev -J-Xmx1024M'
17
+ matrix:
18
+ allow_failures:
19
+ - rvm: ruby-head
20
+ - rvm: jruby-head
data/Gemfile CHANGED
@@ -8,15 +8,13 @@ gem 'roda'
8
8
 
9
9
  platforms :jruby do
10
10
  gem 'jdbc-sqlite3'
11
- gem 'activerecord-jdbc-adapter'
12
11
  end
13
12
 
14
13
  group :test do
14
+ gem 'thread_safe'
15
15
  gem 'rom', github: 'rom-rb/rom', branch: 'master'
16
16
  gem 'rom-sql', github: 'rom-rb/rom-sql', branch: 'master'
17
17
  gem 'rspec', '~> 3.2'
18
+ gem 'rack-test'
18
19
  gem 'codeclimate-test-reporter', require: nil
19
- gem 'database_cleaner'
20
- gem 'capybara'
21
- gem 'byebug', platform: :mri
22
20
  end
data/README.md CHANGED
@@ -75,7 +75,7 @@ end
75
75
 
76
76
  With the ROM environment configured, the following instance methods are available in Roda routes:
77
77
 
78
- **rom**
78
+ #### rom
79
79
 
80
80
  Provides an instance of the ROM environment:
81
81
 
@@ -85,19 +85,23 @@ route do |r|
85
85
  end
86
86
  ```
87
87
 
88
- **relation(name)**
88
+ #### relation(name)
89
89
 
90
90
  Provides an instance of the named relation:
91
91
 
92
92
  ```ruby
93
93
  route do |r|
94
- r.is('catalog') do
95
- relation(:products).where(available_for_purchase: true).limit(20)
94
+ r.on('catalog') do
95
+ @products = relation(:products).in_stock
96
+
97
+ r.is('category/:category') do |category|
98
+ @products.by_category(category)
99
+ end
96
100
  end
97
101
  end
98
102
  ```
99
103
 
100
- **command(name)**
104
+ #### command(name)
101
105
 
102
106
  Provides an instance of the named command:
103
107
 
@@ -4,6 +4,6 @@ require 'rom/roda/plugin'
4
4
 
5
5
  class Roda
6
6
  module RodaPlugins
7
- register_plugin :rom, ROM::Roda::Plugin
7
+ register_plugin :rom, ROM::Roda::Plugin
8
8
  end
9
9
  end
@@ -2,8 +2,10 @@ module ROM
2
2
  module Roda
3
3
  module Plugin
4
4
  def self.configure(app, *args)
5
+ args = args.dup
6
+
5
7
  if args.last.is_a?(Hash) && args.last.key?(:load_path)
6
- load_path = File.expand_path(args.last.delete(:load_path), app.opts[:root])
8
+ load_path = File.expand_path(args.pop.delete(:load_path), app.opts[:root])
7
9
  end
8
10
 
9
11
  ROM.setup(*args)
@@ -40,4 +42,4 @@ module ROM
40
42
  end
41
43
  end
42
44
  end
43
- end
45
+ end
@@ -1,5 +1,5 @@
1
1
  module ROM
2
2
  module Roda
3
- VERSION = '0.0.2'.freeze
3
+ VERSION = '0.1.0'.freeze
4
4
  end
5
5
  end
@@ -17,7 +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.6.0', '>= 0.6.1'
20
+ spec.add_runtime_dependency 'rom', '~> 0.7', '>= 0.7.0'
21
21
  spec.add_runtime_dependency 'inflecto'
22
22
 
23
23
  spec.add_development_dependency 'bundler'
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe ROM::Roda::Plugin do
4
+ it 'uses load_path relative to application by default' do
5
+ subject.should_receive(:load_files).with(File.expand_path('models'))
6
+
7
+ class RelativeLoadPathExample < Roda
8
+ plugin :rom, :memory, load_path: 'models'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,59 @@
1
+ require 'spec_helper'
2
+
3
+ describe ROM::Roda::Plugin do
4
+ SQL_DSN = RUBY_ENGINE == 'jruby' ? 'jdbc:sqlite:memory' : 'sqlite:memory'
5
+
6
+ context 'single adapter' do
7
+ let(:default_gateway) do
8
+ class MemoryAdapterExample < Roda
9
+ plugin :rom, :memory
10
+ end
11
+
12
+ MemoryAdapterExample.freeze
13
+
14
+ ROM.env.gateways[:default]
15
+ end
16
+
17
+ it 'configures gateway with empty args' do
18
+ expect(default_gateway).to be_a(ROM::Memory::Gateway)
19
+ end
20
+ end
21
+
22
+ context 'single adapter with settings' do
23
+ let(:default_gateway) do
24
+ class SqliteAdapterExample < Roda
25
+ plugin :rom, :sql, SQL_DSN
26
+ end
27
+
28
+ SqliteAdapterExample.freeze
29
+
30
+ ROM.env.gateways[:default]
31
+ end
32
+
33
+ it 'configures gateway with a connection string' do
34
+ expect(default_gateway).to be_a(ROM::SQL::Gateway)
35
+ end
36
+ end
37
+
38
+ context 'multiple adapters' do
39
+ let(:gateways) do
40
+ class MultipleAdaptersExample < Roda
41
+ plugin :rom, {
42
+ default: [:sql, SQL_DSN],
43
+ warehouse: [:sql, SQL_DSN],
44
+ transient: :memory
45
+ }
46
+ end
47
+
48
+ MultipleAdaptersExample.freeze
49
+
50
+ ROM.env.gateways
51
+ end
52
+
53
+ it 'configures gateways with given settings' do
54
+ expect(gateways[:default]).to be_a(ROM::SQL::Gateway)
55
+ expect(gateways[:warehouse]).to be_a(ROM::SQL::Gateway)
56
+ expect(gateways[:transient]).to be_a(ROM::Memory::Gateway)
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,12 @@
1
+ require 'rack/test'
2
+
3
+ require 'roda'
4
+ require 'rom-roda'
5
+
6
+ require 'sqlite3' unless defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
7
+
8
+ require 'rom-sql'
9
+
10
+ RSpec.configure do |config|
11
+ config.include Rack::Test::Methods
12
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rom-roda
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Rickerby
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-05 00:00:00.000000000 Z
11
+ date: 2015-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rom
@@ -16,20 +16,20 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.6.0
19
+ version: '0.7'
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 0.6.1
22
+ version: 0.7.0
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - "~>"
28
28
  - !ruby/object:Gem::Version
29
- version: 0.6.0
29
+ version: '0.7'
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: 0.6.1
32
+ version: 0.7.0
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: inflecto
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -95,6 +95,7 @@ extra_rdoc_files: []
95
95
  files:
96
96
  - ".gitignore"
97
97
  - ".rspec"
98
+ - ".travis.yml"
98
99
  - CHANGELOG.md
99
100
  - Gemfile
100
101
  - LICENSE
@@ -103,6 +104,9 @@ files:
103
104
  - lib/rom/roda/plugin.rb
104
105
  - lib/rom/roda/version.rb
105
106
  - rom-roda.gemspec
107
+ - spec/integration/load_path_spec.rb
108
+ - spec/integration/plugin_setup_spec.rb
109
+ - spec/spec_helper.rb
106
110
  homepage: http://rom-rb.org
107
111
  licenses:
108
112
  - MIT
@@ -123,9 +127,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
127
  version: '0'
124
128
  requirements: []
125
129
  rubyforge_project:
126
- rubygems_version: 2.4.2
130
+ rubygems_version: 2.2.2
127
131
  signing_key:
128
132
  specification_version: 4
129
133
  summary: Integrate Ruby Object Mapper with Roda
130
- test_files: []
134
+ test_files:
135
+ - spec/integration/load_path_spec.rb
136
+ - spec/integration/plugin_setup_spec.rb
137
+ - spec/spec_helper.rb
131
138
  has_rdoc: