littlstar 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7e5b3421dd7f891ad026e817e810d41a87b4f8ce
4
+ data.tar.gz: 97acb20149cb7a8066a801559515af8d94503879
5
+ SHA512:
6
+ metadata.gz: 5b8409c18cb9eabb350040506f69955d60706d75c3b52f86294886a8de937104c9eadb756444c1649c90cda105a79d22f53786577445ee7a1f0387e346523751
7
+ data.tar.gz: b3dfa0e3e35e178a2b03f69dc9292aada3b6bf07110f00f987a37b42c4d5eca9960325993635c7b8a7200fe74e0c3367a924504179a7792c1e2491418ff398f5
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ .DS_Store
2
+ /.bundle/
3
+ /.yardoc
4
+ /Gemfile.lock
5
+ /_yardoc/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.5
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in littlstar.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Little Star Media, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,199 @@
1
+ # Littlstar Ruby Gem
2
+
3
+ This gem encapsulates the functionality needed to access content through the Littstar API.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'littlstar'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ ```bash
16
+ $ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+
21
+ ```bash
22
+ $ gem install littlstar
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ This gem defines seven classes that mimic the current Littlstar V1 API endpoints. These classes can be instantiated to interact with each endpoint individually and define the methods that are supported by their corresponding endpoints. Example responses for all endpoints can be found in the relevant sections of the Littlstar [API documentation](http://developer.littlstar.com/docs/).
28
+
29
+ ### Search
30
+
31
+ API search endpoints can be accessed through the `Littlstar::Search` class.
32
+
33
+ ```ruby
34
+ ls_search = Littlstar::Search.new
35
+
36
+ # Search across videos, photos, users, and channels
37
+ ls_search.all(q: 'search query')
38
+
39
+ # Search only videos
40
+ ls_search.videos(q: 'search query')
41
+
42
+ # Search only Photos
43
+ ls_search.photos(q: 'search query')
44
+
45
+ # Search only Users
46
+ ls_search.users(q: 'search query')
47
+
48
+ # Search only Channels
49
+ ls_search.channels(q: 'search query')
50
+ ```
51
+
52
+ ### Users
53
+
54
+ API user endpoints can be accessed through the `Littlstar::Users` class.
55
+
56
+ ```ruby
57
+ ls_users = Littlstar::Users.new
58
+
59
+ # Get a single user
60
+ ls_users.get(id)
61
+
62
+ # Get a single user's videos
63
+ ls_users.videos_for(id, {optional: 'query_params_hash'})
64
+
65
+ # Get a single user's photos
66
+ ls_users.photos_for(id, {optional: 'query_params_hash'})
67
+
68
+ # Get a single user's channels
69
+ ls_users.channels_for(id, {optional: 'query_params_hash'})
70
+
71
+ # Get a single user's followers
72
+ ls_users.followers_for(id, {optional: 'query_params_hash'})
73
+
74
+ # Get users currently followed by a single user
75
+ ls_users.following_for(id, {optional: 'query_params_hash'})
76
+ ```
77
+
78
+ ### Videos
79
+
80
+ API video endpoints can be accessed through the `Littlstar::Videos` class.
81
+
82
+ ```ruby
83
+ ls_videos = Littlstar::Videos.new
84
+
85
+ # Get a single video
86
+ ls_videos.get(id)
87
+
88
+ # Get all videos
89
+ ls_videos.all({optional: 'query_params_hash'})
90
+
91
+ # Get sponsored videos
92
+ ls_videos.sponsored({optional: 'query_params_hash'})
93
+
94
+ # Get featured videos
95
+ ls_videos.featured({optional: 'query_params_hash'})
96
+
97
+ # Get latest videos
98
+ ls_videos.latest({optional: 'query_params_hash'})
99
+
100
+ # Get VR videos
101
+ ls_videos.vr({optional: 'query_params_hash'})
102
+
103
+ # Get comments for a video
104
+ ls_videos.comments_for(id, {optional: 'query_params_hash'})
105
+ ```
106
+
107
+ ### Photos
108
+
109
+ API photo endpoints can be accessed through the `Littlstar::Photos` class.
110
+
111
+ ```ruby
112
+ ls_photos = Littlstar::Photos.new
113
+
114
+ # Get a single photo
115
+ ls_photos.get(id)
116
+
117
+ # Get all photos
118
+ ls_photos.all({optional: 'query_params_hash'})
119
+
120
+ # Get featured photos
121
+ ls_photos.featured({optional: 'query_params_hash'})
122
+
123
+ # Get latest photos
124
+ ls_photos.latest({optional: 'query_params_hash'})
125
+
126
+ # Get VR photos
127
+ ls_photos.vr({optional: 'query_params_hash'})
128
+
129
+ # Get comments for a video
130
+ ls_photos.comments_for(id, {optional: 'query_params_hash'})
131
+ ```
132
+
133
+ ### Categories
134
+
135
+ API category endpoints can be accessed through the `Littlstar::Categories` class.
136
+
137
+ ```ruby
138
+ ls_categories = Littlstar::Categories.new
139
+
140
+ # Get a single category
141
+ ls_categories.get(id)
142
+
143
+ # Get all categories
144
+ ls_categories.all({optional: 'query_params_hash'})
145
+
146
+ # Get single category videos
147
+ ls_categories.videos_for(id, {optional: 'query_params_hash'})
148
+
149
+ # Get single category photos
150
+ ls_categories.photos_for(id, {optional: 'query_params_hash'})
151
+ ```
152
+
153
+ ### Channels
154
+
155
+ API channel endpoints can be accessed through the `Littlstar::Channels` class.
156
+
157
+ ```ruby
158
+ ls_channels = Littlstar::Channels.new
159
+
160
+ # Get a single channel
161
+ ls_channels.get(id)
162
+
163
+ # Get all channels
164
+ ls_channels.all({optional: 'query_params_hash'})
165
+
166
+ # Get single channel videos
167
+ ls_channels.videos_for(id, {optional: 'query_params_hash'})
168
+
169
+ # Get single channel photos
170
+ ls_channels.photos_for(id, {optional: 'query_params_hash'})
171
+ ```
172
+
173
+ ### Hashtags
174
+
175
+ API hashtag endpoints can be accessed through the `Littlstar::Hashtags` class.
176
+
177
+ ```ruby
178
+ ls_hashtags = Littlstar::Hashtags.new
179
+
180
+ # Get a single hashtag
181
+ ls_hashtags.get(id)
182
+
183
+ # Get all hashtags
184
+ ls_hashtags.all({optional: 'query_params_hash'})
185
+
186
+ # Get single hashtag videos
187
+ ls_hashtags.videos_for(id, {optional: 'query_params_hash'})
188
+
189
+ # Get single hashtag photos
190
+ ls_hashtags.photos_for(id, {optional: 'query_params_hash'})
191
+ ```
192
+
193
+ ## Contributing
194
+
195
+ 1. Fork it ( https://github.com/[my-github-username]/littlstar/fork )
196
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
197
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
198
+ 4. Push to the branch (`git push origin my-new-feature`)
199
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,17 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ desc 'Generate gem documentation'
5
+ task :doc do
6
+ system 'rm -rf doc/'
7
+ system 'rdoc --exclude=/spec/'
8
+ end
9
+
10
+ namespace :minitest do
11
+ Rake::TestTask.new(:all) do |t|
12
+ t.libs << 'test'
13
+ t.test_files = FileList['test/test_*.rb']
14
+ end
15
+ end
16
+
17
+ task :default => 'minitest:all'
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "littlstar"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
data/lib/littlstar.rb ADDED
@@ -0,0 +1,64 @@
1
+ # Littlstar Ruby Library
2
+ require 'net/http'
3
+ require 'json'
4
+ require 'littlstar/version'
5
+ require 'littlstar/search'
6
+ require 'littlstar/users'
7
+ require 'littlstar/videos'
8
+ require 'littlstar/photos'
9
+ require 'littlstar/categories'
10
+ require 'littlstar/channels'
11
+ require 'littlstar/hashtags'
12
+
13
+ module Littlstar
14
+
15
+ @@apikey = ''
16
+ @@api_base = 'https://littlstar.com/api/v1'
17
+
18
+ def self.apikey()
19
+ @@apikey
20
+ end
21
+
22
+ def self.apikey=(key)
23
+ @@apikey = key
24
+ end
25
+
26
+ def self.api_base()
27
+ @@api_base
28
+ end
29
+
30
+ def self.api_base=(base)
31
+ @@api_base = base
32
+ end
33
+
34
+ def self.api_url(path='', query={})
35
+ self.api_base + path + self.query_params_from(query)
36
+ end
37
+
38
+ def self.query_params_from(hash)
39
+ "?#{URI.encode(hash.map { |k,v| "#{k}=#{v}" }.join('&'))}"
40
+ end
41
+
42
+ ##
43
+ # The request() method is the heart and soul of the library. It is responsible for taking the
44
+ # connection details from each resource class and creating the Net::HTTP object that will
45
+ # ultimately send the appropriate request and return the response from the Littstar API server.
46
+ def self.request(method, path, query={})
47
+
48
+ # create connection uri
49
+ uri = URI.parse(self.api_url(path, query))
50
+
51
+ # create request object
52
+ req = Net::HTTP::Get.new(uri.to_s)
53
+ req['User-Agent'] = "ruby-sdk/#{Littlstar::VERSION}",
54
+ req['Content-Type'] = 'application/json',
55
+ req['X-Apikey'] = self.apikey
56
+
57
+ # send request and build response
58
+ Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
59
+ res = http.request(req)
60
+ JSON.parse(res.body, symbolize_names: true)
61
+ end
62
+
63
+ end
64
+ end
@@ -0,0 +1,21 @@
1
+ module Littlstar
2
+ class Categories
3
+
4
+ def get(id)
5
+ Littlstar.request(:get, "/categories/#{id}")
6
+ end
7
+
8
+ def all(query={})
9
+ Littlstar.request(:get, '/categories', query)
10
+ end
11
+
12
+ def videos_for(id, query={})
13
+ Littlstar.request(:get, "/categories/#{id}/videos", query)
14
+ end
15
+
16
+ def photos_for(id, query={})
17
+ Littlstar.request(:get, "/categories/#{id}/photos", query)
18
+ end
19
+
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ module Littlstar
2
+ class Channels
3
+
4
+ def get(id)
5
+ Littlstar.request(:get, "/channels/#{id}")
6
+ end
7
+
8
+ def all(query={})
9
+ Littlstar.request(:get, '/channels', query)
10
+ end
11
+
12
+ def videos_for(id, query={})
13
+ Littlstar.request(:get, "/channels/#{id}/videos", query)
14
+ end
15
+
16
+ def photos_for(id, query={})
17
+ Littlstar.request(:get, "/channels/#{id}/photos", query)
18
+ end
19
+
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ module Littlstar
2
+ class Hashtags
3
+
4
+ def get(id)
5
+ Littlstar.request(:get, "/hashtags/#{id}")
6
+ end
7
+
8
+ def all(query={})
9
+ Littlstar.request(:get, '/hashtags', query)
10
+ end
11
+
12
+ def videos_for(id, query={})
13
+ Littlstar.request(:get, "/hashtags/#{id}/videos", query)
14
+ end
15
+
16
+ def photos_for(id, query={})
17
+ Littlstar.request(:get, "/hashtags/#{id}/photos", query)
18
+ end
19
+
20
+ end
21
+ end
@@ -0,0 +1,29 @@
1
+ module Littlstar
2
+ class Photos
3
+
4
+ def get(id)
5
+ Littlstar.request(:get, "/photos/#{id}")
6
+ end
7
+
8
+ def all(query={})
9
+ Littlstar.request(:get, '/photos', query)
10
+ end
11
+
12
+ def featured(query={})
13
+ Littlstar.request(:get, '/photos/featured', query)
14
+ end
15
+
16
+ def latest(query={})
17
+ Littlstar.request(:get, '/photos/latest', query)
18
+ end
19
+
20
+ def vr(query={})
21
+ Littlstar.request(:get, '/photos/vr', query)
22
+ end
23
+
24
+ def comments_for(id, query={})
25
+ Littlstar.request(:get, "/photos/#{id}/comments", query)
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,25 @@
1
+ module Littlstar
2
+ class Search
3
+
4
+ def all(query={})
5
+ Littlstar.request(:get, '/search', query)
6
+ end
7
+
8
+ def videos(query={})
9
+ Littlstar.request(:get, '/search/videos', query)
10
+ end
11
+
12
+ def photos(query={})
13
+ Littlstar.request(:get, '/search/photos', query)
14
+ end
15
+
16
+ def users(query={})
17
+ Littlstar.request(:get, '/search/users', query)
18
+ end
19
+
20
+ def channels(query={})
21
+ Littlstar.request(:get, '/search/channels', query)
22
+ end
23
+
24
+ end
25
+ end
@@ -0,0 +1,29 @@
1
+ module Littlstar
2
+ class Users
3
+
4
+ def get(id)
5
+ Littlstar.request(:get, "/users/#{id}")
6
+ end
7
+
8
+ def videos_for(id, query={})
9
+ Littlstar.request(:get, "/users/#{id}/videos", query)
10
+ end
11
+
12
+ def photos_for(id, query={})
13
+ Littlstar.request(:get, "/users/#{id}/photos", query)
14
+ end
15
+
16
+ def channels_for(id, query={})
17
+ Littlstar.request(:get, "/users/#{id}/channels", query)
18
+ end
19
+
20
+ def followers_for(id, query={})
21
+ Littlstar.request(:get, "/users/#{id}/followers", query)
22
+ end
23
+
24
+ def following_for(id, query={})
25
+ Littlstar.request(:get, "/users/#{id}/following", query)
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,3 @@
1
+ module Littlstar
2
+ VERSION = '0.1.2'
3
+ end
@@ -0,0 +1,33 @@
1
+ module Littlstar
2
+ class Videos
3
+
4
+ def get(id)
5
+ Littlstar.request(:get, "/videos/#{id}")
6
+ end
7
+
8
+ def all(query={})
9
+ Littlstar.request(:get, '/videos', query)
10
+ end
11
+
12
+ def sponsored(query={})
13
+ Littlstar.request(:get, '/videos/sponsored', query)
14
+ end
15
+
16
+ def featured(query={})
17
+ Littlstar.request(:get, '/videos/featured', query)
18
+ end
19
+
20
+ def latest(query={})
21
+ Littlstar.request(:get, '/videos/latest', query)
22
+ end
23
+
24
+ def vr(query={})
25
+ Littlstar.request(:get, '/videos/vr', query)
26
+ end
27
+
28
+ def comments_for(id, query={})
29
+ Littlstar.request(:get, "/videos/#{id}/comments", query)
30
+ end
31
+
32
+ end
33
+ end
data/littlstar.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'littlstar/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'littlstar'
8
+ spec.version = Littlstar::VERSION
9
+ spec.authors = ['Dominic Giglio']
10
+ spec.email = ['support@littlstar.com']
11
+
12
+ spec.summary = %q{Access Littlstar API}
13
+ spec.description = %q{This gem defines methods for controlling your content through the Littlstar API.}
14
+ spec.homepage = 'https://github.com/littlstar/ruby-sdk'
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = 'exe'
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.add_development_dependency 'bundler', '~> 1.9'
23
+ spec.add_development_dependency 'rake', '~> 10.0'
24
+ end
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: littlstar
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - Dominic Giglio
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-07-11 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.9'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: This gem defines methods for controlling your content through the Littlstar
42
+ API.
43
+ email:
44
+ - support@littlstar.com
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".gitignore"
50
+ - ".travis.yml"
51
+ - Gemfile
52
+ - LICENSE.txt
53
+ - README.md
54
+ - Rakefile
55
+ - bin/console
56
+ - bin/setup
57
+ - lib/littlstar.rb
58
+ - lib/littlstar/categories.rb
59
+ - lib/littlstar/channels.rb
60
+ - lib/littlstar/hashtags.rb
61
+ - lib/littlstar/photos.rb
62
+ - lib/littlstar/search.rb
63
+ - lib/littlstar/users.rb
64
+ - lib/littlstar/version.rb
65
+ - lib/littlstar/videos.rb
66
+ - littlstar.gemspec
67
+ homepage: https://github.com/littlstar/ruby-sdk
68
+ licenses:
69
+ - MIT
70
+ metadata: {}
71
+ post_install_message:
72
+ rdoc_options: []
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ requirements: []
86
+ rubyforge_project:
87
+ rubygems_version: 2.2.2
88
+ signing_key:
89
+ specification_version: 4
90
+ summary: Access Littlstar API
91
+ test_files: []