angostura 0.1 → 0.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: dd5f262ac750a782b4dd95cbed9befebb056ed28
4
- data.tar.gz: 58906858019b6d26083f86fee901348ff9623085
3
+ metadata.gz: 35547437d58eaca9ec86406bf957db4f8582abe2
4
+ data.tar.gz: fa9b39acbebe8536980f790d276203c8c6bd0372
5
5
  SHA512:
6
- metadata.gz: decc7c2b227f11842a016e4e0e5530a966ed54d78f4bcde17b4a22b3261e1ee6b9146dc7dc4861b9249ec679652237d373d8f38e0cffbc1344ab686c3ec26325
7
- data.tar.gz: 9648c4555f10ebd85a3a6d0321b6513fa2ae61d3311061a88b8f1f991797d51b8b4add675b3324a23384ed893b1c3923a551b182bfa7a000a7a94873e049fe39
6
+ metadata.gz: baf9b7a7683fb1ada10daa093f9d23cd75a389d123b7986058d1eb2f4555b05be94eed19bd93a294e74ac99074b0e7b2fd70ef86811f0809e7ef32c1ab8f74df
7
+ data.tar.gz: a4f0a38da7d883a0988afca7b23ed1f73d64943d88f1f0eecd4fbb447d7310421e502fe635c97292b954266e29c1cf7478bfb6a30be896a28c3c7ee1c8eb295d
@@ -0,0 +1,32 @@
1
+ module Angostura
2
+ module Dependencies
3
+ extend ActiveSupport::Concern
4
+
5
+ class_methods do
6
+ mattr_accessor :dependencies
7
+
8
+ def setup
9
+ yield self
10
+
11
+ dependencies.each do |dependency|
12
+ raise DependencyError.new(dependency) if self.send(dependency).nil?
13
+ end
14
+ end
15
+
16
+ def dependency(*args, **kargs)
17
+ self.dependencies = args + kargs&.keys
18
+ self.mattr_accessor(*dependencies)
19
+
20
+ kargs.each do |key, default_value|
21
+ self.send("#{key}=", default_value)
22
+ end
23
+
24
+ dependencies.each do |dependency|
25
+ define_singleton_method "#{dependency}_class" do
26
+ Object.const_get(self.send(dependency))
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,5 @@
1
+ class DependencyError < StandardError
2
+ def initialize(missing_dependency)
3
+ super("Component requires setting a #{missing_dependency} dependency.")
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module Angostura
2
+ VERSION = '0.2'
3
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: angostura
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.1'
4
+ version: '0.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - justin
@@ -14,14 +14,14 @@ dependencies:
14
14
  name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">"
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '4.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">"
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '4.0'
27
27
  - !ruby/object:Gem::Dependency
@@ -88,6 +88,9 @@ extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
90
  - lib/angostura.rb
91
+ - lib/angostura/dependencies.rb
92
+ - lib/angostura/dependency_error.rb
93
+ - lib/angostura/version.rb
91
94
  homepage: https://github.com/justindoody/angostura
92
95
  licenses:
93
96
  - MIT