Permalink
Browse files

Merge branch 'release/v0.8.1'

  • Loading branch information...
2 parents b94f77c + cef0cfa commit 9a4db272e87c0445d22a4b46b828511f972fe531 @jammus committed Apr 21, 2012
View
@@ -0,0 +1 @@
+config.js
View
@@ -1,5 +1,9 @@
# Changelog
+## 0.8.1
+* Automatically set album parameter from track details when available.
+* Experimental REPL.
+
## 0.8.0
### Breaking changes
View
@@ -0,0 +1,4 @@
+module.exports = {
+ api_key: '',
+ secret: ''
+};
View
@@ -0,0 +1,44 @@
+var LastFmNode = require('./lib/lastfm').LastFmNode,
+ repl = require('repl'),
+ config = require('./config'),
+ _ = require('underscore');
+
+var echoHandler = function() {
+ _(arguments).each(function(arg) {
+ console.log(arg);
+ });
+};
+
+var errorHandler = function(error) {
+ console.log('Error: ' + error.message);
+};
+
+var quietHandler = function() { };
+
+var _echoHandlers = {
+ error: errorHandler,
+ success: echoHandler,
+ lastPlayed: echoHandler,
+ nowPlaying: echoHandler,
+ scrobbled: echoHandler,
+ stoppedPlaying: echoHandler
+};
+
+var _quietHandlers = {
+ error: errorHandler,
+ success: quietHandler,
+ lastPlayed: quietHandler,
+ nowPlaying: quietHandler,
+ scrobbled: quietHandler,
+ stoppedPlaying: quietHandler
+}
+
+var lastfm = new LastFmNode({
+ api_key: config.api_key,
+ secret: config.secret
+});
+
+var context = repl.start().context;
+context.lastfm = lastfm;
+context._echoHandlers = _echoHandlers;
+context._quietHandlers = _quietHandlers;
@@ -59,6 +59,9 @@ var LastFmRequest = module.exports = function(lastfm, method, params) {
requestParams.artist = params.track.artist["#text"];
requestParams.track = params.track.name;
requestParams.mbid = params.track.mbid;
+ if (params.track.album) {
+ requestParams.album = requestParams.album || params.track.album["#text"];
+ }
}
if (requiresSignature()) {
requestParams.api_sig = createSignature(requestParams, lastfm.secret);
View
@@ -1,5 +1,4 @@
var path = require("path");
-require.paths.unshift(path.dirname(__dirname)+'/lib');
global.Gently = require("gently");
global.GENTLY_HIJACK = new Gently();
global.assert = require("assert");
@@ -8,7 +7,7 @@ global.it = ntest.it;
global.describe = ntest.describe;
global.before = ntest.before;
global.after = ntest.after;
-global.LastFmNode = require("lastfm").LastFmNode;
+global.LastFmNode = require("../lib/lastfm").LastFmNode;
global.FakeData = require("./TestData.js").FakeData;
global.FakeTracks = require("./TestData.js").FakeTracks;
if (process.setMaxListeners) {
@@ -1,5 +1,5 @@
require('./common');
-var LastFmBase = require("lastfm/lastfm-base");
+var LastFmBase = require("../lib/lastfm/lastfm-base");
(function() {
describe("LastFmBase");
@@ -1,6 +1,6 @@
require("./common.js");
-var LastFmInfo = require("lastfm/lastfm-info");
-var LastFmRequest = require("lastfm/lastfm-request");
+var LastFmInfo = require("../lib/lastfm/lastfm-info");
+var LastFmRequest = require("../lib/lastfm/lastfm-request");
var fakes = require("./fakes");
(function() {
@@ -1,6 +1,6 @@
require("./common.js");
-var LastFmInfo = require("lastfm/lastfm-info")
+var LastFmInfo = require("../lib/lastfm/lastfm-info")
, fakes = require("./fakes");
(function() {
View
@@ -201,6 +201,31 @@ var LastFmRequest = fakes.LastFmRequest;
expectDataPair("mbid", "1234567890");
});
+ it("converts track object album details to separate parameters", function() {
+ whenMethodIs("any.method");
+ andParamsAre({
+ track: {
+ artist: { "#text": "The Mae Shi" },
+ name: "Run To Your Grave",
+ album: { "#text": "HLLLYH" }
+ }
+ });
+ expectDataPair("album", "HLLLYH");
+ });
+
+ it("does not overwrite explicitly set album parameters", function() {
+ whenMethodIs("any.method");
+ andParamsAre({
+ track: {
+ artist: { "#text": "The Mae Shi" },
+ name: "Run To Your Grave",
+ album: { "#text": "HLLLYH" }
+ },
+ album: "Run To Your Grave"
+ });
+ expectDataPair("album", "Run To Your Grave");
+ });
+
it("doesn't include mbid if one isn't supplied", function() {
whenMethodIs("any.method");
andParamsAre({
@@ -1,8 +1,8 @@
require("./common.js");
var _ = require("underscore")
- , RecentTracksStream = require("lastfm/recenttracks-stream")
- , LastFmRequest = require("lastfm/lastfm-request")
+ , RecentTracksStream = require("../lib/lastfm/recenttracks-stream")
+ , LastFmRequest = require("../lib/lastfm/lastfm-request")
, fakes = require("./fakes");
(function() {
@@ -1,6 +1,6 @@
require("./common");
var _ = require("underscore"),
- LastFmRequest = require("lastfm/lastfm-request"),
+ LastFmRequest = require("../lib/lastfm/lastfm-request"),
fakes = require("./fakes");
(function() {
@@ -1,5 +1,5 @@
require('./common.js');
-var LastFmSession = require('lastfm/lastfm-session');
+var LastFmSession = require('../lib/lastfm/lastfm-session');
var fakes = require("./fakes");
(function() {
@@ -1,6 +1,6 @@
require('./common.js');
-var LastFmSession = require('lastfm/lastfm-session');
-var LastFmUpdate = require('lastfm/lastfm-update');
+var LastFmSession = require('../lib/lastfm/lastfm-session');
+var LastFmUpdate = require('../lib/lastfm/lastfm-update');
var fakes = require("./fakes");
(function() {
View
@@ -12,3 +12,5 @@ nvm use v0.4.7
node ./index.js
nvm use v0.4.8
node ./index.js
+nvm use v0.6.2
+node ./index.js

0 comments on commit 9a4db27

Please sign in to comment.