static_collection 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/CODEOWNERS +1 -0
- data/.github/workflows/main.yml +31 -0
- data/.gitignore +0 -1
- data/.rubocop.yml +18 -0
- data/.ruby-version +1 -1
- data/Gemfile.lock +94 -0
- data/README.md +2 -1
- data/Rakefile +1 -1
- data/catalog-info.yaml +11 -0
- data/lib/static_collection.rb +24 -12
- data/lib/static_collection/version.rb +1 -1
- data/static_collection.gemspec +9 -6
- metadata +39 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f867a06f9f52e14eec205601c378da8f40dcd824b6c8b89d47e1898efc84576f
|
4
|
+
data.tar.gz: 0a83958ce93a9bb051ad9ca64fcf396f0e7a309cf1004d3c8270cccb85e85b2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ffeab73073a0ab546fce79585ef6786ddd1dad9706f1665b6fb87a803f6c84aed3cd89a140a4b160d679f7a3eafba60b6384d839cca7feb629e747c70ee56e6
|
7
|
+
data.tar.gz: 2bdfb54187ea3bcf2c66f4838f2f3a1d3a7013216c56b21886b8b2fd4c77df07c0512764a4f04062ff26659066b9a5aa402ab33188953d5c96feec07b6d52ed0
|
data/.github/CODEOWNERS
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
* @wealthsimple/developer-tools
|
@@ -0,0 +1,31 @@
|
|
1
|
+
---
|
2
|
+
name: Pipeline
|
3
|
+
on: push
|
4
|
+
jobs:
|
5
|
+
build:
|
6
|
+
name: Build
|
7
|
+
runs-on: ubuntu-20.04
|
8
|
+
steps:
|
9
|
+
- uses: actions/checkout@v2
|
10
|
+
- uses: ruby/setup-ruby@v1
|
11
|
+
with:
|
12
|
+
bundler-cache: true
|
13
|
+
- name: Lint
|
14
|
+
run: bundle exec rubocop
|
15
|
+
- name: Test
|
16
|
+
run: bundle exec rspec
|
17
|
+
- name: Release the gem
|
18
|
+
if: ${{ github.ref == 'refs/heads/main' }}
|
19
|
+
run: |
|
20
|
+
mkdir -p ~/.gem
|
21
|
+
cat << EOF > ~/.gem/credentials
|
22
|
+
---
|
23
|
+
:github: Bearer ${GITHUB_TOKEN}
|
24
|
+
:rubygems_api_key: ${RUBYGEMS_API_KEY}
|
25
|
+
EOF
|
26
|
+
chmod 0600 ~/.gem/credentials
|
27
|
+
git config user.email "noreply@wealthsimple.com"
|
28
|
+
git config user.name "Wolfbot"
|
29
|
+
bundle exec rake release
|
30
|
+
env:
|
31
|
+
RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
|
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
inherit_gem:
|
2
|
+
ws-style:
|
3
|
+
- default.yml
|
4
|
+
|
5
|
+
Metrics/AbcSize:
|
6
|
+
Exclude:
|
7
|
+
- lib/static_collection.rb
|
8
|
+
Metrics/CyclomaticComplexity:
|
9
|
+
Exclude:
|
10
|
+
- lib/static_collection.rb
|
11
|
+
Metrics/PerceivedComplexity:
|
12
|
+
Exclude:
|
13
|
+
- lib/static_collection.rb
|
14
|
+
|
15
|
+
RSpec/RepeatedExampleGroupBody:
|
16
|
+
Exclude:
|
17
|
+
- spec/example_collection_spec.rb
|
18
|
+
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.7.3
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
static_collection (0.2.1)
|
5
|
+
activesupport (>= 4)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
activesupport (6.1.3.2)
|
11
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
12
|
+
i18n (>= 1.6, < 2)
|
13
|
+
minitest (>= 5.1)
|
14
|
+
tzinfo (~> 2.0)
|
15
|
+
zeitwerk (~> 2.3)
|
16
|
+
ast (2.4.2)
|
17
|
+
concurrent-ruby (1.1.8)
|
18
|
+
diff-lcs (1.4.4)
|
19
|
+
i18n (1.8.10)
|
20
|
+
concurrent-ruby (~> 1.0)
|
21
|
+
minitest (5.14.4)
|
22
|
+
parallel (1.20.1)
|
23
|
+
parser (3.0.1.1)
|
24
|
+
ast (~> 2.4.1)
|
25
|
+
rack (2.2.3)
|
26
|
+
rainbow (3.0.0)
|
27
|
+
rake (10.5.0)
|
28
|
+
regexp_parser (2.1.1)
|
29
|
+
rexml (3.2.5)
|
30
|
+
rspec (3.10.0)
|
31
|
+
rspec-core (~> 3.10.0)
|
32
|
+
rspec-expectations (~> 3.10.0)
|
33
|
+
rspec-mocks (~> 3.10.0)
|
34
|
+
rspec-core (3.10.1)
|
35
|
+
rspec-support (~> 3.10.0)
|
36
|
+
rspec-expectations (3.10.1)
|
37
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
38
|
+
rspec-support (~> 3.10.0)
|
39
|
+
rspec-its (1.3.0)
|
40
|
+
rspec-core (>= 3.0.0)
|
41
|
+
rspec-expectations (>= 3.0.0)
|
42
|
+
rspec-mocks (3.10.2)
|
43
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
44
|
+
rspec-support (~> 3.10.0)
|
45
|
+
rspec-support (3.10.2)
|
46
|
+
rubocop (1.14.0)
|
47
|
+
parallel (~> 1.10)
|
48
|
+
parser (>= 3.0.0.0)
|
49
|
+
rainbow (>= 2.2.2, < 4.0)
|
50
|
+
regexp_parser (>= 1.8, < 3.0)
|
51
|
+
rexml
|
52
|
+
rubocop-ast (>= 1.5.0, < 2.0)
|
53
|
+
ruby-progressbar (~> 1.7)
|
54
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
55
|
+
rubocop-ast (1.5.0)
|
56
|
+
parser (>= 3.0.1.1)
|
57
|
+
rubocop-performance (1.11.2)
|
58
|
+
rubocop (>= 1.7.0, < 2.0)
|
59
|
+
rubocop-ast (>= 0.4.0)
|
60
|
+
rubocop-rails (2.10.1)
|
61
|
+
activesupport (>= 4.2.0)
|
62
|
+
rack (>= 1.1)
|
63
|
+
rubocop (>= 1.7.0, < 2.0)
|
64
|
+
rubocop-rspec (2.3.0)
|
65
|
+
rubocop (~> 1.0)
|
66
|
+
rubocop-ast (>= 1.1.0)
|
67
|
+
rubocop-vendor (0.6.0)
|
68
|
+
rubocop (>= 0.53.0)
|
69
|
+
ruby-progressbar (1.11.0)
|
70
|
+
tzinfo (2.0.4)
|
71
|
+
concurrent-ruby (~> 1.0)
|
72
|
+
unicode-display_width (2.0.0)
|
73
|
+
ws-style (6.9.0)
|
74
|
+
rubocop (>= 1.12.1)
|
75
|
+
rubocop-performance (>= 1.10.2)
|
76
|
+
rubocop-rails (>= 2.9.1)
|
77
|
+
rubocop-rspec (>= 2.2.0)
|
78
|
+
rubocop-vendor (>= 0.6.0)
|
79
|
+
zeitwerk (2.4.2)
|
80
|
+
|
81
|
+
PLATFORMS
|
82
|
+
ruby
|
83
|
+
|
84
|
+
DEPENDENCIES
|
85
|
+
bundler (~> 2.0)
|
86
|
+
rake (~> 10.0)
|
87
|
+
rspec (~> 3.0)
|
88
|
+
rspec-its (~> 1.2)
|
89
|
+
rubocop (~> 1.2)
|
90
|
+
static_collection!
|
91
|
+
ws-style
|
92
|
+
|
93
|
+
BUNDLED WITH
|
94
|
+
2.2.16
|
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
#
|
1
|
+
# static_collection
|
2
|
+
[![GitHub Actions Badge](https://github.com/wealthsimple/static_collection/actions/workflows/main.yml/badge.svg)](https://github.com/wealthsimple/static_collection/actions)
|
2
3
|
|
3
4
|
Rubygem for running basic queries against static data.
|
4
5
|
|
data/Rakefile
CHANGED
data/catalog-info.yaml
ADDED
data/lib/static_collection.rb
CHANGED
@@ -4,25 +4,36 @@ require "static_collection/version"
|
|
4
4
|
module StaticCollection
|
5
5
|
class Base
|
6
6
|
def self.set_source(source, defaults: {})
|
7
|
-
raise "Source must be an array"
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
raise "Source must be an array" unless source.is_a?(Array)
|
8
|
+
|
9
|
+
instance_variable_set(:@defaults, defaults.stringify_keys)
|
10
|
+
instance_variable_set(:@source, source.map(&:stringify_keys))
|
11
|
+
raise "Source must have at least one value" unless count > 0
|
11
12
|
|
12
13
|
all.first.attributes.each do |attribute_name, attribute_value|
|
13
14
|
# Class methods
|
14
|
-
|
15
|
-
ActiveSupport::Deprecation.warn(
|
15
|
+
define_singleton_method("find_by_#{attribute_name}") do |value|
|
16
|
+
ActiveSupport::Deprecation.warn(
|
17
|
+
"find_by_#{attribute_name} is deprecated for StaticCollection, " \
|
18
|
+
"use find_by(#{attribute_name}: [value])",
|
19
|
+
)
|
16
20
|
all.find { |instance| instance.send(attribute_name) == value }
|
17
21
|
end
|
18
|
-
|
19
|
-
ActiveSupport::Deprecation.warn(
|
22
|
+
define_singleton_method("find_all_by_#{attribute_name}") do |value|
|
23
|
+
ActiveSupport::Deprecation.warn(
|
24
|
+
"find_all_by_#{attribute_name} is deprecated for StaticCollection, "\
|
25
|
+
"use where(#{attribute_name}: [value])",
|
26
|
+
)
|
20
27
|
all.select { |instance| instance.send(attribute_name) == value }
|
21
28
|
end
|
22
29
|
|
23
30
|
# Instance methods
|
24
|
-
|
25
|
-
|
31
|
+
send(:define_method, attribute_name) { attributes[attribute_name] }
|
32
|
+
next unless attribute_value.is_a?(TrueClass) || attribute_value.is_a?(FalseClass)
|
33
|
+
|
34
|
+
send(:define_method, "#{attribute_name}?") {
|
35
|
+
attributes[attribute_name]
|
36
|
+
}
|
26
37
|
end
|
27
38
|
end
|
28
39
|
|
@@ -35,8 +46,8 @@ module StaticCollection
|
|
35
46
|
end
|
36
47
|
|
37
48
|
def self.all
|
38
|
-
defaults =
|
39
|
-
|
49
|
+
defaults = instance_variable_get(:@defaults)
|
50
|
+
instance_variable_get(:@source).map { |s| new(defaults.merge(s)) }
|
40
51
|
end
|
41
52
|
|
42
53
|
def self.count
|
@@ -45,6 +56,7 @@ module StaticCollection
|
|
45
56
|
singleton_class.send(:alias_method, :size, :count)
|
46
57
|
|
47
58
|
attr_reader :attributes
|
59
|
+
|
48
60
|
def initialize(attributes = {})
|
49
61
|
@attributes = attributes
|
50
62
|
end
|
data/static_collection.gemspec
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
require 'static_collection/version'
|
5
4
|
|
@@ -9,12 +8,14 @@ Gem::Specification.new do |spec|
|
|
9
8
|
spec.authors = ["Peter Graham"]
|
10
9
|
spec.email = ["peter@wealthsimple.com"]
|
11
10
|
|
12
|
-
spec.summary =
|
13
|
-
spec.description =
|
11
|
+
spec.summary = 'Run queries against static data.'
|
12
|
+
spec.description = 'Rubygem for running basic queries against static data.'
|
14
13
|
spec.homepage = "https://github.com/wealthsimple/static_collection"
|
15
14
|
spec.license = "MIT"
|
16
15
|
|
17
|
-
spec.
|
16
|
+
spec.required_ruby_version = '>= 2.7.3'
|
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
21
|
spec.bindir = "exe"
|
@@ -23,8 +24,10 @@ Gem::Specification.new do |spec|
|
|
23
24
|
|
24
25
|
spec.add_dependency "activesupport", ">= 4"
|
25
26
|
|
26
|
-
spec.add_development_dependency "bundler", "~>
|
27
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
27
28
|
spec.add_development_dependency "rake", "~> 10.0"
|
28
29
|
spec.add_development_dependency "rspec", "~> 3.0"
|
29
30
|
spec.add_development_dependency "rspec-its", "~> 1.2"
|
31
|
+
spec.add_development_dependency "rubocop", "~> 1.2"
|
32
|
+
spec.add_development_dependency "ws-style"
|
30
33
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: static_collection
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Graham
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '2.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: '2.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,6 +80,34 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '1.2'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.2'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.2'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: ws-style
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
83
111
|
description: Rubygem for running basic queries against static data.
|
84
112
|
email:
|
85
113
|
- peter@wealthsimple.com
|
@@ -87,15 +115,20 @@ executables: []
|
|
87
115
|
extensions: []
|
88
116
|
extra_rdoc_files: []
|
89
117
|
files:
|
118
|
+
- ".github/CODEOWNERS"
|
119
|
+
- ".github/workflows/main.yml"
|
90
120
|
- ".gitignore"
|
91
121
|
- ".rspec"
|
122
|
+
- ".rubocop.yml"
|
92
123
|
- ".ruby-version"
|
93
124
|
- Gemfile
|
125
|
+
- Gemfile.lock
|
94
126
|
- LICENSE.txt
|
95
127
|
- README.md
|
96
128
|
- Rakefile
|
97
129
|
- bin/console
|
98
130
|
- bin/setup
|
131
|
+
- catalog-info.yaml
|
99
132
|
- lib/static_collection.rb
|
100
133
|
- lib/static_collection/version.rb
|
101
134
|
- static_collection.gemspec
|
@@ -111,15 +144,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
111
144
|
requirements:
|
112
145
|
- - ">="
|
113
146
|
- !ruby/object:Gem::Version
|
114
|
-
version:
|
147
|
+
version: 2.7.3
|
115
148
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
149
|
requirements:
|
117
150
|
- - ">="
|
118
151
|
- !ruby/object:Gem::Version
|
119
152
|
version: '0'
|
120
153
|
requirements: []
|
121
|
-
|
122
|
-
rubygems_version: 2.7.6
|
154
|
+
rubygems_version: 3.1.6
|
123
155
|
signing_key:
|
124
156
|
specification_version: 4
|
125
157
|
summary: Run queries against static data.
|