modis 1.4.1-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +16 -0
- data/.rubocop.yml +31 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +13 -0
- data/Gemfile +17 -0
- data/Gemfile.lock +89 -0
- data/LICENSE.txt +22 -0
- data/README.md +45 -0
- data/Rakefile +17 -0
- data/benchmark/bench.rb +65 -0
- data/benchmark/find.rb +62 -0
- data/benchmark/persistence.rb +82 -0
- data/benchmark/redis/connection/fakedis.rb +90 -0
- data/lib/modis.rb +41 -0
- data/lib/modis/attribute.rb +103 -0
- data/lib/modis/configuration.rb +14 -0
- data/lib/modis/errors.rb +16 -0
- data/lib/modis/finder.rb +76 -0
- data/lib/modis/index.rb +84 -0
- data/lib/modis/model.rb +47 -0
- data/lib/modis/persistence.rb +233 -0
- data/lib/modis/transaction.rb +13 -0
- data/lib/modis/version.rb +3 -0
- data/lib/tasks/quality.rake +41 -0
- data/modis.gemspec +32 -0
- data/spec/attribute_spec.rb +172 -0
- data/spec/errors_spec.rb +18 -0
- data/spec/finder_spec.rb +109 -0
- data/spec/index_spec.rb +84 -0
- data/spec/persistence_spec.rb +319 -0
- data/spec/spec_helper.rb +24 -0
- data/spec/support/simplecov_helper.rb +23 -0
- data/spec/support/simplecov_quality_formatter.rb +12 -0
- data/spec/transaction_spec.rb +16 -0
- data/spec/validations_spec.rb +49 -0
- metadata +173 -0
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
unless ENV['TRAVIS']
|
2
|
+
begin
|
3
|
+
require './spec/support/simplecov_helper'
|
4
|
+
include SimpleCovHelper
|
5
|
+
start_simple_cov('unit')
|
6
|
+
rescue LoadError
|
7
|
+
puts "Coverage disabled."
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
require 'modis'
|
12
|
+
|
13
|
+
Modis.configure do |config|
|
14
|
+
config.namespace = 'modis'
|
15
|
+
end
|
16
|
+
|
17
|
+
RSpec.configure do |config|
|
18
|
+
config.after :each do
|
19
|
+
Modis.with_connection do |connection|
|
20
|
+
keys = connection.keys "#{Modis.config.namespace}:*"
|
21
|
+
connection.del(*keys) unless keys.empty?
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
require './spec/support/simplecov_quality_formatter'
|
3
|
+
|
4
|
+
module SimpleCovHelper
|
5
|
+
def start_simple_cov(name)
|
6
|
+
SimpleCov.start do
|
7
|
+
add_filter '/spec/'
|
8
|
+
command_name name
|
9
|
+
|
10
|
+
formatters = [SimpleCov::Formatter::QualityFormatter]
|
11
|
+
|
12
|
+
if ENV['TRAVIS']
|
13
|
+
require 'codeclimate-test-reporter'
|
14
|
+
|
15
|
+
if CodeClimate::TestReporter.run?
|
16
|
+
formatters << CodeClimate::TestReporter::Formatter
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
formatter SimpleCov::Formatter::MultiFormatter[*formatters]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module SimpleCov
|
2
|
+
module Formatter
|
3
|
+
class QualityFormatter
|
4
|
+
def format(result)
|
5
|
+
SimpleCov::Formatter::HTMLFormatter.new.format(result)
|
6
|
+
File.open("coverage/covered_percent", "w") do |f|
|
7
|
+
f.puts result.source_files.covered_percent.to_f
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module TransactionSpec
|
4
|
+
class MockModel
|
5
|
+
include Modis::Model
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
describe Modis::Transaction do
|
10
|
+
it 'yields the block in a transaction' do
|
11
|
+
redis = double.as_null_object
|
12
|
+
allow(Modis).to receive(:with_connection).and_yield(redis)
|
13
|
+
expect(redis).to receive(:multi)
|
14
|
+
TransactionSpec::MockModel.transaction {}
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'validations' do
|
4
|
+
class TestModel
|
5
|
+
include Modis::Model
|
6
|
+
attribute :name, :string
|
7
|
+
validates :name, presence: true
|
8
|
+
end
|
9
|
+
|
10
|
+
let(:model) { TestModel.new }
|
11
|
+
|
12
|
+
it 'responds to valid?' do
|
13
|
+
model.name = nil
|
14
|
+
expect(model.valid?).to be false
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'sets errors on the model' do
|
18
|
+
model.name = nil
|
19
|
+
model.valid?
|
20
|
+
expect(model.errors[:name]).to eq(["can't be blank"])
|
21
|
+
end
|
22
|
+
|
23
|
+
describe 'save' do
|
24
|
+
it 'returns true if the model is valid' do
|
25
|
+
model.name = "Ian"
|
26
|
+
expect(model.save).to be true
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'returns false if the model is invalid' do
|
30
|
+
model.name = nil
|
31
|
+
expect(model.save).to be false
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe 'save!' do
|
36
|
+
it 'raises an error if the model is invalid' do
|
37
|
+
model.name = nil
|
38
|
+
expect do
|
39
|
+
expect(model.save!).to be false
|
40
|
+
end.to raise_error(Modis::RecordInvalid)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe 'create!' do
|
45
|
+
it 'raises an error if the record is not valid' do
|
46
|
+
expect { TestModel.create!(name: nil) }.to raise_error(Modis::RecordInvalid)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
metadata
ADDED
@@ -0,0 +1,173 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: modis
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.4.1
|
5
|
+
platform: java
|
6
|
+
authors:
|
7
|
+
- Ian Leitch
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-01-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - '>='
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '3.0'
|
19
|
+
name: activemodel
|
20
|
+
prerelease: false
|
21
|
+
type: :runtime
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '3.0'
|
33
|
+
name: activesupport
|
34
|
+
prerelease: false
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '3.0'
|
47
|
+
name: redis
|
48
|
+
prerelease: false
|
49
|
+
type: :runtime
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - '>='
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0.5'
|
61
|
+
name: hiredis
|
62
|
+
prerelease: false
|
63
|
+
type: :runtime
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.5'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - '>='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '2'
|
75
|
+
name: connection_pool
|
76
|
+
prerelease: false
|
77
|
+
type: :runtime
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '2'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
requirement: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - '>='
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
name: msgpack-jruby
|
90
|
+
prerelease: false
|
91
|
+
type: :runtime
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: ActiveModel + Redis
|
98
|
+
email:
|
99
|
+
- port001@gmail.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- .gitignore
|
105
|
+
- .rubocop.yml
|
106
|
+
- .ruby-gemset
|
107
|
+
- .ruby-version
|
108
|
+
- .travis.yml
|
109
|
+
- Gemfile
|
110
|
+
- Gemfile.lock
|
111
|
+
- LICENSE.txt
|
112
|
+
- README.md
|
113
|
+
- Rakefile
|
114
|
+
- benchmark/bench.rb
|
115
|
+
- benchmark/find.rb
|
116
|
+
- benchmark/persistence.rb
|
117
|
+
- benchmark/redis/connection/fakedis.rb
|
118
|
+
- lib/modis.rb
|
119
|
+
- lib/modis/attribute.rb
|
120
|
+
- lib/modis/configuration.rb
|
121
|
+
- lib/modis/errors.rb
|
122
|
+
- lib/modis/finder.rb
|
123
|
+
- lib/modis/index.rb
|
124
|
+
- lib/modis/model.rb
|
125
|
+
- lib/modis/persistence.rb
|
126
|
+
- lib/modis/transaction.rb
|
127
|
+
- lib/modis/version.rb
|
128
|
+
- lib/tasks/quality.rake
|
129
|
+
- modis.gemspec
|
130
|
+
- spec/attribute_spec.rb
|
131
|
+
- spec/errors_spec.rb
|
132
|
+
- spec/finder_spec.rb
|
133
|
+
- spec/index_spec.rb
|
134
|
+
- spec/persistence_spec.rb
|
135
|
+
- spec/spec_helper.rb
|
136
|
+
- spec/support/simplecov_helper.rb
|
137
|
+
- spec/support/simplecov_quality_formatter.rb
|
138
|
+
- spec/transaction_spec.rb
|
139
|
+
- spec/validations_spec.rb
|
140
|
+
homepage: ''
|
141
|
+
licenses: []
|
142
|
+
metadata: {}
|
143
|
+
post_install_message:
|
144
|
+
rdoc_options: []
|
145
|
+
require_paths:
|
146
|
+
- lib
|
147
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - '>='
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
152
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
153
|
+
requirements:
|
154
|
+
- - '>='
|
155
|
+
- !ruby/object:Gem::Version
|
156
|
+
version: '0'
|
157
|
+
requirements: []
|
158
|
+
rubyforge_project:
|
159
|
+
rubygems_version: 2.1.9
|
160
|
+
signing_key:
|
161
|
+
specification_version: 4
|
162
|
+
summary: ActiveModel + Redis
|
163
|
+
test_files:
|
164
|
+
- spec/attribute_spec.rb
|
165
|
+
- spec/errors_spec.rb
|
166
|
+
- spec/finder_spec.rb
|
167
|
+
- spec/index_spec.rb
|
168
|
+
- spec/persistence_spec.rb
|
169
|
+
- spec/spec_helper.rb
|
170
|
+
- spec/support/simplecov_helper.rb
|
171
|
+
- spec/support/simplecov_quality_formatter.rb
|
172
|
+
- spec/transaction_spec.rb
|
173
|
+
- spec/validations_spec.rb
|