attach_function 0.1.0 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 184c80c899df350d373fb5f60ddbc995a379a8f2
4
- data.tar.gz: f02923c5fd1d28b228034f713d5742fde4c4d400
3
+ metadata.gz: 13ee26dfe343552e2bc5fd7807e08afab1a03bd4
4
+ data.tar.gz: 93789012ea84d1177721e0ec6b851e473816bee4
5
5
  SHA512:
6
- metadata.gz: dcbd1c3e00246c42483b3084afc9d8d799af97fcff6771e884d7c79cd422da282d906971a85d83199604330b069671aa4d572c825095aa964d738cd5a65cf7dd
7
- data.tar.gz: 473b3497787bfd6bf5ae9b4362e3f9981018c0a9ddd09cd682bf495144ca8fff4a49f4dec3b66cc79c26acd225b2b6cf580ee0229a894a3e247910fab5141333
6
+ metadata.gz: 132e09d24a243b0624269cc0d22dfab4959f8f36371d007acf829a0d3a4449d7153da4661d18c3c8a1ab6504da7096df9edb28207ed76cb7705d7fafd93c88fc
7
+ data.tar.gz: 41cb13978e31d6aa13df7188376a4603df519a04e93d890726d7f0ea9bc42399bffc121488674452f956aaa5b022c8fbd383735ef403dd07d0d02aac5d6b93f7
data/README.md CHANGED
@@ -8,34 +8,35 @@ the user-specified name is not the same as the basename of the target function,
8
8
  if the user-specified name is the same as the basename of the parameter.
9
9
 
10
10
  ## Usage Example:
11
-
12
- require 'attach_function'
13
-
14
- module Math
15
-
16
- #This will contain the method versions of the functions defined in the Math module
17
- module MethodVersions
18
- #Get the attach_function macro
19
- extend AttachFunction
20
- #Apply it to all methods of the Math module that aren't Object methods
21
- (Math.methods - Object.methods).each do |m|
22
- puts "Attaching #{m}"
23
- attach_function m
24
- end
25
- end
11
+ ```ruby
12
+ require 'attach_function'
13
+
14
+ module Math
15
+
16
+ #This will contain the method versions of the functions defined in the Math module
17
+ module MethodVersions
18
+ #Get the attach_function macro
19
+ extend AttachFunction
20
+ #Apply it to all methods of the Math module that aren't Object methods
21
+ (Math.methods - Object.methods).each do |m|
22
+ puts "Attaching #{m}"
23
+ attach_function m
26
24
  end
25
+ end
26
+ end
27
+
28
+ #Now we include the Math::MethodVersions in Numeric
29
+ Numeric.include(Math::MethodVersions)
30
+ #And now we can do this:
31
+ p "3.14.sin = #{3.14.sin}"
32
+ p "10.log = #{10.log10}"
33
+ p "4.sqrt = #{4.sqrt}"
34
+ ```
27
35
 
28
- #Now we include the Math::MethodVersions in Numeric
29
- Numeric.include(Math::MethodVersions)
30
- #And now we can do this:
31
- p "3.14.sin = #{3.14.sin}"
32
- p "10.log = #{10.log10}"
33
- p "4.sqrt = #{4.sqrt}"
34
-
35
- #The functionality that has been added to Numeric in this way is contained in the Math::MethodVersions mixin.
36
- #I consider this much nicer than rudely monkepatching methods right onto a core class.
37
- #This way, library users can see (in pry, for example, or via introspection) where a certain added method came from, and possibly filter it out.
38
- #(Ruby doesn't currently support unmixing).
36
+ #The functionality that has been added to Numeric in this way is contained in the Math::MethodVersions mixin.
37
+ #I consider this much nicer than rudely monkepatching methods right onto a core class.
38
+ #This way, library users can see (in pry, for example, or via introspection) where a certain added method came from, and possibly filter it out.
39
+ #(Ruby doesn't currently support unmixing).
39
40
 
40
41
 
41
42
  See the specs and the example folder for more examples.
@@ -13,8 +13,8 @@ Gem::Specification.new do |spec|
13
13
 
14
14
  spec.name = gem.name
15
15
  spec.version = (gem.module)::VERSION
16
- spec.summary = %q{True in-place file-editing}
17
- spec.description = %q{True in-place file-editing (i.e, inode(input) == inode(output)) like with sed, awk, or `ruby i -{p|n}e`, but truly in-place}
16
+ spec.summary = %q{Macro to attach a module function to an object by fixing its first argument to self}
17
+ spec.description = %q{Macro to attach a module function to an object by fixing its first argument to self}
18
18
 
19
19
  spec.authors = ["Petr Skocik"]
20
20
  spec.email = ["pskocik@gmail.com"]
@@ -1,3 +1,3 @@
1
1
  module AttachFunction
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: attach_function
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Petr Skocik
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-27 00:00:00.000000000 Z
11
+ date: 2015-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -94,8 +94,8 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
- description: True in-place file-editing (i.e, inode(input) == inode(output)) like
98
- with sed, awk, or `ruby i -{p|n}e`, but truly in-place
97
+ description: Macro to attach a module function to an object by fixing its first argument
98
+ to self
99
99
  email:
100
100
  - pskocik@gmail.com
101
101
  executables: []
@@ -138,7 +138,8 @@ rubyforge_project:
138
138
  rubygems_version: 2.2.1
139
139
  signing_key:
140
140
  specification_version: 4
141
- summary: True in-place file-editing
141
+ summary: Macro to attach a module function to an object by fixing its first argument
142
+ to self
142
143
  test_files:
143
144
  - spec/attach_function_spec.rb
144
145
  - spec/spec_helper.rb