Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: seanslerner/Jammed
base: f335fc665d
...
head fork: seanslerner/Jammed
compare: 4a4ffe3fd3
Checking mergeability… Don't worry, you can still create the pull request.
  • 6 commits
  • 13 files changed
  • 0 commit comments
  • 2 contributors
View
7 .gitignore
@@ -1 +1,6 @@
-Gemfile.lock
+coverage
+rdoc
+pkg/*
+*.gem
+.bundle
+Gemfile.lock
View
12 Rakefile 100644 → 100755
@@ -31,4 +31,14 @@ Jeweler::RubygemsDotOrgTasks.new
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
-task default: :spec
+task default: :spec
+
+require 'rdoc/task'
+Rake::RDocTask.new do |rdoc|
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
+
+ rdoc.rdoc_dir = 'rdoc'
+ rdoc.title = "Jammed #{version}"
+ rdoc.rdoc_files.include('README*')
+ rdoc.rdoc_files.include('lib/**/*.rb')
+end
View
1  lib/jammed.rb
@@ -4,5 +4,6 @@
end
module Jammed
+ #Beta API Key (This will be assignable soon)
API_KEY = '987bcab01b929eb2c07877b224215c92'
end
View
20 lib/jammed/followers.rb
@@ -1,10 +1,26 @@
-module Jammed
+module Jammed #:nodoc:
+ # Provides methods for calling API endpoint /follower.json?
class Followers
- class Search
+ class Search #:nodoc:
include HTTParty
base_uri 'http://api.thisismyjam.com/1'
end
+ # Calls API for user specific data concerning followers
+ #
+ # ==== Attributes
+ #
+ # * +username+ - The username of the user whose followers you want to retrieve
+ # * +opts+ - Options for ordering the data
+ #
+ # ==== Options
+ #
+ # * +:order+ - A symbol determining how the data is orderd like :date, :affinity, or :alpha
+ #
+ # ==== Examples
+ #
+ # Jammed::Followers.followers('IFTFOM') #returns followers unorderd
+ # Jammed::Followers.followers('IFTFOM', :order => :date) # returns followers ordered by date
def self.followers(username, opts={})
case(opts[:order])
when nil
View
20 lib/jammed/following.rb
@@ -1,10 +1,26 @@
-module Jammed
+module Jammed #:nodoc:
+ # Provides methods for calling API endpoint /following.json?
class Following
- class Search
+ class Search #:nodoc:
include HTTParty
base_uri 'http://api.thisismyjam.com/1'
end
+ # Calls API for user specific data concerning who the user is following
+ #
+ # ==== Attributes
+ #
+ # * +username+ - The username of the user whose followings you want to retrieve
+ # * +opts+ - Options for ordering the data
+ #
+ # ==== Options
+ #
+ # * +:order+ - A symbol determining how the data is orderd like :date, :affinity, or :alpha
+ #
+ # ==== Examples
+ #
+ # Jammed::Following.following('IFTFOM') #returns followings unorderd
+ # Jammed::Following.following('IFTFOM', :order => :date) # returns followings ordered by date
def self.following(username, opts={})
case(opts[:order])
when nil
View
20 lib/jammed/jams.rb
@@ -1,10 +1,26 @@
-module Jammed
+module Jammed #:nodoc:
+ # Provides methods for calling API endpoint /jams.json?
class Jams
- class Search
+ class Search #:nodoc:
include HTTParty
base_uri 'http://api.thisismyjam.com/1'
end
+ # Calls API for user specific data concerning jams
+ #
+ # ==== Attributes
+ #
+ # * +username+ - The username of the user whose followings you want to retrieve
+ # * +opts+ - Options for which data is shown
+ #
+ # ==== Options
+ #
+ # * +:show+ - A symbol determining what data is shown like :past or :current
+ #
+ # ==== Examples
+ #
+ # Jammed::Jams.jams('IFTFOM') #returns all jams
+ # Jammed::Jams.jams('IFTFOM', :show => :past) # returns only past jams
def self.jams(username, opts={})
case(opts[:show])
when nil
View
20 lib/jammed/likes.rb
@@ -1,10 +1,26 @@
-module Jammed
+module Jammed #:nodoc:
+ # Provides methods for calling API endpoint /likes.json?
class Likes
- class Search
+ class Search #:nodoc:
include HTTParty
base_uri 'http://api.thisismyjam.com/1'
end
+ # Calls API for user specific data concerning likes
+ #
+ # ==== Attributes
+ #
+ # * +username+ - The username of the user whose followings you want to retrieve
+ # * +opts+ - Options for which data is shown
+ #
+ # ==== Options
+ #
+ # * +:show+ - A symbol determining what data is shown like :past or :current
+ #
+ # ==== Examples
+ #
+ # Jammed::Likes.likes('IFTFOM') #returns all likes
+ # Jammed::Likes.likes('IFTFOM', :show => :past) # returns only past likes
def self.likes(username, opts={})
case(opts[:show])
when nil
View
33 lib/jammed/people_search.rb
@@ -1,24 +1,53 @@
require 'uri'
-module Jammed
+module Jammed #:nodoc:
- class Search
+ class Search #:nodoc:
include HTTParty
base_uri 'http://api.thisismyjam.com/1'
end
+ # Provides methods for calling API endpoint /pseron.json?by=
class PeopleSearch
+ # Calls API for a search by username
+ #
+ # ==== Attributes
+ #
+ # * +name+ - Username to search by
+ #
+ # ==== Examples
+ #
+ # Jammed::PeopleSearch.search_name('IFTFOM')
def self.search_name(name)
search = Search.get "/search/person.json?by=name&q=#{name.split.join('+')}&key=#{API_KEY}"
search["people"][0] ? search["people"] : "No people found"
end
+ # Calls API for a search by artist
+ #
+ # ==== Attributes
+ #
+ # * +artist+ - Artist to search by
+ #
+ # ==== Examples
+ #
+ # Jammed::PeopleSearch.search_artist('beache boys')
def self.search_artist(artist)
search = Search.get "/search/person.json?by=artist&q=#{artist.split.join('+')}&key=#{API_KEY}"
search["people"][0] ? search["people"] : "No artists found"
end
+ # Calls API for a search by track
+ #
+ # ==== Attributes
+ #
+ # * +artist+ - Artist to search by
+ # * +track+ - Track to search by
+ #
+ # ==== Examples
+ #
+ # Jammed::PeopleSearch.search_track('beach boys', 'good vibrations')
def self.search_track(artist, track)
uri = URI.escape("/search/person.json?by=track&q=#{artist.split.join('+')}|#{track.split.join('+')}&key=#{API_KEY}", '|')
search = Search.get uri
View
20 lib/jammed/person.rb
@@ -1,20 +1,36 @@
-module Jammed
+module Jammed #:nodoc:
+ # Provides methods for calling API endpoint /username.json? and accessing user specific data
class Person
- class Search
+ class Search #:nodoc:
include HTTParty
base_uri 'http://api.thisismyjam.com/1'
end
+ # Calls API for a specific user's profile
+ #
+ # ==== Examples
+ #
+ # Jammed::Person.profile(:username => 'IFTFOM') #returns IFTFOM's profile data
def self.profile(opts={})
profile = Search.get "/#{opts[:username]}.json?key=#{API_KEY}"
profile["person"] ? profile["person"] : "404: User Not Found"
end
+ # Calls API for a specific user's name
+ #
+ # ==== Examples
+ #
+ # Jammed::Person.name(:username => 'IFTFOM') #returns 'IFTFOM'
def self.name(opts={})
self.profile(opts)['name']
end
+ # Calls API for a specific attribute of a user's profile
+ #
+ # ==== Examples
+ #
+ # Jammed::Person.joinedDate(:username => 'IFTFOM') #returns IFTFOM's joined date
def self.method_missing(name, *args, &block)
self.profile(args[0]).has_key?(name.to_s) ? self.profile(args[0])[name.to_s] : super
end
View
12 lib/jammed/popular_jams.rb
@@ -1,11 +1,17 @@
-module Jammed
+module Jammed #:nodoc:
+ # Provides method for calling API endpoint /popular.json?
class PopularJams
- class Search
+ class Search #:nodoc:
include HTTParty
base_uri 'http://api.thisismyjam.com/1'
end
-
+
+ # Calls API for popular jams
+ #
+ # ==== Examples
+ #
+ # Jammed::PopularJams.popular_jams #returns a sample of popular jams
def self.popular_jams
Search.get "/popular.json?key=#{API_KEY}"
end
View
10 lib/jammed/suggested_people.rb
@@ -1,11 +1,17 @@
-module Jammed
+module Jammed #:nodoc:
+ # Provides method for calling API endpoint /suggestedPeople.json?
class SuggestedPeople
- class Search
+ class Search #:nodoc:
include HTTParty
base_uri 'http://api.thisismyjam.com/1'
end
+ # Calls API for suggested people
+ #
+ # ==== Examples
+ #
+ # Jammed::SuggestedPeople.people #returns a list of users with many followers/likes
def self.people
response = Search.get "/suggestedPeople.json?key=#{API_KEY}"
response["people"][0] ? response["people"] : "No people found"
View
96 lib/jammed/user.rb
@@ -1,7 +1,19 @@
-module Jammed
+module Jammed #:nodoc:
+ # Provides User objects for interacting with user-specific data
class User
+
+ # Each attr_accessor (except for :username) caches API data on first use in corresponding instance variable
attr_accessor :username, :followers, :following, :jams, :likes, :profile
+ # Creates a new Jammed::User object and assigns a username to @username
+ #
+ # ==== Attributes
+ #
+ # * +username+ - Username of user to make API calls with
+ #
+ # ==== Examples
+ #
+ # iftfom = Jammed::User.new('IFTFOM')
def initialize(username)
@username = username
end
@@ -10,6 +22,21 @@ def followers(opts={})
@followers ||= Jammed::Followers.followers(@username, opts)
end
+ # Clears cached Followers data with a fresh call to Jammed::Followers
+ #
+ # ==== Attributes
+ #
+ # * +opts+ - Options for ordering Followers data
+ #
+ # ==== Options
+ #
+ # * +:order+ - A symbol determining how the data is orderd like :date, :affinity, or :alpha
+ #
+ # ==== Examples
+ #
+ # user = Jammed::User.new('IFTFOM')
+ # user.followers #returns all followers of IFTFOM
+ # user.followers(:order => :date) #reutrns IFTFOM's followers ordered by date
def followers!(opts={})
@followers = Jammed::Followers.followers(@username, opts)
end
@@ -18,6 +45,21 @@ def following(opts={})
@following ||= Jammed::Following.following(@username, opts)
end
+ # Clears cached Following data with a fresh call to Jammed::Following
+ #
+ # ==== Attributes
+ #
+ # * +opts+ - Options for ordering Following data
+ #
+ # ==== Options
+ #
+ # * +:order+ - A symbol determining how the data is orderd like :date, :affinity, or :alpha
+ #
+ # ==== Examples
+ #
+ # user = Jammed::User.new('IFTFOM')
+ # user.following #returns all followings of IFTFOM
+ # user.following(:order => :date) #returns IFTFOM's followings ordered by date
def following!(opts={})
@following = Jammed::Following.following(@username, opts)
end
@@ -26,6 +68,21 @@ def jams(opts={})
@jams ||= Jammed::Jams.jams(@username, opts)
end
+ # Clears cached Jams data with a fresh call to Jammed::Jams
+ #
+ # ==== Attributes
+ #
+ # * +opts+ - Options for which data is shown
+ #
+ # ==== Options
+ #
+ # * +:show+ - A symbol determining what data is shown like :past or :current
+ #
+ # ==== Examples
+ #
+ # user = Jammed::User.new('IFTFOM')
+ # user.jams #returns all jams of IFTFOM
+ # user.jams(:show => :past) #returns IFTFOM's past jams
def jams!(opts={})
@jams = Jammed::Jams.jams(@username, opts)
end
@@ -34,6 +91,21 @@ def likes(opts={})
@likes ||= Jammed::Likes.likes(@username, opts)
end
+ # Clears cached Likes data with a fresh call to Jammed::Likes
+ #
+ # ==== Attributes
+ #
+ # * +opts+ - Options for which data is shown
+ #
+ # ==== Options
+ #
+ # * +:show+ - A symbol determining what data is shown like :past or :current
+ #
+ # ==== Examples
+ #
+ # user = Jammed::User.new('IFTFOM')
+ # user.likes #returns all likes of IFTFOM
+ # user.likes(:show => :past) #returns IFTFOM's past likes
def likes!(opts={})
@likes = Jammed::Likes.likes(@username, opts)
end
@@ -42,16 +114,38 @@ def profile
@profile ||= Jammed::Person.profile(:username => @username)
end
+ # Clears cached Person data with a fresh call to Jammed::Person
+ #
+ # ==== Examples
+ #
+ # user = Jammed::User.new('IFTFOM')
+ # user.profile #returns entire profile of IFTFOM
def profile!
@profile = Jammed::Person.profile(:username => @username)
end
+ # Checks user's profile for attribute and returns value if attribute key is found.
+ #
+ # ==== Examples
+ #
+ # user = Jammed::User.new('IFTFOM')
+ # user.name #returns 'IFTFOM'
+ # user.date_joined #uses js_namify to find 'dateJoined' key and returns date
def method_missing(name, *args, &block)
n = name.to_s.index('_') != nil ? js_namify(name.to_s) : name.to_s
profile.has_key?(n) ? profile[n] : super
end
+ # Converts Ruby styled method names to JavaScript's prefered style. Used by method_missing to generate dynamic attributes methods for user's profile.
+ #
+ # ==== Attributes
+ #
+ # * +name+ - Method name to be converted
+ #
+ # ==== Examples
+ #
+ # js_namify('date_joined') #returns 'dateJoined'
def js_namify(name)
x = []
name.split('_').each_with_index do |e, i|
View
1  lib/jammed/version.rb
@@ -1,3 +1,4 @@
module Jammed
+ #:nodoc:
VERSION = "0.0.1"
end

No commit comments for this range

Something went wrong with that request. Please try again.