Skip to content

Instantly share code, notes, and snippets.

View julesfern's full-sized avatar

Jules Glegg julesfern

View GitHub Profile
describe "request factory" do
before(:all) do
@seed = fixtures.seed
@fixtures = fixtures["read-user"]
@proxy = Videojuicer::OAuth::RequestProxy.new(:consumer_key=>@fixtures.consumer.consumer_key, :consumer_secret=>@fixtures.consumer.consumer_secret, :token=>nil, :token_secret=>nil)
end
it "can successfully retrieve a request token (indicating a successful signature verification)" do
@proxy.consumer_key.should == @fixtures.consumer.consumer_key
response = @proxy.get("/oauth/tokens", :seed_name=>@seed.name)
Configurable is a mixin intended for internal use within the SDK.
It provides a suite of helper methods to objects that use the scoped configuration
system within the root Videojuicer module.
Objects that are Configurable have a local configuration, which will always be
respected, and a shared configuration object which merges the current configuration
scope with the local configuration.
For instance:
http://localhost:5555/users?api_version=1&oauth_consumer_key=osteoncus&oauth_nonce=3657&oauth_signature_method=HMAC-SHA1&oauth_signature=lKlkxvh9k7HtwTgdKfHSIgYU39Y%3D&oauth_timestamp=1244661683&oauth_token=6MqmVlwg73kGd30JWq0jbieklJdZeY&seed_name=unnimbleness&user[email]=646424@test.videojuicer.com&user[login]=testuser77480&user[name]=6825 Jones&user[password]=56108&user[password_confirmation]=56108
---
# This is a sample database file for the DataMapper ORM
development: &defaults
# These are the settings for repository :default
adapter: sqlite3
database: schema/vj_core_development.db
repositories:
garden:
adapter: sqlite3
require 'liquid'
module SMIL
module Helper
class AssetTag < ::Liquid::Block
def initialize(tag_name, id, tokens)
super
@asset_id = id
@attributes ||= {}
end
# Splits a given parameter hash into two hashes - one containing all
# string and non-binary parameters, and one containing all file/binary parameters.
# This action is performed recursively so that:
# params = {:user=>{:attributes=>{:file=>some_file, :name=>"user name"}}, :foo=>"bar"}
# normal, multipart = split_multipart_params(params)
# normal.inspect # => {:user=>{:attributes=>{:name=>"user name"}}, :foo=>"bar"}
# multipart.inspect # => {:user=>{:attributes=>{:file=>some_file}}}
def split_multipart_params(params, *hash_path)
strings = {}
files = {}
after normalizing with asset[bit_rate] and 262144:
{"asset"=>{"bit_rate"=>"262144"}}
after normalizing with asset[duration] and 180000:
{"asset"=>{"bit_rate"=>"262144", "duration"=>"180000"}}
after normalizing with asset[file] and filenameaudio.mp3tempfile#<File:0x3a24b00>size65478content_typeaudio/mpeg:
{"asset"=>{"bit_rate"=>"262144", "duration"=>"180000", "file"=>{:filename=>"audio.mp3", :tempfile=>#<File:/var/folders/Gi/GiZ1eE5AGiCIYegho-sIeE+++TI/-Tmp-/Merb.2340.0>, :size=>65478, :content_type=>"audio/mpeg"}}}
after normalizing with asset[licensed_at] and Mon Jun 29 12:02:30 +0100 2009:
From d1103e9242c4bb55ba4d0c0b52056751200794e4 Mon Sep 17 00:00:00 2001
From: danski <dan@angryamoeba.co.uk>
Date: Mon, 29 Jun 2009 12:52:52 +0100
Subject: [PATCH] fix for repeated normalizer calls against file attributes in multipart posts, including tests
---
.../lib/merb-core/dispatch/request_parsers.rb | 4 +++-
merb-core/spec/public/request/multipart_spec.rb | 2 ++
merb_datamapper/lib/merb_datamapper.rb | 4 ++--
3 files changed, 7 insertions(+), 3 deletions(-)
# BEFORE
# ----------------------------------------------------------------------
# Returns the signature_params as a normalised string in line with
# http://oauth.net/core/1.0#signing_process
def normalise_signature_params(p=signature_params, *hash_path)
p.sort {|a,b| a.to_s<=>b.to_s}.collect do |key, value|
path = hash_path.dup
path << key
if value.is_a?(Hash) or value.is_a?(Mash)
<smil>
<head>
<title>I'm an array, je suis un array</title>
</head>
<body>
<seq>
<ref type="application/smil" src="http://api.videojuicer.com/presentations/999.smil?seed_name=foobar" />
<ref type="application/smil" src="http://api.videojuicer.com/presentations/111.smil?seed_name=foobar" />
</seq>
</body>