nanopop 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 994f18de251ad1a2a547b14c9ec968eb19a7b6c3
4
+ data.tar.gz: c1d213f935d23d2ccc6ab4126fde9403f9f164b7
5
+ SHA512:
6
+ metadata.gz: ed6f7f13b5cc1835572db90602d9bb24542db556d8f3dacb2e5278071bc07baf1ff5f566189578b9154a15c6c9bf4d840810baa39baa7120b2e5a8b0b204a008
7
+ data.tar.gz: cb9375d3e615926512c2329b84f4cd9e64fc5c25e296c6b45cc9f528db239076b6fff9a403a80925cac705f5a96009a4326ed8ca9a7ce87149697613f5590216
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .DS_Store
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in nanopop.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Maiz Lulkin
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,38 @@
1
+ # Nanopop
2
+
3
+ Fetches information on Nanopop API.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'nanopop'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install nanopop
18
+
19
+ ## Usage
20
+
21
+ Config your token in a config or initializer file:
22
+
23
+ Nanopop.configure do |config|
24
+ config.token = '1234'
25
+ end
26
+
27
+ Now you can fetch latest pictures:
28
+
29
+ pictures = Nanopop::Picture.latest(10)
30
+ pictures.first.url
31
+
32
+ ## Contributing
33
+
34
+ 1. Fork it
35
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
36
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
37
+ 4. Push to the branch (`git push origin my-new-feature`)
38
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,34 @@
1
+ require "nokogiri"
2
+ require "rest_client"
3
+ require "addressable/uri"
4
+
5
+ module Nanopop
6
+ API_URL = "http://nanopopapi.cloudapp.net/"
7
+ ASSETS_URL = "https://nanopopapi.blob.core.windows.net"
8
+
9
+ class UndefinedToken < StandardError; end
10
+
11
+ class << self
12
+ attr_accessor :configuration
13
+ end
14
+
15
+ def self.configure
16
+ self.configuration ||= Configuration.new
17
+ yield(configuration)
18
+ end
19
+
20
+ class Configuration
21
+ attr_accessor :token
22
+
23
+ def initialize
24
+ @token = nil
25
+ end
26
+ end
27
+
28
+ configure do
29
+ end
30
+
31
+ end
32
+
33
+ require_relative "nanopop/version"
34
+ require_relative "nanopop/picture"
@@ -0,0 +1,63 @@
1
+ class String
2
+ def underscore
3
+ gsub(/(.)([A-Z])/,'\1_\2').downcase
4
+ end
5
+ end
6
+
7
+ class Nanopop::Picture
8
+
9
+ URL = "#{Nanopop::ASSETS_URL}/tasks/%s/%s"
10
+ AVATAR_URL = "#{Nanopop::ASSETS_URL}/users/%s/%s"
11
+
12
+ def initialize ats
13
+ @ats = ats
14
+ end
15
+
16
+ def url
17
+ URL % [adjust(id), picture_filename]
18
+ end
19
+
20
+ def avatar_url
21
+ AVATAR_URL % [adjust(user_id), user_picture_filename]
22
+ end
23
+
24
+ def self.latest qty
25
+
26
+ raise Nanopop::UndefinedToken unless Nanopop.configuration.token
27
+ response = fetch(:latest, numberOfPictures: qty)
28
+ File.open("test.xml", "w"){|f| f.write response }
29
+ doc = Nokogiri.XML(response)
30
+
31
+ doc.search('PictureLatest').map do |item|
32
+ ats = {}
33
+ item.element_children.each do |at|
34
+ key = at.name.scan(/_x003C_(.+)_x003E_k__BackingField/).flatten.first.underscore
35
+ value = at.text
36
+ ats[key.to_sym] = value
37
+ end
38
+ new(ats)
39
+ end
40
+ end
41
+
42
+ private
43
+
44
+ def self.query_string hash
45
+ uri = Addressable::URI.new
46
+ uri.query_values = hash
47
+ uri.query
48
+ end
49
+
50
+ def self.fetch method, params={}
51
+ url = "#{Nanopop::API_URL}/picture/#{method}/?#{query_string(params)}"
52
+ RestClient.get(url, {"Authorization-Token" => Nanopop.configuration.token})
53
+ end
54
+
55
+ def adjust value
56
+ value.rjust(7, '0')
57
+ end
58
+
59
+ def method_missing method
60
+ @ats[method]
61
+ end
62
+
63
+ end
@@ -0,0 +1,3 @@
1
+ module Nanopop
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'nanopop/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "nanopop"
8
+ spec.version = Nanopop::VERSION
9
+ spec.authors = ["Maiz Lulkin"]
10
+ spec.email = ["maiz@lulk.in"]
11
+ spec.description = %q{Nanopop API}
12
+ spec.summary = %q{Nanopop API}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "mocha"
24
+ spec.add_dependency "nokogiri"
25
+ spec.add_dependency "rest-client"
26
+
27
+ end
@@ -0,0 +1,10 @@
1
+ <ArrayOfPictureLatest xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/NanoPop.Api.Models.Selective">
2
+
3
+ <PictureLatest>
4
+ <_x003C_Id_x003E_k__BackingField xmlns="http://schemas.datacontract.org/2004/07/NanoPop.Api.Models">12251</_x003C_Id_x003E_k__BackingField>
5
+ <_x003C_CreationDate_x003E_k__BackingField>2013-08-09T09:46:17</_x003C_CreationDate_x003E_k__BackingField>
6
+ <_x003C_Likes_x003E_k__BackingField>0</_x003C_Likes_x003E_k__BackingField>
7
+ <_x003C_Location_x003E_k__BackingField>NÃO TE ACHEI!</_x003C_Location_x003E_k__BackingField>
8
+ <_x003C_PictureFilename_x003E_k__BackingField>130809_EHJK3.jpg</_x003C_PictureFilename_x003E_k__BackingField>
9
+ <_x003C_PictureHeight_x003E_k__BackingField>1920</_x003C_PictureHeight_x003E_k__BackingField><_x003C_PictureWidth_x003E_k__BackingField>1920</_x003C_PictureWidth_x003E_k__BackingField><_x003C_TaskHashtag_x003E_k__BackingField>#mudabrasil</_x003C_TaskHashtag_x003E_k__BackingField><_x003C_TaskId_x003E_k__BackingField>6</_x003C_TaskId_x003E_k__BackingField><_x003C_TaskTitle_x003E_k__BackingField>Fotografe, fiscalize, você, a mudança</_x003C_TaskTitle_x003E_k__BackingField><_x003C_Title_x003E_k__BackingField>mais amor</_x003C_Title_x003E_k__BackingField><_x003C_UserId_x003E_k__BackingField>3</_x003C_UserId_x003E_k__BackingField><_x003C_UserName_x003E_k__BackingField>Estelle Rinaudo</_x003C_UserName_x003E_k__BackingField><_x003C_UserPictureFilename_x003E_k__BackingField>1076776_818455156_1803156160_q.jpg</_x003C_UserPictureFilename_x003E_k__BackingField></PictureLatest>
10
+ <PictureLatest><_x003C_Id_x003E_k__BackingField xmlns="http://schemas.datacontract.org/2004/07/NanoPop.Api.Models">12250</_x003C_Id_x003E_k__BackingField><_x003C_CreationDate_x003E_k__BackingField>2013-08-09T09:43:23</_x003C_CreationDate_x003E_k__BackingField><_x003C_Likes_x003E_k__BackingField>1</_x003C_Likes_x003E_k__BackingField><_x003C_Location_x003E_k__BackingField>NÃO TE ACHEI!</_x003C_Location_x003E_k__BackingField><_x003C_PictureFilename_x003E_k__BackingField>130809_ECWAD.jpg</_x003C_PictureFilename_x003E_k__BackingField><_x003C_PictureHeight_x003E_k__BackingField>1920</_x003C_PictureHeight_x003E_k__BackingField><_x003C_PictureWidth_x003E_k__BackingField>1920</_x003C_PictureWidth_x003E_k__BackingField><_x003C_TaskHashtag_x003E_k__BackingField>#jmj</_x003C_TaskHashtag_x003E_k__BackingField><_x003C_TaskId_x003E_k__BackingField>28</_x003C_TaskId_x003E_k__BackingField><_x003C_TaskTitle_x003E_k__BackingField>A cobertura da Jornada Mundial da Juventude é aqui na nanopop!</_x003C_TaskTitle_x003E_k__BackingField><_x003C_Title_x003E_k__BackingField>eeee</_x003C_Title_x003E_k__BackingField><_x003C_UserId_x003E_k__BackingField>3</_x003C_UserId_x003E_k__BackingField><_x003C_UserName_x003E_k__BackingField>Estelle Rinaudo</_x003C_UserName_x003E_k__BackingField><_x003C_UserPictureFilename_x003E_k__BackingField>1076776_818455156_1803156160_q.jpg</_x003C_UserPictureFilename_x003E_k__BackingField></PictureLatest><PictureLatest><_x003C_Id_x003E_k__BackingField xmlns="http://schemas.datacontract.org/2004/07/NanoPop.Api.Models">10290</_x003C_Id_x003E_k__BackingField><_x003C_CreationDate_x003E_k__BackingField>2013-07-26T15:51:35</_x003C_CreationDate_x003E_k__BackingField><_x003C_Likes_x003E_k__BackingField>2</_x003C_Likes_x003E_k__BackingField><_x003C_Location_x003E_k__BackingField>Ipanema, Rio de Janeiro, RJ</_x003C_Location_x003E_k__BackingField><_x003C_PictureFilename_x003E_k__BackingField>130726_RJWIU.jpg</_x003C_PictureFilename_x003E_k__BackingField><_x003C_PictureHeight_x003E_k__BackingField>1200</_x003C_PictureHeight_x003E_k__BackingField><_x003C_PictureWidth_x003E_k__BackingField>1200</_x003C_PictureWidth_x003E_k__BackingField><_x003C_TaskHashtag_x003E_k__BackingField>#jmj</_x003C_TaskHashtag_x003E_k__BackingField><_x003C_TaskId_x003E_k__BackingField>28</_x003C_TaskId_x003E_k__BackingField><_x003C_TaskTitle_x003E_k__BackingField>A cobertura da Jornada Mundial da Juventude é aqui na nanopop!</_x003C_TaskTitle_x003E_k__BackingField><_x003C_Title_x003E_k__BackingField i:nil="true" /><_x003C_UserId_x003E_k__BackingField>2</_x003C_UserId_x003E_k__BackingField><_x003C_UserName_x003E_k__BackingField>Eyal Ben-Ze'ev</_x003C_UserName_x003E_k__BackingField><_x003C_UserPictureFilename_x003E_k__BackingField>276014_770132032_603726249_q.jpg</_x003C_UserPictureFilename_x003E_k__BackingField></PictureLatest><PictureLatest><_x003C_Id_x003E_k__BackingField xmlns="http://schemas.datacontract.org/2004/07/NanoPop.Api.Models">10289</_x003C_Id_x003E_k__BackingField><_x003C_CreationDate_x003E_k__BackingField>2013-07-26T15:50:41</_x003C_CreationDate_x003E_k__BackingField><_x003C_Likes_x003E_k__BackingField>2</_x003C_Likes_x003E_k__BackingField><_x003C_Location_x003E_k__BackingField>Flamengo, Rio de Janeiro, RJ</_x003C_Location_x003E_k__BackingField><_x003C_PictureFilename_x003E_k__BackingField>130726_RIPHZ.jpg</_x003C_PictureFilename_x003E_k__BackingField><_x003C_PictureHeight_x003E_k__BackingField>1200</_x003C_PictureHeight_x003E_k__BackingField><_x003C_PictureWidth_x003E_k__BackingField>1202</_x003C_PictureWidth_x003E_k__BackingField><_x003C_TaskHashtag_x003E_k__BackingField>#jmj</_x003C_TaskHashtag_x003E_k__BackingField><_x003C_TaskId_x003E_k__BackingField>28</_x003C_TaskId_x003E_k__BackingField><_x003C_TaskTitle_x003E_k__BackingField>A cobertura da Jornada Mundial da Juventude é aqui na nanopop!</_x003C_TaskTitle_x003E_k__BackingField><_x003C_Title_x003E_k__BackingField i:nil="true" /><_x003C_UserId_x003E_k__BackingField>2</_x003C_UserId_x003E_k__BackingField><_x003C_UserName_x003E_k__BackingField>Eyal Ben-Ze'ev</_x003C_UserName_x003E_k__BackingField><_x003C_UserPictureFilename_x003E_k__BackingField>276014_770132032_603726249_q.jpg</_x003C_UserPictureFilename_x003E_k__BackingField></PictureLatest><PictureLatest><_x003C_Id_x003E_k__BackingField xmlns="http://schemas.datacontract.org/2004/07/NanoPop.Api.Models">9853</_x003C_Id_x003E_k__BackingField><_x003C_CreationDate_x003E_k__BackingField>2013-07-22T17:43:39</_x003C_CreationDate_x003E_k__BackingField><_x003C_Likes_x003E_k__BackingField>1</_x003C_Likes_x003E_k__BackingField><_x003C_Location_x003E_k__BackingField>Gávea, Rio de Janeiro, RJ</_x003C_Location_x003E_k__BackingField><_x003C_PictureFilename_x003E_k__BackingField>130722_VJ54K.jpg</_x003C_PictureFilename_x003E_k__BackingField><_x003C_PictureHeight_x003E_k__BackingField>960</_x003C_PictureHeight_x003E_k__BackingField><_x003C_PictureWidth_x003E_k__BackingField>960</_x003C_PictureWidth_x003E_k__BackingField><_x003C_TaskHashtag_x003E_k__BackingField>#nanopopvocetambem</_x003C_TaskHashtag_x003E_k__BackingField><_x003C_TaskId_x003E_k__BackingField>5</_x003C_TaskId_x003E_k__BackingField><_x003C_TaskTitle_x003E_k__BackingField>Pop uma foto para nanopop!</_x003C_TaskTitle_x003E_k__BackingField><_x003C_Title_x003E_k__BackingField>Mr Pop</_x003C_Title_x003E_k__BackingField><_x003C_UserId_x003E_k__BackingField>2</_x003C_UserId_x003E_k__BackingField><_x003C_UserName_x003E_k__BackingField>Eyal Ben-Ze'ev</_x003C_UserName_x003E_k__BackingField><_x003C_UserPictureFilename_x003E_k__BackingField>276014_770132032_603726249_q.jpg</_x003C_UserPictureFilename_x003E_k__BackingField></PictureLatest><PictureLatest><_x003C_Id_x003E_k__BackingField xmlns="http://schemas.datacontract.org/2004/07/NanoPop.Api.Models">9725</_x003C_Id_x003E_k__BackingField><_x003C_CreationDate_x003E_k__BackingField>2013-07-20T23:01:44</_x003C_CreationDate_x003E_k__BackingField><_x003C_Likes_x003E_k__BackingField>4</_x003C_Likes_x003E_k__BackingField><_x003C_Location_x003E_k__BackingField>Ipanema, Rio de Janeiro, RJ</_x003C_Location_x003E_k__BackingField><_x003C_PictureFilename_x003E_k__BackingField>130720_16VRJD.jpg</_x003C_PictureFilename_x003E_k__BackingField><_x003C_PictureHeight_x003E_k__BackingField>1200</_x003C_PictureHeight_x003E_k__BackingField><_x003C_PictureWidth_x003E_k__BackingField>1200</_x003C_PictureWidth_x003E_k__BackingField><_x003C_TaskHashtag_x003E_k__BackingField>#jmj</_x003C_TaskHashtag_x003E_k__BackingField><_x003C_TaskId_x003E_k__BackingField>28</_x003C_TaskId_x003E_k__BackingField><_x003C_TaskTitle_x003E_k__BackingField>A cobertura da Jornada Mundial da Juventude é aqui na nanopop!</_x003C_TaskTitle_x003E_k__BackingField><_x003C_Title_x003E_k__BackingField>Me and my friends</_x003C_Title_x003E_k__BackingField><_x003C_UserId_x003E_k__BackingField>2</_x003C_UserId_x003E_k__BackingField><_x003C_UserName_x003E_k__BackingField>Eyal Ben-Ze'ev</_x003C_UserName_x003E_k__BackingField><_x003C_UserPictureFilename_x003E_k__BackingField>276014_770132032_603726249_q.jpg</_x003C_UserPictureFilename_x003E_k__BackingField></PictureLatest><PictureLatest><_x003C_Id_x003E_k__BackingField xmlns="http://schemas.datacontract.org/2004/07/NanoPop.Api.Models">9724</_x003C_Id_x003E_k__BackingField><_x003C_CreationDate_x003E_k__BackingField>2013-07-20T22:59:47</_x003C_CreationDate_x003E_k__BackingField><_x003C_Likes_x003E_k__BackingField>3</_x003C_Likes_x003E_k__BackingField><_x003C_Location_x003E_k__BackingField>Copacabana, Rio de Janeiro, RJ</_x003C_Location_x003E_k__BackingField><_x003C_PictureFilename_x003E_k__BackingField>130720_16UCIG.jpg</_x003C_PictureFilename_x003E_k__BackingField><_x003C_PictureHeight_x003E_k__BackingField>832</_x003C_PictureHeight_x003E_k__BackingField><_x003C_PictureWidth_x003E_k__BackingField>832</_x003C_PictureWidth_x003E_k__BackingField><_x003C_TaskHashtag_x003E_k__BackingField>#jmj</_x003C_TaskHashtag_x003E_k__BackingField><_x003C_TaskId_x003E_k__BackingField>28</_x003C_TaskId_x003E_k__BackingField><_x003C_TaskTitle_x003E_k__BackingField>A cobertura da Jornada Mundial da Juventude é aqui na nanopop!</_x003C_TaskTitle_x003E_k__BackingField><_x003C_Title_x003E_k__BackingField i:nil="true" /><_x003C_UserId_x003E_k__BackingField>2</_x003C_UserId_x003E_k__BackingField><_x003C_UserName_x003E_k__BackingField>Eyal Ben-Ze'ev</_x003C_UserName_x003E_k__BackingField><_x003C_UserPictureFilename_x003E_k__BackingField>276014_770132032_603726249_q.jpg</_x003C_UserPictureFilename_x003E_k__BackingField></PictureLatest><PictureLatest><_x003C_Id_x003E_k__BackingField xmlns="http://schemas.datacontract.org/2004/07/NanoPop.Api.Models">9723</_x003C_Id_x003E_k__BackingField><_x003C_CreationDate_x003E_k__BackingField>2013-07-20T21:39:42</_x003C_CreationDate_x003E_k__BackingField><_x003C_Likes_x003E_k__BackingField>3</_x003C_Likes_x003E_k__BackingField><_x003C_Location_x003E_k__BackingField>Ipanema, Rio de Janeiro, RJ</_x003C_Location_x003E_k__BackingField><_x003C_PictureFilename_x003E_k__BackingField>130720_13Z0YP.jpg</_x003C_PictureFilename_x003E_k__BackingField><_x003C_PictureHeight_x003E_k__BackingField>1200</_x003C_PictureHeight_x003E_k__BackingField><_x003C_PictureWidth_x003E_k__BackingField>1200</_x003C_PictureWidth_x003E_k__BackingField><_x003C_TaskHashtag_x003E_k__BackingField>#jmj</_x003C_TaskHashtag_x003E_k__BackingField><_x003C_TaskId_x003E_k__BackingField>28</_x003C_TaskId_x003E_k__BackingField><_x003C_TaskTitle_x003E_k__BackingField>A cobertura da Jornada Mundial da Juventude é aqui na nanopop!</_x003C_TaskTitle_x003E_k__BackingField><_x003C_Title_x003E_k__BackingField>Welcome</_x003C_Title_x003E_k__BackingField><_x003C_UserId_x003E_k__BackingField>2</_x003C_UserId_x003E_k__BackingField><_x003C_UserName_x003E_k__BackingField>Eyal Ben-Ze'ev</_x003C_UserName_x003E_k__BackingField><_x003C_UserPictureFilename_x003E_k__BackingField>276014_770132032_603726249_q.jpg</_x003C_UserPictureFilename_x003E_k__BackingField></PictureLatest><PictureLatest><_x003C_Id_x003E_k__BackingField xmlns="http://schemas.datacontract.org/2004/07/NanoPop.Api.Models">9722</_x003C_Id_x003E_k__BackingField><_x003C_CreationDate_x003E_k__BackingField>2013-07-20T21:37:58</_x003C_CreationDate_x003E_k__BackingField><_x003C_Likes_x003E_k__BackingField>3</_x003C_Likes_x003E_k__BackingField><_x003C_Location_x003E_k__BackingField>Copacabana, Rio de Janeiro, RJ</_x003C_Location_x003E_k__BackingField><_x003C_PictureFilename_x003E_k__BackingField>130720_13X9RV.jpg</_x003C_PictureFilename_x003E_k__BackingField><_x003C_PictureHeight_x003E_k__BackingField>1200</_x003C_PictureHeight_x003E_k__BackingField><_x003C_PictureWidth_x003E_k__BackingField>1200</_x003C_PictureWidth_x003E_k__BackingField><_x003C_TaskHashtag_x003E_k__BackingField>#jmj</_x003C_TaskHashtag_x003E_k__BackingField><_x003C_TaskId_x003E_k__BackingField>28</_x003C_TaskId_x003E_k__BackingField><_x003C_TaskTitle_x003E_k__BackingField>A cobertura da Jornada Mundial da Juventude é aqui na nanopop!</_x003C_TaskTitle_x003E_k__BackingField><_x003C_Title_x003E_k__BackingField i:nil="true" /><_x003C_UserId_x003E_k__BackingField>2</_x003C_UserId_x003E_k__BackingField><_x003C_UserName_x003E_k__BackingField>Eyal Ben-Ze'ev</_x003C_UserName_x003E_k__BackingField><_x003C_UserPictureFilename_x003E_k__BackingField>276014_770132032_603726249_q.jpg</_x003C_UserPictureFilename_x003E_k__BackingField></PictureLatest><PictureLatest><_x003C_Id_x003E_k__BackingField xmlns="http://schemas.datacontract.org/2004/07/NanoPop.Api.Models">9716</_x003C_Id_x003E_k__BackingField><_x003C_CreationDate_x003E_k__BackingField>2013-07-19T19:39:32</_x003C_CreationDate_x003E_k__BackingField><_x003C_Likes_x003E_k__BackingField>2</_x003C_Likes_x003E_k__BackingField><_x003C_Location_x003E_k__BackingField>Lagoa, Rio de Janeiro, RJ</_x003C_Location_x003E_k__BackingField><_x003C_PictureFilename_x003E_k__BackingField>130719_ZO1DY.jpg</_x003C_PictureFilename_x003E_k__BackingField><_x003C_PictureHeight_x003E_k__BackingField>848</_x003C_PictureHeight_x003E_k__BackingField><_x003C_PictureWidth_x003E_k__BackingField>848</_x003C_PictureWidth_x003E_k__BackingField><_x003C_TaskHashtag_x003E_k__BackingField>#jmj</_x003C_TaskHashtag_x003E_k__BackingField><_x003C_TaskId_x003E_k__BackingField>28</_x003C_TaskId_x003E_k__BackingField><_x003C_TaskTitle_x003E_k__BackingField>A cobertura da Jornada Mundial da Juventude é aqui na nanopop!</_x003C_TaskTitle_x003E_k__BackingField><_x003C_Title_x003E_k__BackingField>Faltam 4 dias!</_x003C_Title_x003E_k__BackingField><_x003C_UserId_x003E_k__BackingField>1</_x003C_UserId_x003E_k__BackingField><_x003C_UserName_x003E_k__BackingField>Felipe Ouro Preto</_x003C_UserName_x003E_k__BackingField><_x003C_UserPictureFilename_x003E_k__BackingField>370086_711253843_1025899297_q.jpg</_x003C_UserPictureFilename_x003E_k__BackingField></PictureLatest></ArrayOfPictureLatest>
@@ -0,0 +1,47 @@
1
+ require_relative '../../test_helper'
2
+
3
+ describe Nanopop::Picture do
4
+
5
+ before do
6
+ Nanopop.configure do |config|
7
+ config.token = '1234'
8
+ end
9
+ RestClient.stubs(:get).returns(File.read("test/fixtures/test.xml"))
10
+ end
11
+
12
+ describe ".latest" do
13
+ subject do
14
+ Nanopop::Picture.latest(10)
15
+ end
16
+
17
+ it "should return 10 items" do
18
+ subject.size.must_equal 10
19
+ end
20
+ end
21
+
22
+ describe ".new" do
23
+ subject do
24
+ Nanopop::Picture.latest(10).last
25
+ end
26
+
27
+ it "should have id" do
28
+ subject.id.must_equal "9716"
29
+ end
30
+
31
+ it "should have url" do
32
+ subject.url.must_equal "https://nanopopapi.blob.core.windows.net/tasks/0009716/130719_ZO1DY.jpg"
33
+ end
34
+
35
+ it "should have user_name" do
36
+ subject.user_name.must_equal "Felipe Ouro Preto"
37
+ end
38
+
39
+ it "should have avatar_url" do
40
+ subject.avatar_url.must_equal "https://nanopopapi.blob.core.windows.net/users/0000001/370086_711253843_1025899297_q.jpg"
41
+ end
42
+
43
+ it "should have task_hashtag" do
44
+ subject.task_hashtag.must_equal "#jmj"
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,4 @@
1
+ require 'minitest/autorun'
2
+ require 'minitest/pride'
3
+ require File.expand_path('../../lib/nanopop.rb', __FILE__)
4
+ require 'mocha/setup'
metadata ADDED
@@ -0,0 +1,129 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nanopop
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Maiz Lulkin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-08-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: mocha
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: nokogiri
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rest-client
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Nanopop API
84
+ email:
85
+ - maiz@lulk.in
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - .gitignore
91
+ - Gemfile
92
+ - LICENSE.txt
93
+ - README.md
94
+ - Rakefile
95
+ - lib/nanopop.rb
96
+ - lib/nanopop/picture.rb
97
+ - lib/nanopop/version.rb
98
+ - nanopop.gemspec
99
+ - test/fixtures/test.xml
100
+ - test/lib/nanopop/picture_test.rb
101
+ - test/test_helper.rb
102
+ homepage: ''
103
+ licenses:
104
+ - MIT
105
+ metadata: {}
106
+ post_install_message:
107
+ rdoc_options: []
108
+ require_paths:
109
+ - lib
110
+ required_ruby_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - '>='
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ required_rubygems_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - '>='
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ requirements: []
121
+ rubyforge_project:
122
+ rubygems_version: 2.0.6
123
+ signing_key:
124
+ specification_version: 4
125
+ summary: Nanopop API
126
+ test_files:
127
+ - test/fixtures/test.xml
128
+ - test/lib/nanopop/picture_test.rb
129
+ - test/test_helper.rb