cacchern 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: d944b92d66f9cf6635c2ac9850e7bc379dfa0c39
4
- data.tar.gz: 205ba66440ff5072cdf08b58cf6bda83ef7c0337
2
+ SHA256:
3
+ metadata.gz: 39d29e6a57fcded65d5750337ca634d9af3b1ef027ffd20d91dc07e0e9ca5605
4
+ data.tar.gz: 0441c18bf22fdee79da25ac1fc8292d01606fa51273e8b377dd847896c693bbc
5
5
  SHA512:
6
- metadata.gz: 69e50cf35eb2d7c46324055994b9b75b19a046d9574ba5e2edd0789628f26bcad5e078de5b1412676e9fe4f3611d620299c40acd841971c2f5369adee72fe2d1
7
- data.tar.gz: e9992b5b9d88a76788bd26b08453303f6e9034e46e36d4cfe6724f188606fc44c17c4da6a2793d39a31a9b8950193a867ce344685e6b9035fee44f607c0df0ee
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
@@ -6,3 +6,6 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ *.iml
10
+ *.rdb
11
+ .env
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1 @@
1
+ inherit_from: .rubocop_todo.yml
@@ -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
@@ -0,0 +1 @@
1
+ 2.5.0
data/Gemfile CHANGED
@@ -1,6 +1,18 @@
1
- source "https://rubygems.org"
1
+ # frozen_string_literal: true
2
2
 
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
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
@@ -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
@@ -1,2 +1,4 @@
1
- require "bundler/gem_tasks"
2
- task :default => :spec
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ task default: :spec
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require "bundler/setup"
4
- require "cacchern"
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 "irb"
14
+ require 'irb'
14
15
  IRB.start(__FILE__)
@@ -1,28 +1,29 @@
1
+ # frozen_string_literal: true
1
2
 
2
- lib = File.expand_path("../lib", __FILE__)
3
+ lib = File.expand_path('lib', __dir__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "cacchern/version"
5
+ require 'cacchern/version'
5
6
 
6
7
  Gem::Specification.new do |spec|
7
- spec.name = "cacchern"
8
+ spec.name = 'cacchern'
8
9
  spec.version = Cacchern::VERSION
9
- spec.authors = ["Shuhei TAKASUGI"]
10
- spec.email = ["shuhei.takasugi@gmail.com"]
10
+ spec.authors = ['Shuhei TAKASUGI']
11
+ spec.email = ['shuhei.takasugi@gmail.com']
11
12
 
12
- spec.summary = %q{ operate Redis like ActiveRecord interface }
13
- spec.description = %q{ operate Redis like ActiveRecord interface }
14
- spec.homepage = "https://github.com/shuyuhey/cacchern"
15
- spec.license = "MIT"
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 = "exe"
21
+ spec.bindir = 'exe'
21
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
- spec.require_paths = ["lib"]
23
+ spec.require_paths = ['lib']
23
24
 
24
- spec.add_development_dependency "bundler", "~> 1.16"
25
- spec.add_development_dependency "rake", "~> 10.0"
26
- spec.add_development_dependency "redis", "~> 4.0.0"
27
- spec.add_development_dependency "activemodel", "~> 4.0.0"
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
@@ -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 "cacchern/version"
8
- require "cacchern/incrementable_sorted_set"
9
- require "cacchern/sorted_set"
10
- require "cacchern/value"
11
-
9
+ require 'cacchern/version'
10
+ require 'cacchern/incrementable_sorted_set'
11
+ require 'cacchern/sorted_set'
12
+ require 'cacchern/value'
@@ -1,8 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'cacchern/sorted_set'
2
4
 
3
5
  module Cacchern
4
6
  class IncrementableSortedSet < Cacchern::SortedSet
5
-
6
7
  def increment(value)
7
8
  return false unless value.instance_of?(self.class.contain_class)
8
9
 
@@ -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
- def self.contain_class
8
- Value
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.contain_class.new(id, score)
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.contain_class.new(value[0], value[1]) }
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.contain_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
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Cacchern
2
4
  class Value
3
5
  include ActiveModel::Model
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Cacchern
2
- VERSION = "0.0.1"
4
+ VERSION = '0.0.2'
3
5
  end
@@ -0,0 +1,8 @@
1
+
2
+ default: &default
3
+ host: localhost
4
+ port: 6379
5
+
6
+ test:
7
+ <<: *default
8
+ database: <%= ENV['CACCHERN_TEST_DATABASE'] || 11 %>
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.1
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-08-23 00:00:00.000000000 Z
11
+ date: 2018-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: bundler
14
+ name: activemodel
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.16'
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: '1.16'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rake
28
+ name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
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: '10.0'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: redis
42
+ name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 4.0.0
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: 4.0.0
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: activemodel
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.6.13
116
+ rubygems_version: 2.7.3
110
117
  signing_key:
111
118
  specification_version: 4
112
119
  summary: operate Redis like ActiveRecord interface