├── .gitignore ├── .rspec ├── .rubocop.yml ├── .rubocop_todo.yml ├── .travis.yml ├── CHANGELOG.md ├── Gemfile ├── LICENSE.txt ├── README.md ├── Rakefile ├── lib ├── rom-yaml.rb └── rom │ ├── yaml.rb │ └── yaml │ ├── dataset.rb │ ├── gateway.rb │ ├── relation.rb │ ├── schema.rb │ └── version.rb ├── rakelib └── rubocop.rake ├── rom-yaml.gemspec └── spec ├── fixtures ├── db │ ├── tasks.yml │ └── users.yml └── test_db.yml ├── integration └── adapter_spec.rb ├── spec_helper.rb └── unit ├── dataset_spec.rb └── gateway_spec.rb /.gitignore: -------------------------------------------------------------------------------- 1 | /.bundle/ 2 | /.yardoc 3 | /Gemfile.lock 4 | /_yardoc/ 5 | /coverage/ 6 | /doc/ 7 | /pkg/ 8 | /spec/reports/ 9 | /tmp/ 10 | *.bundle 11 | *.so 12 | *.o 13 | *.a 14 | mkmf.log 15 | -------------------------------------------------------------------------------- /.rspec: -------------------------------------------------------------------------------- 1 | --color 2 | --order random 3 | --require ./spec/spec_helper.rb 4 | -------------------------------------------------------------------------------- /.rubocop.yml: -------------------------------------------------------------------------------- 1 | # Generated by `rubocop --auto-gen-config` 2 | inherit_from: .rubocop_todo.yml 3 | 4 | # It’s quite readable when we know what we are doing 5 | Lint/AssignmentInCondition: 6 | Enabled: false 7 | 8 | # No need to handle LoadError in rake 9 | Lint/HandleExceptions: 10 | Exclude: 11 | - rakelib/*.rake 12 | 13 | # The enforced style doesn’t match Vim’s defaults 14 | Style/AlignParameters: 15 | Enabled: false 16 | 17 | # UTF-8 is perfectly fine in comments 18 | Style/AsciiComments: 19 | Enabled: false 20 | 21 | # Allow using braces for value-returning blocks 22 | Style/Blocks: 23 | Enabled: false 24 | 25 | # Documentation checked by Inch CI 26 | Style/Documentation: 27 | Enabled: false 28 | 29 | # Early returns have their vices 30 | Style/GuardClause: 31 | Enabled: false 32 | 33 | # Need to be skipped for >-> usage 34 | Style/Lambda: 35 | Enabled: false 36 | 37 | # Multiline block chains are ok 38 | Style/MultilineBlockChain: 39 | Enabled: false 40 | 41 | # Even a single escaped slash can be confusing 42 | Style/RegexpLiteral: 43 | MaxSlashes: 0 44 | 45 | # Don’t introduce semantic fail/raise distinction 46 | Style/SignalException: 47 | EnforcedStyle: only_raise 48 | 49 | # Need to be skipped for >-> usage 50 | Style/SpaceAroundOperators: 51 | Enabled: false 52 | 53 | # Accept both single and double quotes 54 | Style/StringLiterals: 55 | Enabled: false 56 | 57 | # Allow def self.foo; @foo; end 58 | Style/TrivialAccessors: 59 | Enabled: false 60 | 61 | # Allow rom-csv 62 | Style/FileName: 63 | Enabled: false 64 | -------------------------------------------------------------------------------- /.rubocop_todo.yml: -------------------------------------------------------------------------------- 1 | # This configuration was generated by `rubocop --auto-gen-config` 2 | # on 2015-02-09 17:10:04 +0100 using RuboCop version 0.28.0. 3 | # The point is for the user to remove these configuration records 4 | # one by one as the offenses are removed from the code base. 5 | # Note that changes in the inspected code, or installation of new 6 | # versions of RuboCop, may require this file to be generated again. 7 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: ruby 2 | sudo: false 3 | cache: bundler 4 | bundler_args: --without tools 5 | script: "bundle exec rake spec" 6 | after_success: 7 | - '[ -d coverage ] && bundle exec codeclimate-test-reporter' 8 | rvm: 9 | - 2.4 10 | - 2.5 11 | - 2.6 12 | - jruby-9.2.7.0 13 | env: 14 | global: 15 | - JRUBY_OPTS='--dev -J-Xmx1024M' 16 | - COVERAGE='true' 17 | notifications: 18 | webhooks: 19 | urls: 20 | - https://rom-rb.zulipchat.com/api/v1/external/travis?api_key=S1S2GRkXHlzlaCGyUwm7o4lg50IZrwCH&stream=notifications&topic=ci 21 | on_success: change 22 | on_failure: always 23 | on_start: false 24 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## v3.0.0 2019-04-27 2 | 3 | * Updated to work with rom ~> 5.0 (cflipse) 4 | * [BREAKING] Support for ruby <= `2.4` was dropped (cflipse) 5 | 6 | [Compare v2.0.0...v3.0.0](https://github.com/rom-rb/rom-yaml/compare/v2.0.0...v3.0.0) 7 | 8 | ## v2.0.0 2019-04-22 9 | 10 | * Updated to work with rom ~> 4.1 11 | 12 | [Compare v1.0.1...v2.0.0](https://github.com/rom-rb/rom-yaml/compare/v1.0.1...v2.0.0) 13 | 14 | ## v1.0.1 2017-01-31 15 | 16 | ### Changed 17 | 18 | * Fixed dependency to use published version 19 | 20 | [Compare v1.0.0...v1.0.1](https://github.com/rom-rb/rom-yaml/compare/v1.0.0...v1.0.1) 21 | 22 | ## v1.0.0 2017-01-30 23 | 24 | ### Added 25 | 26 | * [BREAKING] Schema support in relations (you *must* define schemas now) (solnic) 27 | * Support for rom-repository (solnic) 28 | 29 | ### Changed 30 | 31 | * `YAML` relations inherit now from `Memory::Relation` (solnic) 32 | 33 | [Compare v0.4.0...v1.0.0](https://github.com/rom-rb/rom-yaml/compare/v0.4.0...v1.0.0) 34 | 35 | ## v0.4.0 36 | 37 | ### Changed 38 | 39 | * Updated to work with ROM 2.0 (pre-release) (cflipse) 40 | 41 | [Compare v0.3.0...v0.4.0](https://github.com/rom-rb/rom-yaml/compare/v0.3.0...v0.4.0) 42 | 43 | ## v0.3.0 44 | 45 | ### Changed 46 | 47 | * Updated to work with ROM 1.0 (cflipse) 48 | 49 | [Compare v0.2.0...v0.3.0](https://github.com/rom-rb/rom-yaml/compare/v0.2.0...v0.3.0) 50 | 51 | ## v0.2.0 52 | 53 | ### Changed 54 | 55 | * Updated to work with pending registration changes (cflipse) 56 | 57 | [Compare v0.1.2...v0.3.0](https://github.com/rom-rb/rom-yaml/compare/v0.1.2...v0.2.0) 58 | 59 | ## v0.1.2 60 | 61 | ### Changed 62 | 63 | * Updated to work with Transproc 0.3.0 (cflipse) 64 | 65 | [Compare v0.1.1...v0.1.2](https://github.com/rom-rb/rom-yaml/compare/v0.1.1...v0.1.2) 66 | 67 | ## v0.1.1 68 | 69 | ### Changed 70 | 71 | * Updated to work with ROM 0.8.0 (solnic) 72 | 73 | [Compare v0.1.0...HEAD](https://github.com/rom-rb/rom-yaml/compare/v0.1.0...HEAD) 74 | 75 | ## v0.1.0 2015-05-19 76 | 77 | ### Added 78 | 79 | * Support for loading relations from multiple files (solnic) 80 | 81 | ### Changed 82 | 83 | * Symbolize keys recursively in tuples (cflipse) 84 | * Make it work with ROM 0.7.0 (cflipse) 85 | 86 | [Compare v0.0.1...v0.1.0](https://github.com/rom-rb/rom-yaml/compare/v0.0.1...v0.1.0) 87 | 88 | ## v0.0.1 2015-03-22 89 | 90 | First public release 91 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gemspec 4 | 5 | group :test do 6 | gem 'rom', git: 'https://github.com/rom-rb/rom.git', branch: 'main' do 7 | gem 'rom-core' 8 | gem 'rom-changeset' 9 | gem 'rom-mapper' 10 | gem 'rom-repository' 11 | end 12 | 13 | gem 'byebug', platform: :mri 14 | gem 'inflecto' 15 | gem 'rspec', '~> 3.1' 16 | gem 'codeclimate-test-reporter', require: false 17 | gem 'virtus' 18 | end 19 | 20 | group :tools do 21 | gem 'rubocop' 22 | end 23 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 Piotr Solnica 2 | 3 | MIT License 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [gem]: https://rubygems.org/gems/rom-yaml 2 | [travis]: https://travis-ci.org/rom-rb/rom-yaml 3 | [gemnasium]: https://gemnasium.com/rom-rb/rom-yaml 4 | [codeclimate]: https://codeclimate.com/github/rom-rb/rom-yaml 5 | [inchpages]: http://inch-ci.org/github/rom-rb/rom-yaml 6 | 7 | # rom-yaml 8 | 9 | [![Gem Version](https://badge.fury.io/rb/rom-yaml.svg)][gem] 10 | [![Build Status](https://travis-ci.org/rom-rb/rom-yaml.svg?branch=master)][travis] 11 | [![Dependency Status](https://gemnasium.com/rom-rb/rom-yaml.svg)][gemnasium] 12 | [![Code Climate](https://codeclimate.com/github/rom-rb/rom-yaml/badges/gpa.svg)][codeclimate] 13 | [![Test Coverage](https://codeclimate.com/github/rom-rb/rom-yaml/badges/coverage.svg)][codeclimate] 14 | [![Inline docs](http://inch-ci.org/github/rom-rb/rom-yaml.svg?branch=master)][inchpages] 15 | 16 | YAML support for [rom-rb](https://github.com/rom-rb/rom) 17 | 18 | ## Installation 19 | 20 | Add this line to your application's Gemfile: 21 | 22 | ```ruby 23 | gem 'rom-yaml' 24 | ``` 25 | 26 | And then execute: 27 | 28 | $ bundle 29 | 30 | Or install it yourself as: 31 | 32 | $ gem install rom-yaml 33 | 34 | ## Usage 35 | 36 | See `spec/integration/adapter_spec.rb` for a sample usage. 37 | 38 | ## License 39 | 40 | See `LICENSE` file. 41 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require 'rspec/core/rake_task' 2 | 3 | RSpec::Core::RakeTask.new(:spec) 4 | task default: :spec 5 | -------------------------------------------------------------------------------- /lib/rom-yaml.rb: -------------------------------------------------------------------------------- 1 | require 'rom/yaml' 2 | -------------------------------------------------------------------------------- /lib/rom/yaml.rb: -------------------------------------------------------------------------------- 1 | require 'rom-core' 2 | 3 | require 'rom/yaml/version' 4 | require 'rom/yaml/gateway' 5 | require 'rom/yaml/relation' 6 | 7 | ROM.register_adapter(:yaml, ROM::YAML) 8 | -------------------------------------------------------------------------------- /lib/rom/yaml/dataset.rb: -------------------------------------------------------------------------------- 1 | require 'rom/memory/dataset' 2 | 3 | module ROM 4 | module YAML 5 | # YAML in-memory dataset used by YAML gateways 6 | # 7 | # @api public 8 | class Dataset < ROM::Memory::Dataset 9 | # Data-row transformation proc 10 | # 11 | # @api private 12 | def self.row_proc 13 | Transforms[:deep_symbolize_keys] 14 | end 15 | end 16 | 17 | 18 | # @api private 19 | class Transforms 20 | extend Transproc::Registry 21 | import Transproc::HashTransformations 22 | import Transproc::Recursion 23 | end 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /lib/rom/yaml/gateway.rb: -------------------------------------------------------------------------------- 1 | require 'yaml' 2 | 3 | require 'rom/gateway' 4 | require 'rom/yaml/dataset' 5 | 6 | module ROM 7 | module YAML 8 | # YAML gateway 9 | # 10 | # Connects to a yaml file and uses it as a data-source 11 | # 12 | # @example 13 | # rom = ROM.container(:yaml, '/path/to/data.yml') 14 | # gateway = rom.gateways[:default] 15 | # gateway[:users] # => data under 'users' key from the yaml file 16 | # 17 | # @api public 18 | class Gateway < ROM::Gateway 19 | adapter :yaml 20 | 21 | # @attr_reader [Hash] sources Data loaded from files 22 | # 23 | # @api private 24 | attr_reader :sources 25 | 26 | # @attr_reader [Hash] datasets YAML datasets from sources 27 | # 28 | # @api private 29 | attr_reader :datasets 30 | 31 | # Create a new yaml gateway from a path to file(s) 32 | # 33 | # @example 34 | # gateway = ROM::YAML::Gateway.new('/path/to/files') 35 | # 36 | # @param [String, Pathname] path The path to your YAML file(s) 37 | # 38 | # @return [Gateway] 39 | # 40 | # @api public 41 | def self.new(path) 42 | super(load_from(path)) 43 | end 44 | 45 | # Load data from yaml file(s) 46 | # 47 | # @api private 48 | def self.load_from(path) 49 | if File.directory?(path) 50 | load_files(path) 51 | else 52 | load_file(path) 53 | end 54 | end 55 | 56 | # Load yaml files from a given directory and return a name => data map 57 | # 58 | # @api private 59 | def self.load_files(path) 60 | Dir["#{path}/*.yml"].each_with_object({}) do |file, h| 61 | name = File.basename(file, '.*') 62 | h[name] = load_file(file).fetch(name) 63 | end 64 | end 65 | 66 | # Load yaml file 67 | # 68 | # @api private 69 | def self.load_file(path) 70 | ::YAML.load_file(path) 71 | end 72 | 73 | # @param [Hash] sources The hashmap containing data loaded from files 74 | # 75 | # @api private 76 | def initialize(sources) 77 | @sources = sources 78 | @datasets = {} 79 | end 80 | 81 | # Return dataset by its name 82 | # 83 | # @param [Symbol] 84 | # 85 | # @return [Array] 86 | # 87 | # @api public 88 | def [](name) 89 | datasets.fetch(name) 90 | end 91 | 92 | # Register a new dataset 93 | # 94 | # @param [Symbol] 95 | # 96 | # @return [Dataset] 97 | # 98 | # @api public 99 | def dataset(name) 100 | datasets[name] = Dataset.new(sources.fetch(name.to_s)) 101 | end 102 | 103 | # Return if a dataset with provided name exists 104 | # 105 | # @api public 106 | def dataset?(name) 107 | datasets.key?(name) 108 | end 109 | end 110 | end 111 | end 112 | -------------------------------------------------------------------------------- /lib/rom/yaml/relation.rb: -------------------------------------------------------------------------------- 1 | require 'rom/memory' 2 | require 'rom/yaml/schema' 3 | 4 | module ROM 5 | module YAML 6 | # YAML-specific relation subclass 7 | # 8 | # @api private 9 | class Relation < ROM::Memory::Relation 10 | adapter :yaml 11 | 12 | schema_class YAML::Schema 13 | end 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /lib/rom/yaml/schema.rb: -------------------------------------------------------------------------------- 1 | require 'rom/types' 2 | require 'rom/schema' 3 | 4 | module ROM 5 | module YAML 6 | # YAML relation schema 7 | # 8 | # @api public 9 | class Schema < ROM::Schema 10 | end 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /lib/rom/yaml/version.rb: -------------------------------------------------------------------------------- 1 | module ROM 2 | module YAML 3 | VERSION = '3.0.0'.freeze 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /rakelib/rubocop.rake: -------------------------------------------------------------------------------- 1 | begin 2 | require "rubocop/rake_task" 3 | 4 | Rake::Task[:default].enhance [:rubocop] 5 | 6 | RuboCop::RakeTask.new do |task| 7 | task.options << "--display-cop-names" 8 | end 9 | 10 | namespace :rubocop do 11 | desc 'Generate a configuration file acting as a TODO list.' 12 | task :auto_gen_config do 13 | exec "bundle exec rubocop --auto-gen-config" 14 | end 15 | end 16 | 17 | rescue LoadError 18 | end 19 | -------------------------------------------------------------------------------- /rom-yaml.gemspec: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | lib = File.expand_path('../lib', __FILE__) 3 | $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) 4 | require 'rom/yaml/version' 5 | 6 | Gem::Specification.new do |spec| 7 | spec.name = 'rom-yaml' 8 | spec.version = ROM::YAML::VERSION.dup 9 | spec.authors = ['Piotr Solnica'] 10 | spec.email = ['piotr.solnica@gmail.com'] 11 | spec.summary = 'YAML support for Ruby Object Mapper' 12 | spec.description = spec.summary 13 | spec.homepage = 'http://rom-rb.org' 14 | spec.license = 'MIT' 15 | 16 | spec.files = `git ls-files -z`.split("\x0") 17 | spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } 18 | spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) 19 | spec.require_paths = ['lib'] 20 | 21 | spec.add_runtime_dependency 'rom-core', '~> 5.0' 22 | 23 | spec.add_development_dependency 'bundler' 24 | spec.add_development_dependency 'rake' 25 | spec.add_development_dependency 'rubocop', '~> 0.49.0' 26 | end 27 | -------------------------------------------------------------------------------- /spec/fixtures/db/tasks.yml: -------------------------------------------------------------------------------- 1 | tasks: 2 | - title: 'Task One' 3 | - title: 'Task Two' 4 | - title: 'Task Three' 5 | -------------------------------------------------------------------------------- /spec/fixtures/db/users.yml: -------------------------------------------------------------------------------- 1 | users: 2 | - name: 'Jane' 3 | email: 'jane@doe.org' 4 | -------------------------------------------------------------------------------- /spec/fixtures/test_db.yml: -------------------------------------------------------------------------------- 1 | users: 2 | - name: 'Jane' 3 | email: 'jane@doe.org' 4 | roles: 5 | - role_name: 'Member' 6 | - role_name: 'Admin' 7 | -------------------------------------------------------------------------------- /spec/integration/adapter_spec.rb: -------------------------------------------------------------------------------- 1 | RSpec.describe ROM::YAML do 2 | let(:configuration) do 3 | ROM::Configuration.new(:yaml, path) 4 | end 5 | 6 | let(:root) { Pathname(__FILE__).dirname.join('..') } 7 | let(:container) { ROM.container(configuration) } 8 | 9 | subject(:rom) { container } 10 | 11 | describe "single file configuration" do 12 | let(:path) { "#{root}/fixtures/test_db.yml" } 13 | 14 | let(:users_relation) do 15 | Class.new(ROM::YAML::Relation) do 16 | schema(:users) do 17 | attribute :name, ROM::Types::String 18 | attribute :email, ROM::Types::String 19 | attribute :roles, ROM::Types::Array 20 | end 21 | 22 | auto_struct true 23 | 24 | def by_name(name) 25 | restrict(name: name) 26 | end 27 | end 28 | end 29 | 30 | before do 31 | configuration.register_relation(users_relation) 32 | end 33 | 34 | describe 'Relation#first' do 35 | it 'returns mapped struct' do 36 | jane = rom.relations[:users].by_name('Jane').first 37 | 38 | expect(jane.name).to eql('Jane') 39 | expect(jane.email).to eql('jane@doe.org') 40 | expect(jane.roles.length).to eql(2) 41 | expect(jane.roles).to eql([ 42 | { role_name: 'Member' }, { role_name: 'Admin' } 43 | ]) 44 | end 45 | end 46 | end 47 | 48 | describe 'multi-file setup' do 49 | let(:path) { "#{root}/fixtures/db" } 50 | 51 | let(:users_relation) do 52 | Class.new(ROM::YAML::Relation) do 53 | schema :users do 54 | attribute :name, ROM::Types::String 55 | attribute :email, ROM::Types::String 56 | end 57 | end 58 | end 59 | 60 | let(:tasks_relation) do 61 | Class.new(ROM::YAML::Relation) do 62 | schema :tasks do 63 | attribute :title, ROM::Types::String 64 | end 65 | end 66 | end 67 | 68 | before do 69 | configuration.register_relation(users_relation) 70 | configuration.register_relation(tasks_relation) 71 | end 72 | 73 | it 'uses one-file-per-relation' do 74 | expect(rom.relations[:users].to_a).to eql([ 75 | { name: 'Jane', email: 'jane@doe.org' } 76 | ]) 77 | 78 | expect(rom.relations[:tasks].to_a).to eql([ 79 | { title: 'Task One' }, 80 | { title: 'Task Two' }, 81 | { title: 'Task Three' } 82 | ]) 83 | end 84 | end 85 | end 86 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | if RUBY_ENGINE == 'ruby' && RUBY_VERSION >= '2.4.0' && ENV['CI'] == 'true' 4 | require 'simplecov' 5 | SimpleCov.start do 6 | add_filter '/spec/' 7 | end 8 | end 9 | 10 | require 'rom-yaml' 11 | 12 | begin 13 | require 'byebug' 14 | rescue LoadError 15 | end 16 | 17 | root = Pathname(__FILE__).dirname 18 | 19 | Dir[root.join('shared/*.rb').to_s].each { |f| require f } 20 | 21 | module Test 22 | def self.remove_constants 23 | constants.each(&method(:remove_const)) 24 | end 25 | end 26 | 27 | RSpec.configure do |config| 28 | config.after do 29 | Test.remove_constants 30 | end 31 | 32 | config.disable_monkey_patching! 33 | end 34 | -------------------------------------------------------------------------------- /spec/unit/dataset_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | require 'rom/lint/spec' 4 | 5 | RSpec.describe ROM::YAML::Dataset do 6 | let(:data) { [{ id: 1 }, { id: 2 }] } 7 | let(:dataset) { ROM::YAML::Dataset.new(data) } 8 | 9 | it_behaves_like "a rom enumerable dataset" 10 | 11 | it "symbolizes keys" do 12 | dataset = ROM::YAML::Dataset.new(["foo" => 23]) 13 | expect(dataset.to_a).to eq([{ foo: 23 }]) 14 | end 15 | 16 | it "symbolizes keys recursively" do 17 | dataset = ROM::YAML::Dataset.new(["foo" => { "bar" => :baz }]) 18 | expect(dataset.to_a).to eq([foo: { bar: :baz }]) 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /spec/unit/gateway_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | require 'rom/lint/spec' 4 | 5 | RSpec.describe ROM::YAML::Gateway do 6 | let(:root) { Pathname(__FILE__).dirname.join('..') } 7 | 8 | it_behaves_like 'a rom gateway' do 9 | let(:identifier) { :yaml } 10 | let(:gateway) { ROM::YAML::Gateway } 11 | let(:uri) { "#{root}/fixtures/test_db.yml" } 12 | end 13 | end 14 | --------------------------------------------------------------------------------