cacchern 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.circleci/config.yml +34 -0
- data/.gitignore +3 -0
- data/.rspec +2 -0
- data/.rubocop.yml +1 -0
- data/.rubocop_todo.yml +29 -0
- data/.ruby-version +1 -0
- data/Gemfile +14 -2
- data/Gemfile.lock +74 -0
- data/Rakefile +4 -2
- data/bin/console +4 -3
- data/cacchern.gemspec +16 -15
- data/lib/cacchern.rb +6 -5
- data/lib/cacchern/incrementable_sorted_set.rb +2 -1
- data/lib/cacchern/sorted_set.rb +13 -5
- data/lib/cacchern/value.rb +2 -0
- data/lib/cacchern/version.rb +3 -1
- data/redis.yml.erb +8 -0
- metadata +26 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 39d29e6a57fcded65d5750337ca634d9af3b1ef027ffd20d91dc07e0e9ca5605
|
4
|
+
data.tar.gz: 0441c18bf22fdee79da25ac1fc8292d01606fa51273e8b377dd847896c693bbc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '028fd2a91be859333fc00e79df867cc723d30d4e3eeb2066b6ebb860d44e261181f57274bf46e2849b8b6b820cf19482e960bf5024d2c7fb5f1319dcc1cd3e4a'
|
7
|
+
data.tar.gz: 4ce77a2843e48785a58412585e9b7f8094a06ba3d661c4d87f81840d618e45a39e62f96386e52b00516b6a1b8448ca3f620ddb8f478d0dc16bf7197e30093acb
|
@@ -0,0 +1,34 @@
|
|
1
|
+
version: 2
|
2
|
+
jobs:
|
3
|
+
build:
|
4
|
+
docker:
|
5
|
+
- image: ruby:2.5.0
|
6
|
+
- image: circleci/redis:4.0
|
7
|
+
|
8
|
+
working_directory: ~/cacchern
|
9
|
+
|
10
|
+
steps:
|
11
|
+
- checkout
|
12
|
+
|
13
|
+
- restore_cache:
|
14
|
+
keys:
|
15
|
+
- v1-dependencies-{{ checksum "Gemfile.lock" }}
|
16
|
+
- run:
|
17
|
+
name: install dependencies
|
18
|
+
command: |
|
19
|
+
bundle install --jobs=4 --retry=3 --path vendor/bundle
|
20
|
+
|
21
|
+
- save_cache:
|
22
|
+
paths:
|
23
|
+
- ./vendor/bundle
|
24
|
+
key: v1-dependencies-{{ checksum "Gemfile.lock" }}
|
25
|
+
|
26
|
+
- run:
|
27
|
+
name: run lint
|
28
|
+
command: |
|
29
|
+
bundle exec rubocop
|
30
|
+
|
31
|
+
- run:
|
32
|
+
name: run tests
|
33
|
+
command: |
|
34
|
+
bundle exec rspec
|
data/.gitignore
CHANGED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2018-09-05 09:03:18 +0900 using RuboCop version 0.58.2.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 1
|
10
|
+
# Configuration parameters: CountComments, ExcludedMethods.
|
11
|
+
# ExcludedMethods: refine
|
12
|
+
Metrics/BlockLength:
|
13
|
+
Max: 56
|
14
|
+
|
15
|
+
# Offense count: 4
|
16
|
+
Style/Documentation:
|
17
|
+
Exclude:
|
18
|
+
- 'spec/**/*'
|
19
|
+
- 'test/**/*'
|
20
|
+
- 'lib/cacchern.rb'
|
21
|
+
- 'lib/cacchern/incrementable_sorted_set.rb'
|
22
|
+
- 'lib/cacchern/sorted_set.rb'
|
23
|
+
- 'lib/cacchern/value.rb'
|
24
|
+
|
25
|
+
# Offense count: 6
|
26
|
+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
27
|
+
# URISchemes: http, https
|
28
|
+
Metrics/LineLength:
|
29
|
+
Max: 118
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.5.0
|
data/Gemfile
CHANGED
@@ -1,6 +1,18 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
|
5
|
+
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
4
6
|
|
5
7
|
# Specify your gem's dependencies in cacchern.gemspec
|
6
8
|
gemspec
|
9
|
+
|
10
|
+
group :development, :test do
|
11
|
+
gem 'dotenv'
|
12
|
+
gem 'rspec'
|
13
|
+
gem 'rubocop'
|
14
|
+
end
|
15
|
+
|
16
|
+
group :test do
|
17
|
+
gem 'database_cleaner'
|
18
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
cacchern (0.0.2)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
activemodel (5.2.1)
|
10
|
+
activesupport (= 5.2.1)
|
11
|
+
activesupport (5.2.1)
|
12
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
13
|
+
i18n (>= 0.7, < 2)
|
14
|
+
minitest (~> 5.1)
|
15
|
+
tzinfo (~> 1.1)
|
16
|
+
ast (2.4.0)
|
17
|
+
concurrent-ruby (1.0.5)
|
18
|
+
database_cleaner (1.7.0)
|
19
|
+
diff-lcs (1.3)
|
20
|
+
dotenv (2.5.0)
|
21
|
+
i18n (1.1.0)
|
22
|
+
concurrent-ruby (~> 1.0)
|
23
|
+
jaro_winkler (1.5.1)
|
24
|
+
minitest (5.11.3)
|
25
|
+
parallel (1.12.1)
|
26
|
+
parser (2.5.1.2)
|
27
|
+
ast (~> 2.4.0)
|
28
|
+
powerpack (0.1.2)
|
29
|
+
rainbow (3.0.0)
|
30
|
+
rake (12.3.1)
|
31
|
+
redis (4.0.2)
|
32
|
+
rspec (3.8.0)
|
33
|
+
rspec-core (~> 3.8.0)
|
34
|
+
rspec-expectations (~> 3.8.0)
|
35
|
+
rspec-mocks (~> 3.8.0)
|
36
|
+
rspec-core (3.8.0)
|
37
|
+
rspec-support (~> 3.8.0)
|
38
|
+
rspec-expectations (3.8.1)
|
39
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
40
|
+
rspec-support (~> 3.8.0)
|
41
|
+
rspec-mocks (3.8.0)
|
42
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
43
|
+
rspec-support (~> 3.8.0)
|
44
|
+
rspec-support (3.8.0)
|
45
|
+
rubocop (0.58.2)
|
46
|
+
jaro_winkler (~> 1.5.1)
|
47
|
+
parallel (~> 1.10)
|
48
|
+
parser (>= 2.5, != 2.5.1.1)
|
49
|
+
powerpack (~> 0.1)
|
50
|
+
rainbow (>= 2.2.2, < 4.0)
|
51
|
+
ruby-progressbar (~> 1.7)
|
52
|
+
unicode-display_width (~> 1.0, >= 1.0.1)
|
53
|
+
ruby-progressbar (1.10.0)
|
54
|
+
thread_safe (0.3.6)
|
55
|
+
tzinfo (1.2.5)
|
56
|
+
thread_safe (~> 0.1)
|
57
|
+
unicode-display_width (1.4.0)
|
58
|
+
|
59
|
+
PLATFORMS
|
60
|
+
ruby
|
61
|
+
|
62
|
+
DEPENDENCIES
|
63
|
+
activemodel
|
64
|
+
bundler
|
65
|
+
cacchern!
|
66
|
+
database_cleaner
|
67
|
+
dotenv
|
68
|
+
rake
|
69
|
+
redis (~> 4.0.0)
|
70
|
+
rspec
|
71
|
+
rubocop
|
72
|
+
|
73
|
+
BUNDLED WITH
|
74
|
+
1.16.4
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
|
-
require
|
4
|
-
require
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'cacchern'
|
5
6
|
|
6
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
8
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +11,5 @@ require "cacchern"
|
|
10
11
|
# require "pry"
|
11
12
|
# Pry.start
|
12
13
|
|
13
|
-
require
|
14
|
+
require 'irb'
|
14
15
|
IRB.start(__FILE__)
|
data/cacchern.gemspec
CHANGED
@@ -1,28 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
|
2
|
-
lib = File.expand_path(
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require
|
5
|
+
require 'cacchern/version'
|
5
6
|
|
6
7
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
8
|
+
spec.name = 'cacchern'
|
8
9
|
spec.version = Cacchern::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
10
|
+
spec.authors = ['Shuhei TAKASUGI']
|
11
|
+
spec.email = ['shuhei.takasugi@gmail.com']
|
11
12
|
|
12
|
-
spec.summary =
|
13
|
-
spec.description =
|
14
|
-
spec.homepage =
|
15
|
-
spec.license =
|
13
|
+
spec.summary = ' operate Redis like ActiveRecord interface '
|
14
|
+
spec.description = ' operate Redis like ActiveRecord interface '
|
15
|
+
spec.homepage = 'https://github.com/shuyuhey/cacchern'
|
16
|
+
spec.license = 'MIT'
|
16
17
|
|
17
18
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
19
|
f.match(%r{^(test|spec|features)/})
|
19
20
|
end
|
20
|
-
spec.bindir =
|
21
|
+
spec.bindir = 'exe'
|
21
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
-
spec.require_paths = [
|
23
|
+
spec.require_paths = ['lib']
|
23
24
|
|
24
|
-
spec.add_development_dependency
|
25
|
-
spec.add_development_dependency
|
26
|
-
spec.add_development_dependency
|
27
|
-
spec.add_development_dependency
|
25
|
+
spec.add_development_dependency 'activemodel'
|
26
|
+
spec.add_development_dependency 'bundler'
|
27
|
+
spec.add_development_dependency 'rake'
|
28
|
+
spec.add_development_dependency 'redis', '~> 4.0.0'
|
28
29
|
end
|
data/lib/cacchern.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'redis'
|
2
4
|
require 'active_model'
|
3
5
|
|
4
6
|
module Cacchern
|
5
7
|
end
|
6
8
|
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
|
9
|
+
require 'cacchern/version'
|
10
|
+
require 'cacchern/incrementable_sorted_set'
|
11
|
+
require 'cacchern/sorted_set'
|
12
|
+
require 'cacchern/value'
|
data/lib/cacchern/sorted_set.rb
CHANGED
@@ -1,11 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'cacchern/value'
|
2
4
|
|
3
5
|
module Cacchern
|
4
6
|
class SortedSet
|
5
7
|
attr_reader :key
|
6
8
|
|
7
|
-
|
8
|
-
|
9
|
+
class << self
|
10
|
+
def contain_class(klass)
|
11
|
+
@value_class = klass
|
12
|
+
end
|
13
|
+
|
14
|
+
def value_class
|
15
|
+
@value_class ||= Value
|
16
|
+
end
|
9
17
|
end
|
10
18
|
|
11
19
|
def initialize(key)
|
@@ -15,7 +23,7 @@ module Cacchern
|
|
15
23
|
def get(id)
|
16
24
|
score = Redis.current.zscore @key, id
|
17
25
|
return nil if score.nil?
|
18
|
-
self.class.
|
26
|
+
self.class.value_class.new(id, score)
|
19
27
|
end
|
20
28
|
|
21
29
|
def order(direction = :asc)
|
@@ -27,11 +35,11 @@ module Cacchern
|
|
27
35
|
else
|
28
36
|
Redis.current.zrange @key, 0, -1, withscores: true
|
29
37
|
end
|
30
|
-
values.map { |value| self.class.
|
38
|
+
values.map { |value| self.class.value_class.new(value[0], value[1]) }
|
31
39
|
end
|
32
40
|
|
33
41
|
def add(value)
|
34
|
-
return false unless value.instance_of?(self.class.
|
42
|
+
return false unless value.instance_of?(self.class.value_class)
|
35
43
|
|
36
44
|
if value.valid?
|
37
45
|
Redis.current.zadd @key, value.value, value.key
|
data/lib/cacchern/value.rb
CHANGED
data/lib/cacchern/version.rb
CHANGED
data/redis.yml.erb
ADDED
metadata
CHANGED
@@ -1,59 +1,59 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cacchern
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shuhei TAKASUGI
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: activemodel
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: redis
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
@@ -73,8 +73,14 @@ executables: []
|
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
+
- ".circleci/config.yml"
|
76
77
|
- ".gitignore"
|
78
|
+
- ".rspec"
|
79
|
+
- ".rubocop.yml"
|
80
|
+
- ".rubocop_todo.yml"
|
81
|
+
- ".ruby-version"
|
77
82
|
- Gemfile
|
83
|
+
- Gemfile.lock
|
78
84
|
- LICENSE.txt
|
79
85
|
- README.md
|
80
86
|
- Rakefile
|
@@ -86,6 +92,7 @@ files:
|
|
86
92
|
- lib/cacchern/sorted_set.rb
|
87
93
|
- lib/cacchern/value.rb
|
88
94
|
- lib/cacchern/version.rb
|
95
|
+
- redis.yml.erb
|
89
96
|
homepage: https://github.com/shuyuhey/cacchern
|
90
97
|
licenses:
|
91
98
|
- MIT
|
@@ -106,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
113
|
version: '0'
|
107
114
|
requirements: []
|
108
115
|
rubyforge_project:
|
109
|
-
rubygems_version: 2.
|
116
|
+
rubygems_version: 2.7.3
|
110
117
|
signing_key:
|
111
118
|
specification_version: 4
|
112
119
|
summary: operate Redis like ActiveRecord interface
|