bossy 0.0.3

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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/bossy.rb +41 -0
  3. metadata +78 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c5cc0874657e8d5dd757856ca705b49bf8033f45
4
+ data.tar.gz: 2de460cffc027e1558263241b5cd5b0442d17015
5
+ SHA512:
6
+ metadata.gz: 4d30c1215b9e759043f31942f696eab41a890dfa8846496d0b08ef6eb45a7a7a64e1dbe2114c2cbb0ba19767231bf3e43a3c099150c32375f3786917d477d518
7
+ data.tar.gz: 80c8111fbb17f498af3b51bb511cd10ac146238686690b32fb286c9187f8ed2a3cac26aea9e802d08e19e2ac1cebe766fe2f462b763b036cf5887486f25f8775
data/lib/bossy.rb ADDED
@@ -0,0 +1,41 @@
1
+ require 'bossy/interface.rb'
2
+ require 'bossy/class_methods.rb'
3
+ require 'bossy/method_signature.rb'
4
+ require 'bossy/errors/method_missing.rb'
5
+
6
+ # That means objects implementing a Bossy interface get the following:
7
+ # def interface=(new_interface)
8
+ # def interface()
9
+ # interface {}
10
+ # @bossy_interface
11
+ module Bossy
12
+
13
+ # This is what you can call to define methods in an interface
14
+ def require_method(args)
15
+ raise "require_method should receive a data type and method name, e.g. 'String: :name'" unless args.is_a?(Hash)
16
+
17
+ @required_methods ||= []
18
+ method_name_and_type, *parameters = *args
19
+ @required_methods << Bossy::MethodSignature.new(
20
+ method_name_and_type.first,
21
+ method_name_and_type.last,
22
+ parameters
23
+ )
24
+ end
25
+
26
+ # This allows users to define an interface in-line in a clas.
27
+ def interface(&block)
28
+ mod = Module.new
29
+ mod.extend(Bossy)
30
+ mod.instance_eval(&block)
31
+ include mod
32
+ mod
33
+ end
34
+
35
+ # Setup the class that is implementing the interface
36
+ def included(base)
37
+ base.extend(Bossy::ClassMethods)
38
+ base.interface = Bossy::Interface.new(base, @required_methods)
39
+ end
40
+
41
+ end
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bossy
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ platform: ruby
6
+ authors:
7
+ - Adam Stasio
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-11-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: " This gem provides a way to easily specify methods that an object
42
+ must implement, \n as well as a way to validate that required methods exist.
43
+ In addition, you can \n specify additional information about the interface of
44
+ your object that can be used \n to produce documentation. Specifically you can
45
+ specify the return type of your \n methods, as well as the method's arguments
46
+ and argument return types. The data \n types are not enforced, but can be viewed
47
+ by running `MyClass.interface.print`.\n"
48
+ email: adam.stasio@scimedsolutions.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - lib/bossy.rb
54
+ homepage: http://nowhere.yet
55
+ licenses:
56
+ - MIT
57
+ metadata: {}
58
+ post_install_message:
59
+ rdoc_options: []
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - '>='
65
+ - !ruby/object:Gem::Version
66
+ version: 2.0.0
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ requirements: []
73
+ rubyforge_project:
74
+ rubygems_version: 2.0.14
75
+ signing_key:
76
+ specification_version: 4
77
+ summary: Define and enforce interfaces for all of your objects!
78
+ test_files: []