bulldoggy 0.0.2.alpha → 0.0.3.alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/bulldoggy/entities/task.rb +11 -0
- data/lib/bulldoggy/repositories/in_memory/tasks.rb +38 -0
- data/lib/bulldoggy/repository.rb +2 -0
- data/lib/bulldoggy/use_cases/task_adder.rb +19 -0
- data/lib/bulldoggy/use_cases/tasks_fetcher.rb +12 -0
- data/lib/bulldoggy/version.rb +1 -1
- data/lib/bulldoggy.rb +16 -5
- data/spec/repositories/in_memory/tasks_spec.rb +0 -0
- data/spec/spec_helper.rb +4 -0
- data/spec/use_cases/task_adder_spec.rb +11 -13
- data/spec/use_cases/tasks_fetcher_spec.rb +32 -0
- metadata +10 -11
- data/lib/bulldoggy/entities/list.rb +0 -10
- data/lib/bulldoggy/repositories/in_memory/lists.rb +0 -33
- data/lib/bulldoggy/use_cases/list_creator.rb +0 -29
- data/spec/entities/list_spec.rb +0 -13
- data/spec/repositories/in_memory/lists_spec.rb +0 -14
- data/spec/use_cases/list_creator_spec.rb +0 -20
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6d8a4206ac727653745dcbe517a26fdb0ab714a4
|
|
4
|
+
data.tar.gz: 0b015676023a0aaf41bac6e3280058238d2db3fe
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 64b2e1c2cee54cf378ea5bb331eb97e2e39ba5670ca623dd5f4e4c92ecb73e52ede8c0150c0515832388e3aec7ed191203c538986d3f6db8148ffc6695fec1a9
|
|
7
|
+
data.tar.gz: 2445bfea6850c94a4a408dac7fe0a2b7492bb662a6553da3ce7e284563fc70173daf37e6edcd43e5ffc28af1cf210e5abf100dd4c1978bb7e81809a696f0073e
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
module Bulldoggy
|
|
2
|
+
module Repositories
|
|
3
|
+
module InMemory
|
|
4
|
+
class Tasks
|
|
5
|
+
def initialize
|
|
6
|
+
@tasks = {}
|
|
7
|
+
@next_id = 1
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def save(task)
|
|
11
|
+
task.id = @next_id
|
|
12
|
+
@tasks[@next_id] = task
|
|
13
|
+
@next_id += 1
|
|
14
|
+
task
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def all
|
|
18
|
+
@tasks
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def delete_all
|
|
22
|
+
@tasks = {}
|
|
23
|
+
@next_id = 1
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def first
|
|
27
|
+
first_key = @tasks.keys.sort.first
|
|
28
|
+
@tasks[first_key]
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def last
|
|
32
|
+
last_key = @tasks.keys.sort.last
|
|
33
|
+
@tasks[last_key]
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
data/lib/bulldoggy/repository.rb
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Bulldoggy
|
|
2
|
+
module UseCases
|
|
3
|
+
class TaskAdder
|
|
4
|
+
def add(description)
|
|
5
|
+
task_repo.save new_task(description)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
private
|
|
9
|
+
|
|
10
|
+
def new_task(description)
|
|
11
|
+
Entities::Task.new(description)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def task_repo
|
|
15
|
+
Repository.for(:task)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
data/lib/bulldoggy/version.rb
CHANGED
data/lib/bulldoggy.rb
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
require "bulldoggy/version"
|
|
2
2
|
|
|
3
|
-
require 'bulldoggy/
|
|
4
|
-
require 'bulldoggy/entities/list'
|
|
3
|
+
require 'bulldoggy/entities/task'
|
|
5
4
|
require 'bulldoggy/repository'
|
|
6
|
-
|
|
5
|
+
|
|
6
|
+
require 'bulldoggy/use_cases/task_adder'
|
|
7
|
+
require 'bulldoggy/use_cases/tasks_fetcher'
|
|
8
|
+
|
|
9
|
+
Bulldoggy::Repository.register :task, Bulldoggy::Repositories::InMemory::Tasks.new
|
|
7
10
|
|
|
8
11
|
module Bulldoggy
|
|
9
|
-
|
|
12
|
+
class << self
|
|
13
|
+
# TODO: test me
|
|
14
|
+
def add_task(description)
|
|
15
|
+
UseCases::TaskAdder.new.add(description)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def fetch
|
|
19
|
+
UseCases::TasksFetcher.new.fetch
|
|
20
|
+
end
|
|
21
|
+
end
|
|
10
22
|
end
|
|
11
23
|
|
|
12
|
-
Bulldoggy::Repository.register :list, Bulldoggy::Repositories::InMemory::Lists.new
|
|
File without changes
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
describe Bulldoggy::UseCases::TaskAdder do
|
|
4
|
+
subject(:adder) { described_class.new }
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
describe '.add' do
|
|
7
|
+
subject(:add) { adder.add(description) }
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
let(:task_repo) { Bulldoggy::Repository.for(:task) }
|
|
10
|
+
let(:description) { 'Create an app with clean architecture' }
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
#end
|
|
18
|
-
#end
|
|
12
|
+
it 'adds the task' do
|
|
13
|
+
expect { add }.to change { task_repo.all.size }.by(1)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Bulldoggy
|
|
4
|
+
module UseCases
|
|
5
|
+
describe TasksFetcher do
|
|
6
|
+
subject(:fetcher) { described_class.new }
|
|
7
|
+
|
|
8
|
+
describe '#fetch' do
|
|
9
|
+
subject(:fetch) { fetcher.fetch }
|
|
10
|
+
|
|
11
|
+
let(:task_repo) { Repository.for(:task) }
|
|
12
|
+
|
|
13
|
+
context 'when there are no tasks yet' do
|
|
14
|
+
it { should == [] }
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
context 'when there are 2 tasks' do
|
|
18
|
+
before do
|
|
19
|
+
2.times do |n|
|
|
20
|
+
Bulldoggy.add_task("task##{n}")
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
let(:task1) { { id: 1, description: 'task#0' } }
|
|
25
|
+
let(:task2) { { id: 2, description: 'task#1' } }
|
|
26
|
+
|
|
27
|
+
it { should == [task1, task2] }
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
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.3.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-29 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -68,16 +68,16 @@ files:
|
|
|
68
68
|
- Rakefile
|
|
69
69
|
- bulldoggy.gemspec
|
|
70
70
|
- lib/bulldoggy.rb
|
|
71
|
-
- lib/bulldoggy/entities/
|
|
72
|
-
- lib/bulldoggy/repositories/in_memory/
|
|
71
|
+
- lib/bulldoggy/entities/task.rb
|
|
72
|
+
- lib/bulldoggy/repositories/in_memory/tasks.rb
|
|
73
73
|
- lib/bulldoggy/repository.rb
|
|
74
|
-
- lib/bulldoggy/use_cases/
|
|
74
|
+
- lib/bulldoggy/use_cases/task_adder.rb
|
|
75
|
+
- lib/bulldoggy/use_cases/tasks_fetcher.rb
|
|
75
76
|
- lib/bulldoggy/version.rb
|
|
76
|
-
- spec/
|
|
77
|
-
- spec/repositories/in_memory/lists_spec.rb
|
|
77
|
+
- spec/repositories/in_memory/tasks_spec.rb
|
|
78
78
|
- spec/spec_helper.rb
|
|
79
|
-
- spec/use_cases/list_creator_spec.rb
|
|
80
79
|
- spec/use_cases/task_adder_spec.rb
|
|
80
|
+
- spec/use_cases/tasks_fetcher_spec.rb
|
|
81
81
|
homepage: ''
|
|
82
82
|
licenses:
|
|
83
83
|
- MIT
|
|
@@ -103,8 +103,7 @@ signing_key:
|
|
|
103
103
|
specification_version: 4
|
|
104
104
|
summary: Bulldoggy is a to-do list app inspired by Uncle Bob's Clean Architecture
|
|
105
105
|
test_files:
|
|
106
|
-
- spec/
|
|
107
|
-
- spec/repositories/in_memory/lists_spec.rb
|
|
106
|
+
- spec/repositories/in_memory/tasks_spec.rb
|
|
108
107
|
- spec/spec_helper.rb
|
|
109
|
-
- spec/use_cases/list_creator_spec.rb
|
|
110
108
|
- spec/use_cases/task_adder_spec.rb
|
|
109
|
+
- spec/use_cases/tasks_fetcher_spec.rb
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
module Bulldoggy
|
|
2
|
-
module Repositories
|
|
3
|
-
module InMemory
|
|
4
|
-
class Lists
|
|
5
|
-
def initialize
|
|
6
|
-
@lists = {}
|
|
7
|
-
@next_id = 1
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def save(list)
|
|
11
|
-
list.id = @next_id
|
|
12
|
-
@lists[@next_id] = list
|
|
13
|
-
@next_id += 1
|
|
14
|
-
list
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def all
|
|
18
|
-
@lists
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def first
|
|
22
|
-
first_key = @lists.keys.sort.first
|
|
23
|
-
@lists[first_key]
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def last
|
|
27
|
-
last_key = @lists.keys.sort.last
|
|
28
|
-
@lists[last_key]
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
module Bulldoggy
|
|
2
|
-
module UseCases
|
|
3
|
-
class ListCreator
|
|
4
|
-
def self.create(name)
|
|
5
|
-
params = { name: name }
|
|
6
|
-
new(params).create
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def initialize(params)
|
|
10
|
-
@params = params
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def create
|
|
14
|
-
saved_list = list_repo.save(list)
|
|
15
|
-
saved_list.id
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
private
|
|
19
|
-
|
|
20
|
-
def list
|
|
21
|
-
Bulldoggy::Entities::List.new(@params[:name])
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def list_repo
|
|
25
|
-
Bulldoggy::Repository.for(:list)
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
data/spec/entities/list_spec.rb
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe Bulldoggy::Entities::List do
|
|
4
|
-
subject(:list) { described_class }
|
|
5
|
-
|
|
6
|
-
describe 'instantiating a new list' do
|
|
7
|
-
let(:name) { 'my awesome list name' }
|
|
8
|
-
|
|
9
|
-
it 'instantiates a new list with a name' do
|
|
10
|
-
list.new(name).should be_kind_of(list)
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
end
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe Bulldoggy::Repositories::InMemory::Lists do
|
|
4
|
-
subject(:lists) { described_class.new }
|
|
5
|
-
|
|
6
|
-
describe '#save' do
|
|
7
|
-
let(:list) { Bulldoggy::Entities::List.new('hello world list') }
|
|
8
|
-
|
|
9
|
-
it 'saves the list' do
|
|
10
|
-
lists.save(list)
|
|
11
|
-
expect { lists.save(list) }.to change { lists.all.size }.by(1)
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe Bulldoggy::UseCases::ListCreator do
|
|
4
|
-
subject(:creator) { described_class }
|
|
5
|
-
|
|
6
|
-
describe '.create' do
|
|
7
|
-
subject(:create) { creator.create(name) }
|
|
8
|
-
|
|
9
|
-
let(:name) { 'Learning Clean Architecture' }
|
|
10
|
-
let(:list_repo) { Bulldoggy::Repository.for(:list) }
|
|
11
|
-
|
|
12
|
-
it 'creates a list' do
|
|
13
|
-
expect { create }.to change { list_repo.all.size }.by(1)
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
it 'responds the list id' do
|
|
17
|
-
create.should == list_repo.all.size
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|