Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
solnic committed Feb 13, 2015
0 parents commit 96a2e34
Show file tree
Hide file tree
Showing 21 changed files with 516 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/.bundle/
/.yardoc
/Gemfile.lock
/_yardoc/
/coverage/
/doc/
/pkg/
/spec/reports/
/tmp/
*.bundle
*.so
*.o
*.a
mkmf.log
log/*.log
2 changes: 2 additions & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--color
--order random
78 changes: 78 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Generated by `rubocop --auto-gen-config`
inherit_from: .rubocop_todo.yml

# Exclude temporary files
AllCops:
Exclude:
- tmp/**/*

# It’s quite readable when we know what we are doing
Lint/AssignmentInCondition:
Enabled: false

# No need to handle LoadError in Rakefile
Lint/HandleExceptions:
Exclude:
- Rakefile

# gemspec is a special snowflake
Metrics/LineLength:
Exclude:
- rom.gemspec

# The enforced style doesn’t match Vim’s defaults
Style/AlignParameters:
Enabled: false

# UTF-8 is perfectly fine in comments
Style/AsciiComments:
Enabled: false

# Allow using braces for value-returning blocks
Style/Blocks:
Enabled: false

# Documentation checked by Inch CI
Style/Documentation:
Enabled: false

# Early returns have their vices
Style/GuardClause:
Enabled: false

# Need to be skipped for >-> usage
Style/Lambda:
Enabled: false

# Multiline block chains are ok
Style/MultilineBlockChain:
Enabled: false

# Result::Success and Result::Failure use > for callbacks
Style/OpMethod:
Exclude:
- lib/rom/command_registry.rb

# Even a single escaped slash can be confusing
Style/RegexpLiteral:
MaxSlashes: 0

# Don’t introduce semantic fail/raise distinction
Style/SignalException:
EnforcedStyle: only_raise

# Need to be skipped for >-> usage
Style/SpaceAroundOperators:
Enabled: false

# Accept both single and double quotes
Style/StringLiterals:
Enabled: false

# Allow def self.foo; @foo; end
Style/TrivialAccessors:
Enabled: false

# Allow rom-sql
Style/FileName:
Enabled: false
15 changes: 15 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This configuration was generated by `rubocop --auto-gen-config`
# on 2015-01-25 22:37:25 +0100 using RuboCop version 0.28.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 3
Metrics/AbcSize:
Max: 20

# Offense count: 2
# Configuration parameters: CountComments.
Metrics/MethodLength:
Max: 14
28 changes: 28 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
language: ruby
sudo: false
cache: bundler
bundler_args: --without yard guard benchmarks tools
env:
- CODECLIMATE_REPO_TOKEN=03d7f66589572702b12426d2bc71c4de6281a96139e33b335b894264b1f8f0b0
before_script:
- psql -c 'create database rom;' -U postgres
script: "bundle exec rake ci"
rvm:
- 2.0
- 2.1
- 2.2
- rbx-2
- jruby
- jruby-head
- ruby-head
matrix:
allow_failures:
- rvm: ruby-head
- rvm: jruby-head
notifications:
webhooks:
urls:
- https://webhooks.gitter.im/e/39e1225f489f38b0bd09
on_success: change
on_failure: always
on_start: false
63 changes: 63 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
## v0.3.3 to-be-released

### Added

* Support for 'postgresql' scheme name which makes it work next to ActiveRecord (solnic)

### Fixed

* Indentation in Rails logger (morgoth)

[Compare v0.3.2...master](https://github.com/rom-rb/rom-sql/compare/v0.3.1...master)

## v0.3.2 2015-01-01

### Fixed

* Checking tuple count in commands (solnic)

[Compare v0.3.1...v0.3.2](https://github.com/rom-rb/rom-sql/compare/v0.3.1...v0.3.2)

## v0.3.1 2014-12-31

### Added

* `Adapter#disconnect` (solnic)
* Support for extra connection options (solnic)

[Compare v0.3.0...v0.3.1](https://github.com/rom-rb/rom-sql/compare/v0.3.0...v0.3.1)

## v0.3.0 2014-12-19

### Changed

* `association_join` now uses Sequel's `graph` interface which qualifies columns automatically (solnic)
* Delete command returns deleted tuples (solnic)

[Compare v0.2.0...v0.3.0](https://github.com/rom-rb/rom-sql/compare/v0.2.0...v0.3.0)

## v0.2.0 2014-12-06

### Added

* Command API (solnic)
* Support for ActiveSupport::Notifications with a log subscriber (solnic)
* New `ROM::SQL::Adapter#dataset?(name)` checking if a given table exists (solnic)

[Compare v0.1.1...v0.2.0](https://github.com/rom-rb/rom-sql/compare/v0.1.1...v0.2.0)

## v0.1.1 2014-11-24

### Fixed

* Equalizer in header (solnic)

### Changed

* minor refactor in adapter (solnic)

[Compare v0.1.0...v0.1.1](https://github.com/rom-rb/rom-sql/compare/v0.1.0...v0.1.1)

## v0.1.0 2014-11-24

First release powered by Sequel
19 changes: 19 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
source 'https://rubygems.org'

gemspec

group :test do
gem 'rom', github: 'rom-rb/rom', branch: 'master'
gem 'rom-sql', github: 'rom-rb/rom-sql', branch: 'master'
gem 'rspec', '~> 3.1'
gem 'codeclimate-test-reporter', require: false
gem 'sqlite3', platforms: [:mri, :rbx]
end

group :tools do
gem 'byebug'
gem 'guard'
gem 'guard-rspec'
gem 'guard-rubocop'
gem 'rubocop', '~> 0.28'
end
24 changes: 24 additions & 0 deletions Guardfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
group :red_green_refactor, halt_on_fail: true do
guard :rspec, cmd: "rspec", all_on_start: true do
# run all specs if Gemfile.lock is modified
watch('Gemfile.lock') { 'spec' }

# run all specs if any library code is modified
watch(%r{\Alib/.+\.rb\z}) { 'spec' }

# run all specs if supporting files are modified
watch('spec/spec_helper.rb') { 'spec' }
watch(%r{\Aspec/(?:lib|support|shared)/.+\.rb\z}) { 'spec' }

# run a spec if it is modified
watch(%r{\Aspec/(?:unit|integration)/.+_spec\.rb\z})

notification :tmux, display_message: true if ENV.key?('TMUX')
end

guard :rubocop do
# run rubocop on modified file
watch(%r{\Alib/.+\.rb\z})
watch(%r{\Aspec/.+\.rb\z})
end
end
22 changes: 22 additions & 0 deletions LICENSE.txt
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.
53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
[gem]: https://rubygems.org/gems/rom-yesql
[travis]: https://travis-ci.org/rom-rb/rom-yesql
[gemnasium]: https://gemnasium.com/rom-rb/rom-yesql
[codeclimate]: https://codeclimate.com/github/rom-rb/rom-yesql
[inchpages]: http://inch-ci.org/github/rom-rb/rom-yesql

# ROM::Yesql

[![Gem Version](https://badge.fury.io/rb/rom-yesql.svg)][gem]
[![Build Status](https://travis-ci.org/rom-rb/rom-yesql.svg?branch=master)][travis]
[![Dependency Status](https://gemnasium.com/rom-rb/rom-yesql.png)][gemnasium]
[![Code Climate](https://codeclimate.com/github/rom-rb/rom-yesql/badges/gpa.svg)][codeclimate]
[![Test Coverage](https://codeclimate.com/github/rom-rb/rom-yesql/badges/coverage.svg)][codeclimate]
[![Inline docs](http://inch-ci.org/github/rom-rb/rom-yesql.svg?branch=master)][inchpages]


Yesql-like adapter for [Ruby Object Mapper](https://github.com/rom-rb/rom).

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'rom-yesql'
```

And then execute:

$ bundle

Or install it yourself as:

$ gem install rom-yesql

## Synopsis

``` ruby
# given sql/users.sql includes "SELECT * FROM users"

ROM.setup(:yesql, ['sqlite://path/to/your/db'])

class MyQueries < ROM::Relation[:yesql]
end

ROM.finalize

my_queries = rom.relations[:my_queries]
my_queries.users.to_a # => gets the users
```

## License

See `LICENSE` file.
18 changes: 18 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
require "rspec/core/rake_task"

RSpec::Core::RakeTask.new(:spec)
task default: [:ci]

desc "Run CI tasks"
task ci: [:spec]

begin
require "rubocop/rake_task"

Rake::Task[:default].enhance [:rubocop]

RuboCop::RakeTask.new do |task|
task.options << "--display-cop-names"
end
rescue LoadError
end
1 change: 1 addition & 0 deletions lib/rom-yesql.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require 'rom/yesql'
Loading

0 comments on commit 96a2e34

Please sign in to comment.