sethyates-content_manager 0.3.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +2 -2
- data/Rakefile +2 -1
- data/VERSION +1 -1
- data/content_manager.gemspec +6 -7
- data/init.rb +1 -1
- data/lib/content_manager.rb +10 -3
- metadata +13 -7
- data/lib/content_helper.rb +0 -28
- data/lib/content_item.rb +0 -85
- data/lib/rack/content_manager.rb +0 -18
- data/rails/init.rb +0 -1
data/README.rdoc
CHANGED
data/Rakefile
CHANGED
@@ -5,11 +5,12 @@ begin
|
|
5
5
|
require 'jeweler'
|
6
6
|
Jeweler::Tasks.new do |gem|
|
7
7
|
gem.name = "content_manager"
|
8
|
-
gem.summary = %Q{
|
8
|
+
gem.summary = %Q{Content::Manager}
|
9
9
|
gem.email = "syates@grandcentralmedia.com.au"
|
10
10
|
gem.homepage = "http://github.com/sethyates/content_manager"
|
11
11
|
gem.authors = ["Seth Yates"]
|
12
12
|
gem.add_dependency('rufus-tokyo', '>= 0.1.12')
|
13
|
+
gem.add_dependency('actsasflinn-ruby-tokyotyrant', '>= 0.1.8')
|
13
14
|
end
|
14
15
|
|
15
16
|
rescue LoadError
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.0
|
data/content_manager.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{content_manager}
|
5
|
-
s.version = "0.
|
5
|
+
s.version = "0.4.0"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Seth Yates"]
|
9
|
-
s.date = %q{2009-06-
|
9
|
+
s.date = %q{2009-06-28}
|
10
10
|
s.email = %q{syates@grandcentralmedia.com.au}
|
11
11
|
s.extra_rdoc_files = [
|
12
12
|
"LICENSE",
|
@@ -21,11 +21,7 @@ Gem::Specification.new do |s|
|
|
21
21
|
"VERSION",
|
22
22
|
"content_manager.gemspec",
|
23
23
|
"init.rb",
|
24
|
-
"lib/content_helper.rb",
|
25
|
-
"lib/content_item.rb",
|
26
24
|
"lib/content_manager.rb",
|
27
|
-
"lib/rack/content_manager.rb",
|
28
|
-
"rails/init.rb",
|
29
25
|
"test/content_manager_test.rb",
|
30
26
|
"test/test_helper.rb"
|
31
27
|
]
|
@@ -33,7 +29,7 @@ Gem::Specification.new do |s|
|
|
33
29
|
s.rdoc_options = ["--charset=UTF-8"]
|
34
30
|
s.require_paths = ["lib"]
|
35
31
|
s.rubygems_version = %q{1.3.3}
|
36
|
-
s.summary = %q{
|
32
|
+
s.summary = %q{Content::Manager}
|
37
33
|
s.test_files = [
|
38
34
|
"test/content_manager_test.rb",
|
39
35
|
"test/test_helper.rb"
|
@@ -45,10 +41,13 @@ Gem::Specification.new do |s|
|
|
45
41
|
|
46
42
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
47
43
|
s.add_runtime_dependency(%q<rufus-tokyo>, [">= 0.1.12"])
|
44
|
+
s.add_runtime_dependency(%q<actsasflinn-ruby-tokyotyrant>, [">= 0.1.8"])
|
48
45
|
else
|
49
46
|
s.add_dependency(%q<rufus-tokyo>, [">= 0.1.12"])
|
47
|
+
s.add_dependency(%q<actsasflinn-ruby-tokyotyrant>, [">= 0.1.8"])
|
50
48
|
end
|
51
49
|
else
|
52
50
|
s.add_dependency(%q<rufus-tokyo>, [">= 0.1.12"])
|
51
|
+
s.add_dependency(%q<actsasflinn-ruby-tokyotyrant>, [">= 0.1.8"])
|
53
52
|
end
|
54
53
|
end
|
data/init.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/rails/init"
|
1
|
+
#require File.dirname(__FILE__) + "/rails/init"
|
data/lib/content_manager.rb
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
3
|
-
require '
|
1
|
+
require 'content/item/adapters/base'
|
2
|
+
require 'content/item/adapters/tyrant_adapter'
|
3
|
+
require 'content/item/adapters/cabinet_adapter'
|
4
|
+
require 'content/item_association_class_methods'
|
5
|
+
require 'content/item_finder_class_methods'
|
6
|
+
require 'content/item'
|
7
|
+
require 'content/sublayout'
|
8
|
+
require 'content/template'
|
9
|
+
require 'content/manager'
|
10
|
+
require 'component'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sethyates-content_manager
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Seth Yates
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-06-
|
12
|
+
date: 2009-06-28 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -22,6 +22,16 @@ dependencies:
|
|
22
22
|
- !ruby/object:Gem::Version
|
23
23
|
version: 0.1.12
|
24
24
|
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: actsasflinn-ruby-tokyotyrant
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.1.8
|
34
|
+
version:
|
25
35
|
description:
|
26
36
|
email: syates@grandcentralmedia.com.au
|
27
37
|
executables: []
|
@@ -40,11 +50,7 @@ files:
|
|
40
50
|
- VERSION
|
41
51
|
- content_manager.gemspec
|
42
52
|
- init.rb
|
43
|
-
- lib/content_helper.rb
|
44
|
-
- lib/content_item.rb
|
45
53
|
- lib/content_manager.rb
|
46
|
-
- lib/rack/content_manager.rb
|
47
|
-
- rails/init.rb
|
48
54
|
- test/content_manager_test.rb
|
49
55
|
- test/test_helper.rb
|
50
56
|
has_rdoc: false
|
@@ -72,7 +78,7 @@ rubyforge_project:
|
|
72
78
|
rubygems_version: 1.2.0
|
73
79
|
signing_key:
|
74
80
|
specification_version: 3
|
75
|
-
summary:
|
81
|
+
summary: Content::Manager
|
76
82
|
test_files:
|
77
83
|
- test/content_manager_test.rb
|
78
84
|
- test/test_helper.rb
|
data/lib/content_helper.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
module ContentHelper
|
2
|
-
def render_components(name)
|
3
|
-
querystring = "" # TODO
|
4
|
-
|
5
|
-
env = {
|
6
|
-
"rack.version" => [0, 1],
|
7
|
-
"rack.input" => StringIO.new(""),
|
8
|
-
"rack.errors" => $stderr,
|
9
|
-
"rack.url_scheme" => "http",
|
10
|
-
"rack.run_once" => false,
|
11
|
-
"rack.multithread" => false,
|
12
|
-
"rack.multiprocess" => false,
|
13
|
-
"QUERY_STRING" => querystring,
|
14
|
-
"REQUEST_METHOD" => "GET",
|
15
|
-
"PATH_INFO" => name,
|
16
|
-
"REQUEST_PATH" => name,
|
17
|
-
"REQUEST_URI" => name
|
18
|
-
}
|
19
|
-
|
20
|
-
%w(SERVER_SOFTWARE HTTP_USER_AGENT HTTP_ACCEPT_ENCODING HTTP_ACCEPT_CHARSET
|
21
|
-
HTTP_ACCEPT_LANGUAGE HTTP_KEEP_ALIVE HTTP_COOKIE HTTP_VERSION SERVER_PROTOCOL HTTP_HOST
|
22
|
-
SERVER_NAME SERVER_PORT REMOTE_ADDR SCRIPT_NAME).each { |key| env[key] = request.env[key] }
|
23
|
-
|
24
|
-
resp = ActionController::Dispatcher.new.call(env)
|
25
|
-
raise "Error executing component '#{name}' - #{resp[0]}" unless resp[0] == 200
|
26
|
-
resp[2].body
|
27
|
-
end
|
28
|
-
end
|
data/lib/content_item.rb
DELETED
@@ -1,85 +0,0 @@
|
|
1
|
-
class ContentItem
|
2
|
-
attr_accessor :attributes
|
3
|
-
|
4
|
-
def self.establish_connection(name)
|
5
|
-
@@connection = Rufus::Tokyo::Table.new("db/#{name}.tdb", "create")
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.connection()
|
9
|
-
@@connection ||= self.establish_connection('contents')
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.mock_attr(*syms)
|
13
|
-
syms.each do |sym|
|
14
|
-
define_method(sym) { "#{attributes[sym.to_s]}" }
|
15
|
-
define_method("#{sym.to_s}=".to_sym) { |val| attributes[sym.to_s] = val }
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def self.wrap_result(attrs)
|
20
|
-
attrs.nil? ? nil : ContentItem.new(attrs)
|
21
|
-
end
|
22
|
-
|
23
|
-
def self.find_first_by_url(url)
|
24
|
-
wrap_result connection[url]
|
25
|
-
end
|
26
|
-
|
27
|
-
def self.find_all_by_url(url)
|
28
|
-
[self.find_first_by_url(url)]
|
29
|
-
end
|
30
|
-
|
31
|
-
def self.find(options)
|
32
|
-
options ||= {}
|
33
|
-
connection.query { |q|
|
34
|
-
(options[:conditions] || {}).each { |cond| q.add_condition cond.key, :eq, cond.value }
|
35
|
-
(options[:order] || []).each {|order| q.order_by order }
|
36
|
-
}
|
37
|
-
end
|
38
|
-
|
39
|
-
def self.polymorphic_finder(which, name, *arguments)
|
40
|
-
hash = (connection.query {|q| q.add_condition name.to_s, :eq, arguments.first.to_s })
|
41
|
-
hash = hash.first if which == :first
|
42
|
-
wrap_result hash
|
43
|
-
end
|
44
|
-
|
45
|
-
def self.method_missing(name, *arguments)
|
46
|
-
if name.to_s =~ /^find_all(_by)?_(.+)$/
|
47
|
-
polymorphic_finder(:all, $2, arguments)
|
48
|
-
elsif name.to_s =~ /^find_(first_by|by)_(.+)$/
|
49
|
-
polymorphic_finder(:first, $2, arguments)
|
50
|
-
else
|
51
|
-
super
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def initialize(attrs = {})
|
56
|
-
self.attributes = {}
|
57
|
-
(attrs || {}).each { |key, value| self.attributes[key.to_s] = value.to_s }
|
58
|
-
end
|
59
|
-
|
60
|
-
def save()
|
61
|
-
hash = self.attributes.dup
|
62
|
-
url = hash.delete "url"
|
63
|
-
ContentItem.connection[url] = hash
|
64
|
-
end
|
65
|
-
|
66
|
-
def to_yaml
|
67
|
-
attributes.to_yaml
|
68
|
-
end
|
69
|
-
|
70
|
-
def to_json
|
71
|
-
attributes.to_json
|
72
|
-
end
|
73
|
-
|
74
|
-
def method_missing(name, *arguments)
|
75
|
-
if arguments.length > 0
|
76
|
-
attributes[name.to_s.chomp('=')] = arguments.first
|
77
|
-
elsif attributes.has_key? name.to_s
|
78
|
-
attributes[name.to_s]
|
79
|
-
else
|
80
|
-
super
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
mock_attr :id, :status, :version, :url, :heading, :summary, :content_type, :sublayout
|
85
|
-
end
|
data/lib/rack/content_manager.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
module Rack
|
2
|
-
class ContentManager
|
3
|
-
def initialize(app)
|
4
|
-
@app = app
|
5
|
-
end
|
6
|
-
|
7
|
-
def call(env)
|
8
|
-
item = ContentItem.find_first_by_url(env["REQUEST_PATH"])
|
9
|
-
unless item.nil?
|
10
|
-
response = Rack::Response.new
|
11
|
-
response.write "Hi there"
|
12
|
-
response.finish
|
13
|
-
else
|
14
|
-
@app.call(env)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
data/rails/init.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
ActionController::Dispatcher.middleware.use ::Rack::ContentManager
|