cacchern 0.0.2 → 0.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 39d29e6a57fcded65d5750337ca634d9af3b1ef027ffd20d91dc07e0e9ca5605
4
- data.tar.gz: 0441c18bf22fdee79da25ac1fc8292d01606fa51273e8b377dd847896c693bbc
3
+ metadata.gz: cada82336b3402cd99bbf835bfd3e6b1bb8188f3481a42832e0221505abb008b
4
+ data.tar.gz: 64e923503de48ada4e5d4203fb39bb86e4be592bbbbae85f6e88e1fac0dfba74
5
5
  SHA512:
6
- metadata.gz: '028fd2a91be859333fc00e79df867cc723d30d4e3eeb2066b6ebb860d44e261181f57274bf46e2849b8b6b820cf19482e960bf5024d2c7fb5f1319dcc1cd3e4a'
7
- data.tar.gz: 4ce77a2843e48785a58412585e9b7f8094a06ba3d661c4d87f81840d618e45a39e62f96386e52b00516b6a1b8448ca3f620ddb8f478d0dc16bf7197e30093acb
6
+ metadata.gz: b36a6076033a42c7f68efbe37cd6497b3ab2bf6c9c70892e37ea1d8aa62d632ccd23223795f182ddc18b81ebfd30ea3f5a8b045a055c97b164ba92e8ea4efd4a
7
+ data.tar.gz: 7c1c2c95e2270fbdb48cd179325ab63b3bb81932aedf2a0e3396f7e2630e1112ac3325267d32f3d7d47676dbea31508acd41d0cc603df6f7b60a862c4d2bd46c
data/.rspec CHANGED
@@ -1,2 +1,3 @@
1
1
  --format documentation
2
- --color
2
+ --color
3
+ --require spec_helper
@@ -1,24 +1,26 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2018-09-05 09:03:18 +0900 using RuboCop version 0.58.2.
3
+ # on 2018-09-06 16:46:12 +0900 using RuboCop version 0.58.2.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- # Offense count: 1
9
+ # Offense count: 2
10
10
  # Configuration parameters: CountComments, ExcludedMethods.
11
11
  # ExcludedMethods: refine
12
12
  Metrics/BlockLength:
13
13
  Max: 56
14
14
 
15
- # Offense count: 4
15
+ # Offense count: 6
16
16
  Style/Documentation:
17
17
  Exclude:
18
18
  - 'spec/**/*'
19
19
  - 'test/**/*'
20
20
  - 'lib/cacchern.rb'
21
21
  - 'lib/cacchern/incrementable_sorted_set.rb'
22
+ - 'lib/cacchern/member.rb'
23
+ - 'lib/cacchern/set.rb'
22
24
  - 'lib/cacchern/sorted_set.rb'
23
25
  - 'lib/cacchern/value.rb'
24
26
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cacchern (0.0.2)
4
+ cacchern (0.0.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -9,4 +9,6 @@ end
9
9
  require 'cacchern/version'
10
10
  require 'cacchern/incrementable_sorted_set'
11
11
  require 'cacchern/sorted_set'
12
+ require 'cacchern/set'
12
13
  require 'cacchern/value'
14
+ require 'cacchern/member'
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cacchern
4
+ class Member
5
+ include ActiveModel::Model
6
+
7
+ attr_reader :value
8
+
9
+ define_model_callbacks :initialize
10
+ before_initialize { throw(:abort) unless valid? }
11
+
12
+ def initialize(value)
13
+ @value = value
14
+ run_callbacks :initialize
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'cacchern/member'
4
+
5
+ module Cacchern
6
+ class Set
7
+ attr_reader :key
8
+
9
+ class << self
10
+ def contain_class(klass)
11
+ @value_class = klass
12
+ end
13
+
14
+ def value_class
15
+ @value_class || Member
16
+ end
17
+ end
18
+
19
+ def initialize(key)
20
+ @key = "#{self.class.name.underscore}:#{key}"
21
+ end
22
+
23
+ def all
24
+ values = Redis.current.smembers @key
25
+ values.map { |value| self.class.value_class.new(value) }
26
+ end
27
+
28
+ def add(value)
29
+ return false unless value.instance_of?(self.class.value_class)
30
+
31
+ if value.valid?
32
+ Redis.current.sadd @key, value.value
33
+ true
34
+ else
35
+ false
36
+ end
37
+ end
38
+ end
39
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cacchern
4
- VERSION = '0.0.2'
4
+ VERSION = '0.0.3'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cacchern
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
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-09-05 00:00:00.000000000 Z
11
+ date: 2018-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -89,6 +89,8 @@ files:
89
89
  - cacchern.gemspec
90
90
  - lib/cacchern.rb
91
91
  - lib/cacchern/incrementable_sorted_set.rb
92
+ - lib/cacchern/member.rb
93
+ - lib/cacchern/set.rb
92
94
  - lib/cacchern/sorted_set.rb
93
95
  - lib/cacchern/value.rb
94
96
  - lib/cacchern/version.rb