instagram 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/instagram.rb +12 -0
  2. data/lib/instagram/models.rb +24 -0
  3. metadata +6 -12
@@ -10,6 +10,8 @@ module Instagram
10
10
  Popular = Addressable::URI.parse 'http://instagr.am/api/v1/feed/popular/'
11
11
  UserFeed = Addressable::Template.new 'http://instagr.am/api/v1/feed/user/{user_id}/'
12
12
  UserInfo = Addressable::Template.new 'http://instagr.am/api/v1/users/{user_id}/info/'
13
+ SearchTags = Addressable::URI.parse 'http://instagr.am/api/v1/tags/search/'
14
+ TagFeed = Addressable::Template.new 'http://instagr.am/api/v1/feed/tag/{tag}/'
13
15
 
14
16
  def popular(params = {}, options = {})
15
17
  parse_response(Popular.dup, params, options.fetch(:parse_with, Timeline))
@@ -25,6 +27,16 @@ module Instagram
25
27
  parse_response(url, params, options.fetch(:parse_with, UserWrap))
26
28
  end
27
29
 
30
+ def search_tags(query, params = {}, options = {})
31
+ params = {:q => query}.merge(params)
32
+ parse_response(SearchTags.dup, params, options.fetch(:parse_with, SearchTagsResults))
33
+ end
34
+
35
+ def by_tag(tag, params = {}, options = {})
36
+ url = TagFeed.expand :tag => tag
37
+ parse_response(url, params, options.fetch(:parse_with, Timeline))
38
+ end
39
+
28
40
  private
29
41
 
30
42
  def parse_response(url, params, parser = nil)
@@ -47,6 +47,8 @@ module Instagram
47
47
  element :user, :with => User
48
48
 
49
49
  # array of people who liked this media
50
+ elements :likers, :with => User
51
+ # user IDs of people who liked this (only if "likers" are not present)
50
52
  element :liker_ids
51
53
 
52
54
  elements :comments, :with => NibblerJSON do
@@ -130,6 +132,28 @@ module Instagram
130
132
  end
131
133
  end
132
134
 
135
+ class Tag < String
136
+ attr_reader :media_count
137
+
138
+ def initialize(str, count)
139
+ super(str)
140
+ @media_count = count
141
+ end
142
+
143
+ def self.parse(hash)
144
+ new hash['name'], hash['media_count']
145
+ end
146
+
147
+ def inspect
148
+ "#{super} (#{media_count})"
149
+ end
150
+ end
151
+
152
+ class SearchTagsResults < NibblerJSON
153
+ elements :results, :with => Tag
154
+ def parse() super.results end
155
+ end
156
+
133
157
  class Timeline < NibblerJSON
134
158
  elements :items, :with => Media
135
159
  # return items instead of self when done
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: instagram
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
5
- prerelease:
4
+ prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 3
9
- - 1
10
- version: 0.3.1
8
+ - 2
9
+ version: 0.3.2
11
10
  platform: ruby
12
11
  authors:
13
12
  - "Mislav Marohni\xC4\x87"
@@ -15,7 +14,7 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2011-01-21 00:00:00 -08:00
17
+ date: 2011-01-28 00:00:00 +01:00
19
18
  default_executable:
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
@@ -26,7 +25,6 @@ dependencies:
26
25
  requirements:
27
26
  - - ">="
28
27
  - !ruby/object:Gem::Version
29
- hash: 3
30
28
  segments:
31
29
  - 0
32
30
  version: "0"
@@ -40,7 +38,6 @@ dependencies:
40
38
  requirements:
41
39
  - - ">="
42
40
  - !ruby/object:Gem::Version
43
- hash: 3
44
41
  segments:
45
42
  - 0
46
43
  version: "0"
@@ -54,7 +51,6 @@ dependencies:
54
51
  requirements:
55
52
  - - ">="
56
53
  - !ruby/object:Gem::Version
57
- hash: 31
58
54
  segments:
59
55
  - 1
60
56
  - 2
@@ -78,7 +74,7 @@ files:
78
74
  - lib/instagram.rb
79
75
  - README.md
80
76
  - MIT-LICENSE
81
- has_rdoc: false
77
+ has_rdoc: true
82
78
  homepage: http://github.com/mislav/instagram
83
79
  licenses: []
84
80
 
@@ -92,7 +88,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
92
88
  requirements:
93
89
  - - ">="
94
90
  - !ruby/object:Gem::Version
95
- hash: 3
96
91
  segments:
97
92
  - 0
98
93
  version: "0"
@@ -101,14 +96,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
96
  requirements:
102
97
  - - ">="
103
98
  - !ruby/object:Gem::Version
104
- hash: 3
105
99
  segments:
106
100
  - 0
107
101
  version: "0"
108
102
  requirements: []
109
103
 
110
104
  rubyforge_project:
111
- rubygems_version: 1.4.1
105
+ rubygems_version: 1.3.7
112
106
  signing_key:
113
107
  specification_version: 3
114
108
  summary: Instagram API client