pour 0.0.0.0 → 0.0.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c039f0e4eca3e8018a95e7f5bcc823cf6b23f8e9
4
- data.tar.gz: 4406f1f25c30217e87aec67b04698b3564432a42
3
+ metadata.gz: 5ef5ad8bbb4b854fa418d20e93e7ecbcdab07776
4
+ data.tar.gz: 2b8ca3aa0a4d9037afdb4858e5aa57b3d7332c3d
5
5
  SHA512:
6
- metadata.gz: 8b25d8864c01739de93ff174881fa946286e83dce7c07acfdab8b2e1e3cb9ed67df564145e7bc3945686684658c1c27c7b620a94d8b283e675c4fd6753e25572
7
- data.tar.gz: 4795ba6e91db9177943e83f5ad2688ce156b0601b1bd4bced6d93026af7608da5abfb0ae1991db61e30f40f0e0e4b035c76f61563c340a63d46366e065da8489
6
+ metadata.gz: fe51850bfc230fb1d9dd0440d61c4abb310bb2a32a8e5ae446167f71d4e9fbd335bb3d8c1e125fe03659553e9adc87471e5c461c5930006aebebb07b069ff667
7
+ data.tar.gz: 8a94f44016ea6bb93fbc02d7f7c8b89c120baef6b70718303e8fc0835958300dafec2777c819b64f806472c1fa92e82ec001a8dfdcc32cf662694d753d40ec9f
data/Gemfile.lock ADDED
@@ -0,0 +1,61 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ pour (0.0.0.0)
5
+ typespec
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ aruba (0.10.2)
11
+ childprocess (~> 0.5.6)
12
+ contracts (~> 0.9)
13
+ cucumber (>= 1.3.19)
14
+ ffi (~> 1.9.10)
15
+ rspec-expectations (>= 2.99)
16
+ thor (~> 0.19)
17
+ builder (3.2.2)
18
+ childprocess (0.5.8)
19
+ ffi (~> 1.0, >= 1.0.11)
20
+ contracts (0.12.0)
21
+ cucumber (2.1.0)
22
+ builder (>= 2.1.2)
23
+ cucumber-core (~> 1.3.0)
24
+ diff-lcs (>= 1.1.3)
25
+ gherkin3 (~> 3.1.0)
26
+ multi_json (>= 1.7.5, < 2.0)
27
+ multi_test (>= 0.1.2)
28
+ cucumber-core (1.3.0)
29
+ gherkin3 (~> 3.1.0)
30
+ diff-lcs (1.2.5)
31
+ ffi (1.9.10-x86-mingw32)
32
+ gherkin3 (3.1.2)
33
+ multi_json (1.11.2)
34
+ multi_test (0.1.2)
35
+ rspec (3.4.0)
36
+ rspec-core (~> 3.4.0)
37
+ rspec-expectations (~> 3.4.0)
38
+ rspec-mocks (~> 3.4.0)
39
+ rspec-core (3.4.1)
40
+ rspec-support (~> 3.4.0)
41
+ rspec-expectations (3.4.0)
42
+ diff-lcs (>= 1.2.0, < 2.0)
43
+ rspec-support (~> 3.4.0)
44
+ rspec-mocks (3.4.0)
45
+ diff-lcs (>= 1.2.0, < 2.0)
46
+ rspec-support (~> 3.4.0)
47
+ rspec-support (3.4.1)
48
+ thor (0.19.1)
49
+ typespec (0.1.0.6)
50
+
51
+ PLATFORMS
52
+ x86-mingw32
53
+
54
+ DEPENDENCIES
55
+ aruba
56
+ cucumber
57
+ pour!
58
+ rspec
59
+
60
+ BUNDLED WITH
61
+ 1.10.6
data/README.md CHANGED
@@ -0,0 +1,8 @@
1
+ # [Pour](http://mtwilliams.github.io/pour)
2
+
3
+ [![Gem Version](https://img.shields.io/gem/v/pour.svg)](https://rubygems.org/gems/pour)
4
+ [![Build Status](https://img.shields.io/travis/mtwilliams/pour/master.svg)](https://travis-ci.org/mtwilliams/pour)
5
+ [![Code Climate](https://img.shields.io/codeclimate/github/mtwilliams/pour.svg)](https://codeclimate.com/github/mtwilliams/pour)
6
+ [![Dependency Status](https://img.shields.io/gemnasium/mtwilliams/pour.svg)](https://gemnasium.com/mtwilliams/pour)
7
+
8
+ :construction: Allow time to cure!
data/lib/pour/gem.rb CHANGED
@@ -22,7 +22,7 @@ module Pour
22
22
 
23
23
  # This Gem's homepage URL.
24
24
  def self.homepage
25
- "http://#{self.name}.mtwilliams.github.io"
25
+ "http://mtwilliams.github.io/#{self.name}"
26
26
  end
27
27
 
28
28
  # This Gem's URL.
@@ -32,16 +32,16 @@ module Pour
32
32
 
33
33
  # A short summary of this Gem.
34
34
  def self.summary
35
- "Compose concrete classes."
35
+ "Easily compose type-safe, concrete classes."
36
36
  end
37
37
 
38
38
  # A full description of this Gem.
39
39
  def self.description
40
- "Pour is a clean and extensible Ruby library that allows you to compose concrete classes and keep yourself DRY."
40
+ "Pour lets you to easily compose type-safe, concrete classes."
41
41
  end
42
42
 
43
43
  module VERSION #:nodoc:
44
- MAJOR, MINOR, PATCH, PRE = [0, 0, 0, 0]
44
+ MAJOR, MINOR, PATCH, PRE = [0, 0, 1, 0]
45
45
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.')
46
46
  end
47
47
 
data/lib/pour/mould.rb ADDED
@@ -0,0 +1,31 @@
1
+ module Pour
2
+ class Mould
3
+ module ClassMethods
4
+ def pour(pourable)
5
+ unless pourable.class.included_modules.include?(Pour::Pourable)
6
+ raise Pour::Unpourable.new(pourable)
7
+ end
8
+
9
+ poured = self.class_variable_get(:@@__poured__)
10
+
11
+ unless poured.include? pourable
12
+ self.class_variable_set(:@@__poured__, poured + pourable)
13
+ # This capture all the properties as well as any user-defined methods.
14
+ self.include(pourable)
15
+ end
16
+ end
17
+ end
18
+
19
+ module InstanceMethods
20
+ end
21
+
22
+ def self.inherited(mould)
23
+ mould.send :extend, ClassMethods
24
+ mould.send :include, InstanceMethods
25
+
26
+ # We can assume nothing has been "poured" into |mold|.
27
+ poured = self.class_variable_get(:@@__poured__) || []
28
+ mould.class_variable_set(:@@__poured__, poured)
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,57 @@
1
+ module Pour
2
+ module Pourable
3
+ module ClassMethods
4
+ def property(name, typespec)
5
+ if self.__properties__.map(&:name).include?(name)
6
+ raise "Already have a property called '#{name}'!"
7
+ end
8
+
9
+ property = Pour::Property.new(name: name, typespec: typespec)
10
+ self.__properties__ = self.__properties__ + [property]
11
+
12
+ decorated = "@#{name}".to_sym
13
+ reader = name.to_sym
14
+ writer = "#{name}=".to_sym
15
+
16
+ self.class_eval do
17
+ define_method reader do
18
+ self.insance_variable_get(decorated)
19
+ end
20
+
21
+ define_method writer do |new_value|
22
+ if property.typespec.valid?(new_value)
23
+ self.insance_variable_set(decorated, new_value)
24
+ else
25
+ # TODO(mtwilliams): recursively map to determine where and why the
26
+ # |new_value| doesn't match the typespec.
27
+ raise ":("
28
+ end
29
+ end
30
+ end
31
+ end
32
+
33
+ def __properties__
34
+ if self.class.superclass.included_modules.include? Pour::Pourable
35
+ properties = self.class.superclass.class_variable_get(:@@__properties__)
36
+ self.class_variable_set(:@@__properties__, properties)
37
+ end
38
+
39
+ self.class_variable_get(:@@__properties__)
40
+ end
41
+
42
+ def __properties__=(properties)
43
+ self.class_variable_set(:@@__properties__, properties)
44
+ end
45
+ end
46
+
47
+ module InstanceMethods
48
+ end
49
+
50
+ def self.included(pourable)
51
+ pourable.send :extend, ClassMethods
52
+ pourable.send :include, InstanceMethods
53
+
54
+ pourable.class_variable_set :@@__properties__, []
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,13 @@
1
+ module Pour
2
+ class Property
3
+ attr_reader :name
4
+ attr_reader :typespec
5
+
6
+ def initialize(name:, typespec:)
7
+ @name = name
8
+ @typespec = typespec
9
+ # @factory = Pour::Factory.from(typespec)
10
+ # @validator = Pour::Validator.from(typespec)
11
+ end
12
+ end
13
+ end
data/lib/pour.rb CHANGED
@@ -1,3 +1,10 @@
1
- module Pour
2
- require 'pour/gem'
3
- end
1
+ module Pour
2
+ # Pour uses https://github.com/mtwilliams/typespec.
3
+ require 'typespec'
4
+
5
+ require 'pour/gem'
6
+
7
+ require 'pour/property'
8
+ require 'pour/pourable'
9
+ require 'pour/mould'
10
+ end
data/pour.gemspec CHANGED
@@ -1,25 +1,27 @@
1
- $:.push File.expand_path(File.join(File.dirname(__FILE__), 'lib'))
2
- require 'pour/gem'
3
-
4
- Gem::Specification.new do |s|
5
- s.name = Pour::Gem.name
6
- s.version = Pour::Gem.version
7
- s.platform = Gem::Platform::RUBY
8
- s.author = Pour::Gem.author.name
9
- s.email = Pour::Gem.author.email
10
- s.homepage = Pour::Gem.homepage
11
- s.summary = Pour::Gem.summary
12
- s.description = Pour::Gem.description
13
- s.license = Pour::Gem.license
14
-
15
- s.required_ruby_version = '>= 1.9.3'
16
-
17
- s.files = `git ls-files`.split("\n")
18
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
- s.require_paths = %w(lib)
21
-
22
- s.add_development_dependency 'rspec'
23
- s.add_development_dependency 'cucumber'
24
- s.add_development_dependency 'aruba'
25
- end
1
+ $:.push File.expand_path(File.join(File.dirname(__FILE__), 'lib'))
2
+ require 'pour/gem'
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = Pour::Gem.name
6
+ s.version = Pour::Gem.version
7
+ s.platform = Gem::Platform::RUBY
8
+ s.author = Pour::Gem.author.name
9
+ s.email = Pour::Gem.author.email
10
+ s.homepage = Pour::Gem.homepage
11
+ s.summary = Pour::Gem.summary
12
+ s.description = Pour::Gem.description
13
+ s.license = Pour::Gem.license
14
+
15
+ s.required_ruby_version = '>= 1.9.3'
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = %w(lib)
21
+
22
+ s.add_dependency 'typespec'
23
+
24
+ s.add_development_dependency 'rspec'
25
+ s.add_development_dependency 'cucumber'
26
+ s.add_development_dependency 'aruba'
27
+ end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pour
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0.0
4
+ version: 0.0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-29 00:00:00.000000000 Z
11
+ date: 2016-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: typespec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rspec
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -52,8 +66,7 @@ dependencies:
52
66
  - - ">="
53
67
  - !ruby/object:Gem::Version
54
68
  version: '0'
55
- description: Pour is a clean and extensible Ruby library that allows you to compose
56
- concrete classes and keep yourself DRY.
69
+ description: Pour lets you to easily compose type-safe, concrete classes.
57
70
  email: m.t.williams@live.com
58
71
  executables: []
59
72
  extensions: []
@@ -62,13 +75,17 @@ files:
62
75
  - ".gitignore"
63
76
  - AUTHORS
64
77
  - Gemfile
78
+ - Gemfile.lock
65
79
  - LICENSE
66
80
  - README.md
67
81
  - Rakefile
68
82
  - lib/pour.rb
69
83
  - lib/pour/gem.rb
84
+ - lib/pour/mould.rb
85
+ - lib/pour/pourable.rb
86
+ - lib/pour/property.rb
70
87
  - pour.gemspec
71
- homepage: http://pour.mtwilliams.github.io
88
+ homepage: http://mtwilliams.github.io/pour
72
89
  licenses:
73
90
  - Public Domain
74
91
  metadata: {}
@@ -91,5 +108,5 @@ rubyforge_project:
91
108
  rubygems_version: 2.4.5
92
109
  signing_key:
93
110
  specification_version: 4
94
- summary: Compose concrete classes.
111
+ summary: Easily compose type-safe, concrete classes.
95
112
  test_files: []