wideopenspaces-flickry 0.1.6 → 0.2.0

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/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
- :minor: 1
3
- :patch: 6
2
+ :minor: 2
3
+ :patch: 0
4
4
  :major: 0
data/lib/flickry.rb CHANGED
@@ -3,6 +3,7 @@ require 'super_struct'
3
3
 
4
4
  require 'flickry/base'
5
5
  require 'flickry/location'
6
+ require 'flickry/tag'
6
7
  require 'flickry/person'
7
8
  require 'flickry/sizes'
8
9
  require 'flickry/photo'
@@ -1,39 +1,28 @@
1
1
  module Flickry
2
- class Comment < Flickry::Base
2
+ class Comment < String
3
+ attr_reader :comment_id, :author_id, :authorname, :datecreate, :permalink
3
4
  def initialize(comment)
4
- super(nil)
5
+ super(comment.to_s)
5
6
  @comment_id = comment.id
6
- extract_attrs!(comment, [:authorname, :datecreate, :permalink])
7
- self.content = comment.to_s
8
- self.author_id = comment.author
9
- end
10
-
11
- def comment_id
12
- @comment_id
13
- end
14
-
15
- def to_s
16
- self.content
17
- end
18
-
19
- # Clean permalink
20
- def to_url
21
- clean(self.permalink)
7
+ @author_id = comment.author
8
+ @authorname = comment.authorname
9
+ @datecreate = comment.datecreate
10
+ @permalink = comment.permalink
22
11
  end
23
12
 
24
13
  # datecreate converted into Time object
25
14
  def created_at
26
- Time.at(self.datecreate.to_i)
15
+ Time.at(@datecreate.to_i)
27
16
  end
28
17
 
29
18
  # Get a Person record for the author_id
30
19
  def author
31
- Flickry::Person.find(self.author_id)
20
+ Flickry::Person.find(@author_id)
32
21
  end
33
22
 
34
23
  # name = authornane
35
24
  def name
36
- self.authorname
25
+ @authorname
37
26
  end
38
27
  end
39
28
  end
@@ -1,8 +1,18 @@
1
+ require 'flickry/place'
2
+
1
3
  module Flickry
2
4
  class Location < Flickry::Base
3
5
  def initialize(locus)
4
6
  super(nil)
5
- extract_attrs!(locus, [:accuracy, :country, :county, :latitude, :locality, :longitude, :neighbourhood, :place_id, :region, :woeid])
7
+ extract_attrs!(locus, [:accuracy, :latitude, :longitude, :place_id, :woeid])
8
+
9
+ [:country, :county, :locality, :neighbourhood, :region].each do |scale|
10
+ if locus.respond_to?(scale) and loc = locus.send(scale)
11
+ self[scale] = Flickry::Place.new(loc, scale)
12
+ else
13
+ self[scale] = nil
14
+ end
15
+ end
6
16
  end
7
17
  end
8
18
  end
data/lib/flickry/photo.rb CHANGED
@@ -18,7 +18,11 @@ module Flickry
18
18
  })
19
19
  self.location = Flickry::Location.new(foto.respond_to?(:location) ? foto.location : nil)
20
20
  self.owner = Flickry::Person.new(foto.respond_to?(:owner) ? foto.owner : nil)
21
-
21
+
22
+ _tags = self.tags.dup
23
+ self.tags = _tags.collect do |t|
24
+ Flickry::Tag.new(t)
25
+ end
22
26
  end
23
27
 
24
28
  # Lazily fetches the photo's sizes when called, memoizes so later calls are faster...
@@ -42,6 +46,11 @@ module Flickry
42
46
  return @comments
43
47
  end
44
48
 
49
+ # Join tags into a single string
50
+ def tag_list(separator = ', ')
51
+ self.tags.join(separator)
52
+ end
53
+
45
54
  def visible_to_family?
46
55
  self.visibility.isfamily == 1
47
56
  end
@@ -0,0 +1,12 @@
1
+ module Flickry
2
+ class Place < String
3
+ attr_reader :place_id, :woeid, :scale, :name
4
+ def initialize(loc, scale)
5
+ super(loc.to_s)
6
+ @place_id = loc.place_id
7
+ @woeid = loc.woeid
8
+ @scale = scale
9
+ @name = self.to_s
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,21 @@
1
+ module Flickry
2
+ class Tag < String
3
+ attr_reader :tag_id, :machine_tag, :author_id, :name
4
+ def initialize(tag)
5
+ super(tag.to_s)
6
+ @tag_id = tag.id
7
+ @machine_tag = tag.machine_tag
8
+ @author_id = tag.author
9
+ @name = self.to_s
10
+ end
11
+
12
+ def machine_tag?
13
+ @machine_tag == 0 ? false : true
14
+ end
15
+
16
+ # Get a Person record for the author_id
17
+ def author
18
+ Flickry::Person.find(@author_id)
19
+ end
20
+ end
21
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wideopenspaces-flickry
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jacob Stetser
@@ -37,8 +37,10 @@ files:
37
37
  - lib/flickry/location.rb
38
38
  - lib/flickry/person.rb
39
39
  - lib/flickry/photo.rb
40
+ - lib/flickry/place.rb
40
41
  - lib/flickry/size.rb
41
42
  - lib/flickry/sizes.rb
43
+ - lib/flickry/tag.rb
42
44
  - lib/flickry.rb
43
45
  - lib/super_struct.rb
44
46
  - test/flickry_test.rb