Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ja/add skip #512

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
PATH
remote: .
specs:
mongo_aggregation_dsl (1.1.0)
mongo_aggregation_dsl (1.2.0)
autoloaded (~> 2)
contracts-lite
mongo
mongoid (~> 8)
mongoid (~> 7.3)

GEM
remote: https://rubygems.org/
Expand Down Expand Up @@ -65,9 +65,9 @@ GEM
minitest (5.17.0)
mongo (2.18.2)
bson (>= 4.14.1, < 5.0.0)
mongoid (8.0.3)
mongoid (7.5.2)
activemodel (>= 5.1, < 7.1, != 7.0.0)
mongo (>= 2.18.0, < 3.0.0)
mongo (>= 2.10.5, < 3.0.0)
ruby2_keywords (~> 0.0.5)
multi_xml (0.6.0)
octokit (6.0.1)
Expand Down
18 changes: 18 additions & 0 deletions lib/aggregate/stages/skip.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_string_literal: true

module Aggregate
module Stages
# Represents an aggregation skip
# https://www.mongodb.com/docs/manual/reference/operator/aggregation/skip/
class Skip < Base
Contract Integer => Any
def initialize(options)
super(options)
end

def transpose
{ '$skip': options }
end
end
end
end
4 changes: 2 additions & 2 deletions mongo_aggregation_dsl.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Gem::Specification.new do |spec|
spec.name = "mongo_aggregation_dsl"
spec.version = "1.1.0"
spec.version = "1.2.0"
spec.authors = ["KrimsonKla"]
spec.email = ["[email protected]"]
spec.date = "2018-09-10"
Expand All @@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
spec.add_dependency "autoloaded", "~> 2"
spec.add_dependency "contracts-lite"
spec.add_dependency "mongo"
spec.add_dependency "mongoid", "~> 8"
spec.add_dependency "mongoid", "~> 7.3"

spec.add_development_dependency "codecov", "~> 0.1", "~> 0.6.0"
spec.add_development_dependency "database_cleaner"
Expand Down
2 changes: 1 addition & 1 deletion spec/aggregate/stages/limit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "rails_helper"

RSpec.describe Aggregate::Stages::Group do
RSpec.describe Aggregate::Stages::Limit do
describe "#transpose" do
it "should properly format" do
expect(
Expand Down
21 changes: 21 additions & 0 deletions spec/aggregate/stages/skip_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

require "rails_helper"

RSpec.describe Aggregate::Stages::Skip do
describe "#transpose" do
it "should properly format" do
expect(
Aggregate::Stages::Skip.new(5).transpose
).to eq('$skip': 5)
end
end
describe "schema" do
it "should raise if option is not an integer" do
expect { Aggregate::Stages::Skip.new("test") }.to raise_error(ParamContractError)
end
it "does not raise if option is an integer" do
expect { Aggregate::Stages::Skip.new(1) }.not_to raise_error
end
end
end