kernel_let 1.0.0
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/.gitignore +5 -0
- data/.rspec +2 -0
- data/Gemfile +8 -0
- data/Rakefile +1 -0
- data/kernel_let.gemspec +24 -0
- data/lib/kernel_let.rb +13 -0
- data/lib/kernel_let/version.rb +3 -0
- data/spec/kernel_let_spec.rb +21 -0
- data/spec/spec_helper.rb +17 -0
- metadata +75 -0
data/.rspec
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/kernel_let.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "kernel_let/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "kernel_let"
|
7
|
+
s.version = KernelLet::VERSION
|
8
|
+
s.authors = ["Kenta Murata"]
|
9
|
+
s.email = ["mrkn@mrkn.jp"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{Kernel#let for block-local vairables}
|
12
|
+
s.description = %q{Provide Kernel#let for binding names and values as block-local method}
|
13
|
+
|
14
|
+
s.rubyforge_project = "kernel_let"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
# specify any dependencies here; for example:
|
22
|
+
# s.add_development_dependency "rspec"
|
23
|
+
# s.add_runtime_dependency "rest-client"
|
24
|
+
end
|
data/lib/kernel_let.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require "kernel_let/version"
|
2
|
+
|
3
|
+
module Kernel
|
4
|
+
def let(variables, &block)
|
5
|
+
scope = Object.new
|
6
|
+
(class << scope; self; end).class_eval do
|
7
|
+
variables.each do |name, value|
|
8
|
+
define_method(name) { value }
|
9
|
+
end
|
10
|
+
end
|
11
|
+
scope.instance_eval &block
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'kernel_let'
|
3
|
+
|
4
|
+
describe 'let' do
|
5
|
+
it 'should bind name and value pairs in the given hash as block-local methods' do
|
6
|
+
expect(let(:foo => 42) { foo }).to eq(42)
|
7
|
+
expect(let(:bar => 88) { bar }).to eq(88)
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should not bind name and value pairs not in the given hash as block-local methods' do
|
11
|
+
expect {
|
12
|
+
let(:foo => 42) { bar }
|
13
|
+
}.to raise_error(NameError)
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should raise ArgumentError' do
|
17
|
+
expect {
|
18
|
+
let(:foo => 42)
|
19
|
+
}.to raise_error(ArgumentError)
|
20
|
+
end
|
21
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
4
|
+
# loaded once.
|
5
|
+
#
|
6
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
+
RSpec.configure do |config|
|
8
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
9
|
+
config.run_all_when_everything_filtered = true
|
10
|
+
config.filter_run :focus
|
11
|
+
|
12
|
+
# Run specs in random order to surface order dependencies. If you find an
|
13
|
+
# order dependency and want to debug it, you can fix the order by providing
|
14
|
+
# the seed, which is printed after each run.
|
15
|
+
# --seed 1234
|
16
|
+
config.order = 'random'
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kernel_let
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 23
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
version: 1.0.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Kenta Murata
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2012-07-27 00:00:00 Z
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: Provide Kernel#let for binding names and values as block-local method
|
22
|
+
email:
|
23
|
+
- mrkn@mrkn.jp
|
24
|
+
executables: []
|
25
|
+
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files: []
|
29
|
+
|
30
|
+
files:
|
31
|
+
- .gitignore
|
32
|
+
- .rspec
|
33
|
+
- Gemfile
|
34
|
+
- Rakefile
|
35
|
+
- kernel_let.gemspec
|
36
|
+
- lib/kernel_let.rb
|
37
|
+
- lib/kernel_let/version.rb
|
38
|
+
- spec/kernel_let_spec.rb
|
39
|
+
- spec/spec_helper.rb
|
40
|
+
homepage: ""
|
41
|
+
licenses: []
|
42
|
+
|
43
|
+
post_install_message:
|
44
|
+
rdoc_options: []
|
45
|
+
|
46
|
+
require_paths:
|
47
|
+
- lib
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
hash: 3
|
54
|
+
segments:
|
55
|
+
- 0
|
56
|
+
version: "0"
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
hash: 3
|
63
|
+
segments:
|
64
|
+
- 0
|
65
|
+
version: "0"
|
66
|
+
requirements: []
|
67
|
+
|
68
|
+
rubyforge_project: kernel_let
|
69
|
+
rubygems_version: 1.8.15
|
70
|
+
signing_key:
|
71
|
+
specification_version: 3
|
72
|
+
summary: Kernel#let for block-local vairables
|
73
|
+
test_files:
|
74
|
+
- spec/kernel_let_spec.rb
|
75
|
+
- spec/spec_helper.rb
|