c3-dci 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source :rubygems
2
+
3
+ group :development do
4
+ gem "rake"
5
+ gem "rspec"
6
+ gem "bundler"
7
+ gem "jeweler"
8
+
9
+ gem "pry"
10
+ gem "pry-doc"
11
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,44 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ coderay (1.0.7)
5
+ diff-lcs (1.1.3)
6
+ git (1.2.5)
7
+ jeweler (1.8.4)
8
+ bundler (~> 1.0)
9
+ git (>= 1.2.5)
10
+ rake
11
+ rdoc
12
+ json (1.7.5)
13
+ method_source (0.8)
14
+ pry (0.9.10)
15
+ coderay (~> 1.0.5)
16
+ method_source (~> 0.8)
17
+ slop (~> 3.3.1)
18
+ pry-doc (0.4.4)
19
+ pry (>= 0.9.9.6)
20
+ yard (~> 0.8.1)
21
+ rake (0.9.2.2)
22
+ rdoc (3.12)
23
+ json (~> 1.4)
24
+ rspec (2.11.0)
25
+ rspec-core (~> 2.11.0)
26
+ rspec-expectations (~> 2.11.0)
27
+ rspec-mocks (~> 2.11.0)
28
+ rspec-core (2.11.1)
29
+ rspec-expectations (2.11.2)
30
+ diff-lcs (~> 1.1.3)
31
+ rspec-mocks (2.11.2)
32
+ slop (3.3.2)
33
+ yard (0.8.2.1)
34
+
35
+ PLATFORMS
36
+ ruby
37
+
38
+ DEPENDENCIES
39
+ bundler
40
+ jeweler
41
+ pry
42
+ pry-doc
43
+ rake
44
+ rspec
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Christoph Grabo
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # c3-dci — CarrotCornCat DCI library
2
+
3
+ A tiny helper library to build applications based on the DCI pattern.
data/Rakefile ADDED
@@ -0,0 +1,47 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+ require 'jeweler'
14
+ require 'rspec/core'
15
+ require 'rspec/core/rake_task'
16
+
17
+ require "c3-dci"
18
+
19
+ Jeweler::Tasks.new do |gem|
20
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
21
+ gem.name = "c3-dci"
22
+ gem.homepage = "http://github.com/CarrotCornCat/c3-dci"
23
+ gem.version = C3DCI.version
24
+ gem.license = "MIT"
25
+ gem.summary = %Q{A tiny DCI helper library}
26
+ gem.description = %Q{TA tiny helper library for the DCI pattern}
27
+ gem.email = "chris@dinarrr.com"
28
+ gem.authors = ["Christoph Grabo"]
29
+ # dependencies defined in Gemfile
30
+ end
31
+ Jeweler::RubygemsDotOrgTasks.new
32
+
33
+ RSpec::Core::RakeTask.new(:spec) do |spec|
34
+ spec.pattern = FileList['spec/**/*_spec.rb']
35
+ end
36
+
37
+ desc "Starts IRB with gem loaded"
38
+ task :irb do
39
+ sh "irb -I lib -r c3-dci"
40
+ end
41
+
42
+ desc "Starts PRY with gem loaded"
43
+ task :pry do
44
+ sh "pry -I lib -r c3-dci --no-pager"
45
+ end
46
+
47
+ task :default => :spec
data/c3-dci.gemspec ADDED
@@ -0,0 +1,70 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "c3-dci"
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Christoph Grabo"]
12
+ s.date = "2012-08-27"
13
+ s.description = "TA tiny helper library for the DCI pattern"
14
+ s.email = "chris@dinarrr.com"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.md"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".rspec",
22
+ "Gemfile",
23
+ "Gemfile.lock",
24
+ "LICENSE.txt",
25
+ "README.md",
26
+ "Rakefile",
27
+ "c3-dci.gemspec",
28
+ "lib/c3-dci.rb",
29
+ "lib/c3-dci/dci.rb",
30
+ "lib/c3-dci/dci/dsl.rb",
31
+ "lib/c3-dci/dci/type.rb",
32
+ "lib/c3-dci/helpers.rb",
33
+ "lib/c3-dci/version.rb",
34
+ "spec/c3-dci_spec.rb",
35
+ "spec/spec_helper.rb"
36
+ ]
37
+ s.homepage = "http://github.com/CarrotCornCat/c3-dci"
38
+ s.licenses = ["MIT"]
39
+ s.require_paths = ["lib"]
40
+ s.rubygems_version = "1.8.24"
41
+ s.summary = "A tiny DCI helper library"
42
+
43
+ if s.respond_to? :specification_version then
44
+ s.specification_version = 3
45
+
46
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
47
+ s.add_development_dependency(%q<rake>, [">= 0"])
48
+ s.add_development_dependency(%q<rspec>, [">= 0"])
49
+ s.add_development_dependency(%q<bundler>, [">= 0"])
50
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
51
+ s.add_development_dependency(%q<pry>, [">= 0"])
52
+ s.add_development_dependency(%q<pry-doc>, [">= 0"])
53
+ else
54
+ s.add_dependency(%q<rake>, [">= 0"])
55
+ s.add_dependency(%q<rspec>, [">= 0"])
56
+ s.add_dependency(%q<bundler>, [">= 0"])
57
+ s.add_dependency(%q<jeweler>, [">= 0"])
58
+ s.add_dependency(%q<pry>, [">= 0"])
59
+ s.add_dependency(%q<pry-doc>, [">= 0"])
60
+ end
61
+ else
62
+ s.add_dependency(%q<rake>, [">= 0"])
63
+ s.add_dependency(%q<rspec>, [">= 0"])
64
+ s.add_dependency(%q<bundler>, [">= 0"])
65
+ s.add_dependency(%q<jeweler>, [">= 0"])
66
+ s.add_dependency(%q<pry>, [">= 0"])
67
+ s.add_dependency(%q<pry-doc>, [">= 0"])
68
+ end
69
+ end
70
+
data/lib/c3-dci.rb ADDED
@@ -0,0 +1,12 @@
1
+ # encoding: utf-8
2
+ require "c3-dci/version"
3
+ require "c3-dci/helpers"
4
+ require "c3-dci/dci"
5
+
6
+ module C3DCI
7
+ def self.version
8
+ Version::STRING
9
+ end
10
+ end
11
+
12
+ #include C3DCI::DCI::DSL
data/lib/c3-dci/dci.rb ADDED
@@ -0,0 +1,3 @@
1
+ # encoding: utf-8
2
+ require "c3-dci/dci/type"
3
+ require "c3-dci/dci/dsl"
@@ -0,0 +1,50 @@
1
+ # encoding: utf-8
2
+
3
+ module C3DCI
4
+ module DCI
5
+ module DSL
6
+
7
+ # you can also use your basic model type
8
+ # this is a nice helper for POROs
9
+ def data name, &block
10
+ klass_name = camelize_me! "#{name.to_s}_data"
11
+ klass = Class.new ::C3DCI::DCI::Type::Data, &block
12
+ parent, child = parent_and_child klass_name
13
+ parent.const_set child, klass
14
+ end
15
+
16
+ def role name, &block
17
+ module_name = camelize_me! "#{name.to_s}_role"
18
+ module_defs = Module.new do
19
+ include ::C3DCI::DCI::Type::Role
20
+ end
21
+ module_defs.module_eval &block
22
+ parent, child = parent_and_child module_name
23
+ parent.const_set child, module_defs
24
+ end
25
+
26
+
27
+ def context name, &block
28
+ klass_name = camelize_me! "#{name.to_s}_context"
29
+ klass = Class.new ::C3DCI::DCI::Type::Context, &block
30
+ parent, child = parent_and_child klass_name
31
+ parent.const_set child, klass
32
+ end
33
+
34
+ private
35
+
36
+ def camelize_me! string
37
+ ::C3DCI::Helpers.camelize! string
38
+ end
39
+
40
+ def parent_and_child string
41
+ child, *parent = ::C3DCI::Helpers.camelize!(string).split("::").reverse
42
+ parent = parent.reverse.join("::")
43
+ parent_object = parent.empty? ? Object : ::C3DCI::Helpers.constantize!(parent)
44
+
45
+ [parent_object, child]
46
+ end
47
+
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,24 @@
1
+ # encoding: utf-8
2
+
3
+ module C3DCI
4
+ module DCI
5
+ module Type
6
+
7
+ Data = Class.new
8
+ Role = Module.new
9
+
10
+ class Context
11
+ # helper method to instantiate and call 'call' a context in one step
12
+ # the 'call' instance method MUST BE implemented!
13
+ def self.call *args
14
+ if args.empty?
15
+ new.call
16
+ else
17
+ new(*args).call
18
+ end
19
+ end
20
+ end
21
+
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,31 @@
1
+ # encoding: utf-8
2
+
3
+ module C3DCI
4
+ module Helpers
5
+ extend self
6
+
7
+ def camelize! literal
8
+ literal.to_s.
9
+ sub(/^(.)/){$1.upcase}.
10
+ gsub(/[_](.)/){$1.upcase}.
11
+ gsub(/(\/|::)(.)/){'::'+$2.upcase}
12
+ end
13
+
14
+ def constantize! literal
15
+ pieces = literal.to_s.split('::')
16
+ pieces.inject(Object) do |parent, child|
17
+ parent = parent.const_get(child)
18
+ end
19
+ end
20
+
21
+ def objectify! literal
22
+ constantize! camelize! literal
23
+ end
24
+
25
+ def rolefy! literal
26
+ type = camelize!(literal)
27
+ constantize!(type.include?("Role") ? type : type + "Role")
28
+ end
29
+
30
+ end
31
+ end
@@ -0,0 +1,13 @@
1
+ # encoding: utf-8
2
+ module C3DCI
3
+ module Version
4
+
5
+ MAJOR = 0
6
+ MINOR = 1
7
+ PATCH = 0
8
+ BUILD = nil
9
+
10
+ STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
11
+
12
+ end
13
+ end
@@ -0,0 +1,7 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "C3Dci" do
4
+ it "fails" do
5
+ fail "hey buddy, you should probably rename this file and start specing for real"
6
+ end
7
+ end
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'c3-dci'
5
+
6
+ # Requires supporting files with custom matchers and macros, etc,
7
+ # in ./support/ and its subdirectories.
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+
12
+ end
metadata ADDED
@@ -0,0 +1,162 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: c3-dci
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Christoph Grabo
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-08-27 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rspec
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: bundler
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: jeweler
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: pry
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: pry-doc
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ description: TA tiny helper library for the DCI pattern
111
+ email: chris@dinarrr.com
112
+ executables: []
113
+ extensions: []
114
+ extra_rdoc_files:
115
+ - LICENSE.txt
116
+ - README.md
117
+ files:
118
+ - .document
119
+ - .rspec
120
+ - Gemfile
121
+ - Gemfile.lock
122
+ - LICENSE.txt
123
+ - README.md
124
+ - Rakefile
125
+ - c3-dci.gemspec
126
+ - lib/c3-dci.rb
127
+ - lib/c3-dci/dci.rb
128
+ - lib/c3-dci/dci/dsl.rb
129
+ - lib/c3-dci/dci/type.rb
130
+ - lib/c3-dci/helpers.rb
131
+ - lib/c3-dci/version.rb
132
+ - spec/c3-dci_spec.rb
133
+ - spec/spec_helper.rb
134
+ homepage: http://github.com/CarrotCornCat/c3-dci
135
+ licenses:
136
+ - MIT
137
+ post_install_message:
138
+ rdoc_options: []
139
+ require_paths:
140
+ - lib
141
+ required_ruby_version: !ruby/object:Gem::Requirement
142
+ none: false
143
+ requirements:
144
+ - - ! '>='
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ segments:
148
+ - 0
149
+ hash: -1028221442063224353
150
+ required_rubygems_version: !ruby/object:Gem::Requirement
151
+ none: false
152
+ requirements:
153
+ - - ! '>='
154
+ - !ruby/object:Gem::Version
155
+ version: '0'
156
+ requirements: []
157
+ rubyforge_project:
158
+ rubygems_version: 1.8.24
159
+ signing_key:
160
+ specification_version: 3
161
+ summary: A tiny DCI helper library
162
+ test_files: []