abc 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +24 -0
- data/.travis.yml +28 -0
- data/.yardopts +8 -0
- data/Gemfile +16 -0
- data/LICENSE +27 -0
- data/README.md +72 -0
- data/Rakefile +1 -0
- data/abc.gemspec +20 -0
- data/adapters/Gemfile +19 -0
- data/adapters/Rakefile +1 -0
- data/adapters/abc-adapters.gemspec +24 -0
- data/adapters/abc/adapters/persistence/repositories/base.rb +43 -0
- data/adapters/abc/adapters/persistence/repositories/page.rb +18 -0
- data/adapters/abc/adapters/persistence/repositories/text.rb +18 -0
- data/adapters/lib/abc-adapters.rb +17 -0
- data/adapters/lib/adapters/config.rb +29 -0
- data/adapters/spec/adapters/persistence/repositories/base_spec.rb +45 -0
- data/adapters/spec/adapters/persistence/repositories/page_spec.rb +15 -0
- data/adapters/spec/adapters/persistence/repositories/text_spec.rb +15 -0
- data/adapters/spec/lib/adapters/config_spec.rb +30 -0
- data/adapters/spec/spec_helper.rb +10 -0
- data/contributing.md +66 -0
- data/core/Gemfile +20 -0
- data/core/Guardfile +6 -0
- data/core/Rakefile +1 -0
- data/core/abc-core.gemspec +22 -0
- data/core/abc/entities/content/text.rb +19 -0
- data/core/abc/entities/menu/menu.rb +16 -0
- data/core/abc/entities/menu/menu_entry.rb +20 -0
- data/core/abc/entities/menu/menuable.rb +6 -0
- data/core/abc/entities/menu/path.rb +17 -0
- data/core/abc/entities/pages/page.rb +16 -0
- data/core/abc/entities/view/viewable.rb +7 -0
- data/core/abc/entities/view/viewable_presenter.rb +9 -0
- data/core/abc/interactors/creates_menu.rb +23 -0
- data/core/abc/interactors/pages/builds_page.rb +21 -0
- data/core/lib/abc-core.rb +1 -0
- data/core/spec/entities/content/text_spec.rb +37 -0
- data/core/spec/entities/menu/menu_entry_spec.rb +11 -0
- data/core/spec/entities/menu/menu_spec.rb +17 -0
- data/core/spec/entities/menu/menuable_spec.rb +7 -0
- data/core/spec/entities/menu/path_spec.rb +8 -0
- data/core/spec/entities/pages/page_spec.rb +19 -0
- data/core/spec/entities/view/viewable_presenter_spec.rb +7 -0
- data/core/spec/entities/view/viewable_spec.rb +7 -0
- data/core/spec/interactors/creates_menu_spec.rb +31 -0
- data/core/spec/interactors/pages/builds_page_spec.rb +15 -0
- data/core/spec/spec_helper.rb +10 -0
- data/delivery/backend/Gemfile +44 -0
- data/delivery/backend/Guardfile +6 -0
- data/delivery/backend/Rakefile +1 -0
- data/delivery/backend/abc-backend.gemspec +26 -0
- data/delivery/backend/app/controllers/abc/application_controller.rb +6 -0
- data/delivery/backend/app/controllers/abc/backend/base_controller.rb +8 -0
- data/delivery/backend/app/presenters/abc/html/menu_entry_presenter.rb +87 -0
- data/delivery/backend/app/presenters/abc/html/menu_presenter.rb +68 -0
- data/delivery/backend/app/views/abc/backend/base/index.html.erb +1 -0
- data/delivery/backend/config.ru +6 -0
- data/delivery/backend/config/routes.rb +3 -0
- data/delivery/backend/lib/abc-backend.rb +2 -0
- data/delivery/backend/lib/abc/backend/engine.rb +7 -0
- data/delivery/backend/spec/integration/backend_spec.rb +10 -0
- data/delivery/backend/spec/integration/menu_spec.rb +18 -0
- data/delivery/backend/spec/internal/config/database.yml +3 -0
- data/delivery/backend/spec/internal/config/routes.rb +5 -0
- data/delivery/backend/spec/internal/db/schema.rb +3 -0
- data/delivery/backend/spec/internal/log/.gitignore +1 -0
- data/delivery/backend/spec/internal/public/favicon.ico +0 -0
- data/delivery/backend/spec/presenters/html/menu_entry_presenter_spec.rb +49 -0
- data/delivery/backend/spec/presenters/html/menu_presenter_spec.rb +74 -0
- data/delivery/backend/spec/spec_helper.rb +14 -0
- data/delivery/backend/spec/tiny_spec_helper.rb +13 -0
- data/delivery/frontend/Gemfile +45 -0
- data/delivery/frontend/Guardfile +6 -0
- data/delivery/frontend/Rakefile +1 -0
- data/delivery/frontend/abc-frontend.gemspec +29 -0
- data/delivery/frontend/app/conductors/abc/frontend/conductors/shows_page.rb +69 -0
- data/delivery/frontend/app/controllers/abc/application_controller.rb +6 -0
- data/delivery/frontend/app/controllers/abc/frontend/base_controller.rb +8 -0
- data/delivery/frontend/app/controllers/abc/frontend/pages_controller.rb +12 -0
- data/delivery/frontend/app/presenters/abc/html/page_presenter.rb +13 -0
- data/delivery/frontend/app/views/abc/frontend/base/index.html.erb +1 -0
- data/delivery/frontend/app/views/abc/frontend/pages/show.html.haml +1 -0
- data/delivery/frontend/config.ru +6 -0
- data/delivery/frontend/config/routes.rb +5 -0
- data/delivery/frontend/lib/abc-frontend.rb +3 -0
- data/delivery/frontend/lib/abc/frontend/engine.rb +7 -0
- data/delivery/frontend/spec/conductors/abc/frontend/shows_page_spec.rb +41 -0
- data/delivery/frontend/spec/integration/backend_spec.rb +10 -0
- data/delivery/frontend/spec/integration/pages_spec.rb +11 -0
- data/delivery/frontend/spec/internal/config/database.yml +3 -0
- data/delivery/frontend/spec/internal/config/routes.rb +5 -0
- data/delivery/frontend/spec/internal/db/schema.rb +3 -0
- data/delivery/frontend/spec/internal/log/.gitignore +1 -0
- data/delivery/frontend/spec/internal/public/favicon.ico +0 -0
- data/delivery/frontend/spec/presenters/html/page_presenter_spec.rb +19 -0
- data/delivery/frontend/spec/spec_helper.rb +15 -0
- data/delivery/frontend/spec/tiny_spec_helper.rb +14 -0
- data/documentation/architecture.md +131 -0
- data/documentation/architecture.png +0 -0
- data/documentation/architecture.svg +1192 -0
- data/lib/abc.rb +7 -0
- data/lib/abc/base_conductor.rb +63 -0
- data/lib/abc/base_conductor_spec.rb +9 -0
- data/lib/abc/base_interactor.rb +17 -0
- data/lib/abc/package.rb +11 -0
- data/script/bundle +2 -0
- data/script/projects +2 -0
- data/script/rspec +2 -0
- data/script/run +8 -0
- data/spec/lib/abc/base_interactor_spec.rb +11 -0
- data/spec/shared/callable.rb +24 -0
- data/yard/setup.rb +10 -0
- data/yard/templates/default/fulldoc/html/css/common.css +109 -0
- data/yard/templates/default/layout/html/layout.erb +56 -0
- metadata +163 -0
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class Mock; end
|
4
|
+
|
5
|
+
|
6
|
+
module Abc
|
7
|
+
module Adapters
|
8
|
+
describe Config do
|
9
|
+
subject { Mock.send(:extend, Config) }
|
10
|
+
|
11
|
+
it "uses a datastore unless specified otherwise" do
|
12
|
+
subject.use_datastore?.should be_true
|
13
|
+
end
|
14
|
+
|
15
|
+
it "doesn't use a datastore if told not to" do
|
16
|
+
subject.use_datastore = false
|
17
|
+
subject.use_datastore?.should be_false
|
18
|
+
end
|
19
|
+
|
20
|
+
it "uses a memory datastore by default" do
|
21
|
+
subject.datastore_options.should == [:memory]
|
22
|
+
end
|
23
|
+
|
24
|
+
it "allows overriding options for datastores" do
|
25
|
+
subject.datastore_options = [:sqlite]
|
26
|
+
subject.datastore_options.should == [:sqlite]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/contributing.md
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
# Contribution Guidelines #
|
2
|
+
|
3
|
+
Thank you for your interest! There are a few ways you can help make this project better!
|
4
|
+
|
5
|
+
## Submitting a new issue ##
|
6
|
+
|
7
|
+
If you want to ensure that your issue gets fixed *fast* you should
|
8
|
+
attempt to reproduce the issue in an isolated example application that
|
9
|
+
you can share.
|
10
|
+
|
11
|
+
## Making a pull request ##
|
12
|
+
|
13
|
+
If you'd like to submit a pull request please adhere to the following:
|
14
|
+
|
15
|
+
1. Your code *must* be tested. Please TDD your code!
|
16
|
+
2. No single-character variables
|
17
|
+
3. Two-spaces instead of tabs
|
18
|
+
4. Single-quotes instead of double-quotes unless you are using string
|
19
|
+
interpolation or escapes.
|
20
|
+
5. General Rails/Ruby naming conventions for files and classes
|
21
|
+
6. *Do not* use Ruby 1.9 stabby proc syntax
|
22
|
+
|
23
|
+
Plase note that you must adhere to each of the above mentioned rules.
|
24
|
+
Failure to do so will result in an immediate closing of the pull
|
25
|
+
request. If you update and rebase the pull request to follow the
|
26
|
+
guidelines your pull request will be re-opened and considered for
|
27
|
+
inclusion.
|
28
|
+
|
29
|
+
## Chief Contributors
|
30
|
+
|
31
|
+
- Josh Adams ([knewter](https://github.com/knewter/) / IRC: jadams)
|
32
|
+
- Philip Arndt ([parndt](https://github.com/parndt/) / IRC: parndt)
|
33
|
+
- Ryan Bigg ([Radar](https://github.com/radar/) / IRC: Radar)
|
34
|
+
- Johan Bruning ([JohanB](https://github.com/johanb/) / IRC: gidogeek)
|
35
|
+
- Garrett Heinlen ([GoGoGarrett](https://github.com/gogogarrett/) / IRC: GoGoGarrett)
|
36
|
+
- Andrew Hooker ([GeekOnCoffee](https://github.com/geekoncoffee/) / IRC: GeekOnCoffee)
|
37
|
+
- Uģis Ozols ([ugisozols](https://github.com/ugisozols/) / IRC: ugisozols)
|
38
|
+
- Rob Yurkowski ([robyurkowski](https://github.com/robyurkowski/) / IRC: robyurkowski)
|
39
|
+
|
40
|
+
And with much thanks to the following people:
|
41
|
+
|
42
|
+
- Wiljo Rouwenhorst (logos, design)
|
43
|
+
|
44
|
+
## Learn & listen
|
45
|
+
|
46
|
+
* IRC channel: irc.freenode.net #afterburner
|
47
|
+
|
48
|
+
## Adding new features
|
49
|
+
|
50
|
+
- Please open a pull request for your code change, no matter how small the change. As irritating as that is, someone should be around to commit it at almost all hours of the day, so you shouldn't be delayed that long.
|
51
|
+
- Please keep the master branch deployable at all times. New features in branches. Bugfixes in branches.
|
52
|
+
- Rebase where possible--don't merge.
|
53
|
+
- Name your branches descriptively, and delete them when they're merged in.
|
54
|
+
|
55
|
+
### Documentation
|
56
|
+
|
57
|
+
All code should be thoroughly documented using Markdown with YARD tags. You can run the YARD server and have it reload while you work so you can preview your changes:
|
58
|
+
|
59
|
+
```shell
|
60
|
+
yard server --reload
|
61
|
+
```
|
62
|
+
|
63
|
+
Then tune in to `locahost:8808` to see what's going on.
|
64
|
+
|
65
|
+
Don’t get discouraged! We estimate that the response time from the
|
66
|
+
maintainers is around: NaN
|
data/core/Gemfile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
gemspec
|
4
|
+
|
5
|
+
group :development, :test do
|
6
|
+
gem 'rspec'
|
7
|
+
unless ENV['TRAVIS']
|
8
|
+
gem 'simplecov'
|
9
|
+
gem 'guard-shell'
|
10
|
+
gem 'rb-fsevent', '~> 0.9', :platform => :ruby
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
group :development do
|
15
|
+
gem 'yard', "~> 0.8.4.1"
|
16
|
+
gem 'rdoc'
|
17
|
+
gem 'kramdown'
|
18
|
+
end
|
19
|
+
|
20
|
+
gem 'abc', :path => '../'
|
data/core/Guardfile
ADDED
data/core/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# Maintain your gem's version:
|
2
|
+
require File.expand_path('../lib/abc/package', File.dirname(__FILE__))
|
3
|
+
|
4
|
+
# Describe your gem and declare its dependencies:
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "abc-core"
|
7
|
+
s.version = Abc::VERSION
|
8
|
+
s.authors = Abc::AUTHORS
|
9
|
+
s.email = Abc::EMAILS
|
10
|
+
s.homepage = Abc::HOMEPAGE
|
11
|
+
s.summary = Abc::SUMMARY
|
12
|
+
s.description = Abc::DESCRIPTION
|
13
|
+
|
14
|
+
s.require_paths = ["lib"]
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split($/)
|
17
|
+
s.test_files = s.files.grep(%r{^(spec)/})
|
18
|
+
|
19
|
+
s.required_ruby_version = '>= 1.9.3' # that's right.
|
20
|
+
|
21
|
+
s.add_dependency 'abc', Abc::VERSION
|
22
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Abc
|
2
|
+
|
3
|
+
# This is the actual main menu class. It holds logic for spitting out menus.
|
4
|
+
# It doesn't know how to render each node; it just knows how to spit out a
|
5
|
+
# tree.
|
6
|
+
class Menu
|
7
|
+
|
8
|
+
# This holds a tree of entries.
|
9
|
+
attr_accessor :entries
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
self.entries = []
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Abc
|
2
|
+
# A MenuEntry is the class that actually holds entries to the {Menu} class.
|
3
|
+
# This is the parent type of the subtypes that can be registered
|
4
|
+
# ({Menuable}s). Note that these do not define entry points; those are done
|
5
|
+
# by {Path}s, though you shouldn't have to ever see a Path unless you define
|
6
|
+
# an additional one for a {Viewable}. If you have defined an additional path,
|
7
|
+
# then the interface should let you specify which you want to use for the
|
8
|
+
# menu entry.
|
9
|
+
class MenuEntry
|
10
|
+
attr_accessor :title, :children
|
11
|
+
|
12
|
+
def initialize(title, children = [])
|
13
|
+
self.title = title
|
14
|
+
self.children = Array(children).map do |child|
|
15
|
+
self.class.new(child[:title], child[:children])
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Abc
|
2
|
+
# Path is an object that represents a valid entry point to a viewable. This
|
3
|
+
# is a mostly invisible object that's created when you set a custom URL on a
|
4
|
+
# {MenuEntry}, but this makes it possible to also add custom, non-canonical
|
5
|
+
# entry points to {Viewable}s.
|
6
|
+
#
|
7
|
+
# This will be particularly valuable for a number of reasons:
|
8
|
+
#
|
9
|
+
# 1. Custom URLs, obviously;
|
10
|
+
# 2. Entry points with additional options: you could specify an additional
|
11
|
+
# route that would pass along information to the {Viewable} or its renderer,
|
12
|
+
# such as whether comments should be displayed. A trivial example would be a
|
13
|
+
# Path that's used in a BlogPost-style {MenuEntry} that shows comments or not
|
14
|
+
# (i.e. /blog/post/blah/no-comments).
|
15
|
+
class Path
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
module Abc
|
2
|
+
# This is a superclass that's used to define some sensible defaults and
|
3
|
+
# provide additional methods to presenters, which are used to determine how
|
4
|
+
# to present a {Viewable} for a specific medium. Without reference to the
|
5
|
+
# medium, these are just HTML presenters... but we could have something like
|
6
|
+
# a JsonPagePresenter, too.
|
7
|
+
class ViewablePresenter
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'abc'
|
2
|
+
require 'entities/menu/menu'
|
3
|
+
require 'entities/menu/menu_entry'
|
4
|
+
|
5
|
+
module Abc
|
6
|
+
module Interactors
|
7
|
+
class CreatesMenu < Abc::BaseInteractor
|
8
|
+
attr_reader :menu
|
9
|
+
|
10
|
+
def to_response
|
11
|
+
menu
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(menu_entries, options = {})
|
15
|
+
@menu = Menu.new
|
16
|
+
@menu.entries = menu_entries.map do |entry|
|
17
|
+
MenuEntry.new entry[:title], entry[:children]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'abc'
|
2
|
+
require 'entities/pages/page'
|
3
|
+
|
4
|
+
module Abc
|
5
|
+
module Interactors
|
6
|
+
class BuildsPage < Abc::BaseInteractor
|
7
|
+
attr_reader :page
|
8
|
+
|
9
|
+
def to_response
|
10
|
+
page
|
11
|
+
end
|
12
|
+
|
13
|
+
protected
|
14
|
+
def initialize(data, options = {})
|
15
|
+
@page = Entities::Page.new(data[:title])
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
$LOAD_PATH.push File.expand_path('../../abc', __FILE__)
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'abc/entities/content/text'
|
3
|
+
|
4
|
+
module Abc
|
5
|
+
module Entities
|
6
|
+
module Content
|
7
|
+
describe Text do
|
8
|
+
let(:text) { "Afterburner" }
|
9
|
+
|
10
|
+
subject { Text.new(text) }
|
11
|
+
|
12
|
+
it 'encapsulates a block of text' do
|
13
|
+
subject.text.should == text
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'responds to to_s' do
|
17
|
+
subject.to_s.should == text
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'accepts text in the initialize call' do
|
21
|
+
subject.class.new(text).to_s.should == text
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'requires text in the initialize call' do
|
25
|
+
expect { subject.class.new }.to raise_exception(ArgumentError)
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'can be hashified' do
|
29
|
+
text1 = text
|
30
|
+
hsh = {:text => text1}
|
31
|
+
subject.class.new(text).to_hash.should == hsh
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'abc/entities/menu/menu_entry'
|
3
|
+
|
4
|
+
module Abc
|
5
|
+
describe MenuEntry do
|
6
|
+
it "wraps passed children" do
|
7
|
+
e = MenuEntry.new('My title', [{:title => 'Child 1'}])
|
8
|
+
expect(e.children.first).to be_kind_of Abc::MenuEntry
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'abc/entities/menu/menu'
|
3
|
+
|
4
|
+
module Abc
|
5
|
+
describe Menu do
|
6
|
+
it "lists nothing when empty" do
|
7
|
+
subject.entries.should be_empty
|
8
|
+
end
|
9
|
+
|
10
|
+
it "lists root nodes" do
|
11
|
+
entry1 = "node"
|
12
|
+
entry2 = "node2"
|
13
|
+
subject.entries = [entry1, entry2]
|
14
|
+
subject.entries.should == [entry1, entry2]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|