Skip to content
This repository has been archived by the owner on Feb 16, 2018. It is now read-only.

Commit

Permalink
Rename tent-server to tentd
Browse files Browse the repository at this point in the history
  • Loading branch information
titanous committed Sep 3, 2012
1 parent 99ed314 commit 131f435
Show file tree
Hide file tree
Showing 78 changed files with 345 additions and 345 deletions.
2 changes: 1 addition & 1 deletion Guardfile
@@ -1,6 +1,6 @@
guard 'rspec', :version => 2 do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/tent-server/(.+)\.rb$}) { |m| "spec/unit/#{m[1]}_spec.rb" }
watch(%r{^lib/tentd/(.+)\.rb$}) { |m| "spec/unit/#{m[1]}_spec.rb" }
watch(%r{^lib/[^/]+\.rb$}) { "spec" }
watch(%r{spec/(spec_helper|support/).*\.rb}) { "spec" }
end
6 changes: 3 additions & 3 deletions README.md
@@ -1,20 +1,20 @@
# Tent::Server
# TentD

TODO: Write a gem description

## Installation

Add this line to your application's Gemfile:

gem 'tent-server'
gem 'tentd'

And then execute:

$ bundle

Or install it yourself as:

$ gem install tent-server
$ gem install tentd

## Usage

Expand Down
17 changes: 0 additions & 17 deletions lib/tent-server.rb

This file was deleted.

30 changes: 0 additions & 30 deletions lib/tent-server/api.rb

This file was deleted.

24 changes: 0 additions & 24 deletions lib/tent-server/model.rb

This file was deleted.

18 changes: 0 additions & 18 deletions lib/tent-server/model/permission.rb

This file was deleted.

17 changes: 17 additions & 0 deletions lib/tentd.rb
@@ -0,0 +1,17 @@
require 'tentd/version'
require 'tent-client'

module TentD
autoload :API, 'tentd/api'
autoload :Action, 'tentd/action'
autoload :JsonPatch, 'tentd/json_patch'
autoload :TentVersion, 'tentd/tent_version'
autoload :RackRequest, 'tentd/rack_request'

def self.new(options={})
DataMapper.setup(:default, options[:database] || ENV['DATABASE_URL'])
API.new
end
end

require 'tentd/model'
30 changes: 30 additions & 0 deletions lib/tentd/api.rb
@@ -0,0 +1,30 @@
module TentD
class API
PER_PAGE = 50
MAX_PER_PAGE = 200
MEDIA_TYPE = 'application/vnd.tent.v0+json'

autoload :Apps, 'tentd/api/apps'
autoload :Posts, 'tentd/api/posts'
autoload :Groups, 'tentd/api/groups'
autoload :Profile, 'tentd/api/profile'
autoload :Followers, 'tentd/api/followers'
autoload :Followings, 'tentd/api/followings'
autoload :CoreProfileData, 'tentd/api/core_profile_data'
autoload :AuthenticationLookup, 'tentd/api/authentication_lookup'
autoload :AuthenticationVerification, 'tentd/api/authentication_verification'
autoload :AuthenticationFinalize, 'tentd/api/authentication_finalize'
autoload :Authorization, 'tentd/api/authorization'
autoload :Authorizable, 'tentd/api/authorizable'
autoload :Router, 'tentd/api/router'
autoload :Middleware, 'tentd/api/middleware'
include Router

mount Apps
mount Posts
mount Groups
mount Profile
mount Followers
mount Followings
end
end
2 changes: 1 addition & 1 deletion lib/tent-server/api/apps.rb → lib/tentd/api/apps.rb
@@ -1,4 +1,4 @@
module TentServer
module TentD
class API
class Apps
include Router
Expand Down
@@ -1,4 +1,4 @@
module TentServer
module TentD
class API
class AuthenticationFinalize < Middleware
def action(env)
Expand Down
@@ -1,16 +1,16 @@
module TentServer
module TentD
class API
class AuthenticationLookup < Middleware
def action(env)
return env unless env['HTTP_AUTHORIZATION']
env['hmac'] = Hash[env['HTTP_AUTHORIZATION'].scan(/([a-z]+)="([^"]+)"/i)]
case env['hmac']['id'].to_s[0,1]
when 's'
env.potential_auth = TentServer::Model::Follower.first(:mac_key_id => env['hmac']['id'])
env.potential_auth = TentD::Model::Follower.first(:mac_key_id => env['hmac']['id'])
when 'a'
env.potential_auth = TentServer::Model::App.first(:mac_key_id => env['hmac']['id'])
env.potential_auth = TentD::Model::App.first(:mac_key_id => env['hmac']['id'])
when 'u'
env.potential_auth = TentServer::Model::AppAuthorization.first(:mac_key_id => env['hmac']['id'])
env.potential_auth = TentD::Model::AppAuthorization.first(:mac_key_id => env['hmac']['id'])
end
env.hmac.secret = env.potential_auth.mac_key
env.hmac.algorithm = env.potential_auth.mac_algorithm
Expand Down
@@ -1,7 +1,7 @@
require 'openssl'
require 'base64'

module TentServer
module TentD
class API
class AuthenticationVerification < Middleware
def action(env)
Expand Down
@@ -1,4 +1,4 @@
module TentServer
module TentD
class API
module Authorizable
class Error < StandardError
Expand Down
@@ -1,4 +1,4 @@
module TentServer
module TentD
class API
class Authorization < Middleware
def action(env)
Expand Down
@@ -1,6 +1,6 @@
require 'hashie'

module TentServer
module TentD
class API
class CoreProfileData < Hashie::Mash
def expected_version
Expand Down
@@ -1,4 +1,4 @@
module TentServer
module TentD
class API
class Followers
include Router
Expand Down
@@ -1,4 +1,4 @@
module TentServer
module TentD
class API
class Followings
include Router
Expand Down
2 changes: 1 addition & 1 deletion lib/tent-server/api/groups.rb → lib/tentd/api/groups.rb
@@ -1,4 +1,4 @@
module TentServer
module TentD
class API
class Groups
include Router
Expand Down
@@ -1,6 +1,6 @@
require 'hashie'

module TentServer
module TentD
class API
class Middleware
include Authorizable
Expand Down
6 changes: 3 additions & 3 deletions lib/tent-server/api/posts.rb → lib/tentd/api/posts.rb
@@ -1,4 +1,4 @@
module TentServer
module TentD
class API
class Posts
include Router
Expand Down Expand Up @@ -56,9 +56,9 @@ def action(env)
conditions[:type] = env.current_auth.post_types
end
if env.params.limit
conditions[:limit] = [env.params.limit.to_i, TentServer::API::MAX_PER_PAGE].min
conditions[:limit] = [env.params.limit.to_i, TentD::API::MAX_PER_PAGE].min
else
conditions[:limit] = TentServer::API::PER_PAGE
conditions[:limit] = TentD::API::PER_PAGE
end
if conditions[:limit] == 0
env.response = []
Expand Down
@@ -1,4 +1,4 @@
module TentServer
module TentD
class API
class Profile
include Router
Expand Down
8 changes: 4 additions & 4 deletions lib/tent-server/api/router.rb → lib/tentd/api/router.rb
Expand Up @@ -19,12 +19,12 @@ def merge_route(route)
end
end

module TentServer
module TentD
class API
module Router
autoload :ExtractParams, 'tent-server/api/router/extract_params'
autoload :SerializeResponse, 'tent-server/api/router/serialize_response'
autoload :CachingHeaders, 'tent-server/api/router/caching_headers'
autoload :ExtractParams, 'tentd/api/router/extract_params'
autoload :SerializeResponse, 'tentd/api/router/serialize_response'
autoload :CachingHeaders, 'tentd/api/router/caching_headers'

def self.included(base)
base.extend(ClassMethods)
Expand Down
@@ -1,6 +1,6 @@
require 'time'

module TentServer
module TentD
class API
module Router
class CachingHeaders
Expand Down
@@ -1,4 +1,4 @@
module TentServer
module TentD
class API
module Router
class ExtractParams
Expand Down
@@ -1,6 +1,6 @@
require 'json'

module TentServer
module TentD
class API
module Router
class SerializeResponse
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion lib/tent-server/json_patch.rb → lib/tentd/json_patch.rb
@@ -1,4 +1,4 @@
module TentServer
module TentD
class JsonPatch
OPERATIONS = %w( add remove replace move copy test )

Expand Down
24 changes: 24 additions & 0 deletions lib/tentd/model.rb
@@ -0,0 +1,24 @@
require 'data_mapper'
require 'dm-ar-finders'
require 'tentd/datamapper/array_property'
require 'tentd/datamapper/binary_string_property'
require 'tentd/datamapper/query'

module TentD
module Model
require 'tentd/model/permissible'
require 'tentd/model/random_public_id'
require 'tentd/model/post'
require 'tentd/model/post_attachment'
require 'tentd/model/follower'
require 'tentd/model/following'
require 'tentd/model/app'
require 'tentd/model/app_authorization'
require 'tentd/model/notification_subscription'
require 'tentd/model/profile_info'
require 'tentd/model/group'
require 'tentd/model/permission'
end
end

DataMapper.finalize
6 changes: 3 additions & 3 deletions lib/tent-server/model/app.rb → lib/tentd/model/app.rb
@@ -1,7 +1,7 @@
require 'securerandom'
require 'tent-server/core_ext/hash/slice'
require 'tentd/core_ext/hash/slice'

module TentServer
module TentD
module Model
class App
include DataMapper::Resource
Expand All @@ -23,7 +23,7 @@ class App
property :created_at, DateTime
property :updated_at, DateTime

has n, :authorizations, 'TentServer::Model::AppAuthorization', :constraint => :destroy
has n, :authorizations, 'TentD::Model::AppAuthorization', :constraint => :destroy

def self.create_from_params(params)
create(params.slice(:name, :description, :url, :icon, :redirect_uris, :scopes))
Expand Down
@@ -1,6 +1,6 @@
require 'securerandom'

module TentServer
module TentD
module Model
class AppAuthorization
include DataMapper::Resource
Expand All @@ -22,8 +22,8 @@ class AppAuthorization
property :created_at, DateTime
property :updated_at, DateTime

belongs_to :app, 'TentServer::Model::App'
has n, :notification_subscriptions, 'TentServer::Model::NotificationSubscription', :constraint => :destroy
belongs_to :app, 'TentD::Model::App'
has n, :notification_subscriptions, 'TentD::Model::NotificationSubscription', :constraint => :destroy
end
end
end

0 comments on commit 131f435

Please sign in to comment.