rom-roda 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +21 -0
- data/.rspec +1 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +22 -0
- data/LICENSE +20 -0
- data/README.md +121 -0
- data/lib/rom-roda.rb +9 -0
- data/lib/rom/roda/plugin.rb +37 -0
- data/lib/rom/roda/version.rb +5 -0
- data/rom-roda.gemspec +26 -0
- metadata +131 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 94128573e1131ec1686eea12afc94ba659d9a8fa
|
4
|
+
data.tar.gz: d328cf7ec6c7475dc64889b8fe9bbf68f3747ad6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f24734f031600a90ad3360f8e9ac9f166abacfec999b905246e157ac0e6be509f1bc69433a76260cdd1c3f8dbbc644f5deaf73843fa4eb28bc6edaf299dcefe4
|
7
|
+
data.tar.gz: 228bba2fefdb31f7c6745fe8214b681aa7b6ceac7e36a55d7a1770bb8995a28c00a33054d5d61cba85580b597a7ff19c242ec5ef414f6e686e4db1a21b36c9da
|
data/.gitignore
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
.ruby-version
|
7
|
+
Gemfile.lock
|
8
|
+
InstalledFiles
|
9
|
+
_yardoc
|
10
|
+
coverage
|
11
|
+
doc/
|
12
|
+
lib/bundler/man
|
13
|
+
pkg
|
14
|
+
rdoc
|
15
|
+
spec/reports
|
16
|
+
test/tmp
|
17
|
+
test/version_tmp
|
18
|
+
tmp
|
19
|
+
spec/dummy/db/*.sqlite3
|
20
|
+
spec/dummy/tmp
|
21
|
+
spec/dummy/log
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gemspec
|
4
|
+
|
5
|
+
gem 'sqlite3', platforms: [:mri, :rbx]
|
6
|
+
|
7
|
+
gem 'roda'
|
8
|
+
|
9
|
+
platforms :jruby do
|
10
|
+
gem 'jdbc-sqlite3'
|
11
|
+
gem 'activerecord-jdbc-adapter'
|
12
|
+
end
|
13
|
+
|
14
|
+
group :test do
|
15
|
+
gem 'rom', github: 'rom-rb/rom', branch: 'master'
|
16
|
+
gem 'rom-sql', github: 'rom-rb/rom-sql', branch: 'master'
|
17
|
+
gem 'rspec', '~> 3.2'
|
18
|
+
gem 'codeclimate-test-reporter', require: nil
|
19
|
+
gem 'database_cleaner'
|
20
|
+
gem 'capybara'
|
21
|
+
gem 'byebug', platform: :mri
|
22
|
+
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/README.md
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
# rom-roda
|
2
|
+
|
3
|
+
Roda plugin for [Ruby Object Mapper](https://github.com/rom-rb/rom).
|
4
|
+
|
5
|
+
## Issues
|
6
|
+
|
7
|
+
Please report any issues in the main [rom-rb/rom](https://github.com/rom-rb/rom/issues) issue tracker.
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
In your app file, require `rom-roda` and any additional adapter Gems needed to set up your data sources:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
require 'rom-roda'
|
15
|
+
require 'rom-sql'
|
16
|
+
```
|
17
|
+
|
18
|
+
### Setup
|
19
|
+
|
20
|
+
Embed a ROM environment in your Roda app using the `plugin` hook:
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
class App < Roda
|
24
|
+
plugin :rom
|
25
|
+
end
|
26
|
+
```
|
27
|
+
|
28
|
+
Options passed to the plugin are used to set up one or more adapters, using the [repository args format](http://www.rubydoc.info/gems/rom/ROM/Global#setup-instance_method) supported by `ROM.setup`.
|
29
|
+
|
30
|
+
To register a single `sql` repository with an Sqlite data source:
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
class App < Roda
|
34
|
+
plugin :rom, :sql, 'sqlite::memory'
|
35
|
+
end
|
36
|
+
```
|
37
|
+
|
38
|
+
To register a 'default' and a 'warehouse' repository:
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
class App < Roda
|
42
|
+
plugin :rom, {
|
43
|
+
default: [:sql, 'sqlite::memory'],
|
44
|
+
warehouse: [:sql, 'postgres://localhost/warehouse']
|
45
|
+
}
|
46
|
+
end
|
47
|
+
```
|
48
|
+
|
49
|
+
### Loading ROM components
|
50
|
+
|
51
|
+
Relations, commands and mappers are automatically registered with the ROM environment when their classes are loaded. This means that these components must be required by the app in a specific order during setup.
|
52
|
+
|
53
|
+
You can autoload ROM components from a local path in your app by passing the `:load_path` option to the plugin:
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
class App < Roda
|
57
|
+
# register ROM components from './models'
|
58
|
+
plugin :rom, :sql, 'sqlite::memory', load_path: 'models'
|
59
|
+
end
|
60
|
+
```
|
61
|
+
|
62
|
+
In situations where your app is loaded from a path that isn’t the `pwd` of the Rack server process, the ROM plugin plays nicely with Roda’s `opts[:root]` setting:
|
63
|
+
|
64
|
+
```ruby
|
65
|
+
class MyApplication < Roda
|
66
|
+
# app file is at './app/my_application.rb'
|
67
|
+
opts[:root] = 'app'
|
68
|
+
|
69
|
+
# register ROM components from './app/model'
|
70
|
+
plugin :rom, :sql, 'sqlite::memory', load_path: 'model'
|
71
|
+
end
|
72
|
+
```
|
73
|
+
|
74
|
+
### Using ROM in Roda routes
|
75
|
+
|
76
|
+
With the ROM environment configured, the following instance methods are available in Roda routes:
|
77
|
+
|
78
|
+
**rom**
|
79
|
+
|
80
|
+
Provides an instance of the ROM environment:
|
81
|
+
|
82
|
+
```ruby
|
83
|
+
route do |r|
|
84
|
+
rom
|
85
|
+
end
|
86
|
+
```
|
87
|
+
|
88
|
+
**relation(name)**
|
89
|
+
|
90
|
+
Provides an instance of the named relation:
|
91
|
+
|
92
|
+
```ruby
|
93
|
+
route do |r|
|
94
|
+
r.is('catalog') do
|
95
|
+
relation(:products).where(available_for_purchase: true).limit(20)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
```
|
99
|
+
|
100
|
+
**command(name)**
|
101
|
+
|
102
|
+
Provides an instance of the named command:
|
103
|
+
|
104
|
+
```ruby
|
105
|
+
route do |r|
|
106
|
+
r.is('products') do
|
107
|
+
r.post do
|
108
|
+
command(:products).create.call(r['product'])
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
```
|
113
|
+
|
114
|
+
## Community
|
115
|
+
|
116
|
+
* [](https://gitter.im/rom-rb/chat)
|
117
|
+
* [Ruby Object Mapper](https://groups.google.com/forum/#!forum/rom-rb) mailing list
|
118
|
+
|
119
|
+
## License
|
120
|
+
|
121
|
+
See `LICENSE` file.
|
data/lib/rom-roda.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
module ROM
|
2
|
+
module Roda
|
3
|
+
module Plugin
|
4
|
+
def self.configure(app, *args)
|
5
|
+
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])
|
7
|
+
end
|
8
|
+
|
9
|
+
ROM.setup(*args)
|
10
|
+
|
11
|
+
self.load_files(load_path) if load_path
|
12
|
+
|
13
|
+
ROM.finalize
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.load_files(path)
|
17
|
+
Dir["#{path}/**/*.rb"].each do |class_file|
|
18
|
+
require class_file
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
module InstanceMethods
|
23
|
+
def rom
|
24
|
+
ROM.env
|
25
|
+
end
|
26
|
+
|
27
|
+
def relation(name)
|
28
|
+
ROM.env.relation(name)
|
29
|
+
end
|
30
|
+
|
31
|
+
def command(name)
|
32
|
+
ROM.env.command(name)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/rom-roda.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'rom/roda/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'rom-roda'
|
8
|
+
spec.version = ROM::Roda::VERSION.dup
|
9
|
+
spec.authors = ['Mark Rickerby']
|
10
|
+
spec.email = ['me@maetl.net']
|
11
|
+
spec.summary = 'Integrate Ruby Object Mapper with Roda'
|
12
|
+
spec.homepage = 'http://rom-rb.org'
|
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 'rom', '~> 0.6.0', '>= 0.6.1'
|
21
|
+
spec.add_runtime_dependency 'inflecto'
|
22
|
+
|
23
|
+
spec.add_development_dependency 'bundler'
|
24
|
+
spec.add_development_dependency 'rake'
|
25
|
+
spec.add_development_dependency 'rubocop', '~> 0.28.0'
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rom-roda
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mark Rickerby
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-04-05 00:00:00.000000000 Z
|
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.6.0
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.6.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.6.0
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.6.1
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: inflecto
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
type: :runtime
|
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: bundler
|
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
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: rake
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: rubocop
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: 0.28.0
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 0.28.0
|
89
|
+
description:
|
90
|
+
email:
|
91
|
+
- me@maetl.net
|
92
|
+
executables: []
|
93
|
+
extensions: []
|
94
|
+
extra_rdoc_files: []
|
95
|
+
files:
|
96
|
+
- ".gitignore"
|
97
|
+
- ".rspec"
|
98
|
+
- CHANGELOG.md
|
99
|
+
- Gemfile
|
100
|
+
- LICENSE
|
101
|
+
- README.md
|
102
|
+
- lib/rom-roda.rb
|
103
|
+
- lib/rom/roda/plugin.rb
|
104
|
+
- lib/rom/roda/version.rb
|
105
|
+
- rom-roda.gemspec
|
106
|
+
homepage: http://rom-rb.org
|
107
|
+
licenses:
|
108
|
+
- MIT
|
109
|
+
metadata: {}
|
110
|
+
post_install_message:
|
111
|
+
rdoc_options: []
|
112
|
+
require_paths:
|
113
|
+
- lib
|
114
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
requirements: []
|
125
|
+
rubyforge_project:
|
126
|
+
rubygems_version: 2.4.2
|
127
|
+
signing_key:
|
128
|
+
specification_version: 4
|
129
|
+
summary: Integrate Ruby Object Mapper with Roda
|
130
|
+
test_files: []
|
131
|
+
has_rdoc:
|