active_registry 0.1.0 → 0.1.1.pre.1

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: a45fdd8c57209c6e4124d4bf76bdcf77b23078e7ff55cce31ab73de3d25f1764
4
- data.tar.gz: cb740a2184216be2aff84af2ba3c9bdbdf6a7f9d7963c33d65b41b2012036c77
3
+ metadata.gz: 7bcc4cc819c371e65f8063075ea173a8abc4f3f55fa4dbb67dbe64e1b6d3e7b3
4
+ data.tar.gz: 758e28e6a5adb6158c13018b00e97794753a6e5a315db1d42532d7faeb4786e4
5
5
  SHA512:
6
- metadata.gz: 67731f1dada2e8da7809d8faa285f5591f5a6ee5ca07cf99df2a912e676c2fede230a61bdebc6b02bb80f3fca88dbb3c21a5833f82dea25fabbc2b908f4d7f71
7
- data.tar.gz: 4e8f72faeb357e6f0a5bbd9fb44f59be9e0ba637b9b74fe92844f8a666b4d1ab9bce0d46f0771842f2dae0be2ca6645c077f9e4222872377cfa666971cebc67c
6
+ metadata.gz: 54056406049f1465c27d419f9369438da8dc9264416e95897afcb0b3de85a010c4a7ec5e75512fd1fcfed3c53a2b7019ad2509d7c57d90344c89aa13ae502978
7
+ data.tar.gz: e3393fec75a7cd8b828268bd7b1e1cf62b7cfae9b4cf61e1514543c554923b18a7f885c49994721554f617e93015b5497f47cda2bfdb5156e73f12ed22f52468
data/CHANGELOG.md ADDED
File without changes
File without changes
data/README.md CHANGED
@@ -33,16 +33,16 @@ Or install it yourself as:
33
33
  Person = Struct.new(:id, :name, :email)
34
34
 
35
35
  registry = ActiveRegistry.new([
36
- Person.new(1, 'Dale', 'dale@twilightcoders.net'),
37
- Person.new(2, 'Dale', 'dale@chillywinds.com')
36
+ Person.new(1, 'Dale', 'jason@twilightcoders.net'),
37
+ Person.new(2, 'Dale', 'dale@twilightcoders.net')
38
38
  ])
39
39
 
40
40
  registry.index(:name)
41
41
 
42
42
  d = registry[:name, 'Dale'].first
43
- d.name = "Bob"
43
+ d.name = "Jason"
44
44
 
45
- registry.find(:name, 'Bob')
45
+ registry.find(:name, 'Jason')
46
46
  ```
47
47
 
48
48
  ## Development
@@ -2,7 +2,7 @@ class ActiveRegistry < Set
2
2
  class MoreThanOneRecordFound < StandardError
3
3
  end
4
4
 
5
- VERSION = "0.1.0"
5
+ VERSION = "0.1.1-1"
6
6
 
7
7
  DEFAULT_INDEX = :object_id
8
8
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_registry
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1.pre.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dale Stevens
@@ -69,27 +69,14 @@ dependencies:
69
69
  description:
70
70
  email:
71
71
  - dale@twilightcoders.net
72
- executables:
73
- - console
74
- - setup
72
+ executables: []
75
73
  extensions: []
76
74
  extra_rdoc_files: []
77
75
  files:
78
- - ".gitignore"
79
- - ".rspec"
80
- - ".travis.yml"
81
- - CODE_OF_CONDUCT.md
82
- - Gemfile
83
- - LICENSE.txt
76
+ - CHANGELOG.md
77
+ - LICENSE
84
78
  - README.md
85
- - Rakefile
86
- - active_registry.gemspec
87
- - bin/console
88
- - bin/setup
89
79
  - lib/active_registry.rb
90
- - spec/active_registry/active_registry_spec.rb
91
- - spec/spec_helper.rb
92
- - spec/support/custom_matchers.rb
93
80
  homepage: https://github.com/TwilightCoders/active_registry.
94
81
  licenses:
95
82
  - MIT
@@ -107,16 +94,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
107
94
  version: '2.2'
108
95
  required_rubygems_version: !ruby/object:Gem::Requirement
109
96
  requirements:
110
- - - ">="
97
+ - - ">"
111
98
  - !ruby/object:Gem::Version
112
- version: '0'
99
+ version: 1.3.1
113
100
  requirements: []
114
101
  rubyforge_project:
115
102
  rubygems_version: 2.7.6
116
103
  signing_key:
117
104
  specification_version: 4
118
- summary: Data Structure with multiple
119
- test_files:
120
- - spec/active_registry/active_registry_spec.rb
121
- - spec/spec_helper.rb
122
- - spec/support/custom_matchers.rb
105
+ summary: Data structure for quick item lookup via indexes.
106
+ test_files: []
data/.gitignore DELETED
@@ -1,79 +0,0 @@
1
- # See http://help.github.com/ignore-files/ for more about ignoring files.
2
- #
3
- # If you find yourself ignoring temporary files generated by your text editor
4
- # or operating system, you probably want to add a global ignore instead:
5
- # git config --global core.excludesfile ~/.gitignore_global
6
-
7
- # Database config and secrets
8
- /config/database.yml
9
- /config/secrets.yml
10
-
11
- # Ignore bundler config
12
- /.bundle
13
-
14
- # Ignore client credentials
15
- /config/client_api_credentials.yml
16
-
17
- # Ignore the default SQLite database.
18
- /db/*.sqlite3
19
-
20
- # Ignore all logfiles and tempfiles.
21
- /log/*.log
22
- /tmp
23
- /db/structure.sql
24
- /doc/app/*
25
- /vendor/cldr/*
26
- /public/uploads/*
27
- /public/photo/*
28
- /public/test/*
29
- /test/assets/*
30
- /spec/assets/*
31
- /public/assets/**
32
- .powenv
33
- .rvmrc
34
- .env
35
- .ruby-version
36
- .rspec_status
37
-
38
- # Compiled source #
39
- ###################
40
- /pkg/
41
- *.com
42
- *.class
43
- *.dll
44
- *.exe
45
- *.o
46
- *.so
47
-
48
- # Packages #
49
- ############
50
- # it's better to unpack these files and commit the raw source
51
- # git has its own built in compression methods
52
- *.7z
53
- *.dmg
54
- *.gz
55
- *.iso
56
- *.jar
57
- *.rar
58
- *.tar
59
- *.zip
60
-
61
- # Logs and databases #
62
- ######################
63
- *.log
64
- *.sql
65
- *.sqlite
66
-
67
- # OS generated files #
68
- ######################
69
- .DS_Store
70
- .DS_Store?
71
- ._*
72
- .Spotlight-V100
73
- .Trashes
74
- Icon?
75
- ehthumbs.db
76
- Thumbs.db
77
- /Gemfile.lock
78
- /coverage
79
- /.editorconfig
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
data/.travis.yml DELETED
@@ -1,20 +0,0 @@
1
- language: ruby
2
- sudo: false
3
-
4
- cache: bundler
5
-
6
- before_script:
7
- - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
8
- - chmod +x ./cc-test-reporter
9
- - ./cc-test-reporter before-build
10
-
11
- script:
12
- - bundle exec rspec
13
-
14
- after_script:
15
- - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
16
-
17
- rvm:
18
- - 2.5
19
- - 2.4
20
- - 2.3
data/CODE_OF_CONDUCT.md DELETED
@@ -1,74 +0,0 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- In the interest of fostering an open and welcoming environment, we as
6
- contributors and maintainers pledge to making participation in our project and
7
- our community a harassment-free experience for everyone, regardless of age, body
8
- size, disability, ethnicity, gender identity and expression, level of experience,
9
- nationality, personal appearance, race, religion, or sexual identity and
10
- orientation.
11
-
12
- ## Our Standards
13
-
14
- Examples of behavior that contributes to creating a positive environment
15
- include:
16
-
17
- * Using welcoming and inclusive language
18
- * Being respectful of differing viewpoints and experiences
19
- * Gracefully accepting constructive criticism
20
- * Focusing on what is best for the community
21
- * Showing empathy towards other community members
22
-
23
- Examples of unacceptable behavior by participants include:
24
-
25
- * The use of sexualized language or imagery and unwelcome sexual attention or
26
- advances
27
- * Trolling, insulting/derogatory comments, and personal or political attacks
28
- * Public or private harassment
29
- * Publishing others' private information, such as a physical or electronic
30
- address, without explicit permission
31
- * Other conduct which could reasonably be considered inappropriate in a
32
- professional setting
33
-
34
- ## Our Responsibilities
35
-
36
- Project maintainers are responsible for clarifying the standards of acceptable
37
- behavior and are expected to take appropriate and fair corrective action in
38
- response to any instances of unacceptable behavior.
39
-
40
- Project maintainers have the right and responsibility to remove, edit, or
41
- reject comments, commits, code, wiki edits, issues, and other contributions
42
- that are not aligned to this Code of Conduct, or to ban temporarily or
43
- permanently any contributor for other behaviors that they deem inappropriate,
44
- threatening, offensive, or harmful.
45
-
46
- ## Scope
47
-
48
- This Code of Conduct applies both within project spaces and in public spaces
49
- when an individual is representing the project or its community. Examples of
50
- representing a project or community include using an official project e-mail
51
- address, posting via an official social media account, or acting as an appointed
52
- representative at an online or offline event. Representation of a project may be
53
- further defined and clarified by project maintainers.
54
-
55
- ## Enforcement
56
-
57
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
- reported by contacting the project team at dale@getnotion.com. All
59
- complaints will be reviewed and investigated and will result in a response that
60
- is deemed necessary and appropriate to the circumstances. The project team is
61
- obligated to maintain confidentiality with regard to the reporter of an incident.
62
- Further details of specific enforcement policies may be posted separately.
63
-
64
- Project maintainers who do not follow or enforce the Code of Conduct in good
65
- faith may face temporary or permanent repercussions as determined by other
66
- members of the project's leadership.
67
-
68
- ## Attribution
69
-
70
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
- available at [http://contributor-covenant.org/version/1/4][version]
72
-
73
- [homepage]: http://contributor-covenant.org
74
- [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile DELETED
@@ -1,18 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gemspec
4
-
5
- group :test do
6
-
7
- # Generates coverage stats of specs
8
- gem 'simplecov'
9
-
10
- # Publishes coverage to codeclimate
11
- gem 'codeclimate-test-reporter'
12
-
13
- # Gives CircleCI more perspective on our tests
14
- gem 'rspec_junit_formatter'
15
-
16
- gem 'rspec'
17
-
18
- end
data/Rakefile DELETED
@@ -1,6 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task :default => :spec
@@ -1,34 +0,0 @@
1
- lib = File.expand_path("../lib", __FILE__)
2
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
- require "active_registry"
4
-
5
- Gem::Specification.new do |spec|
6
- spec.name = "active_registry"
7
- spec.version = ActiveRegistry::VERSION
8
- spec.authors = ["Dale Stevens"]
9
- spec.email = ["dale@twilightcoders.net"]
10
-
11
- spec.summary = %q{Data Structure with multiple}
12
- # spec.description = %q{}
13
- spec.homepage = "https://github.com/TwilightCoders/active_registry."
14
- spec.license = "MIT"
15
-
16
- if spec.respond_to?(:metadata)
17
- spec.metadata['allowed_push_host'] = 'https://rubygems.org'
18
- else
19
- raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
20
- end
21
-
22
- spec.files = `git ls-files -z`.split("\x0")
23
- spec.bindir = 'bin'
24
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
25
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
26
- spec.require_paths = ['lib', 'spec']
27
-
28
- spec.required_ruby_version = '>= 2.2'
29
-
30
- spec.add_development_dependency 'pry-byebug', '~> 3'
31
- spec.add_development_dependency 'bundler', '~> 1.0'
32
- spec.add_development_dependency 'rake', '~> 12.0'
33
- spec.add_development_dependency 'rspec', "~> 3.0"
34
- end
data/bin/console DELETED
@@ -1,12 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "active_registry"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- require "pry"
11
- Pry.start
12
-
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
@@ -1,180 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe ActiveRegistry do
4
- Person = Struct.new(:id, :name, :email)
5
- let(:u1) { Person.new(1, 'Dale', 'dale@twilightcoders.net') }
6
- let(:u2) { Person.new(2, 'Dale', 'dale@billyjoel.com') }
7
- let(:u3) { Person.new(3, 'Foo', 'foobar@twilightcoders.net') }
8
-
9
- context 'Helper Methods' do
10
- let!(:r1) { ActiveRegistry.new([ u1, u2 ]) }
11
-
12
- it 'should not raise error' do
13
- expect{r1.to_h}.to_not raise_error
14
- end
15
-
16
- it 'should not raise error' do
17
- expect{r1.inspect}.to_not raise_error
18
- end
19
- end
20
-
21
- context 'Adding' do
22
- let!(:r1) { ActiveRegistry.new([ u1, u2 ]) }
23
-
24
- it 'should add the correct item' do
25
- r1 << u3
26
-
27
- expect(r1).to contain_mappings(
28
- object_id: {
29
- u1.object_id => [u1],
30
- u2.object_id => [u2],
31
- u3.object_id => [u3]
32
- }
33
- )
34
- end
35
- end
36
-
37
- context 'Deleting' do
38
- let!(:r1) { ActiveRegistry.new([ u1, u2 ]) }
39
-
40
- before(:each) do
41
- r1 << u3
42
- end
43
-
44
- it 'should remove the correct item' do
45
- r1.delete(u2)
46
-
47
- expect(r1).to contain_mappings(
48
- object_id: {
49
- u1.object_id => [u1],
50
- u3.object_id => [u3]
51
- }
52
- )
53
- end
54
- end
55
-
56
- context "Access" do
57
- let!(:registry) { ActiveRegistry.new([u1, u2, u3]) }
58
-
59
- before(:each) do
60
- registry.index(:name, :email)
61
- end
62
-
63
- it 'should return a registry' do
64
- subregistry = registry.where(name: 'Dale')
65
- expect(subregistry).to be_a_kind_of(ActiveRegistry)
66
- end
67
-
68
- it 'should be able to access with the subregistry' do
69
- subregistry = registry.where(name: 'Dale')
70
- item = subregistry.where(email: 'dale@billyjoel.com')
71
- expect(item.first).to eq(u2)
72
- end
73
-
74
- it 'should be able to access with the subregistry' do
75
- subregistry = registry.where(name: 'Dale', email: 'dale@billyjoel.com')
76
- expect(subregistry.first).to eq(u2)
77
- end
78
-
79
- it 'should be able to access with the subregistry' do
80
- subregistry = registry.where(name: 'Dale', email: 'snail@billyjoel.com')
81
- expect(subregistry.count).to eq(0)
82
- end
83
-
84
- it 'should find the element' do
85
- item = registry.find(name: 'Dale', email: 'dale@billyjoel.com')
86
- expect(item).to eq(u2)
87
- end
88
-
89
- it 'should find! the element' do
90
- item = registry.find!(name: 'Dale', email: 'dale@billyjoel.com')
91
- expect(item).to eq(u2)
92
- end
93
-
94
- it 'should raise a MoreThanOneRecordFound exception' do
95
- expect{registry.find!(name: 'Dale')}.to raise_error(ActiveRegistry::MoreThanOneRecordFound)
96
- end
97
- end
98
-
99
- context "Indexing" do
100
- let!(:registry) { ActiveRegistry.new([ u1, u2 ]) }
101
-
102
- before(:each) do
103
- registry.index(:name)
104
- end
105
-
106
- it 'indexes' do
107
- expect(registry).to contain_mappings(
108
- object_id: {
109
- u1.object_id => [u1],
110
- u2.object_id => [u2]
111
- },
112
- name: {
113
- "Dale" => [u1, u2]
114
- }
115
- )
116
- end
117
-
118
- it 'reindexes' do
119
- d = registry.where(name: 'Dale').first
120
- d.name = "Bob"
121
-
122
- expect(registry.where(name: 'Bob').first).to eq(d)
123
- end
124
-
125
- context 'Error conditions' do
126
- it 'should raise exception when adding' do
127
- expect{registry.add("billyjoel")}.to raise_error(StandardError)
128
- end
129
-
130
- it 'should raise exception when deleting' do
131
- expect{registry.delete("billyjoel")}.to raise_error(StandardError)
132
- end
133
- end
134
- end
135
-
136
- context 'watches' do
137
- Animal = Struct.new(:id, :name)
138
- let!(:a1) { Animal.new(1, 'Boris') }
139
- let!(:a1_original_methods) { a1.methods }
140
- let!(:a1_original_method_count) { a1.methods.count }
141
- let!(:registry) { ActiveRegistry.new([ a1 ]) }
142
-
143
- before(:each) do
144
- registry.index(:name)
145
- end
146
-
147
- it 'should add only two methods' do
148
- d = registry.where(name: 'Boris').first
149
- expect(d.methods.count).to eq(a1_original_method_count + 2)
150
- end
151
-
152
- it 'should include expected methods' do
153
- d = registry.where(name: 'Boris').first
154
- expect(d.methods).to include(:__watched_name=, :__unwatched_name=)
155
- end
156
- end
157
-
158
- context 'unwatches' do
159
- let!(:registry) { ActiveRegistry.new([ u1, u2 ]) }
160
-
161
- before(:each) do
162
- registry.index(:name)
163
- end
164
-
165
- it 'should not include expected methods' do
166
- d = registry.where(name: 'Dale').first
167
- registry.delete(d)
168
-
169
- expect(d.methods).to_not include(:__watched_name=, :__unwatched_name=)
170
- end
171
-
172
- it 'should set the name after removing an element from the registry' do
173
- d = registry.where(name: 'Dale').first
174
- registry.delete(d)
175
-
176
- d.name="Bob"
177
- expect(d.name).to eq("Bob")
178
- end
179
- end
180
- end
data/spec/spec_helper.rb DELETED
@@ -1,13 +0,0 @@
1
- require 'pry'
2
-
3
- require 'simplecov'
4
-
5
- Dir['./spec/support/**/*.rb'].each { |f| require f }
6
- SimpleCov.start do
7
- add_filter 'spec'
8
- end
9
-
10
- require 'active_registry'
11
-
12
- RSpec.configure do |config|
13
- end
@@ -1,18 +0,0 @@
1
- RSpec::Matchers.define :contain_mappings do |expected_mappings|
2
-
3
- match do |registry|
4
- expected_mappings.each do |index_name, expected_mapping|
5
- expected_mapping.each do |index, expected|
6
- actual = registry.where(index_name => index).to_a
7
-
8
- actual.sort!{ |a, b| a.object_id <=> b.object_id }
9
- expected.sort!{ |a, b| a.object_id <=> b.object_id }
10
-
11
- return false unless actual == expected
12
- end
13
- end
14
-
15
- true
16
- end
17
- end
18
-