in_array 0.0.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 +15 -0
- data/README +8 -0
- data/lib/in_array.rb +22 -0
- data/license.txt +21 -0
- data/rakefile.rb +18 -0
- data/reek.txt +1 -0
- data/tests/in_array_test.rb +26 -0
- metadata +93 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NjE2YjE3YTI1MmU2ZjA1MjYyYWVjZmI1ZTAyMjQ2M2Y2MGM2OTNlNQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NjVjMDFiYmE4NDdjMGY4ZjRkZWEzODdhMzJkNGY4MDAxNDlkZGMxOQ==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NWIwNjNlZDMzODEyMWM5ZmM4MzRhNmVmZDEwOWVjZWI4NmE0MDE5NTQ2YjRj
|
10
|
+
ZGQzNDZlMmJlY2RkNTJlYTIyYWYxYWEwZTYzMTc4M2UxYTEyOWE4M2JhZDhj
|
11
|
+
ODY5ZjQ2ZjNlMTYyMDk0YmE4OWE2NmRmZGU1Y2I2OTRmY2U0MjA=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NjZhZDAwYmYxZGFjNzUzNDM1MWFmZWRkMjZkNzA5MjdlNTE2MzAxNTkxNGYz
|
14
|
+
MzExMjE3MDdmODIzZDlmOWE3NDkzYzNkM2ZmZmFkNTg0NGJhODk1MWE4YWJm
|
15
|
+
NTYwMmRkMTUxZjZjZWJhZGY3MTljZWRjNmNmZjc0ZmNiYjYwZDY=
|
data/README
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
This project contains the Ruby in_array gem. This is perhaps the tiniest gem
|
2
|
+
ever created. It allows all objects to respond to the :in_array method that
|
3
|
+
encapsulates the object in an array unless it is already an array. So
|
4
|
+
|
5
|
+
'Hello'.in_array ====> ['Hello']
|
6
|
+
['Hello'].in_array ====> ['Hello']
|
7
|
+
my_object.in_array ====> [my_object]
|
8
|
+
[1,2,3].in_array ====> [1,2,3]
|
data/lib/in_array.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
#Add support for the in_array method to ruby.
|
2
|
+
|
3
|
+
#Extend everything with in_array.
|
4
|
+
class BasicObject
|
5
|
+
#Return the object in an array.
|
6
|
+
def in_array
|
7
|
+
[self]
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
#A mixinable module to be included in class that already holds data in_array.
|
12
|
+
module InArrayable
|
13
|
+
#Return the object in an array. Already is!
|
14
|
+
def in_array
|
15
|
+
self
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
#Arrays already have their data in_array.
|
20
|
+
class Array
|
21
|
+
include InArrayable
|
22
|
+
end
|
data/license.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
=== The MIT License (MIT).
|
2
|
+
|
3
|
+
Copyright (c) 2014 Peter Camilleri
|
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.
|
data/rakefile.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rdoc/task'
|
4
|
+
|
5
|
+
RDoc::Task.new do |rdoc|
|
6
|
+
rdoc.rdoc_dir = "rdoc"
|
7
|
+
rdoc.rdoc_files = ['lib/in_array.rb', 'license.txt']
|
8
|
+
rdoc.options << '--visibility' << 'private'
|
9
|
+
end
|
10
|
+
|
11
|
+
Rake::TestTask.new do |t|
|
12
|
+
t.test_files = ['tests/in_array_test.rb']
|
13
|
+
t.verbose = false
|
14
|
+
end
|
15
|
+
|
16
|
+
task :reek do |t|
|
17
|
+
`reek lib\\*.rb > reek.txt`
|
18
|
+
end
|
data/reek.txt
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
lib/in_array.rb -- 0 warnings
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require_relative '../lib/in_array'
|
2
|
+
require 'minitest/autorun'
|
3
|
+
|
4
|
+
class InArrayTester < MiniTest::Unit::TestCase
|
5
|
+
$do_this_only_one_time = "" unless defined? $do_this_only_one_time
|
6
|
+
|
7
|
+
def initialize(*all)
|
8
|
+
if $do_this_only_one_time != __FILE__
|
9
|
+
puts
|
10
|
+
puts "Running test file: #{File.split(__FILE__)[1]}"
|
11
|
+
$do_this_only_one_time = __FILE__
|
12
|
+
end
|
13
|
+
|
14
|
+
super(*all)
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_that_it_encapsulates_in_arrays
|
18
|
+
assert_equal(nil.in_array, [nil])
|
19
|
+
assert_equal('Hello'.in_array, ['Hello'])
|
20
|
+
assert_equal(:Hello.in_array, [:Hello])
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_that_it_leaves_arrays_alone
|
24
|
+
assert_equal([1,2,3].in_array, [1,2,3])
|
25
|
+
end
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: in_array
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Peter Camilleri
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-01-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ! '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ! '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: reek
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: ! 'Encapsulate data in an array unless it''s already in one. '
|
56
|
+
email: peter.c.camilleri@gmail.com
|
57
|
+
executables: []
|
58
|
+
extensions: []
|
59
|
+
extra_rdoc_files:
|
60
|
+
- license.txt
|
61
|
+
files:
|
62
|
+
- lib/in_array.rb
|
63
|
+
- tests/in_array_test.rb
|
64
|
+
- rakefile.rb
|
65
|
+
- license.txt
|
66
|
+
- README
|
67
|
+
- reek.txt
|
68
|
+
homepage: http://teuthida-technologies.com/
|
69
|
+
licenses:
|
70
|
+
- MIT
|
71
|
+
metadata: {}
|
72
|
+
post_install_message:
|
73
|
+
rdoc_options: []
|
74
|
+
require_paths:
|
75
|
+
- lib
|
76
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ! '>='
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: 1.9.3
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
requirements: []
|
87
|
+
rubyforge_project:
|
88
|
+
rubygems_version: 2.1.4
|
89
|
+
signing_key:
|
90
|
+
specification_version: 4
|
91
|
+
summary: Encapsulate data in an array unless it's already in one.
|
92
|
+
test_files:
|
93
|
+
- tests/in_array_test.rb
|