dci-ruby 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -1,16 +1,57 @@
1
1
  = dci-ruby
2
2
 
3
- Description goes here.
4
-
5
- == Contributing to dci-ruby
6
-
7
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
- * Fork the project.
10
- * Start a feature/bugfix branch.
11
- * Commit and push until you are happy with your contribution.
12
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
3
+ Trygve Reenskaug, the parent of MVC, proposes an evolution to traditional OO paradigm. (http://www.artima.com/articles/dci_vision.html).
4
+ This gem makes Data-Context-Interaction paradigm ready to be used in your Ruby application.
5
+
6
+
7
+ == Installation
8
+
9
+ Install as usual, either with rubygems or including it in your Gemfile and running bundle install:
10
+ gem install dci-ruby
11
+ or
12
+ # Gemfile
13
+ gem "dci-ruby"
14
+
15
+
16
+ == Use
17
+
18
+ dci-ruby gives you the class Context to inherit from to create your own contexts:
19
+
20
+ class MoneyTransfer < Context
21
+
22
+ # Roles
23
+ role :source_account do
24
+ def transfer(amount)
25
+ balance -= amount
26
+ target_account.get_transfer(amount)
27
+ end
28
+ end
29
+
30
+ role :target_account do
31
+ def get_transfer(amount)
32
+ balance += amount
33
+ end
34
+ end
35
+
36
+ # Interactions
37
+ def run(amount)
38
+ source_account.transfer(amount)
39
+ end
40
+ end
41
+
42
+ Every context defines some roles to be played by external objects (players) and their interactions. This way
43
+ you have the whole agents and operations in a user case wrapped in just one entity instead of spreaded througout the
44
+ whole application code.
45
+
46
+ Use the defined contexts in your application, instantiating them wherever you need them in your code:
47
+
48
+ MoneyTransfer.new(:source_account => Account.new(1),
49
+ :target_account => Account.new(2)).run(100)
50
+
51
+ Role player objects (the two account instances above) respond to their corresponding role methods inside the context.
52
+ Moreover, every role player has access to the rest of role players. That's why target_account is reachable inside source_account#transfer
53
+ rolemethod.
54
+
14
55
 
15
56
  == Copyright
16
57
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.4.1
data/dci-ruby.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "dci-ruby"
8
- s.version = "0.4.0"
8
+ s.version = "0.4.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Lorenzo Tello"]
@@ -33,9 +33,7 @@ Gem::Specification.new do |s|
33
33
  "spec/interaction_spec.rb",
34
34
  "spec/role_spec.rb",
35
35
  "spec/roleplayers_spec.rb",
36
- "spec/spec_helper.rb",
37
- "test/helper.rb",
38
- "test/test_dci-ruby.rb"
36
+ "spec/spec_helper.rb"
39
37
  ]
40
38
  s.homepage = "http://github.com/ltello/dci-ruby"
41
39
  s.licenses = ["MIT"]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dci-ruby
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 0
10
- version: 0.4.0
9
+ - 1
10
+ version: 0.4.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Lorenzo Tello
@@ -119,8 +119,6 @@ files:
119
119
  - spec/role_spec.rb
120
120
  - spec/roleplayers_spec.rb
121
121
  - spec/spec_helper.rb
122
- - test/helper.rb
123
- - test/test_dci-ruby.rb
124
122
  homepage: http://github.com/ltello/dci-ruby
125
123
  licenses:
126
124
  - MIT
data/test/helper.rb DELETED
@@ -1,18 +0,0 @@
1
- require 'rubygems'
2
- require 'bundler'
3
- begin
4
- Bundler.setup(:default, :development)
5
- rescue Bundler::BundlerError => e
6
- $stderr.puts e.message
7
- $stderr.puts "Run `bundle install` to install missing gems"
8
- exit e.status_code
9
- end
10
- require 'test/unit'
11
- require 'shoulda'
12
-
13
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
- $LOAD_PATH.unshift(File.dirname(__FILE__))
15
- require 'dci-ruby'
16
-
17
- class Test::Unit::TestCase
18
- end
@@ -1,7 +0,0 @@
1
- require 'helper'
2
-
3
- class TestDciRuby < Test::Unit::TestCase
4
- should "probably rename this file and start testing for real" do
5
- flunk "hey buddy, you should probably rename this file and start testing for real"
6
- end
7
- end