bulldoggy 0.0.6.alpha → 0.0.7.alpha

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: 1b41989bb826910d417a76482acf1b948afd8d58
4
- data.tar.gz: ef06915807d3f2a28422644534d3106cf684fd25
3
+ metadata.gz: 1b8f48158b1ab987418c0ce36448255fe30272a1
4
+ data.tar.gz: 981454050d6fbca1a22ac11d1acd7bf99d92ace7
5
5
  SHA512:
6
- metadata.gz: 7bdcee0b7e16a0ee1fd5065efb1859a92c911619814fd6b925e77223b1da3db46ec4b2f124eaacfbe3956b20c18986bd04a22b73f5b05bff572605631984f746
7
- data.tar.gz: c8d0c51b83e12c853af7f7f50a0ebf305b0fa7948091bfef4dca29b77330765c42d07ac3bae889060068b986528948f3b8a764a880e0d65247f60f59bbf31918
6
+ metadata.gz: c5d1f13bc2303e0204f1b1e085bfec91b40da7cf3e79d5b7e700395f9baa96d1e91bf021f8c5a41343d5cec701455ee62d814c822bc1abe3c1db8e6bda0b8c0d
7
+ data.tar.gz: 07f5e0da91299a64e8b5b9baa924c2fdb3d43096ab6b886cff3c576281b89e804acbdb1ffd614f11eb9723f5ab300d1decbe3372ecf5df8146b08b644726b5fd
data/README.md CHANGED
@@ -9,11 +9,12 @@ The idea of is to have a concrete implementation of the architecture and use var
9
9
 
10
10
  Implementations of the delivery mechanisms are welcome and will be listed here:
11
11
 
12
- # Web as the delivery mechanism:
12
+ ## Web as the delivery mechanism:
13
13
 
14
14
  * [bulldoggy-sinatra](https://github.com/bezelga/bulldoggy-sinatra)
15
+ * [bulldoggy-rails](https://github.com/bezelga/bulldoggy-rails)
15
16
 
16
- # CLI the delivery mechanism:
17
+ ## CLI (command line interface) as the delivery mechanism:
17
18
 
18
19
  * [bulldoggy-thor](https://github.com/philss/bulldoggy-thor)
19
20
 
@@ -21,7 +22,7 @@ Implementations of the delivery mechanisms are welcome and will be listed here:
21
22
 
22
23
  Add this line to your application's Gemfile:
23
24
 
24
- gem 'bulldoggy'
25
+ gem 'bulldoggy', '~> 0.0.1.alpha'
25
26
 
26
27
  And then execute:
27
28
 
@@ -52,3 +53,15 @@ Or install it yourself as:
52
53
  ### Fetching tasks:
53
54
 
54
55
  Bulldoggy.fetch
56
+
57
+ ## Usage with Rails:
58
+
59
+ ### Connecting entities to ActiveRecord models
60
+
61
+ Inside your Rails app, create an initializer and register your repository adapters to make it work with Rails AR models.
62
+
63
+ config/initializers/bulldoggy.rb:
64
+
65
+ Bulldoggy::Repository.register :task, TasksRespositoryAdapter.new
66
+
67
+ TODO: add repository adapter example
@@ -1,8 +1,6 @@
1
1
  require "bulldoggy/version"
2
-
3
2
  require 'bulldoggy/entities/task'
4
3
  require 'bulldoggy/repository'
5
-
6
4
  Dir[File.dirname(__FILE__) + "/bulldoggy/use_cases/**/*.rb"].each { |file| require file }
7
5
 
8
6
  Bulldoggy::Repository.register :task, Bulldoggy::Repositories::InMemory::Tasks.new
@@ -3,9 +3,9 @@ module Bulldoggy
3
3
  class Task
4
4
  attr_accessor :id, :description, :done
5
5
 
6
- def initialize(description)
6
+ def initialize(description, done=false)
7
7
  @description = description
8
- @done = false
8
+ @done = done
9
9
  end
10
10
  end
11
11
  end
@@ -8,13 +8,27 @@ module Bulldoggy
8
8
  end
9
9
 
10
10
  def all
11
- @tasks
11
+ @tasks.values
12
12
  end
13
13
 
14
14
  def find(id)
15
15
  @tasks[id]
16
16
  end
17
17
 
18
+ def check(id)
19
+ task = @tasks[id]
20
+ return :task_not_found unless task
21
+ task.done = true
22
+ task
23
+ end
24
+
25
+ def uncheck(id)
26
+ task = @tasks[id]
27
+ return :task_not_found unless task
28
+ task.done = false
29
+ task
30
+ end
31
+
18
32
  def save(task)
19
33
  task.id = @next_id
20
34
  @tasks[@next_id] = task
@@ -6,9 +6,7 @@ module Bulldoggy
6
6
  end
7
7
 
8
8
  def check
9
- return :task_not_found unless task
10
- task.done = true
11
- task
9
+ task_repo.check(@task_id)
12
10
  end
13
11
 
14
12
  private
@@ -16,10 +14,6 @@ module Bulldoggy
16
14
  def task_repo
17
15
  Repository.for(:task)
18
16
  end
19
-
20
- def task
21
- @task ||= task_repo.find(@task_id)
22
- end
23
17
  end
24
18
  end
25
19
  end
@@ -6,9 +6,7 @@ module Bulldoggy
6
6
  end
7
7
 
8
8
  def uncheck
9
- return :task_not_found unless task
10
- task.done = false
11
- task
9
+ task_repo.uncheck(@task_id)
12
10
  end
13
11
 
14
12
  private
@@ -16,10 +14,6 @@ module Bulldoggy
16
14
  def task_repo
17
15
  Repository.for(:task)
18
16
  end
19
-
20
- def task
21
- @task ||= task_repo.find(@task_id)
22
- end
23
17
  end
24
18
  end
25
19
  end
@@ -2,9 +2,9 @@ module Bulldoggy
2
2
  module UseCases
3
3
  class TasksFetcher
4
4
  def fetch
5
- Bulldoggy::Repository.for(:task).all.map do |id, task|
5
+ Bulldoggy::Repository.for(:task).all.map do |task|
6
6
  # IMPROVE: create a TaskSerializer to do this job
7
- { id: id, description: task.description, :done => task.done }
7
+ { id: task.id, description: task.description, :done => task.done }
8
8
  end
9
9
  end
10
10
  end
@@ -1,3 +1,3 @@
1
1
  module Bulldoggy
2
- VERSION = "0.0.6.alpha"
2
+ VERSION = "0.0.7.alpha"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bulldoggy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6.alpha
4
+ version: 0.0.7.alpha
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fabiano B.