abc-core 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/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 => '../'
@@ -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
+
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+ require 'abc/entities/pages/page'
3
+
4
+ module Abc
5
+ module Entities
6
+ describe Page do
7
+ let(:title) { "Afterburner" }
8
+ subject { Page.new(title) }
9
+
10
+ it "has a title" do
11
+ subject.title.should == title
12
+ end
13
+
14
+ it "can be hashified" do
15
+ subject.to_hash.should == {:title => title}
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+ require 'abc/entities/view/viewable_presenter'
3
+
4
+ module Abc
5
+ describe ViewablePresenter do
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+ require 'abc/entities/view/viewable'
3
+
4
+ module Abc
5
+ describe Viewable do
6
+ end
7
+ end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+ require 'abc/interactors/creates_menu'
3
+
4
+ module Abc
5
+ module Interactors
6
+ describe CreatesMenu do
7
+ let(:menu_entries) do
8
+ [{:title => "One", :children => [{ :title => "One first child"}]}]
9
+ end
10
+
11
+ describe ".new" do
12
+ it "creates new menu" do
13
+ menu_creator = CreatesMenu.send(:new, [])
14
+ expect(menu_creator.to_response).to be_kind_of(Abc::Menu)
15
+ end
16
+
17
+ it "adds menu entries to menu" do
18
+ menu_creator = CreatesMenu.send(:new, menu_entries)
19
+ menu_creator.menu.entries.each do |menu_entry|
20
+ expect(menu_entry).to be_kind_of(Abc::MenuEntry)
21
+ end
22
+ end
23
+ end
24
+
25
+ it "returns a menu" do
26
+ menu_creator = CreatesMenu.call(menu_entries)
27
+ expect(menu_creator).to be_kind_of(Abc::Menu)
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+ require 'abc/interactors/pages/builds_page'
3
+
4
+ module Abc
5
+ module Interactors
6
+ describe BuildsPage do
7
+ let(:data) {{:title => "More like Awesome-burner, amirite??"}}
8
+
9
+ it "returns a page" do
10
+ builder = BuildsPage.call(data)
11
+ expect(builder).to be_kind_of(Abc::Entities::Page)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,10 @@
1
+ $LOAD_PATH.push File.expand_path('../../', __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-core'
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: abc-core
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - The Afterburner CMS Team
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-03-18 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: abc
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - '='
20
+ - !ruby/object:Gem::Version
21
+ version: 0.0.1
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - '='
28
+ - !ruby/object:Gem::Version
29
+ version: 0.0.1
30
+ description: An easy-to-use, easy-to-extend CMS.
31
+ email:
32
+ - info@afterburnercms.com
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - Gemfile
38
+ - Guardfile
39
+ - Rakefile
40
+ - abc-core.gemspec
41
+ - abc/entities/content/text.rb
42
+ - abc/entities/menu/menu.rb
43
+ - abc/entities/menu/menu_entry.rb
44
+ - abc/entities/menu/menuable.rb
45
+ - abc/entities/menu/path.rb
46
+ - abc/entities/pages/page.rb
47
+ - abc/entities/view/viewable.rb
48
+ - abc/entities/view/viewable_presenter.rb
49
+ - abc/interactors/creates_menu.rb
50
+ - abc/interactors/pages/builds_page.rb
51
+ - lib/abc-core.rb
52
+ - spec/entities/content/text_spec.rb
53
+ - spec/entities/menu/menu_entry_spec.rb
54
+ - spec/entities/menu/menu_spec.rb
55
+ - spec/entities/menu/menuable_spec.rb
56
+ - spec/entities/menu/path_spec.rb
57
+ - spec/entities/pages/page_spec.rb
58
+ - spec/entities/view/viewable_presenter_spec.rb
59
+ - spec/entities/view/viewable_spec.rb
60
+ - spec/interactors/creates_menu_spec.rb
61
+ - spec/interactors/pages/builds_page_spec.rb
62
+ - spec/spec_helper.rb
63
+ homepage: http://www.afterburnercms.com/
64
+ licenses: []
65
+ post_install_message:
66
+ rdoc_options: []
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ! '>='
73
+ - !ruby/object:Gem::Version
74
+ version: 1.9.3
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ none: false
77
+ requirements:
78
+ - - ! '>='
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubyforge_project:
83
+ rubygems_version: 1.8.24
84
+ signing_key:
85
+ specification_version: 3
86
+ summary: An easy-to-use, easy-to-extend CMS.
87
+ test_files:
88
+ - spec/entities/content/text_spec.rb
89
+ - spec/entities/menu/menu_entry_spec.rb
90
+ - spec/entities/menu/menu_spec.rb
91
+ - spec/entities/menu/menuable_spec.rb
92
+ - spec/entities/menu/path_spec.rb
93
+ - spec/entities/pages/page_spec.rb
94
+ - spec/entities/view/viewable_presenter_spec.rb
95
+ - spec/entities/view/viewable_spec.rb
96
+ - spec/interactors/creates_menu_spec.rb
97
+ - spec/interactors/pages/builds_page_spec.rb
98
+ - spec/spec_helper.rb
99
+ has_rdoc: