abyss 0.1.0 → 0.2.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/Rakefile CHANGED
@@ -1,2 +1,13 @@
1
1
  #!/usr/bin/env rake
2
2
  require "bundler/gem_tasks"
3
+
4
+ begin
5
+ require 'rspec/core/rake_task'
6
+
7
+ desc "Run all examples"
8
+ RSpec::Core::RakeTask.new(:spec) do |t|
9
+ t.rspec_opts = %w[--color]
10
+ end
11
+
12
+ task :default => [:spec]
13
+ rescue LoadError; end
@@ -55,11 +55,12 @@ module Abyss
55
55
  # Could be a DeepStore instance or some arbitrary configuration.
56
56
  #
57
57
  def method_missing(method_name, *args, &block)
58
- raise ArgumentError.new("Can't supply both a method argument and a block.") if block_given? && args.size > 0
59
58
 
59
+ # TODO: document the block + arguments scenario when subclassing
60
60
  if block_given?
61
- @configurations[method_name] ||= self.class.new(method_name)
61
+ @configurations[method_name] ||= self.class.new(*args.unshift(method_name))
62
62
  @configurations[method_name].instance_eval &block
63
+ return @configurations[method_name]
63
64
  end
64
65
 
65
66
  return get(method_name) if args.length == 0
@@ -1,3 +1,3 @@
1
1
  module Abyss
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -56,7 +56,7 @@ module Abyss
56
56
 
57
57
  describe "#method_missing behavior" do
58
58
 
59
- context "when given a block and no args" do
59
+ context "when given a block" do
60
60
 
61
61
  let(:config_mock) { mock }
62
62
  let(:empty_proc) { proc {} }
@@ -77,6 +77,15 @@ module Abyss
77
77
  subject.some_undefined_method &empty_proc
78
78
  end
79
79
 
80
+ context "with arguments" do
81
+
82
+ it "initializes a new configuration instance with the passed args" do
83
+ DeepStore.should_receive(:new).with(:some_undefined_method, "foo")
84
+ subject.some_undefined_method "foo", &empty_proc
85
+ end
86
+
87
+ end
88
+
80
89
  end
81
90
 
82
91
  context "with no arguments and no block" do
@@ -97,20 +106,6 @@ module Abyss
97
106
 
98
107
  end
99
108
 
100
- describe "invalid scenarios" do
101
-
102
- context "with an argument and a block" do
103
-
104
- it "raises an InvalidArguemnt error" do
105
- expect {
106
- subject.some_undefined_method("foo") {}
107
- }.to raise_error ArgumentError, /can't supply both a method argument and a block/i
108
- end
109
-
110
- end
111
-
112
- end
113
-
114
109
  end
115
110
 
116
111
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: abyss
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-21 00:00:00.000000000 Z
12
+ date: 2012-05-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
16
- requirement: &70184979232340 !ruby/object:Gem::Requirement
16
+ requirement: &70142667444280 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: 3.2.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70184979232340
24
+ version_requirements: *70142667444280
25
25
  description: Manage arbitrarily-deep configurations through a friendly DSL.
26
26
  email:
27
27
  - jesseltrimble@gmail.com