-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ab3ee00
Showing
16 changed files
with
249 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/.bundle/ | ||
/.yardoc | ||
/Gemfile.lock | ||
/_yardoc/ | ||
/coverage/ | ||
/doc/ | ||
/pkg/ | ||
/spec/reports/ | ||
/tmp/ | ||
*.bundle | ||
*.so | ||
*.o | ||
*.a | ||
mkmf.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--color | ||
--order random |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
language: ruby | ||
bundler_args: --without yard guard benchmarks | ||
env: | ||
- CODECLIMATE_REPO_TOKEN=886f3b795e74159719804f8e18b853f4c23a81bd814404e52ec248a0dae6d656 | ||
script: "bundle exec rake spec" | ||
rvm: | ||
- 2.0 | ||
- 2.1 | ||
- rbx-2 | ||
- jruby | ||
- ruby-head | ||
matrix: | ||
allow_failures: | ||
- rvm: ruby-head | ||
notifications: | ||
webhooks: | ||
urls: | ||
- https://webhooks.gitter.im/e/39e1225f489f38b0bd09 | ||
on_success: change | ||
on_failure: always | ||
on_start: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
## v0.0.2 2014-12-06 | ||
|
||
### Added | ||
|
||
* Command API (solnic) | ||
|
||
[Compare v0.0.1...v0.0.2](https://github.com/rom-rb/rom-sql/compare/v0.0.1...v0.0.2) | ||
|
||
## v0.0.1 2014-11-25 | ||
|
||
First public release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
source 'https://rubygems.org' | ||
|
||
gemspec | ||
|
||
group :test do | ||
gem 'rom', git: 'https://github.com/rom-rb/rom.git', branch: 'master' | ||
gem 'rspec', '~> 3.1' | ||
gem 'codeclimate-test-reporter', require: false | ||
gem 'virtus' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Copyright (c) 2014 Piotr Solnica | ||
|
||
MIT License | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
[gem]: https://rubygems.org/gems/rom-yaml | ||
[travis]: https://travis-ci.org/rom-rb/rom-yaml | ||
[gemnasium]: https://gemnasium.com/rom-rb/rom-yaml | ||
[codeclimate]: https://codeclimate.com/github/rom-rb/rom-yaml | ||
[inchpages]: http://inch-ci.org/github/rom-rb/rom-yaml | ||
|
||
# ROM::yaml | ||
|
||
[][gem] | ||
[][travis] | ||
[][gemnasium] | ||
[][codeclimate] | ||
[][codeclimate] | ||
[][inchpages] | ||
|
||
YAML support for [Ruby Object Mapper](https://github.com/rom-rb/rom) | ||
|
||
## Installation | ||
|
||
Add this line to your application's Gemfile: | ||
|
||
```ruby | ||
gem 'rom-yaml' | ||
``` | ||
|
||
And then execute: | ||
|
||
$ bundle | ||
|
||
Or install it yourself as: | ||
|
||
$ gem install rom-yaml | ||
|
||
## Usage | ||
|
||
See `spec/integration/adapter_spec.rb` for a sample usage. | ||
|
||
## License | ||
|
||
See `LICENSE` file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
require "rspec/core/rake_task" | ||
require "rubocop/rake_task" | ||
|
||
task default: [:spec, :rubocop] | ||
|
||
RSpec::Core::RakeTask.new(:spec) | ||
|
||
RuboCop::RakeTask.new do |task| | ||
task.options << "--display-cop-names" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require 'rom/yaml' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
require 'yaml' | ||
|
||
require 'rom' | ||
require 'rom/yaml/version' | ||
require 'rom/yaml/adapter' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
module ROM | ||
module YAML | ||
class Adapter < ROM::Adapter | ||
def self.schemes | ||
[:yaml] | ||
end | ||
|
||
def initialize(*args) | ||
super | ||
@connection = ::YAML.load_file("#{uri.host}#{uri.path}") | ||
end | ||
|
||
def [](name) | ||
connection.fetch(name.to_s) | ||
end | ||
|
||
def dataset?(name) | ||
connection.key?(name.to_s) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module ROM | ||
module YAML | ||
VERSION = '0.0.2'.freeze | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# coding: utf-8 | ||
lib = File.expand_path('../lib', __FILE__) | ||
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) | ||
require 'rom/yaml/version' | ||
|
||
Gem::Specification.new do |spec| | ||
spec.name = "rom-yaml" | ||
spec.version = ROM::YAML::VERSION.dup | ||
spec.authors = ["Piotr Solnica"] | ||
spec.email = ["[email protected]"] | ||
spec.summary = 'YAML support for Ruby Object Mapper' | ||
spec.description = spec.summary | ||
spec.homepage = "" | ||
spec.license = "MIT" | ||
|
||
spec.files = `git ls-files -z`.split("\x0") | ||
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } | ||
spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) | ||
spec.require_paths = ["lib"] | ||
|
||
spec.add_runtime_dependency "moped" | ||
spec.add_runtime_dependency "rom", "~> 0.4", ">= 0.4.0" | ||
|
||
spec.add_development_dependency "bundler" | ||
spec.add_development_dependency "rake" | ||
spec.add_development_dependency "rubocop", "~> 0.28.0" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
users: | ||
- name: 'Jane' | ||
email: '[email protected]' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
require 'spec_helper' | ||
|
||
describe 'YAML adapter' do | ||
subject(:rom) { setup.finalize } | ||
|
||
let(:root) { Pathname(__FILE__).dirname.join('..') } | ||
|
||
let(:setup) { ROM.setup("yaml://#{root}/fixtures/test_db.yml") } | ||
|
||
before do | ||
setup.schema do | ||
base_relation(:users) do | ||
repository :default | ||
|
||
attribute 'name' | ||
attribute 'email' | ||
end | ||
end | ||
|
||
setup.relation(:users) do | ||
def by_name(name) | ||
find_all { |user| user['name'] == name } | ||
end | ||
end | ||
|
||
setup.mappers do | ||
define(:users) do | ||
model name: 'User' | ||
|
||
attribute :name, from: 'name' | ||
attribute :email, from: 'email' | ||
end | ||
end | ||
end | ||
|
||
describe 'env#read' do | ||
it 'returns mapped object' do | ||
jane = rom.read(:users).by_name('Jane').to_a.first | ||
|
||
expect(jane.name).to eql('Jane') | ||
expect(jane.email).to eql('[email protected]') | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# encoding: utf-8 | ||
|
||
if RUBY_ENGINE == 'rbx' | ||
require "codeclimate-test-reporter" | ||
CodeClimate::TestReporter.start | ||
end | ||
|
||
require 'rom-yaml' | ||
|
||
root = Pathname(__FILE__).dirname | ||
|
||
Dir[root.join('shared/*.rb').to_s].each { |f| require f } |