orthor 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +2 -2
- data/lib/orthor.rb +4 -0
- data/lib/orthor/templates.rb +4 -1
- data/spec/orthor/templates_spec.rb +6 -0
- data/spec/orthor_spec.rb +12 -0
- metadata +2 -2
data/README.md
CHANGED
@@ -11,11 +11,11 @@ The Orthor gem is used to fetch and display your content from orthor.com
|
|
11
11
|
Add the below to a file and require it:
|
12
12
|
|
13
13
|
Orthor.setup do
|
14
|
-
|
14
|
+
site "orthor" # your orthor site/account id
|
15
15
|
caching :basic_file, 300, :path => "tmp/" # cache content in tmp/ for 5 mins
|
16
16
|
end
|
17
17
|
|
18
|
-
You can specify any Moneta cache store you like, e.g. basic_file, memcache etc. The (optional) second argument is cache expiry in seconds, you can provide any initialize options required by your cache store as the 3rd arg.
|
18
|
+
You can specify any Moneta cache store you like, e.g. basic_file, memory, memcache etc. The (optional) second argument is cache expiry in seconds, you can provide any initialize options required by your cache store as the 3rd arg.
|
19
19
|
|
20
20
|
## Usage
|
21
21
|
|
data/lib/orthor.rb
CHANGED
data/lib/orthor/templates.rb
CHANGED
@@ -35,6 +35,8 @@ class Orthor
|
|
35
35
|
|
36
36
|
private
|
37
37
|
def self.parse(item, template_name_or_mapping)
|
38
|
+
return "" if item == ""
|
39
|
+
|
38
40
|
# ensure we're dealing with an array
|
39
41
|
unless item.is_a?(Array)
|
40
42
|
if item["type"] == "category"
|
@@ -61,8 +63,9 @@ class Orthor
|
|
61
63
|
end
|
62
64
|
end
|
63
65
|
end.join("")
|
66
|
+
rescue Orthor::Templates::Unknown => e
|
67
|
+
raise e
|
64
68
|
rescue => e
|
65
|
-
raise e if e.is_a?(Orthor::Templates::Unknown)
|
66
69
|
return ""
|
67
70
|
end
|
68
71
|
|
@@ -75,6 +75,12 @@ describe Orthor::Templates do
|
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
|
+
describe "parsing an empty result" do
|
79
|
+
it "should return an empty string" do
|
80
|
+
Orthor.render("", :blurb).should == ""
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
78
84
|
describe "a content query" do
|
79
85
|
it "should render the template for each item" do
|
80
86
|
Orthor.query("query", :brief).should == %!<h2>User Manual updated</h2><h2>Account event tracking</h2><h2>Tutorials have been updated</h2>!
|
data/spec/orthor_spec.rb
CHANGED
@@ -38,6 +38,18 @@ describe Orthor do
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
+
describe "site config" do
|
42
|
+
before(:all) do
|
43
|
+
Orthor.setup do
|
44
|
+
site "bob"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should use the site id as the account id" do
|
49
|
+
Orthor.account_id.should == "bob"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
41
53
|
describe "getting" do
|
42
54
|
before(:all) do
|
43
55
|
Orthor.setup do
|