abc 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. data/.gitignore +24 -0
  2. data/.travis.yml +28 -0
  3. data/.yardopts +8 -0
  4. data/Gemfile +16 -0
  5. data/LICENSE +27 -0
  6. data/README.md +72 -0
  7. data/Rakefile +1 -0
  8. data/abc.gemspec +20 -0
  9. data/adapters/Gemfile +19 -0
  10. data/adapters/Rakefile +1 -0
  11. data/adapters/abc-adapters.gemspec +24 -0
  12. data/adapters/abc/adapters/persistence/repositories/base.rb +43 -0
  13. data/adapters/abc/adapters/persistence/repositories/page.rb +18 -0
  14. data/adapters/abc/adapters/persistence/repositories/text.rb +18 -0
  15. data/adapters/lib/abc-adapters.rb +17 -0
  16. data/adapters/lib/adapters/config.rb +29 -0
  17. data/adapters/spec/adapters/persistence/repositories/base_spec.rb +45 -0
  18. data/adapters/spec/adapters/persistence/repositories/page_spec.rb +15 -0
  19. data/adapters/spec/adapters/persistence/repositories/text_spec.rb +15 -0
  20. data/adapters/spec/lib/adapters/config_spec.rb +30 -0
  21. data/adapters/spec/spec_helper.rb +10 -0
  22. data/contributing.md +66 -0
  23. data/core/Gemfile +20 -0
  24. data/core/Guardfile +6 -0
  25. data/core/Rakefile +1 -0
  26. data/core/abc-core.gemspec +22 -0
  27. data/core/abc/entities/content/text.rb +19 -0
  28. data/core/abc/entities/menu/menu.rb +16 -0
  29. data/core/abc/entities/menu/menu_entry.rb +20 -0
  30. data/core/abc/entities/menu/menuable.rb +6 -0
  31. data/core/abc/entities/menu/path.rb +17 -0
  32. data/core/abc/entities/pages/page.rb +16 -0
  33. data/core/abc/entities/view/viewable.rb +7 -0
  34. data/core/abc/entities/view/viewable_presenter.rb +9 -0
  35. data/core/abc/interactors/creates_menu.rb +23 -0
  36. data/core/abc/interactors/pages/builds_page.rb +21 -0
  37. data/core/lib/abc-core.rb +1 -0
  38. data/core/spec/entities/content/text_spec.rb +37 -0
  39. data/core/spec/entities/menu/menu_entry_spec.rb +11 -0
  40. data/core/spec/entities/menu/menu_spec.rb +17 -0
  41. data/core/spec/entities/menu/menuable_spec.rb +7 -0
  42. data/core/spec/entities/menu/path_spec.rb +8 -0
  43. data/core/spec/entities/pages/page_spec.rb +19 -0
  44. data/core/spec/entities/view/viewable_presenter_spec.rb +7 -0
  45. data/core/spec/entities/view/viewable_spec.rb +7 -0
  46. data/core/spec/interactors/creates_menu_spec.rb +31 -0
  47. data/core/spec/interactors/pages/builds_page_spec.rb +15 -0
  48. data/core/spec/spec_helper.rb +10 -0
  49. data/delivery/backend/Gemfile +44 -0
  50. data/delivery/backend/Guardfile +6 -0
  51. data/delivery/backend/Rakefile +1 -0
  52. data/delivery/backend/abc-backend.gemspec +26 -0
  53. data/delivery/backend/app/controllers/abc/application_controller.rb +6 -0
  54. data/delivery/backend/app/controllers/abc/backend/base_controller.rb +8 -0
  55. data/delivery/backend/app/presenters/abc/html/menu_entry_presenter.rb +87 -0
  56. data/delivery/backend/app/presenters/abc/html/menu_presenter.rb +68 -0
  57. data/delivery/backend/app/views/abc/backend/base/index.html.erb +1 -0
  58. data/delivery/backend/config.ru +6 -0
  59. data/delivery/backend/config/routes.rb +3 -0
  60. data/delivery/backend/lib/abc-backend.rb +2 -0
  61. data/delivery/backend/lib/abc/backend/engine.rb +7 -0
  62. data/delivery/backend/spec/integration/backend_spec.rb +10 -0
  63. data/delivery/backend/spec/integration/menu_spec.rb +18 -0
  64. data/delivery/backend/spec/internal/config/database.yml +3 -0
  65. data/delivery/backend/spec/internal/config/routes.rb +5 -0
  66. data/delivery/backend/spec/internal/db/schema.rb +3 -0
  67. data/delivery/backend/spec/internal/log/.gitignore +1 -0
  68. data/delivery/backend/spec/internal/public/favicon.ico +0 -0
  69. data/delivery/backend/spec/presenters/html/menu_entry_presenter_spec.rb +49 -0
  70. data/delivery/backend/spec/presenters/html/menu_presenter_spec.rb +74 -0
  71. data/delivery/backend/spec/spec_helper.rb +14 -0
  72. data/delivery/backend/spec/tiny_spec_helper.rb +13 -0
  73. data/delivery/frontend/Gemfile +45 -0
  74. data/delivery/frontend/Guardfile +6 -0
  75. data/delivery/frontend/Rakefile +1 -0
  76. data/delivery/frontend/abc-frontend.gemspec +29 -0
  77. data/delivery/frontend/app/conductors/abc/frontend/conductors/shows_page.rb +69 -0
  78. data/delivery/frontend/app/controllers/abc/application_controller.rb +6 -0
  79. data/delivery/frontend/app/controllers/abc/frontend/base_controller.rb +8 -0
  80. data/delivery/frontend/app/controllers/abc/frontend/pages_controller.rb +12 -0
  81. data/delivery/frontend/app/presenters/abc/html/page_presenter.rb +13 -0
  82. data/delivery/frontend/app/views/abc/frontend/base/index.html.erb +1 -0
  83. data/delivery/frontend/app/views/abc/frontend/pages/show.html.haml +1 -0
  84. data/delivery/frontend/config.ru +6 -0
  85. data/delivery/frontend/config/routes.rb +5 -0
  86. data/delivery/frontend/lib/abc-frontend.rb +3 -0
  87. data/delivery/frontend/lib/abc/frontend/engine.rb +7 -0
  88. data/delivery/frontend/spec/conductors/abc/frontend/shows_page_spec.rb +41 -0
  89. data/delivery/frontend/spec/integration/backend_spec.rb +10 -0
  90. data/delivery/frontend/spec/integration/pages_spec.rb +11 -0
  91. data/delivery/frontend/spec/internal/config/database.yml +3 -0
  92. data/delivery/frontend/spec/internal/config/routes.rb +5 -0
  93. data/delivery/frontend/spec/internal/db/schema.rb +3 -0
  94. data/delivery/frontend/spec/internal/log/.gitignore +1 -0
  95. data/delivery/frontend/spec/internal/public/favicon.ico +0 -0
  96. data/delivery/frontend/spec/presenters/html/page_presenter_spec.rb +19 -0
  97. data/delivery/frontend/spec/spec_helper.rb +15 -0
  98. data/delivery/frontend/spec/tiny_spec_helper.rb +14 -0
  99. data/documentation/architecture.md +131 -0
  100. data/documentation/architecture.png +0 -0
  101. data/documentation/architecture.svg +1192 -0
  102. data/lib/abc.rb +7 -0
  103. data/lib/abc/base_conductor.rb +63 -0
  104. data/lib/abc/base_conductor_spec.rb +9 -0
  105. data/lib/abc/base_interactor.rb +17 -0
  106. data/lib/abc/package.rb +11 -0
  107. data/script/bundle +2 -0
  108. data/script/projects +2 -0
  109. data/script/rspec +2 -0
  110. data/script/run +8 -0
  111. data/spec/lib/abc/base_interactor_spec.rb +11 -0
  112. data/spec/shared/callable.rb +24 -0
  113. data/yard/setup.rb +10 -0
  114. data/yard/templates/default/fulldoc/html/css/common.css +109 -0
  115. data/yard/templates/default/layout/html/layout.erb +56 -0
  116. metadata +163 -0
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ module Abc
4
+ module Adapters
5
+ module Persistence
6
+ module Repositories
7
+ describe Text do
8
+ it "should be of kind text" do
9
+ Text.send(:kind).should == :text
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -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
@@ -0,0 +1,10 @@
1
+ $LOAD_PATH.push File.expand_path('../../abc/', __FILE__)
2
+
3
+ unless ENV['TRAVIS']
4
+ require 'simplecov'
5
+ SimpleCov.start do
6
+ add_filter "/spec/"
7
+ end
8
+ end
9
+
10
+ require 'abc-adapters'
@@ -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
@@ -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 => '../'
@@ -0,0 +1,6 @@
1
+ guard :shell do
2
+ watch(/\A.*\.(rb|erb|haml)\z/) do |m|
3
+ system "rspec spec"
4
+ system "date"
5
+ end
6
+ end
@@ -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,19 @@
1
+ module Abc
2
+ module Entities
3
+ module Content
4
+ class Text
5
+ attr_accessor :text
6
+
7
+ def initialize(text)
8
+ @text = text
9
+ end
10
+
11
+ def to_hash
12
+ {:text => text}
13
+ end
14
+
15
+ alias_method :to_s, :text
16
+ end
17
+ end
18
+ end
19
+ 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,6 @@
1
+ module Abc
2
+ # Menuable is the class that Datatypes implement for themselves when they
3
+ # should present themselves as valid types of {MenuEntry}.
4
+ class Menuable
5
+ end
6
+ 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,16 @@
1
+ module Abc
2
+ module Entities
3
+ class Page
4
+ attr_reader :title
5
+
6
+ def initialize(title)
7
+ @title = title
8
+ end
9
+
10
+ def to_hash
11
+ {:title => title}
12
+ end
13
+ end
14
+ end
15
+ end
16
+
@@ -0,0 +1,7 @@
1
+ module Abc
2
+ # This defines any class that is displayed as main content--i.e. blog post,
3
+ # page, resource (PDF or html or word doc), etc. These content types are
4
+ # tracked so we can have a list of what we can create at any given time.
5
+ class Viewable
6
+ end
7
+ 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
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+ require 'abc/entities/menu/menuable'
3
+
4
+ module Abc
5
+ describe Menuable do
6
+ end
7
+ end
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+ require 'abc/entities/menu/path'
3
+
4
+ module Abc
5
+ describe Path do
6
+ end
7
+ end
8
+