atacama 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 19cf3faed089b84664b48c4763716aff698a7704
4
- data.tar.gz: ca47f3998ce6c1969af3f1bd9a14aa31c08c1a2b
3
+ metadata.gz: 57d7c04c5890cdf6985a82af71ac69e32739a3eb
4
+ data.tar.gz: 891d78acb5338faf7785095d141428805e7bc292
5
5
  SHA512:
6
- metadata.gz: 497071ad81e594c2718bfdfea42ca40575c420119a82750050a0b1242c0dcb50a7ff5171c7e9a38b5c9b3fe8dfa252c1e3ccf31d01cb155b79e7a51394b33dd9
7
- data.tar.gz: 88e82961f4539b4553369b9b53dfbec83e8e1c5999fc3a75444982b71576fcb9c4d3c02c9288ec9961581a6a6fb0a1628784925e6fb3c534818a7db706c6df8b
6
+ metadata.gz: 43c1eeb7e3f30baf02bd20439e13524d5ee945a85cb6445ec6458d4578341d64a8e0def14361e3c13794a25616b0784822360c19da0fef5c046cec2425059735
7
+ data.tar.gz: d656e76622ecff876f02f9b826dc112fe38adea3f5ae444945f4bbde08a60381a9cfa53b8f4e5b5434b19c865eb3d48090ea19d0a989c060f655f01f11dd8b2e
data/Gemfile.lock CHANGED
@@ -1,13 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- atacama (0.1.0)
4
+ atacama (0.1.1)
5
5
  dry-types (~> 0.13.2)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- concurrent-ruby (1.1.0)
10
+ concurrent-ruby (1.0.5)
11
11
  dry-configurable (0.7.0)
12
12
  concurrent-ruby (~> 1.0)
13
13
  dry-container (0.6.0)
data/Rakefile CHANGED
@@ -9,6 +9,6 @@ end
9
9
 
10
10
  task default: :test
11
11
 
12
- task :bash do
13
- exec 'docker run -v `pwd`:/app:cached -it spatialnetworks/alpine bash -l -c "gem install rerun && bundle && bash"'
12
+ task :watch do
13
+ exec 'docker run -v `pwd`:/app:cached -it spatialnetworks/alpine bash -l -c "gem install rerun && bundle && /usr/local/bundle/bin/rerun -x rake"'
14
14
  end
@@ -9,14 +9,16 @@ module Atacama
9
9
  module Types
10
10
  include Dry::Types.module
11
11
  Boolean = Types::True | Types::False
12
- ContextOrHash = Strict::Hash | Instance(Context)
13
12
  end
14
13
 
15
14
  # This class enables a DSL for creating a contract for the initializer
16
15
  class Contract
17
16
  RESERVED_KEYS = %i[call initialize context].freeze
18
17
 
18
+ Types = Atacama::Types
19
+
19
20
  NameInterface = Types::Strict::Symbol.constrained(excluded_from: RESERVED_KEYS)
21
+ ContextInterface = Types::Strict::Hash | Types.Instance(Context)
20
22
 
21
23
  class << self
22
24
  def options
@@ -26,9 +28,7 @@ module Atacama
26
28
  # Define an initializer value.
27
29
  # @param [Symbol] name of the argument
28
30
  def option(name, **kwargs)
29
- # Validate it's a symbol and not reserved
30
- name = NameInterface[name]
31
-
31
+ NameInterface[name] # Validate type
32
32
  options[name] = Parameter.new(name: name, **kwargs)
33
33
 
34
34
  define_method(name) { @context[name] }
@@ -43,8 +43,7 @@ module Atacama
43
43
  attr_reader :context
44
44
 
45
45
  def initialize(context: {}, **)
46
- # Validate the type
47
- Types::ContextOrHash[context]
46
+ ContextInterface[context] # Validate the type
48
47
  @context = context.is_a?(Context) ? context : Context.new(context)
49
48
  Validator.call(options: self.class.options, context: @context)
50
49
  end
@@ -7,10 +7,6 @@ module Atacama
7
7
  option :with, type: Types::Any.optional
8
8
  option :yielding, type: Types::Any.optional
9
9
 
10
- def yielding?
11
- !!yielding
12
- end
13
-
14
10
  def proc_invocation?
15
11
  with.is_a? Proc
16
12
  end
@@ -51,6 +51,7 @@ module Atacama
51
51
  def execute(steps)
52
52
  steps.each do |step|
53
53
  evaluate(step).tap do |result|
54
+ raise HaltExecution.new(result) if result.is_a? Values::Return
54
55
  context.merge!(result.value) if result.is_a? Values::Option
55
56
  end
56
57
  end
@@ -16,7 +16,7 @@ module Atacama
16
16
  end
17
17
 
18
18
  def Return(value)
19
- raise HaltExecution.new(Values::Return.call(value: value))
19
+ Values::Return.call(value: value)
20
20
  end
21
21
  # rubocop:enable Naming/MethodName
22
22
  end
@@ -1,3 +1,3 @@
1
1
  module Atacama
2
- VERSION = '0.1.1'.freeze
2
+ VERSION = '0.1.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: atacama
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Johnston
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-10-31 00:00:00.000000000 Z
11
+ date: 2018-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-types