Permalink
Browse files

reconfigure application folders, implement as very raw rack app, just…

… for root
  • Loading branch information...
1 parent 16ab607 commit ef1fddf15eb1c46b5c7574e8e030347d81d5ff51 @wizardwerdna committed Jul 28, 2012
View
@@ -0,0 +1,3 @@
+require_relative 'interactors'
+require_relative 'boundaries'
+require_relative 'entities'
View
@@ -0,0 +1 @@
+require_relative 'boundaries/repository.rb'
View
@@ -0,0 +1,4 @@
+# This file is used by Rack-based servers to start the application.
+
+require ::File.expand_path('../main', __FILE__)
+run Bobbit::Main.new
View
@@ -0,0 +1 @@
+require_relative 'entities/page'
View
@@ -1,4 +0,0 @@
-require 'ostruct'
-class Entity < OpenStruct; end
-
-class Page < OpenStruct; end
View
@@ -0,0 +1,2 @@
+require_relative '../lib/entity'
+class Page < OpenStruct; end
View
@@ -0,0 +1 @@
+require_relative 'interactors/pages.rb'
View
@@ -1,3 +1,4 @@
+require_relative '../entities'
require_relative '../lib/interactor.rb'
module Pages
View
@@ -0,0 +1,2 @@
+require 'ostruct'
+class Entity < OpenStruct; end
View
@@ -8,7 +8,11 @@ def initialize request = {}
end
def execute
- raise "abstract class should not be executed"
+ raise "abstract class instance should not be executed"
end
+
+private
+
+ attr_reader :r
end
View
52 main.rb
@@ -0,0 +1,52 @@
+require_relative 'application'
+require_relative 'repositories/memory_repos'
+module Bobbit
+ class Main
+ def initialize
+ link_to_inmemory_repository
+ seed_repository
+ end
+ def call env
+ [200, {"content-type" => 'text/html'}, [response_html]]
+ end
+
+ def link_to_inmemory_repository
+ Repository.configure ({
+ Page => MemoryRepos::PageRepo.new
+ })
+ end
+
+ def seed_repository
+ [
+ Page.new(name: 'google', locator: 'http://www.google.com'),
+ Page.new(name: 'cnn', locator: 'http://www.cnn.com'),
+ Page.new(name: 'apple', locator: 'http://www.apple.com')
+ ].each{|each| Repository.for(Page).store each}
+ end
+
+ def response_html
+ <<-HTML
+ <HTML>
+ <HEAD>
+ <TITLE>List of Shortcuts</TITLE>
+ </HEAD>
+ <BODY>
+ <H1>List of Shortcuts</H1>
+ <TABLE style="outline: 2pt solid black;">
+ <TR><TH>Shortcut</TH><TH>Locator</TH></TR>
+ #{rows_html}
+ </TABLE>
+ </BODY>
+ </HTML>
+ HTML
+ end
+
+ def rows_html
+ Pages::All.new.execute.pages.map do |page|
+ "<TR><TD><A href=\"#{page.locator}\">#{page.name}</A></TD><TD>#{page.locator}</TD></TR>"
+ end.join("\n")
+ end
+
+ end
+
+end
View
@@ -0,0 +1,52 @@
+require_relative 'application'
+require_relative 'repositories/memory_repos'
+module Bobbit
+ class Main
+ def initialize
+ link_to_inmemory_repository
+ seed_repository
+ end
+ def call env
+ [200, {"content-type" => 'text/html'}, [response_html]]
+ end
+
+ def link_to_inmemory_repository
+ Repository.configure ({
+ Page => MemoryRepos::PageRepo.new
+ })
+ end
+
+ def seed_repository
+ [
+ Page.new(name: 'google', locator: 'http://www.google.com'),
+ Page.new(name: 'cnn', locator: 'http://www.cnn.com'),
+ Page.new(name: 'apple', locator: 'http://www.apple.com')
+ ].each{|each| Repository.for(Page).store each}
+ end
+
+ def response_html
+ <<-HTML
+ <HTML>
+ <HEAD>
+ <TITLE>List of Shortcuts</TITLE>
+ </HEAD>
+ <BODY>
+ <H1>List of Shortcuts</H1>
+ <TABLE style="outline: 2pt solid black;">
+ <TR><TH>Shortcut</TH><TH>Locator</TH></TR>
+ #{rows_html}
+ </TABLE>
+ </BODY>
+ </HTML>
+ HTML
+ end
+
+ def rows_html
+ Pages::All.new.execute.pages.map do |page|
+ "<TR><TD><A href=\"#{page.locator}\">#{page.name}</A></TD><TD>#{page.locator}</TD></TR>"
+ end.join("\n")
+ end
+
+ end
+
+end
File renamed without changes.
@@ -1,4 +1,4 @@
-require_relative '../../boundaries/interactor_interface'
+require_relative '../boundaries/interactor_interface'
require_relative '../../boundaries/repository'
require_relative '../../interactors/pages'
@@ -1,6 +1,5 @@
-require_relative '../../entities/entities'
-require_relative '../../boundaries/memory_repos'
-require_relative '../../boundaries/indexed_repository_interface.rb'
+require_relative '../boundaries/indexed_repository_interface'
+require_relative '../../repositories/memory_repos'
describe MemoryRepos do
context MemoryRepos::IndexedRepo do

0 comments on commit ef1fddf

Please sign in to comment.