music_xray_api 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/LICENSE +20 -0
- data/README.rdoc +64 -0
- data/Rakefile +54 -0
- data/VERSION +1 -0
- data/lib/music_xray_api.rb +16 -0
- data/lib/music_xray_api/base.rb +33 -0
- data/lib/music_xray_api/tracks.rb +14 -0
- data/test/helper.rb +12 -0
- data/test/test_music_xray_api.rb +18 -0
- metadata +74 -0
data/.document
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 jeff durand
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
= amazon_ses
|
2
|
+
|
3
|
+
Really simple gem that allows you to send email through amazon simple email
|
4
|
+
service.
|
5
|
+
|
6
|
+
<b>Installation</b>
|
7
|
+
|
8
|
+
gem install amazon_ses
|
9
|
+
|
10
|
+
<b>Usage:</b>
|
11
|
+
|
12
|
+
require 'rubygems'
|
13
|
+
require 'amazon_ses'
|
14
|
+
|
15
|
+
# all methods return a raw http response object
|
16
|
+
# to get the xml just call body on the return object from any of
|
17
|
+
# the following methods.
|
18
|
+
# Exceptions will be throw on any api call that doesn't result in
|
19
|
+
# a 200 OK response from amazon.
|
20
|
+
|
21
|
+
|
22
|
+
# you must have a verified address with amazon to send mail
|
23
|
+
AmazonSES::Verify.address("youremail@gmail.com",amazon_secret,amazon_key)
|
24
|
+
|
25
|
+
# after verifying the address you can send mail
|
26
|
+
|
27
|
+
# simple send mail text only
|
28
|
+
AmazonSES::AmzMail.send(from,to,subject,body,secret,key)
|
29
|
+
# send html email
|
30
|
+
AmazonSES::AmzMail.send_html(from,to,subject,body,secret,key)
|
31
|
+
# if you produce your own email via the mail gem you can pass the result of calling to_s on the mail object
|
32
|
+
# to the following method
|
33
|
+
AmazonSES::AmzMail.send_raw(mail_string,amazon_secret,amazon_key)
|
34
|
+
|
35
|
+
# the following are two methods for getting stats
|
36
|
+
|
37
|
+
puts AmazonSES::Stats.send_quota(amazon_secret,amazon_key).body
|
38
|
+
puts AmazonSES::Stats.send_stats(amazon_secret,amazon_key).body
|
39
|
+
|
40
|
+
# the following is a helper object for looking at your stats
|
41
|
+
|
42
|
+
stobj = StatObject.new(amazon_secret,amazon_key)
|
43
|
+
puts stobj.sent_last_24_hours
|
44
|
+
puts stobj.reached_quota?
|
45
|
+
|
46
|
+
|
47
|
+
Hope you enjoy the Gem. If anyone wants to write a plugin for rails I would link definately link to it and find it useful.
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
== Note on Patches/Pull Requests
|
53
|
+
|
54
|
+
* Fork the project.
|
55
|
+
* Make your feature addition or bug fix.
|
56
|
+
* Add tests for it. This is important so I don't break it in a
|
57
|
+
future version unintentionally.
|
58
|
+
* Commit, do not mess with rakefile, version, or history.
|
59
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
60
|
+
* Send me a pull request. Bonus points for topic branches.
|
61
|
+
|
62
|
+
== Copyright
|
63
|
+
|
64
|
+
Copyright (c) 2011 jeff durand. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "music_xray_api"
|
8
|
+
gem.summary = %Q{Interface with the music xray api}
|
9
|
+
gem.description = %Q{wrapper for music xray api }
|
10
|
+
gem.email = "jeff.durand@gmail.com"
|
11
|
+
gem.homepage = "http://github.com/johnnyiller/Music-Xray-Api-Wrapper"
|
12
|
+
gem.authors = ["jeff durand"]
|
13
|
+
gem.add_dependency "xml-simple"
|
14
|
+
#gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
|
15
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
16
|
+
end
|
17
|
+
Jeweler::GemcutterTasks.new
|
18
|
+
rescue LoadError
|
19
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
20
|
+
end
|
21
|
+
|
22
|
+
require 'rake/testtask'
|
23
|
+
Rake::TestTask.new(:test) do |test|
|
24
|
+
test.libs << 'lib' << 'test'
|
25
|
+
test.pattern = 'test/**/test_*.rb'
|
26
|
+
test.verbose = true
|
27
|
+
end
|
28
|
+
|
29
|
+
begin
|
30
|
+
require 'rcov/rcovtask'
|
31
|
+
Rcov::RcovTask.new do |test|
|
32
|
+
test.libs << 'test'
|
33
|
+
test.pattern = 'test/**/test_*.rb'
|
34
|
+
test.verbose = true
|
35
|
+
end
|
36
|
+
rescue LoadError
|
37
|
+
task :rcov do
|
38
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
task :test => :check_dependencies
|
43
|
+
|
44
|
+
task :default => :test
|
45
|
+
|
46
|
+
require 'rake/rdoctask'
|
47
|
+
Rake::RDocTask.new do |rdoc|
|
48
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
49
|
+
|
50
|
+
rdoc.rdoc_dir = 'rdoc'
|
51
|
+
rdoc.title = "music_xray_api #{version}"
|
52
|
+
rdoc.rdoc_files.include('README*')
|
53
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
54
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'net/https'
|
2
|
+
require 'uri'
|
3
|
+
require 'time'
|
4
|
+
require "cgi"
|
5
|
+
require "base64"
|
6
|
+
require "openssl"
|
7
|
+
require "digest/sha1"
|
8
|
+
require "rubygems"
|
9
|
+
require "mail"
|
10
|
+
require "xmlsimple"
|
11
|
+
|
12
|
+
$:.unshift(File.dirname(__FILE__))
|
13
|
+
require 'music_xray_api/base'
|
14
|
+
require 'music_xray_api/tracks'
|
15
|
+
#require 'amazon_ses/stats'
|
16
|
+
#require 'amazon_ses/amz_mail'
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module MusicXrayApi
|
2
|
+
class Base
|
3
|
+
|
4
|
+
def self.rfc2616(time)
|
5
|
+
time.utc.strftime("%a, %d %b %Y %H:%M:%S")+" +0000"
|
6
|
+
end
|
7
|
+
def self.sign_https_request(request,date,secret,key)
|
8
|
+
return "{'client_key_id':'#{key}', 'algorithm':'HmacSHA256', 'signature':'#{Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest::Digest.new("sha256"), secret, date)).strip}'}"
|
9
|
+
end
|
10
|
+
def self.make_request(secret,key,postfix,form_hash)
|
11
|
+
date = MusicXrayApi::Base.rfc2616(Time.now)
|
12
|
+
uri = URI.parse("https://api-load-balancer-467937692.us-east-1.elb.amazonaws.com/#{postfix}.xml")
|
13
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
14
|
+
http.use_ssl = true
|
15
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
16
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
17
|
+
request.set_form_data(form_hash)
|
18
|
+
request['Content-Type'] = 'application/x-www-form-urlencoded; charset=utf-8'
|
19
|
+
request.add_field("Date",date)
|
20
|
+
request.add_field("X-Xray-Authorization",MusicXrayApi::Base.sign_https_request(request,date,secret,key))
|
21
|
+
response = http.request(request)
|
22
|
+
#puts response.inspect
|
23
|
+
case response
|
24
|
+
when Net::HTTPSuccess then return response
|
25
|
+
when Net::HTTPClientError then raise response.body
|
26
|
+
when Net::HTTPServerError then raise response.body
|
27
|
+
else raise response.body
|
28
|
+
end
|
29
|
+
#return response
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'shoulda'
|
4
|
+
|
5
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
6
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
7
|
+
require 'music_xray_api'
|
8
|
+
|
9
|
+
class Test::Unit::TestCase
|
10
|
+
|
11
|
+
#YAML.load_file("./test/credentials.yml").each { |key,value| instance_variable_set("@#{key}", value) }
|
12
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestMusicXrayApi < Test::Unit::TestCase
|
4
|
+
context "Has valid credentials" do
|
5
|
+
setup do
|
6
|
+
YAML.load_file("./test/credentials.yml").each { |key,value| instance_variable_set("@#{key}", value) }
|
7
|
+
end
|
8
|
+
should "Be able to create a track." do
|
9
|
+
threads = []
|
10
|
+
10.times do
|
11
|
+
threads << Thread.new do
|
12
|
+
MusicXrayApi::Tracks.create(@secret,@key).body
|
13
|
+
end
|
14
|
+
end
|
15
|
+
threads.each { |aThread| aThread.join }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: music_xray_api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- jeff durand
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-05-10 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: xml-simple
|
17
|
+
prerelease: false
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
type: :runtime
|
25
|
+
version_requirements: *id001
|
26
|
+
description: "wrapper for music xray api "
|
27
|
+
email: jeff.durand@gmail.com
|
28
|
+
executables: []
|
29
|
+
|
30
|
+
extensions: []
|
31
|
+
|
32
|
+
extra_rdoc_files:
|
33
|
+
- LICENSE
|
34
|
+
- README.rdoc
|
35
|
+
files:
|
36
|
+
- .document
|
37
|
+
- LICENSE
|
38
|
+
- README.rdoc
|
39
|
+
- Rakefile
|
40
|
+
- VERSION
|
41
|
+
- lib/music_xray_api.rb
|
42
|
+
- lib/music_xray_api/base.rb
|
43
|
+
- lib/music_xray_api/tracks.rb
|
44
|
+
- test/helper.rb
|
45
|
+
- test/test_music_xray_api.rb
|
46
|
+
homepage: http://github.com/johnnyiller/Music-Xray-Api-Wrapper
|
47
|
+
licenses: []
|
48
|
+
|
49
|
+
post_install_message:
|
50
|
+
rdoc_options: []
|
51
|
+
|
52
|
+
require_paths:
|
53
|
+
- lib
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: "0"
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: "0"
|
66
|
+
requirements: []
|
67
|
+
|
68
|
+
rubyforge_project:
|
69
|
+
rubygems_version: 1.7.2
|
70
|
+
signing_key:
|
71
|
+
specification_version: 3
|
72
|
+
summary: Interface with the music xray api
|
73
|
+
test_files: []
|
74
|
+
|