bulldoggy 0.0.4.alpha → 0.0.5.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: dec01c191923c7efa17a1180c172158553b78be5
4
- data.tar.gz: b48212664b74ba0846ede26190994b9dbfbe8599
3
+ metadata.gz: ef772b794d9e848bd2fb6c51125b182703cb24e9
4
+ data.tar.gz: 1c23bff72019e5fcc1356ba10aed40054d3851a5
5
5
  SHA512:
6
- metadata.gz: 93be88ea83d33a5bb8dafc516f268ee871f62dab37d904417deb04d6371c532c6f22cec90d654cec73db78b49dce96beb866b04b1e9867401e458c0560a5d567
7
- data.tar.gz: 01917a3f3d46d074d2b81125de4d7d6bbbc2ddeeb10dd13779daa3574b03d6f135ef2f9b3c80925de178da67112b872f2d26ab1c59ddaee92c29efab3304edab
6
+ metadata.gz: 231e7e5b21e17931455ddfea9556c22c1183fdd340778c5c0adb321b1828dc5bcd3ce7470b3ffa505d55fa2c3f72a7b7de67b58b4dc2c5ba384367392e27ccd0
7
+ data.tar.gz: f59a347042979b583069d8aec33d1862337cd7a30683a0bb61de3f10b5d4bb9e1633f893a44027594187e49da569dd0bd7aa66e572bbe450a6baef2cc68f1a5c
data/.travis.yml CHANGED
@@ -5,3 +5,7 @@ rvm:
5
5
 
6
6
  script:
7
7
  - bundle exec rspec
8
+
9
+ addons:
10
+ code_climate:
11
+ repo_token: 78d6bcb8824913bd7f29b83dc5ed72fc94e6baaef2d2c1b68419c2d558732c0b
data/README.md CHANGED
@@ -3,11 +3,11 @@
3
3
  [![Build Status](https://travis-ci.org/bezelga/bulldoggy.png?branch=master)](https://travis-ci.org/bezelga/bulldoggy)
4
4
  [![Code Climate](https://codeclimate.com/repos/52e6f81869568017b5003aa8/badges/a99a662bbea4283cf60f/gpa.png)](https://codeclimate.com/repos/52e6f81869568017b5003aa8/feed)
5
5
 
6
- A proof of concept inspired on Uncle Bob's Clean Architecture examplified by a **to-do list app** named Bulldoggy.
6
+ A **to-do list app** inspired by Uncle Bob's Clean Architecture.
7
7
 
8
- This gem is the core of the to-do list.
8
+ The idea of is to have a concrete implementation of the architecture and use various deliveries mechanisms and storages that will act as plugins to the core app.
9
9
 
10
- The delivery mechanisms and the databases are deferred decisions, for now the focus on the app itself and not on these details, but the idea is that they act as plugins.
10
+ Implementations of the delivery mechanisms are welcome and will be listed here.
11
11
 
12
12
  ## Installation
13
13
 
@@ -33,6 +33,14 @@ Or install it yourself as:
33
33
 
34
34
  Bulldoggy.check_task(task.id)
35
35
 
36
+ ### Unchecking tasks:
37
+
38
+ Bulldoggy.uncheck_task(task.id)
39
+
40
+ ### Removing tasks:
41
+
42
+ Bulldoggy.remove(task.id)
43
+
36
44
  ### Fetching tasks:
37
45
 
38
46
  Bulldoggy.fetch
@@ -7,19 +7,19 @@ module Bulldoggy
7
7
  @next_id = 1
8
8
  end
9
9
 
10
- def save(task)
11
- task.id = @next_id
12
- @tasks[@next_id] = task
13
- @next_id += 1
14
- task
10
+ def all
11
+ @tasks
15
12
  end
16
13
 
17
14
  def find(id)
18
15
  @tasks[id]
19
16
  end
20
17
 
21
- def all
22
- @tasks
18
+ def save(task)
19
+ task.id = @next_id
20
+ @tasks[@next_id] = task
21
+ @next_id += 1
22
+ task
23
23
  end
24
24
 
25
25
  def delete_all
@@ -27,14 +27,8 @@ module Bulldoggy
27
27
  @next_id = 1
28
28
  end
29
29
 
30
- def first
31
- first_key = @tasks.keys.sort.first
32
- @tasks[first_key]
33
- end
34
-
35
- def last
36
- last_key = @tasks.keys.sort.last
37
- @tasks[last_key]
30
+ def delete(id)
31
+ @tasks.delete id
38
32
  end
39
33
  end
40
34
  end
@@ -0,0 +1,16 @@
1
+ module Bulldoggy
2
+ module UseCases
3
+ class TaskRemover
4
+
5
+ def remove(task_id)
6
+ task_repo.delete(task_id) || :task_not_found
7
+ end
8
+
9
+ private
10
+
11
+ def task_repo
12
+ Repository.for(:task)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,25 @@
1
+ module Bulldoggy
2
+ module UseCases
3
+ class TaskUnchecker
4
+ def initialize(task_id)
5
+ @task_id = task_id
6
+ end
7
+
8
+ def uncheck
9
+ return :task_not_found unless task
10
+ task.done = false
11
+ task
12
+ end
13
+
14
+ private
15
+
16
+ def task_repo
17
+ Repository.for(:task)
18
+ end
19
+
20
+ def task
21
+ @task ||= task_repo.find(@task_id)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -1,3 +1,3 @@
1
1
  module Bulldoggy
2
- VERSION = "0.0.4.alpha"
2
+ VERSION = "0.0.5.alpha"
3
3
  end
data/lib/bulldoggy.rb CHANGED
@@ -3,9 +3,7 @@ require "bulldoggy/version"
3
3
  require 'bulldoggy/entities/task'
4
4
  require 'bulldoggy/repository'
5
5
 
6
- require 'bulldoggy/use_cases/task_adder'
7
- require 'bulldoggy/use_cases/task_checker'
8
- require 'bulldoggy/use_cases/tasks_fetcher'
6
+ Dir[File.dirname(__FILE__) + "/bulldoggy/use_cases/**/*.rb"].each { |file| require file }
9
7
 
10
8
  Bulldoggy::Repository.register :task, Bulldoggy::Repositories::InMemory::Tasks.new
11
9
 
@@ -15,6 +13,10 @@ module Bulldoggy
15
13
  UseCases::TaskAdder.new.add(description)
16
14
  end
17
15
 
16
+ def remove_task(task_id)
17
+ UseCases::TaskRemover.new.remove(task_id)
18
+ end
19
+
18
20
  def fetch
19
21
  UseCases::TasksFetcher.new.fetch
20
22
  end
@@ -22,5 +24,9 @@ module Bulldoggy
22
24
  def check_task(task_id)
23
25
  UseCases::TaskChecker.new(task_id).check
24
26
  end
27
+
28
+ def uncheck_task(task_id)
29
+ UseCases::TaskUnchecker.new(task_id).uncheck
30
+ end
25
31
  end
26
32
  end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ module Bulldoggy
4
+ module UseCases
5
+ describe TaskRemover do
6
+ subject(:remover) { described_class.new }
7
+
8
+ let(:task_repo) { Bulldoggy::Repository.for(:task) }
9
+
10
+ describe '#remove' do
11
+ subject(:remove) { remover.remove(task_id) }
12
+
13
+ let(:task) { Bulldoggy.add_task('hi') }
14
+ let(:task_id) { task.id }
15
+
16
+ before { task }
17
+
18
+ context 'when the task with the given id exists' do
19
+ it 'removes the task' do
20
+ expect { remove }.to change { task_repo.all.size }.by(-1)
21
+ end
22
+ end
23
+
24
+ context 'when there is no task with this id' do
25
+ let(:task_id) { 42 }
26
+ it { should == :task_not_found }
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+
3
+ module Bulldoggy
4
+ module UseCases
5
+ describe TaskUnchecker do
6
+ subject(:unchecker) { described_class.new(task_id) }
7
+
8
+ describe '#uncheck' do
9
+ subject(:uncheck) { unchecker.uncheck }
10
+ let(:task) { Bulldoggy.add_task('hi') }
11
+ let(:task_id) { task.id }
12
+
13
+ before do
14
+ Bulldoggy.check_task(task_id)
15
+ end
16
+
17
+ context 'when the task with the given id exists' do
18
+ it 'unchecks the task' do
19
+ expect { uncheck }.to change { task.done }.from(true).to(false)
20
+ end
21
+ end
22
+
23
+ context 'when there is no task with this id' do
24
+ let(:task_id) { 42 }
25
+ it { should == :task_not_found }
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bulldoggy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4.alpha
4
+ version: 0.0.5.alpha
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fabiano B.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-30 00:00:00.000000000 Z
11
+ date: 2014-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -73,12 +73,16 @@ files:
73
73
  - lib/bulldoggy/repository.rb
74
74
  - lib/bulldoggy/use_cases/task_adder.rb
75
75
  - lib/bulldoggy/use_cases/task_checker.rb
76
+ - lib/bulldoggy/use_cases/task_remover.rb
77
+ - lib/bulldoggy/use_cases/task_unchecker.rb
76
78
  - lib/bulldoggy/use_cases/tasks_fetcher.rb
77
79
  - lib/bulldoggy/version.rb
78
80
  - spec/repositories/in_memory/tasks_spec.rb
79
81
  - spec/spec_helper.rb
80
82
  - spec/use_cases/task_adder_spec.rb
81
83
  - spec/use_cases/task_checker_spec.rb
84
+ - spec/use_cases/task_remover_spec.rb
85
+ - spec/use_cases/task_unchecker_spec.rb
82
86
  - spec/use_cases/tasks_fetcher_spec.rb
83
87
  homepage: https://github.com/bezelga/bulldoggy
84
88
  licenses:
@@ -109,4 +113,6 @@ test_files:
109
113
  - spec/spec_helper.rb
110
114
  - spec/use_cases/task_adder_spec.rb
111
115
  - spec/use_cases/task_checker_spec.rb
116
+ - spec/use_cases/task_remover_spec.rb
117
+ - spec/use_cases/task_unchecker_spec.rb
112
118
  - spec/use_cases/tasks_fetcher_spec.rb