orthorings 0.4.1 → 0.4.2

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.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/lib/orthorings.rb +5 -4
  3. data/orthorings.gemspec +2 -2
  4. metadata +3 -3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.1
1
+ 0.4.2
data/lib/orthorings.rb CHANGED
@@ -44,6 +44,7 @@ class Orthorings
44
44
  Moneta.autoload(klass.to_sym, "moneta/#{file}")
45
45
  @cache = Moneta.const_get(klass).new(options)
46
46
  @cache_expiry = expiry
47
+ @cache_options = options.merge(:expires_in => @cache_expiry)
47
48
  end
48
49
 
49
50
  def setup(&block)
@@ -67,7 +68,7 @@ class Orthorings
67
68
 
68
69
  def get_cached_content(id, url)
69
70
  content = @cache[id]
70
- if content.empty?
71
+ if content.nil? || content.empty?
71
72
  content = get_response(url)
72
73
  cache_content(id, content)
73
74
  end
@@ -75,7 +76,7 @@ class Orthorings
75
76
  end
76
77
 
77
78
  def cache_content(id, content)
78
- @cache.store(id, content, :expires_in => @cache_expiry) unless content.empty?
79
+ @cache.store(id, content, @cache_options) unless content.empty?
79
80
  end
80
81
 
81
82
  def get_response(uri)
@@ -87,7 +88,7 @@ class Orthorings
87
88
 
88
89
  def render(type, id, template = nil)
89
90
  suffix = type == :feeds ? "rss" : "json"
90
- resp = get_content(id, "http://content.orthor.com/#{@account_id}/#{type}/#{id}.#{suffix}")
91
+ resp = get_content("#{id}-#{type}", "http://content.orthor.com/#{@account_id}/#{type}/#{id}.#{suffix}")
91
92
 
92
93
  return resp unless suffix == "json"
93
94
 
@@ -114,7 +115,7 @@ class Orthorings
114
115
  html = html.gsub("{{#{key}}}", val.to_s)
115
116
  elsif val.is_a?(Hash) && html.include?("{{#{key}.")
116
117
  # we've got something like Author.Email
117
- html = val.inject(html) { |h, (k, v)| h = h.gsub("{{#{key}.#{k}}}", v) }
118
+ html = val.inject(html) { |h, (k, v)| h = h.gsub("{{#{key}.#{k}}}", v.to_s) }
118
119
  else
119
120
  html = html.gsub("{{#{key}}}", val.to_s)
120
121
  end
data/orthorings.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{orthorings}
8
- s.version = "0.4.1"
8
+ s.version = "0.4.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Anthony Langhorne"]
12
- s.date = %q{2010-06-09}
12
+ s.date = %q{2010-06-10}
13
13
  s.email = %q{anthony@orthor.com}
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE",
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 4
8
- - 1
9
- version: 0.4.1
8
+ - 2
9
+ version: 0.4.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Anthony Langhorne
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-06-09 00:00:00 +10:00
17
+ date: 2010-06-10 00:00:00 +10:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency