junk_drawer 0.0.1 → 0.0.2
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.
- data/lib/core_extensions/kernel.rb +1 -1
- data/lib/core_extensions/object_id.rb +3 -2
- data/lib/core_extensions/string.rb +15 -9
- data/lib/junk_drawer/version.rb +1 -1
- metadata +9 -12
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'all_your_base
|
1
|
+
require 'all_your_base'
|
2
2
|
|
3
3
|
module BSON
|
4
4
|
class ObjectID
|
@@ -6,7 +6,8 @@ module BSON
|
|
6
6
|
# The reverse operation is String#to_oid.
|
7
7
|
# Requires the all-your-base gem.
|
8
8
|
def to_display
|
9
|
-
to_s.reverse.to_i(16)
|
9
|
+
number = to_s.reverse.to_i(16)
|
10
|
+
::AllYourBase::Are.convert_from_base_10 number, :radix => 62
|
10
11
|
end
|
11
12
|
end
|
12
13
|
end
|
@@ -1,25 +1,31 @@
|
|
1
|
-
require 'all_your_base/are/belong_to_us'
|
2
|
-
|
3
1
|
class String
|
4
2
|
class << self
|
5
3
|
# Build a url/human-friendly random string. Defaults to 25 characters long.
|
6
4
|
def friendly(length = 25)
|
7
|
-
|
8
|
-
(1..length).map{@friendly_characters.sample}.join
|
5
|
+
(1..length).map{ friendly_characters.sample }.join
|
9
6
|
end
|
10
7
|
|
11
8
|
# Build a completely unfriendly random string. Defaults to 25 characters long.
|
12
9
|
def crazy(length = 25)
|
13
|
-
|
14
|
-
|
15
|
-
|
10
|
+
(1..length).map{ crazy_characters.sample }.join
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def friendly_characters
|
16
|
+
@friendly_characters ||= ['0'..'9', 'a'..'z', 'A'..'Z'].map(&:to_a).flatten!
|
17
|
+
end
|
18
|
+
|
19
|
+
def crazy_characters
|
20
|
+
@crazy_characters ||= friendly_characters + ["\\", '(', ')', ' ', '`', '#', '"', "'", '?'] +
|
21
|
+
%w(~ ! @ $ % ^ & * _ - + = [ ] { } | ; : , < . > /)
|
16
22
|
end
|
17
23
|
end
|
18
24
|
|
19
25
|
# Translate a human-readable representation of an ObjectID instance back to an ObjectID.
|
20
26
|
# Requires the all-your-base gem.
|
21
27
|
def to_oid
|
22
|
-
string =
|
28
|
+
string = ::AllYourBase::Are.convert_to_base_10(self, :radix => 62).to_s(16)
|
23
29
|
|
24
30
|
# replace leading zeroes that were lost during the hex conversion
|
25
31
|
until string.length == 24
|
@@ -36,6 +42,6 @@ class String
|
|
36
42
|
|
37
43
|
# Convenience method, for whenever you need to pepper something.
|
38
44
|
def peppered
|
39
|
-
self + ENV['
|
45
|
+
self + ENV['PASSWORD_PEPPER']
|
40
46
|
end
|
41
47
|
end
|
data/lib/junk_drawer/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: junk_drawer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 29
|
5
4
|
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 0
|
8
7
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
8
|
+
- 2
|
9
|
+
version: 0.0.2
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Chris Hanks
|
@@ -15,24 +14,23 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2010-
|
17
|
+
date: 2010-09-12 00:00:00 -07:00
|
19
18
|
default_executable:
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
21
|
name: all-your-base
|
23
|
-
prerelease: false
|
24
22
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
23
|
none: false
|
26
24
|
requirements:
|
27
25
|
- - "="
|
28
26
|
- !ruby/object:Gem::Version
|
29
|
-
hash: 19
|
30
27
|
segments:
|
31
28
|
- 0
|
32
29
|
- 3
|
33
30
|
- 0
|
34
31
|
version: 0.3.0
|
35
32
|
type: :runtime
|
33
|
+
prerelease: false
|
36
34
|
version_requirements: *id001
|
37
35
|
description: A collection of Ruby core extensions and other goodies.
|
38
36
|
email:
|
@@ -44,14 +42,14 @@ extensions: []
|
|
44
42
|
extra_rdoc_files: []
|
45
43
|
|
46
44
|
files:
|
47
|
-
- lib/
|
45
|
+
- lib/junk_drawer/version.rb
|
48
46
|
- lib/core_extensions/object_id.rb
|
49
|
-
- lib/core_extensions/
|
50
|
-
- lib/core_extensions/kernel.rb
|
47
|
+
- lib/core_extensions/array.rb
|
51
48
|
- lib/core_extensions/object.rb
|
49
|
+
- lib/core_extensions/kernel.rb
|
52
50
|
- lib/core_extensions/string.rb
|
51
|
+
- lib/core_extensions/time.rb
|
53
52
|
- lib/junk_drawer.rb
|
54
|
-
- lib/junk_drawer/version.rb
|
55
53
|
- LICENSE
|
56
54
|
- README.md
|
57
55
|
- ROADMAP.md
|
@@ -70,7 +68,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
70
68
|
requirements:
|
71
69
|
- - ">="
|
72
70
|
- !ruby/object:Gem::Version
|
73
|
-
hash:
|
71
|
+
hash: -680439407
|
74
72
|
segments:
|
75
73
|
- 0
|
76
74
|
version: "0"
|
@@ -79,7 +77,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
77
|
requirements:
|
80
78
|
- - ">="
|
81
79
|
- !ruby/object:Gem::Version
|
82
|
-
hash: 23
|
83
80
|
segments:
|
84
81
|
- 1
|
85
82
|
- 3
|