flareshow 0.3.4 → 0.3.6

Sign up to get free protection for your applications and to get access to all the features.
data/Flareshow.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{flareshow}
8
- s.version = "0.3.4"
8
+ s.version = "0.3.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Will Bailey"]
@@ -44,7 +44,7 @@ Gem::Specification.new do |s|
44
44
  "test/flareshow_test.rb",
45
45
  "test/test_helper.rb"
46
46
  ]
47
- s.homepage = %q{http://github.com/willbailey/flareshow}
47
+ s.homepage = %q{http://github.com/zenbe/flareshow}
48
48
  s.rdoc_options = ["--charset=UTF-8"]
49
49
  s.require_paths = ["lib"]
50
50
  s.rubyforge_project = %q{flareshow}
@@ -65,12 +65,14 @@ Gem::Specification.new do |s|
65
65
  s.add_runtime_dependency(%q<curb>, ["> 0"])
66
66
  s.add_runtime_dependency(%q<facets>, ["> 0"])
67
67
  s.add_runtime_dependency(%q<uuid>, ["> 0"])
68
+ s.add_runtime_dependency(%q<nokogiri>, ["> 0"])
68
69
  else
69
70
  s.add_dependency(%q<thoughtbot-shoulda>, ["> 0"])
70
71
  s.add_dependency(%q<json>, ["> 0"])
71
72
  s.add_dependency(%q<curb>, ["> 0"])
72
73
  s.add_dependency(%q<facets>, ["> 0"])
73
74
  s.add_dependency(%q<uuid>, ["> 0"])
75
+ s.add_dependency(%q<nokogiri>, ["> 0"])
74
76
  end
75
77
  else
76
78
  s.add_dependency(%q<thoughtbot-shoulda>, ["> 0"])
@@ -78,5 +80,6 @@ Gem::Specification.new do |s|
78
80
  s.add_dependency(%q<curb>, ["> 0"])
79
81
  s.add_dependency(%q<facets>, ["> 0"])
80
82
  s.add_dependency(%q<uuid>, ["> 0"])
83
+ s.add_dependency(%q<nokogiri>, ["> 0"])
81
84
  end
82
85
  end
data/Rakefile CHANGED
@@ -8,13 +8,14 @@ begin
8
8
  gem.summary = %Q{a ruby gem for interacting with the shareflow collaboration service}
9
9
  gem.description = %Q{a ruby gem for interacting with the shareflow collaboration service by Zenbe}
10
10
  gem.email = "will.bailey@gmail.com"
11
- gem.homepage = "http://github.com/willbailey/flareshow"
11
+ gem.homepage = "http://github.com/zenbe/flareshow"
12
12
  gem.authors = ["Will Bailey"]
13
13
  gem.add_development_dependency "thoughtbot-shoulda", "> 0"
14
14
  gem.add_dependency "json", "> 0"
15
15
  gem.add_dependency "curb", "> 0"
16
16
  gem.add_dependency "facets", "> 0"
17
17
  gem.add_dependency "uuid", "> 0"
18
+ gem.add_dependency "nokogiri", "> 0"
18
19
  gem.rubyforge_project = "flareshow"
19
20
  end
20
21
  rescue LoadError
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.4
1
+ 0.3.6
data/lib/comment.rb CHANGED
@@ -16,13 +16,25 @@ class Comment < Flareshow::Resource
16
16
 
17
17
  # get the post for this comment
18
18
  def post
19
- Post.first(:id => post_id)
19
+ post = Post.get_from_cache(reply_to)
20
+ post || Post.first(:id => reply_to)
20
21
  end
21
22
 
22
23
  # user for this post
23
24
  def user
24
25
  return User.current unless user_id
25
- User.first({:id => user_id})
26
+ user = User.get_from_cache(user_id)
27
+ user || User.first({:id => user_id})
28
+ end
29
+
30
+ # persisted files for this post
31
+ def files
32
+ cached = FileAttachment.list_cache
33
+ files = cached.select{|f|f.post_id == id}
34
+ end
35
+
36
+ def content
37
+ Nokogiri::HTML::Document.new.fragment(get("content")).to_s
26
38
  end
27
39
 
28
40
  end
@@ -28,13 +28,17 @@ class FileAttachment < Flareshow::Resource
28
28
  # post for this file
29
29
  def post
30
30
  return false unless post_id
31
- Post.find({:id => post_id})
31
+ post = Post.get_from_cache(post_id)
32
+ post ||= Comment.get_from_cache(post_id)
33
+ post ||= Post.find({:id => post_id})
34
+ post ||= Comment.find({:id => post_id})
32
35
  end
33
36
 
34
- # get the user for this file
37
+ # user for this post
35
38
  def user
36
- p = post && post.first
37
- p.user && p.user.first
39
+ return User.current unless user_id
40
+ user = User.get_from_cache(user_id)
41
+ user || User.first({:id => user_id})
38
42
  end
39
43
 
40
44
  end
data/lib/flareshow.rb CHANGED
@@ -8,6 +8,7 @@ require 'facets/dictionary'
8
8
  require 'uuid'
9
9
  require 'mime/types'
10
10
  require 'cgi'
11
+ require 'nokogiri'
11
12
 
12
13
  # std lib
13
14
  require 'net/http'
data/lib/post.rb CHANGED
@@ -40,14 +40,21 @@ class Post < Flareshow::Resource
40
40
  self.files = []
41
41
  end
42
42
 
43
+ def content
44
+ Nokogiri::HTML::Document.new.fragment(get("content")).to_s
45
+ end
46
+
43
47
  # persisted files for this post
44
48
  def files
45
- FileAttachment.find({:post_id => id}) || []
49
+ cached = FileAttachment.list_cache
50
+ files = cached.select{|f|f.post_id == id}
46
51
  end
47
52
 
48
53
  # comments for this post
49
54
  def comments
50
- Comment.find({:post_id => id})
55
+ cached = Comment.list_cache
56
+ comments = cached.select{|c|c.reply_to == id}
57
+ comments
51
58
  end
52
59
 
53
60
  # user for this post
data/lib/resource.rb CHANGED
@@ -21,7 +21,7 @@ class Flareshow::Resource
21
21
 
22
22
  # list out the instances in memory
23
23
  def list_cache
24
- store.list_resource(resource_key)
24
+ store.list_resource(resource_key).map{|k,v|v}
25
25
  end
26
26
 
27
27
  # store the response resources in the cache
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flareshow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Will Bailey
@@ -62,6 +62,16 @@ dependencies:
62
62
  - !ruby/object:Gem::Version
63
63
  version: "0"
64
64
  version:
65
+ - !ruby/object:Gem::Dependency
66
+ name: nokogiri
67
+ type: :runtime
68
+ version_requirement:
69
+ version_requirements: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">"
72
+ - !ruby/object:Gem::Version
73
+ version: "0"
74
+ version:
65
75
  description: a ruby gem for interacting with the shareflow collaboration service by Zenbe
66
76
  email: will.bailey@gmail.com
67
77
  executables: []
@@ -99,7 +109,7 @@ files:
99
109
  - test/flareshow_test.rb
100
110
  - test/test_helper.rb
101
111
  has_rdoc: true
102
- homepage: http://github.com/willbailey/flareshow
112
+ homepage: http://github.com/zenbe/flareshow
103
113
  licenses: []
104
114
 
105
115
  post_install_message: