heresy 4.0.0 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +0 -0
- data/.rspec +0 -0
- data/.travis.yml +0 -0
- data/CODE_OF_CONDUCT.md +0 -0
- data/Gemfile +0 -0
- data/README.md +46 -10
- data/Rakefile +9 -3
- data/heresy.gemspec +5 -13
- data/lib/heresy.rb +0 -0
- data/lib/heresy/all.rb +4 -0
- data/lib/heresy/default.rb +22 -0
- data/lib/heresy/scoped_accessors.rb +44 -0
- data/lib/heresy/string.rb +21 -0
- data/lib/heresy/version.rb +1 -1
- data/notes.markdown +0 -0
- metadata +17 -55
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b82c3c60526e9d01013a472d98d446441c77e67f967b8e69395f400f68025141
|
4
|
+
data.tar.gz: 50b7c8ddd95db6d6916b4685eef672c7ee7ff61d96778bbd84060105e64bc26a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e25f8a810eb00ffa2336471700b74a4ed950502fae05dbe3ed263533628c3c4bbe1f35ea906048ad1678d1e6bcf3cd099d33598ff824c40f5b4330e6d7fba8c
|
7
|
+
data.tar.gz: '08a50c39cd6ad24279d8cb63a0994ec7c37f1d43bdb46b881f73fc8c197e52984d6230b57d9977e9afffc6b6cce7abf55717cabdad539879605cf4b0f530474f'
|
data/.gitignore
CHANGED
File without changes
|
data/.rspec
CHANGED
File without changes
|
data/.travis.yml
CHANGED
File without changes
|
data/CODE_OF_CONDUCT.md
CHANGED
File without changes
|
data/Gemfile
CHANGED
File without changes
|
data/README.md
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
# Heresy
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
Adds all sorts of things to Ruby that are basically blasphemy.
|
4
|
+
|
5
|
+
You may also be interested in
|
6
|
+
[Net::Socket](https://github.com/duckinator/net-socket), which provides
|
7
|
+
an improved socket API.
|
5
8
|
|
6
9
|
## Installation
|
7
10
|
|
@@ -21,19 +24,53 @@ Or install it yourself as:
|
|
21
24
|
|
22
25
|
## Usage
|
23
26
|
|
24
|
-
### String
|
25
|
-
|
26
|
-
#### String#format
|
27
|
+
### String#format
|
27
28
|
|
28
29
|
```ruby
|
29
30
|
"{2} {1} {foo} {bar}".format('1', '2', foo: 'foo', 'bar' => 'bar')
|
30
31
|
# => "2 1 foo bar"
|
31
32
|
```
|
32
33
|
|
33
|
-
|
34
|
+
### Default
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
def foo(bar = default)
|
38
|
+
bar = "default value for bar" if bar.default?
|
39
|
+
|
40
|
+
bar
|
41
|
+
end
|
42
|
+
|
43
|
+
foo #=> "default value for bar"
|
44
|
+
foo(1) #=> 1
|
45
|
+
foo(nil) #=> nil
|
46
|
+
```
|
47
|
+
|
48
|
+
### Scoped Accessors
|
49
|
+
|
50
|
+
Instead of:
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
attr_accessor :foo, :bar, :baz
|
54
|
+
protected :foo, :bar, :baz
|
55
|
+
|
56
|
+
attr_reader :foo2, :bar2, :baz2
|
57
|
+
protected :foo2, :bar2, :baz2
|
58
|
+
|
59
|
+
attr_writer :foo3, :bar3, :baz3
|
60
|
+
protected :foo3, :bar3, :baz3
|
61
|
+
```
|
62
|
+
|
63
|
+
you can do:
|
34
64
|
|
35
|
-
|
36
|
-
|
65
|
+
```ruby
|
66
|
+
require 'scoped_accessors'
|
67
|
+
|
68
|
+
protected accessor(:foo, :bar, :baz)
|
69
|
+
protected reader(:foo2, :bar2, :baz2)
|
70
|
+
protected writer(:foo3, :bar3, :baz3)
|
71
|
+
```
|
72
|
+
|
73
|
+
And ditto for `private` and `public`.
|
37
74
|
|
38
75
|
## Development
|
39
76
|
|
@@ -43,5 +80,4 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
43
80
|
|
44
81
|
## Contributing
|
45
82
|
|
46
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
47
|
-
|
83
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/duckinator/heresy.
|
data/Rakefile
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
|
-
require "
|
2
|
+
require "rake/testtask"
|
3
3
|
|
4
|
-
|
4
|
+
Rake::TestTask.new do |t|
|
5
|
+
%w[lib spec].each do |dir|
|
6
|
+
t.libs.push File.join(File.dirname(__FILE__), dir)
|
7
|
+
end
|
5
8
|
|
6
|
-
|
9
|
+
t.pattern = "spec/**/*_spec.rb"
|
10
|
+
end
|
11
|
+
task :spec => [:test] # Because theres no way in hell I'll remember.
|
12
|
+
task :default => [:test]
|
data/heresy.gemspec
CHANGED
@@ -9,29 +9,21 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Ellen Marie Dash"]
|
10
10
|
spec.email = ["me@duckie.co"]
|
11
11
|
|
12
|
-
spec.summary = %q{
|
12
|
+
spec.summary = %q{Bringing heretical technology to a Ruby near you!}
|
13
13
|
spec.description = spec.summary
|
14
|
-
spec.homepage = "https://github.com/
|
14
|
+
spec.homepage = "https://github.com/duckinator/heresy"
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
17
|
spec.bindir = "exe"
|
18
18
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_development_dependency "bundler", "~> 1.11"
|
22
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
-
spec.add_development_dependency "rspec", "~> 3.0"
|
24
|
-
|
25
|
-
# Core class improvements.
|
26
|
-
spec.add_runtime_dependency "heresy-string", "~> 1.0.0"
|
27
|
-
|
28
21
|
# Miscellaneous things.
|
29
22
|
# NOTE: from relies indirectly on debug_inspector (via wot-utilities),
|
30
23
|
# which can't be installed inside of Bash on Windows. :(
|
31
24
|
#spec.add_runtime_dependency "from", "~> 1.0.0"
|
32
|
-
spec.add_runtime_dependency "default", "~> 1.0.0"
|
33
25
|
|
34
|
-
|
35
|
-
spec.
|
36
|
-
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
27
|
+
spec.add_development_dependency "rake", "~> 12.3"
|
28
|
+
spec.add_development_dependency "minitest", "~> 5.10"
|
37
29
|
end
|
data/lib/heresy.rb
CHANGED
File without changes
|
data/lib/heresy/all.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require "heresy/version"
|
2
|
+
|
3
|
+
module Heresy::DefaultValue
|
4
|
+
def self.nil?
|
5
|
+
true
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.inspect
|
9
|
+
"default"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
module Kernel
|
14
|
+
def default
|
15
|
+
Heresy::DefaultValue
|
16
|
+
end
|
17
|
+
|
18
|
+
def default?
|
19
|
+
self == default
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require "heresy/version"
|
2
|
+
|
3
|
+
class Object
|
4
|
+
class << self
|
5
|
+
def public(*args)
|
6
|
+
super(*normalize_args(*args))
|
7
|
+
end
|
8
|
+
|
9
|
+
def private(*args)
|
10
|
+
super(*normalize_args(*args))
|
11
|
+
end
|
12
|
+
|
13
|
+
def protected(*args)
|
14
|
+
super(*normalize_args(*args))
|
15
|
+
end
|
16
|
+
|
17
|
+
def normalize_args(*args)
|
18
|
+
# Allow passing in an Array of method names.
|
19
|
+
args = args.first if args.length == 1 && args.first.is_a?(Array)
|
20
|
+
|
21
|
+
args
|
22
|
+
end
|
23
|
+
|
24
|
+
# +accessor+, +reader+, and +writer+ are equivalent to +attr_accessor+,
|
25
|
+
# +attr_reader+, and +attr_writer+, except they return the arguments passed
|
26
|
+
# to them, allowing chaining with public, private, and protected.
|
27
|
+
|
28
|
+
def accessor(*args)
|
29
|
+
attr_accessor(*args)
|
30
|
+
args
|
31
|
+
end
|
32
|
+
|
33
|
+
def reader(*args)
|
34
|
+
attr_reader(*args)
|
35
|
+
args
|
36
|
+
end
|
37
|
+
|
38
|
+
def writer(*args)
|
39
|
+
attr_writer(*args)
|
40
|
+
args
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "heresy/version"
|
2
|
+
|
3
|
+
class String
|
4
|
+
if method_defined?("format")
|
5
|
+
raise RuntimeError, "Required heresy/string, but String#format() is already defined!"
|
6
|
+
end
|
7
|
+
|
8
|
+
##
|
9
|
+
# String format.
|
10
|
+
#
|
11
|
+
# +"{2} {1} {foo} {bar}".format('1', '2', foo: 'foo', 'bar' => 'bar')+
|
12
|
+
# becomes +"2 1 foo bar"+.
|
13
|
+
def format(*args)
|
14
|
+
hsh = args.last.is_a?(Hash) ? args.last : {}
|
15
|
+
|
16
|
+
self.clone.gsub(/{(\S)}/) do
|
17
|
+
hsh[$1] || hsh[$1.to_sym] || args[$1.to_i]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
data/lib/heresy/version.rb
CHANGED
data/notes.markdown
CHANGED
File without changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: heresy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 5.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ellen Marie Dash
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,85 +16,43 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.16'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
26
|
+
version: '1.16'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '12.3'
|
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: '12.3'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: minitest
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '5.10'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
55
|
-
|
56
|
-
name: heresy-string
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 1.0.0
|
62
|
-
type: :runtime
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: 1.0.0
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: default
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: 1.0.0
|
76
|
-
type: :runtime
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: 1.0.0
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: net-socket
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: 1.0.0
|
90
|
-
type: :runtime
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: 1.0.0
|
97
|
-
description: An alternative standard library with no intent of compatibility.
|
54
|
+
version: '5.10'
|
55
|
+
description: Bringing heretical technology to a Ruby near you!
|
98
56
|
email:
|
99
57
|
- me@duckie.co
|
100
58
|
executables: []
|
@@ -112,9 +70,13 @@ files:
|
|
112
70
|
- bin/setup
|
113
71
|
- heresy.gemspec
|
114
72
|
- lib/heresy.rb
|
73
|
+
- lib/heresy/all.rb
|
74
|
+
- lib/heresy/default.rb
|
75
|
+
- lib/heresy/scoped_accessors.rb
|
76
|
+
- lib/heresy/string.rb
|
115
77
|
- lib/heresy/version.rb
|
116
78
|
- notes.markdown
|
117
|
-
homepage: https://github.com/
|
79
|
+
homepage: https://github.com/duckinator/heresy
|
118
80
|
licenses: []
|
119
81
|
metadata: {}
|
120
82
|
post_install_message:
|
@@ -133,8 +95,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
133
95
|
version: '0'
|
134
96
|
requirements: []
|
135
97
|
rubyforge_project:
|
136
|
-
rubygems_version: 2.
|
98
|
+
rubygems_version: 2.7.2
|
137
99
|
signing_key:
|
138
100
|
specification_version: 4
|
139
|
-
summary:
|
101
|
+
summary: Bringing heretical technology to a Ruby near you!
|
140
102
|
test_files: []
|