any 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 7f16d3b57611b4f542704564cee6a770489cce27682961bbd973604c4d380ea7
4
+ data.tar.gz: d7b2eeb418966a87dc097491d2b34f7132ddd300dcc5e371382fb764f3a7a0ff
5
+ SHA512:
6
+ metadata.gz: 3460dda87623bef8340ef564298891d54bcf81691c7afa87cf9eb634594aaa858294d33bcfb626fcc8b7a6da0d9c95c819743e327779b72ae57042c6308c5159
7
+ data.tar.gz: 13d8a7e8f343547a5642a076d37249abbaa8fd07abe4ec27038b6a9d8bab0fd0729e0aac8d0cf0c7dda907c471b6eea891586599866ab5eb42c763fac56a4bf0
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+
13
+ # gem files
14
+ *.gem
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.5.1
5
+ before_install: gem install bundler -v 1.16.1
@@ -0,0 +1,74 @@
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 keystonelemur@gmail.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 ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in any.gemspec
6
+ gemspec
@@ -0,0 +1,74 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ any (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ coderay (1.1.2)
10
+ diff-lcs (1.3)
11
+ ffi (1.9.25)
12
+ formatador (0.2.5)
13
+ guard (2.14.2)
14
+ formatador (>= 0.2.4)
15
+ listen (>= 2.7, < 4.0)
16
+ lumberjack (>= 1.0.12, < 2.0)
17
+ nenv (~> 0.1)
18
+ notiffany (~> 0.0)
19
+ pry (>= 0.9.12)
20
+ shellany (~> 0.0)
21
+ thor (>= 0.18.1)
22
+ guard-compat (1.2.1)
23
+ guard-rspec (4.7.3)
24
+ guard (~> 2.1)
25
+ guard-compat (~> 1.1)
26
+ rspec (>= 2.99.0, < 4.0)
27
+ listen (3.1.5)
28
+ rb-fsevent (~> 0.9, >= 0.9.4)
29
+ rb-inotify (~> 0.9, >= 0.9.7)
30
+ ruby_dep (~> 1.2)
31
+ lumberjack (1.0.13)
32
+ method_source (0.9.0)
33
+ nenv (0.3.0)
34
+ notiffany (0.1.1)
35
+ nenv (~> 0.1)
36
+ shellany (~> 0.0)
37
+ pry (0.11.3)
38
+ coderay (~> 1.1.0)
39
+ method_source (~> 0.9.0)
40
+ qo (0.3.0)
41
+ rake (10.5.0)
42
+ rb-fsevent (0.10.3)
43
+ rb-inotify (0.9.10)
44
+ ffi (>= 0.5.0, < 2)
45
+ rspec (3.8.0)
46
+ rspec-core (~> 3.8.0)
47
+ rspec-expectations (~> 3.8.0)
48
+ rspec-mocks (~> 3.8.0)
49
+ rspec-core (3.8.0)
50
+ rspec-support (~> 3.8.0)
51
+ rspec-expectations (3.8.0)
52
+ diff-lcs (>= 1.2.0, < 2.0)
53
+ rspec-support (~> 3.8.0)
54
+ rspec-mocks (3.8.0)
55
+ diff-lcs (>= 1.2.0, < 2.0)
56
+ rspec-support (~> 3.8.0)
57
+ rspec-support (3.8.0)
58
+ ruby_dep (1.5.0)
59
+ shellany (0.0.1)
60
+ thor (0.20.0)
61
+
62
+ PLATFORMS
63
+ ruby
64
+
65
+ DEPENDENCIES
66
+ any!
67
+ bundler (~> 1.16)
68
+ guard-rspec
69
+ qo (= 0.3.0)
70
+ rake (~> 10.0)
71
+ rspec (~> 3.0)
72
+
73
+ BUNDLED WITH
74
+ 1.16.1
@@ -0,0 +1,16 @@
1
+ guard :rspec, cmd: "bundle exec rspec" do
2
+ require "guard/rspec/dsl"
3
+ dsl = Guard::RSpec::Dsl.new(self)
4
+
5
+ # Feel free to open issues for suggestions and improvements
6
+
7
+ # RSpec files
8
+ rspec = dsl.rspec
9
+ watch(rspec.spec_helper) { rspec.spec_dir }
10
+ watch(rspec.spec_support) { rspec.spec_dir }
11
+ watch(rspec.spec_files)
12
+
13
+ # Ruby files
14
+ ruby = dsl.ruby
15
+ dsl.watch_spec_files_for(ruby.lib_files)
16
+ end
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Brandon Weaver
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,105 @@
1
+ # Any
2
+
3
+ Any is a simple gem. When you compare it against anything, it's always true.
4
+
5
+ This is a play at Scala's Any type, mostly used for pattern matching type
6
+ techniques.
7
+
8
+ * https://docs.scala-lang.org/tour/unified-types.html
9
+ * https://www.scala-lang.org/api/2.12.3/scala/Any.html
10
+
11
+ ## Credits
12
+
13
+ Thanks to [@soffes](https://github.com/soffes) for allowing me to repurpose the gem `Any`!
14
+
15
+ The original will be maintained at versions 0.0.1 and 0.0.2 from [this repo](https://github.com/soffes/any)
16
+
17
+ ## Usage
18
+
19
+ Note that I'm using Qo here. If these two issues are
20
+ added in Ruby 2.6+ it'll enable us to do this without
21
+ the need for Qo:
22
+
23
+ * Hash#=== - https://bugs.ruby-lang.org/issues/14869
24
+ * Array#=== - https://bugs.ruby-lang.org/issues/14916
25
+
26
+ I've commented on each to note this.
27
+
28
+ For now, I will leave Qo in the specs so that we don't
29
+ have a hard dependency on 2.6+, especially considering
30
+ that at the time of writing this it's still in development.
31
+
32
+ ```ruby
33
+ require 'qo' # gem install qo @ v0.3.0
34
+
35
+ case ['Foo', 25]
36
+ when Qo[/^F/, Any] then true
37
+ else false
38
+ end
39
+ # => true
40
+
41
+ case {id: 1, name: 'foo', age: 42}
42
+ when Qo[id: Any, name: /^f/, age: Any] then true
43
+ else false
44
+ end
45
+ # => true
46
+
47
+ case {id: 1, name: 'foo'}
48
+ when Qo[id: Any, name: /^f/, age: Any] then true
49
+ else false
50
+ end
51
+ # => false
52
+ ```
53
+
54
+ Qo behaves much like the proposals, except in that it's permissive
55
+ for Arrays of mismatched lengths and works with Objects.
56
+
57
+ In 2.6+, assuming the two above are accepted, you could do this:
58
+
59
+ ```ruby
60
+ case ['Foo', 25]
61
+ when [/^F/, Any] then true
62
+ else false
63
+ end
64
+ # => true
65
+
66
+ case {id: 1, name: 'foo', age: 42}
67
+ when {id: Any, name: /^f/, age: Any} then true
68
+ else false
69
+ end
70
+ # => true
71
+
72
+ case {id: 1, name: 'foo'}
73
+ when {id: Any, name: /^f/, age: Any} then true
74
+ else false
75
+ end
76
+ # => false
77
+ ```
78
+
79
+ ## Installation
80
+
81
+ Add this line to your application's Gemfile:
82
+
83
+ ```ruby
84
+ gem 'any'
85
+ ```
86
+
87
+ And then execute:
88
+
89
+ $ bundle
90
+
91
+ Or install it yourself as:
92
+
93
+ $ gem install any
94
+
95
+ ## Contributing
96
+
97
+ Bug reports and pull requests are welcome on GitHub at https://github.com/baweaver/any. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
98
+
99
+ ## License
100
+
101
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
102
+
103
+ ## Code of Conduct
104
+
105
+ Everyone interacting in the Any project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/baweaver/any/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile CHANGED
@@ -1,4 +1,6 @@
1
- require 'rubygems'
2
- require 'rake'
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
3
 
4
- Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,29 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "any/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "any"
8
+ spec.version = Any::VERSION
9
+ spec.authors = ["Brandon Weaver"]
10
+ spec.email = ["keystonelemur@gmail.com"]
11
+
12
+ spec.summary = %q{An Any type, much like Scala, that matches anything.}
13
+ # spec.description = %q{TODO: Write a longer description or delete this line.}
14
+ spec.homepage = "https://www.github.com/baweaver/any"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.16"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "rspec", "~> 3.0"
27
+ spec.add_development_dependency "guard-rspec"
28
+ spec.add_development_dependency "qo", '0.3.0'
29
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "any"
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
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
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
data/lib/any.rb CHANGED
@@ -1,15 +1,32 @@
1
- module Any
2
- def self.included(base)
3
- base.extend ClassMethods
4
- end
5
-
6
- module ClassMethods
7
- def any
8
- limit(1).offset((count * rand).to_i).first
1
+ require "any/version"
2
+
3
+ class Any
4
+ class << self
5
+ # Always returns true in a comparison
6
+ #
7
+ # @param other [Any]
8
+ # Any other type
9
+ #
10
+ # @return true
11
+ def ==(other)
12
+ true
9
13
  end
10
- end
11
- end
12
14
 
13
- class ActiveRecord::Base
14
- include Any
15
+ # Always returns true in a comparison
16
+ #
17
+ # @param other [Any]
18
+ # Any other type
19
+ #
20
+ # @return true
21
+ def ===(other)
22
+ true
23
+ end
24
+
25
+ # Always returns true from a proc
26
+ #
27
+ # @return Proc[Any] => true
28
+ def to_proc
29
+ proc { true }
30
+ end
31
+ end
15
32
  end
@@ -0,0 +1,3 @@
1
+ class Any
2
+ VERSION = '0.1.0'
3
+ end
metadata CHANGED
@@ -1,85 +1,129 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: any
3
- version: !ruby/object:Gem::Version
4
- hash: 27
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 0
9
- - 2
10
- version: 0.0.2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
11
5
  platform: ruby
12
- authors:
13
- - Sam Soffes
6
+ authors:
7
+ - Brandon Weaver
14
8
  autorequire:
15
- bindir: bin
9
+ bindir: exe
16
10
  cert_chain: []
17
-
18
- date: 2010-06-16 00:00:00 -05:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
22
- name: activerecord
11
+ date: 2018-08-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: guard-rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
23
63
  prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ~>
28
- - !ruby/object:Gem::Version
29
- hash: 7
30
- segments:
31
- - 3
32
- - 0
33
- version: "3.0"
34
- type: :runtime
35
- version_requirements: *id001
36
- description: Super easy way to get any model instance from an Active Record model.
37
- email: sam@samsoff.es
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: qo
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '='
74
+ - !ruby/object:Gem::Version
75
+ version: 0.3.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '='
81
+ - !ruby/object:Gem::Version
82
+ version: 0.3.0
83
+ description:
84
+ email:
85
+ - keystonelemur@gmail.com
38
86
  executables: []
39
-
40
87
  extensions: []
41
-
42
88
  extra_rdoc_files: []
43
-
44
- files:
45
- - lib/any.rb
46
- - Changelog.markdown
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".travis.yml"
93
+ - CODE_OF_CONDUCT.md
94
+ - Gemfile
95
+ - Gemfile.lock
96
+ - Guardfile
97
+ - LICENSE.txt
98
+ - README.md
47
99
  - Rakefile
48
- - Readme.markdown
49
- - init.rb
50
- has_rdoc: true
51
- homepage: http://github.com/samsoffes/any
52
- licenses: []
53
-
100
+ - any.gemspec
101
+ - bin/console
102
+ - bin/setup
103
+ - lib/any.rb
104
+ - lib/any/version.rb
105
+ homepage: https://www.github.com/baweaver/any
106
+ licenses:
107
+ - MIT
108
+ metadata: {}
54
109
  post_install_message:
55
110
  rdoc_options: []
56
-
57
- require_paths:
111
+ require_paths:
58
112
  - lib
59
- required_ruby_version: !ruby/object:Gem::Requirement
60
- none: false
61
- requirements:
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ requirements:
62
115
  - - ">="
63
- - !ruby/object:Gem::Version
64
- hash: 3
65
- segments:
66
- - 0
67
- version: "0"
68
- required_rubygems_version: !ruby/object:Gem::Requirement
69
- none: false
70
- requirements:
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ requirements:
71
120
  - - ">="
72
- - !ruby/object:Gem::Version
73
- hash: 3
74
- segments:
75
- - 0
76
- version: "0"
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
77
123
  requirements: []
78
-
79
124
  rubyforge_project:
80
- rubygems_version: 1.3.7
125
+ rubygems_version: 2.7.6
81
126
  signing_key:
82
- specification_version: 3
83
- summary: Super easy way to get any model instance.
127
+ specification_version: 4
128
+ summary: An Any type, much like Scala, that matches anything.
84
129
  test_files: []
85
-
@@ -1,8 +0,0 @@
1
- 0.0.2 (Jun 15, 2010)
2
-
3
- * Fix ActiveRecord dependency
4
-
5
-
6
- 0.0.1 (Jun 15, 2010)
7
-
8
- * Initial release
@@ -1,11 +0,0 @@
1
- # Any
2
-
3
- Any provides a super easy way to get any model instance from an Active Record model. This is really handy when testing or populating your database with dummy data.
4
-
5
- ## Usage
6
-
7
- Say you have a model named `Post`. All you have to do is:
8
-
9
- Post.any
10
-
11
- If you have no posts, it will return `nil` instead.
data/init.rb DELETED
@@ -1 +0,0 @@
1
- require "any"