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,24 @@
1
+ # Get rid of Gemfile.lock, which is inappropriate in a gem.
2
+ Gemfile.lock
3
+ *.rbc
4
+ *.sassc
5
+ .sass-cache
6
+ capybara-*.html
7
+ .rspec
8
+ .bundle/
9
+ vendor/bundle
10
+ log/*
11
+ tmp/*
12
+ db/*.sqlite3
13
+ public/system/*
14
+ coverage/
15
+ pkg/
16
+ test/dummy/
17
+ spec/tmp/*
18
+ .yardoc
19
+ doc/
20
+ **.orig
21
+ rerun.txt
22
+ pickle-email-*.html
23
+ spec/internal/log
24
+ .rvmrc
@@ -0,0 +1,28 @@
1
+ language: ruby
2
+ bundler_args: --without development
3
+ before_install:
4
+ - cd $GEM
5
+ - export BUNDLE_GEMFILE="`pwd`/Gemfile"
6
+ script: bundle exec rspec spec --colour
7
+ rvm:
8
+ - 2.0.0
9
+ - 1.9.3
10
+ - rbx-19mode
11
+ - jruby-19mode
12
+ env:
13
+ - GEM=adapters
14
+ - GEM=core
15
+ - GEM=delivery/backend
16
+ - GEM=delivery/frontend
17
+ notifications:
18
+ email: false
19
+ irc:
20
+ use_notice: true
21
+ skip_join: true
22
+ channels:
23
+ - "irc.freenode.org#afterburner"
24
+ campfire:
25
+ on_success: always
26
+ on_failure: always
27
+ rooms:
28
+ - secure: "X5X39BTgXacSdc32F8mIjJKPqm5dZzmgZfJ14qYpJeMETTdA5JfByt2uCfU8\njJkkxT+XGWta0bSSlRIHQJO6pK26U94A95VYDX0jNuneKEnsoAsqJ6U0VY6v\nH5oxXMAZ2perP/FH9ZsPNR+ulyFfbMQCeGPJw5AXKZQqzf6qPOI="
@@ -0,0 +1,8 @@
1
+ --main README.md
2
+ -e ./yard/setup.rb
3
+ --markup-provider=kramdown
4
+ --markup=markdown
5
+ --asset documentation/architecture.png:architecture.png
6
+ -
7
+ README.md
8
+ documentation/architecture.md
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ group :development, :test do
6
+ gem 'rspec'
7
+ gem 'capybara'
8
+ gem 'pry'
9
+ gem 'pry-nav'
10
+ end
11
+
12
+ group :development do
13
+ gem 'yard', "~> 0.8.4.1"
14
+ gem 'rdoc'
15
+ gem 'kramdown'
16
+ end
data/LICENSE ADDED
@@ -0,0 +1,27 @@
1
+ Copyright (c) 2013 The Afterburner Project
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+
7
+ - Redistributions of source code must retain the above copyright notice, this
8
+ list of conditions and the following disclaimer.
9
+
10
+ - Redistributions in binary form must reproduce the above copyright notice,
11
+ this list of conditions and the following disclaimer in the documentation
12
+ and/or other materials provided with the distribution.
13
+
14
+ - Neither the name of The Afterburner Project nor the names of its contributors
15
+ may be used to endorse or promote products derived from this software without
16
+ specific prior written permission.
17
+
18
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,72 @@
1
+ # ABC - Afterburner CMS
2
+ ------
3
+
4
+ ## We make building sites as easy as 1-2-3.
5
+
6
+ ### 1. Install the gem.
7
+
8
+ Grab it off of rubygems with:
9
+
10
+ ```ruby
11
+ gem install abc
12
+ ```
13
+
14
+ Add it to an existing Rails project:
15
+
16
+ ```ruby
17
+ gem 'abc'
18
+ ```
19
+
20
+ Or fetch it directly from Github:
21
+
22
+ ```ruby
23
+ gem 'abc', :git => 'git://github.com/afterburnercms/afterburnercms.git'
24
+ ```
25
+
26
+ ### 2. ???
27
+
28
+ TODO: Fill this in
29
+
30
+ ### 3. Profit!
31
+
32
+ ![Please!](http://i2.kym-cdn.com/photos/images/newsfeed/000/264/200/acb.jpg)
33
+
34
+ ## Using it with Rails
35
+ You need to mount both the backend (administrative section) and the frontend (user-facing section) in your rails app. This can be accomplished by adding the following to your `config/routes.rb`:
36
+
37
+ ```ruby
38
+ mount Abc::Backend::Engine => '/admin'
39
+ mount Abc::Frontend::Engine => '/'
40
+ ```
41
+
42
+ *NOTE:* Do not use the `:as` option when mounting the Afterburner engines. This will yield unfavorable results / all manner of brokenness.
43
+
44
+
45
+ ## Development
46
+ To run the tests inside a subproject (i.e. `/core`):
47
+
48
+ ```shell
49
+ bundle
50
+ bundle exec rspec spec
51
+ ```
52
+
53
+ To run all tests:
54
+
55
+ ```shell
56
+ script/rspec
57
+ ```
58
+
59
+ To bundle install for all the projects:
60
+ ```shell
61
+ script/bundle
62
+ ```
63
+
64
+ To run some command in all sub-projects:
65
+ ```shell
66
+ script/run somecommand
67
+ ```
68
+
69
+ To list out the sub-projects:
70
+ ```shell
71
+ script/projects
72
+ ```
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,20 @@
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"
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
+ end
@@ -0,0 +1,19 @@
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 'pry'
10
+ gem 'pry-nav'
11
+ end
12
+ end
13
+
14
+ group :development do
15
+ gem 'yard', "~> 0.8.4.1"
16
+ gem 'rdoc'
17
+ end
18
+
19
+ gem 'abc', :path => '../'
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,24 @@
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-adapters"
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
+ s.add_dependency 'hyperion-api'
23
+ s.add_dependency 'hyperion-sqlite'
24
+ end
@@ -0,0 +1,43 @@
1
+ # TODO: These should probably be namespaced under hyperion, too, since they are
2
+ # explicitly relevant to it.
3
+ # Thought: move the actual domain-specific query objects into the DSL, and use
4
+ # this as the cross-barrier interface.
5
+ # That would let us do something to standardize the interface so we could potentially
6
+ # work with AR.
7
+
8
+ module Abc
9
+ module Adapters
10
+ module Persistence
11
+ module Repositories
12
+ class Base
13
+ class << self
14
+
15
+ # Serialize a hash to the datastore.
16
+ def store(values)
17
+ Hyperion.save({:kind => kind}.merge(values))
18
+ end
19
+
20
+ # Find an entity by its key.
21
+ def find(key)
22
+ Hyperion.find_by_key(key)
23
+ end
24
+
25
+ # Search for an entity.
26
+ def search(options = {})
27
+ Hyperion.find_by_kind(kind, options)
28
+ end
29
+
30
+ protected
31
+ def kind
32
+ raise "Kind was not specified in repository."
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+
41
+
42
+
43
+
@@ -0,0 +1,18 @@
1
+ require_relative 'base'
2
+
3
+ module Abc
4
+ module Adapters
5
+ module Persistence
6
+ module Repositories
7
+ class Page < Base
8
+ class << self
9
+ protected
10
+ def kind
11
+ :page
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ require_relative 'base'
2
+
3
+ module Abc
4
+ module Adapters
5
+ module Persistence
6
+ module Repositories
7
+ class Text < Base
8
+ class << self
9
+ protected
10
+ def kind
11
+ :text
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,17 @@
1
+ $LOAD_PATH.push File.expand_path('../../abc', __FILE__)
2
+ require 'adapters/config'
3
+ require 'adapters/persistence/repositories/text'
4
+ require 'adapters/persistence/repositories/page'
5
+
6
+ module Abc
7
+ module Adapters
8
+ extend Config
9
+
10
+ # Override this if you want to change the datastore
11
+ def self.enable_datastore!
12
+ Hyperion.datastore = Abc::Adapters.datastore_from_options(Abc::Adapters.datastore_options)
13
+ end
14
+ end
15
+ end
16
+
17
+ Abc::Adapters.enable_datastore!
@@ -0,0 +1,29 @@
1
+ require 'hyperion'
2
+
3
+ module Abc
4
+ module Adapters
5
+ module Config
6
+
7
+ def datastore_from_options(opts)
8
+ Hyperion.datastore = Hyperion.new_datastore(*opts) if use_datastore?
9
+ end
10
+
11
+ def use_datastore?
12
+ @use_datastore.nil? ? true : @use_datastore
13
+ end
14
+
15
+ def use_datastore=(val)
16
+ @use_datastore = val
17
+ end
18
+
19
+ def datastore_options
20
+ @datastore_options ||= [:memory]
21
+ end
22
+
23
+ def datastore_options=(opts)
24
+ @datastore_options = opts
25
+ end
26
+ end
27
+ end
28
+ end
29
+
@@ -0,0 +1,45 @@
1
+ require 'spec_helper'
2
+
3
+ class MockRepo < Abc::Adapters::Persistence::Repositories::Base
4
+ def self.kind; :mock; end
5
+ end
6
+
7
+ module Abc
8
+ module Adapters
9
+ module Persistence
10
+ module Repositories
11
+ describe Base do
12
+ context "without kind" do
13
+ let(:repo) { Base }
14
+ it "should raise an error" do
15
+ lambda{ repo.send(:kind) }.should raise_error
16
+ end
17
+ end
18
+
19
+ context "with kind" do
20
+ let(:repo) { MockRepo }
21
+ let(:hash) { {:text => 'giggity'} }
22
+
23
+ # Truncate each run.
24
+ before(:each) { Abc::Adapters.enable_datastore! }
25
+
26
+ it "can store an item" do
27
+ Text.store(hash)[:text].should == hash[:text]
28
+ end
29
+
30
+ it "can retrieve an item by key" do
31
+ key = repo.store(hash)[:key]
32
+ repo.find(key)[:text].should == hash[:text]
33
+ end
34
+
35
+ it "can find an item by attributes" do
36
+ key = Text.store(hash)[:key]
37
+ result = Text.search(:filters => [[:text, '=', hash[:text]]])
38
+ result.first[:key].should == key
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ module Abc
4
+ module Adapters
5
+ module Persistence
6
+ module Repositories
7
+ describe Page do
8
+ it "should be of kind page" do
9
+ Page.send(:kind).should == :page
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end