Skip to content
This repository has been archived by the owner on Dec 24, 2019. It is now read-only.

Commit

Permalink
Replace L{} with the standard lambda{}.
Browse files Browse the repository at this point in the history
I'd use ->{}, but I'm not sure I can completely drop 1.9 support just
yet.
  • Loading branch information
benhoskings committed Mar 3, 2017
1 parent 74ee582 commit 2fabc8d
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 27 deletions.
2 changes: 1 addition & 1 deletion deps/templates/managed.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
managed_template = L{
managed_template = lambda{
def packages
installs.versions
end
Expand Down
2 changes: 1 addition & 1 deletion lib/babushka/accepts_block_for.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def has_block? block_name

def default_block_for block_name
differentiator = Babushka.host.differentiator_for payload[block_name].keys
L{
lambda{
debug "#{block_name} not defined#{" for #{differentiator}" unless differentiator.nil?}."
true
}
Expand Down
2 changes: 1 addition & 1 deletion lib/babushka/cmdline/handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def self.for name
attr_reader :name, :description, :opt_definer, :handler

def initialize name, description, opt_definer
@name, @description, @opt_definer = name, description, (opt_definer || L{})
@name, @description, @opt_definer = name, description, (opt_definer || lambda{})
end

def run &handler
Expand Down
5 changes: 4 additions & 1 deletion lib/babushka/core_patches/object.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
alias :L :proc
def L(&blk)
Babushka::LogHelpers.deprecated! '2017-09-01', instead: '`->(){}` (or `lambda{}`)'
proc(&blk)
end

class Object
# Return this object's metaclass; i.e. the value of self within a
Expand Down
2 changes: 1 addition & 1 deletion lib/babushka/dep.rb
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def parse_positional_arguments args
# the same arguments.
def process_with_caching and_meet
cache.read(
cache_key, :hit => lambda {|value| log_cached(value, and_meet) }
cache_key, :hit => lambda{|value| log_cached(value, and_meet) }
) {
process!(and_meet)
}
Expand Down
4 changes: 2 additions & 2 deletions lib/babushka/prompt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ def read_from_prompt prompt, choices = nil
Readline.completion_append_character = nil

Readline.completion_proc = if !choices.nil?
L{|str| choices.select {|i| i.starts_with? choice } }
lambda{|str| choices.select {|i| i.starts_with? choice } }
else
L{|str|
lambda{|str|
Dir["#{str}*"].map {|path|
path.end_with(if File.directory?(path)
using_libedit ? '' : '/' # libedit adds its own trailing slash to dirs
Expand Down
8 changes: 4 additions & 4 deletions spec/babushka/accepts_for_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
end
it "should return the result of callable items" do
[:package, :renders, :format].each {|method_name|
expect(subject.send(method_name, L{ "world" }).send(method_name)).to eq("world")
expect(subject.send(method_name, lambda{ "world" }).send(method_name)).to eq("world")
}
end
it "should replace existing values with new ones" do
Expand Down Expand Up @@ -100,7 +100,7 @@
end
it "should return the result of callable items" do
[:records, :produces, :valid_formats].each {|method_name|
expect(subject.send(method_name, "hello", L{ "world" }).send(method_name)).to eq(["hello", "world"])
expect(subject.send(method_name, "hello", lambda{ "world" }).send(method_name)).to eq(["hello", "world"])
}
end
it "should append new values to existing ones" do
Expand Down Expand Up @@ -142,7 +142,7 @@
describe "lambda and value input" do
test_lists.each_pair {|input, expected|
it "should return #{expected.inspect} when passed #{input.inspect} within a lambda" do
l = L{
l = lambda{
via :brew, input
}
list = AcceptsForTest.new
Expand All @@ -154,7 +154,7 @@

describe "nested lambdas" do
it "should choose recursively" do
l = L{
l = lambda{
via :brew do
via :brew, "haha, excellent"
via :apt, ":|"
Expand Down
16 changes: 8 additions & 8 deletions spec/babushka/accepts_for_support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ def test_lists

def test_value_lambdas
{
L{ } => nil,
L{
lambda{ } => nil,
lambda{
via :apt, "git-core"
} => nil,
L{
lambda{
via :brew, 'ruby'
via :apt, 'git-core'
} => 'ruby',
L{
lambda{
via :brew, 'something else'
via :apt, 'some apt packages'
} => 'something else'
Expand All @@ -67,15 +67,15 @@ def test_value_lambdas

def test_list_lambdas
{
L{ } => [],
L{
lambda{ } => [],
lambda{
via :apt, %w[ruby irb ri rdoc]
} => [],
L{
lambda{
via :brew, 'ruby'
via :apt, %w[ruby irb ri rdoc]
} => ['ruby'],
L{
lambda{
via :brew, 'something else'
via :apt, 'some apt packages'
} => ['something else']
Expand Down
6 changes: 3 additions & 3 deletions spec/babushka/dep_context_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
end

RSpec.describe "accepts_block_for behaviour" do
let(:lambda_hello) { L{ "hello world!" } }
let(:lambda_hello) { lambda{ "hello world!" } }

def test_accepts_block_for_response accepter_name, lambda, value, opts = {}
Babushka::DepContext.accepts_block_for accepter_name
Expand All @@ -46,7 +46,7 @@ def test_accepts_block_for_response accepter_name, lambda, value, opts = {}

it "should return lambda" do
Babushka::DepContext.accepts_block_for :test_defining
lambda = L{ 'blah' }
lambda = lambda{ 'blah' }
value_from_block = nil
dep 'returning test' do
value_from_block = test_defining(&lambda)
Expand All @@ -65,7 +65,7 @@ def test_accepts_block_for_response accepter_name, lambda, value, opts = {}
end

it "should use default blocks when no specific one is specified" do
lambda = L{ 'default value' }
lambda = lambda{ 'default value' }
Babushka::DepContext.accepts_block_for :test_defaults, &lambda
value_from_block = nil
dep 'default test' do
Expand Down
8 changes: 4 additions & 4 deletions spec/babushka/dep_definer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@

it "should define and invoke when undefined" do
expect(definer).to receive(:define!)
expect(definer).to receive(:met?).and_return(lambda {|_| })
expect(definer).to receive(:met?).and_return(lambda{|_| })
definer.invoke(:met?)
end

it "should invoke only when already defined" do
allow(definer).to receive(:loaded?).and_return(true)
expect(definer).not_to receive(:define!)
expect(definer).to receive(:met?).and_return(lambda {|_| })
expect(definer).to receive(:met?).and_return(lambda{|_| })
definer.invoke(:met?)
end

Expand Down Expand Up @@ -219,8 +219,8 @@ def helper_test
end

RSpec.describe "#on for scoping accepters" do
let!(:the_lambda) { L{ 'hello from the lambda' } }
let!(:other_lambda) { L{ 'hello from the other lambda' } }
let!(:the_lambda) { lambda{ 'hello from the lambda' } }
let!(:other_lambda) { lambda{ 'hello from the other lambda' } }
before {
allow(Babushka).to receive(:host).and_return(Babushka::OSXSystemProfile.new)
allow(Babushka.host).to receive(:match_list).and_return([:osx])
Expand Down
2 changes: 1 addition & 1 deletion spec/babushka/git_fs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
end

describe '#snapshotting_with' do
let(:blk) { lambda {} }
let(:blk) { lambda{} }
context "when snapshotting is enabled" do
before {
allow(Babushka::Base.task).to receive(:opt).with(:git_fs) { true }
Expand Down

0 comments on commit 2fabc8d

Please sign in to comment.