object_selector 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 36990c5ec8e590664913cde4a6b50eadf856eb7b
4
+ data.tar.gz: c009448788df2690cdc1d46bff45629737477ca7
5
+ SHA512:
6
+ metadata.gz: 453c9e8f79222e721cb5df6f9531159bc29d5d826d618e118decee839242172f60c28669f4f6ef45cc54091d6d2a6ee7d557030480e6de014a9e351fa11bdf3d
7
+ data.tar.gz: ec1d11da08994aed5580a64aa5fed57a4fcb38362205b7c5abac026510e4cd76f5b22ae7204717bc96101c713f499368a983464e083a63e665ede6462765164f
data/.gemspec ADDED
@@ -0,0 +1,12 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.name = "object_selector"
3
+ spec.version = "0.0.1"
4
+ spec.authors = ["Charles Mulder"]
5
+ spec.email = ["charles.mulder@hetzner.co.za"]
6
+
7
+ spec.summary = %q{ Regex rule based object selector }
8
+ spec.homepage = "https://github.com/hetznerZA/object_selector-regex_rule_list"
9
+
10
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
11
+ spec.require_paths = ["lib"]
12
+ end
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ regex_rule_list_object_selector
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.3.1
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
3
+
4
+ group :test do
5
+ gem 'rspec', '~> 3.5'
6
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,32 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ object_selector-regex_rule_list (0.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.3)
10
+ rspec (3.5.0)
11
+ rspec-core (~> 3.5.0)
12
+ rspec-expectations (~> 3.5.0)
13
+ rspec-mocks (~> 3.5.0)
14
+ rspec-core (3.5.4)
15
+ rspec-support (~> 3.5.0)
16
+ rspec-expectations (3.5.0)
17
+ diff-lcs (>= 1.2.0, < 2.0)
18
+ rspec-support (~> 3.5.0)
19
+ rspec-mocks (3.5.0)
20
+ diff-lcs (>= 1.2.0, < 2.0)
21
+ rspec-support (~> 3.5.0)
22
+ rspec-support (3.5.0)
23
+
24
+ PLATFORMS
25
+ ruby
26
+
27
+ DEPENDENCIES
28
+ object_selector-regex_rule_list!
29
+ rspec (~> 3.5)
30
+
31
+ BUNDLED WITH
32
+ 1.14.3
data/README.md ADDED
@@ -0,0 +1,25 @@
1
+ # Object Selector
2
+
3
+ ## Regex Rule List
4
+
5
+ ### Quickstart
6
+ ```ruby
7
+ > Struct.new('MyObject')
8
+ > selected_object = ObjectSelector::RegexRuleList.select({
9
+ value: SecureRandom.hex,
10
+ rules: [{
11
+ regex: /\w/,
12
+ object: Struct::MyObject.new
13
+ }]
14
+ })
15
+ > puts selected_object.class.name
16
+ Struct::MyObject
17
+ ```
18
+
19
+ ### Testing
20
+
21
+ #### Local
22
+
23
+ ```bash
24
+ $ rspec
25
+ ```
@@ -0,0 +1,16 @@
1
+ module ObjectSelector
2
+ class RegexRuleList
3
+
4
+ class NoMatchError < StandardError; end;
5
+
6
+ def self.select(rules: [], value: "")
7
+ object = rules.each { |rule|
8
+ break rule[:object] if rule[:regex].match(value)
9
+ }
10
+ raise ObjectSelector::RegexRuleList::NoMatchError, 'No rules matched' if object.is_a?(Array) and object.empty?
11
+ return object
12
+ end
13
+
14
+ end
15
+
16
+ end
metadata ADDED
@@ -0,0 +1,51 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: object_selector
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Charles Mulder
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-02-07 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email:
15
+ - charles.mulder@hetzner.co.za
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".gemspec"
21
+ - ".rspec"
22
+ - ".ruby-gemset"
23
+ - ".ruby-version"
24
+ - Gemfile
25
+ - Gemfile.lock
26
+ - README.md
27
+ - lib/object_selector/regex_rule_list.rb
28
+ homepage: https://github.com/hetznerZA/object_selector-regex_rule_list
29
+ licenses: []
30
+ metadata: {}
31
+ post_install_message:
32
+ rdoc_options: []
33
+ require_paths:
34
+ - lib
35
+ required_ruby_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ required_rubygems_version: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ requirements: []
46
+ rubyforge_project:
47
+ rubygems_version: 2.5.1
48
+ signing_key:
49
+ specification_version: 4
50
+ summary: Regex rule based object selector
51
+ test_files: []