transmute 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/README.md +60 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/transmute.rb +19 -0
- data/lib/transmute/version.rb +3 -0
- data/transmute.gemspec +25 -0
- metadata +123 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9c7540ac26c3c67034ad57f50fa70639cfe92962
|
4
|
+
data.tar.gz: eb7668a19f1f0cb5ac64028ae939343c36f2007a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d321d17a2472553107d48431024a6f495651eafafba07092985399392b65aac4b49d10da2beef1c5aea57078ba49d1ce648574a7999c3bd007ef607ed14e4900
|
7
|
+
data.tar.gz: 3a20aaf76a0ed553f31d2a620f60c4462bbc4ae4ba5d55879b791baf76ec62c3be3551c9afcc3e867e03178ca8e3cb5a9a82cb201b029860372c9aff2db89e81
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
# Transmute
|
2
|
+
|
3
|
+
a framework for writing functional helpers in ruby
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
```rb
|
8
|
+
gem 'transmute'
|
9
|
+
```
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
```rb
|
14
|
+
require 'transmute'
|
15
|
+
|
16
|
+
# Transmute provides a very light weight framework for definining
|
17
|
+
# helpers in a functional, chainable manner
|
18
|
+
#
|
19
|
+
# To define a function, simply add an instance method to Transmute::Definition
|
20
|
+
|
21
|
+
Transmute::Definition.module_eval do
|
22
|
+
def increment(value, n = 1)
|
23
|
+
value + n
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# The methods you add to Transmute::Definition can then be used via the Transmute
|
28
|
+
# module
|
29
|
+
|
30
|
+
[1, 2, 3].map(&Transmute.increment)
|
31
|
+
#=> [2, 3, 4]
|
32
|
+
|
33
|
+
[1, 2, 3].map(&Transmute.increment).map(&Transmute.increment)
|
34
|
+
#=> [3, 4, 5]
|
35
|
+
|
36
|
+
[1, 2, 3].map(&Transmute.increment(2))
|
37
|
+
#=> [3, 4, 5]
|
38
|
+
```
|
39
|
+
|
40
|
+
## TODO
|
41
|
+
|
42
|
+
- support some pattern matching-esque format (e.g.
|
43
|
+
```rb
|
44
|
+
on Integer
|
45
|
+
def increment(value, n = 1)
|
46
|
+
value + n
|
47
|
+
end
|
48
|
+
|
49
|
+
on String
|
50
|
+
def increment(value, n = 1)
|
51
|
+
value.to_i + n
|
52
|
+
end
|
53
|
+
|
54
|
+
on -> (value) { value.is_a?(Array) && value.all? { |v| v.is_a?(Integer) } }
|
55
|
+
def increment(value, n = 1)
|
56
|
+
# Should recurse into other patterns
|
57
|
+
value.map(&Transmute.increment(n))
|
58
|
+
end
|
59
|
+
```
|
60
|
+
)
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "transmute"
|
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
|
data/bin/setup
ADDED
data/lib/transmute.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'transmute/version'
|
2
|
+
|
3
|
+
module Transmute
|
4
|
+
def self._define(name)
|
5
|
+
define_singleton_method(name) do |*args, &block|
|
6
|
+
lambda do |receiver|
|
7
|
+
Definitions.public_send(name, receiver, *args, &block)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
module Definitions
|
13
|
+
extend self
|
14
|
+
|
15
|
+
def self.method_added(name)
|
16
|
+
Transmute._define(name)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/transmute.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'transmute/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "transmute"
|
8
|
+
spec.version = Transmute::VERSION
|
9
|
+
spec.authors = ["Josh Bodah"]
|
10
|
+
spec.email = ["jb3689@yahoo.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{a framework for writing functional helpers in ruby}
|
13
|
+
spec.homepage = "https://github.com/jbodah/transmute"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
16
|
+
spec.bindir = "exe"
|
17
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
21
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
22
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
23
|
+
spec.add_development_dependency "pry"
|
24
|
+
spec.add_development_dependency "byebug"
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: transmute
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Josh Bodah
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-06-09 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.12'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.12'
|
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: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
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: byebug
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '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'
|
83
|
+
description:
|
84
|
+
email:
|
85
|
+
- jb3689@yahoo.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".travis.yml"
|
92
|
+
- Gemfile
|
93
|
+
- README.md
|
94
|
+
- Rakefile
|
95
|
+
- bin/console
|
96
|
+
- bin/setup
|
97
|
+
- lib/transmute.rb
|
98
|
+
- lib/transmute/version.rb
|
99
|
+
- transmute.gemspec
|
100
|
+
homepage: https://github.com/jbodah/transmute
|
101
|
+
licenses: []
|
102
|
+
metadata: {}
|
103
|
+
post_install_message:
|
104
|
+
rdoc_options: []
|
105
|
+
require_paths:
|
106
|
+
- lib
|
107
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
requirements: []
|
118
|
+
rubyforge_project:
|
119
|
+
rubygems_version: 2.4.8
|
120
|
+
signing_key:
|
121
|
+
specification_version: 4
|
122
|
+
summary: a framework for writing functional helpers in ruby
|
123
|
+
test_files: []
|