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 +4 -4
- data/.travis.yml +4 -0
- data/README.md +11 -3
- data/lib/bulldoggy/repositories/in_memory/tasks.rb +9 -15
- data/lib/bulldoggy/use_cases/task_remover.rb +16 -0
- data/lib/bulldoggy/use_cases/task_unchecker.rb +25 -0
- data/lib/bulldoggy/version.rb +1 -1
- data/lib/bulldoggy.rb +9 -3
- data/spec/use_cases/task_remover_spec.rb +31 -0
- data/spec/use_cases/task_unchecker_spec.rb +30 -0
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef772b794d9e848bd2fb6c51125b182703cb24e9
|
4
|
+
data.tar.gz: 1c23bff72019e5fcc1356ba10aed40054d3851a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 231e7e5b21e17931455ddfea9556c22c1183fdd340778c5c0adb321b1828dc5bcd3ce7470b3ffa505d55fa2c3f72a7b7de67b58b4dc2c5ba384367392e27ccd0
|
7
|
+
data.tar.gz: f59a347042979b583069d8aec33d1862337cd7a30683a0bb61de3f10b5d4bb9e1633f893a44027594187e49da569dd0bd7aa66e572bbe450a6baef2cc68f1a5c
|
data/.travis.yml
CHANGED
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
|
6
|
+
A **to-do list app** inspired by Uncle Bob's Clean Architecture.
|
7
7
|
|
8
|
-
|
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
|
-
|
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
|
11
|
-
|
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
|
22
|
-
@
|
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
|
31
|
-
|
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,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
|
data/lib/bulldoggy/version.rb
CHANGED
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
|
-
|
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
|
+
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-
|
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
|