lastfm-path-finder 1.0.0 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +13 -10
- data/VERSION +1 -1
- data/bin/lastfm-path-finder +72 -0
- data/lib/lastfm_path_finder/settings.rb +3 -2
- metadata +12 -12
- data/lastfm-path-finder.rb +0 -33
data/Gemfile
CHANGED
@@ -1,12 +1,15 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
2
|
|
3
|
-
|
4
|
-
gem "rspec", "2.11"
|
5
|
-
gem "spork"
|
6
|
-
gem "vcr"
|
7
|
-
gem "webmock"
|
8
|
-
gem
|
9
|
-
gem '
|
10
|
-
|
11
|
-
|
12
|
-
gem "
|
3
|
+
group :development do
|
4
|
+
gem "rspec", "2.11"
|
5
|
+
gem "spork", "0.9.2"
|
6
|
+
gem "vcr", "2.2.4"
|
7
|
+
gem "webmock", "1.8.8"
|
8
|
+
gem 'rspec-redis_helper', '0.1.2'
|
9
|
+
gem "jeweler", '1.8.4'
|
10
|
+
end
|
11
|
+
|
12
|
+
gem "lastfm", '1.7.0'
|
13
|
+
gem "redis-objects", '0.5.3'
|
14
|
+
gem "settingslogic", '2.0.8'
|
15
|
+
gem "commander", '4.1.2'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
0.0.0
|
@@ -0,0 +1,72 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'commander/import'
|
5
|
+
require_relative '../lib/lastfm_path_finder'
|
6
|
+
|
7
|
+
program :version, "1.0"
|
8
|
+
program :description, 'Finding paths between artists in Lastfm since 1888'
|
9
|
+
|
10
|
+
default_command :find
|
11
|
+
|
12
|
+
command :find do |c|
|
13
|
+
c.syntax = 'lastfm-path-finder find [options]'
|
14
|
+
c.summary = 'Find paths between two artists'
|
15
|
+
c.description = 'Find paths between two artists in Last.fm'
|
16
|
+
c.example 'Search the path between Pink Floyd and Franz Ferdinand', 'lastfm-path-finder find "Pink Floyd" "Franz Ferdinand"'
|
17
|
+
c.example 'Search the path without putting the artist names in the command line (the command will ask for them)', 'lastfm-path-finder find'
|
18
|
+
c.example 'Load settings in a different path', 'lastfm-path-finder find --settings path/to/settings'
|
19
|
+
c.option '--settings SETTINGS_PATH', String, 'Path to the settings file (DEFAULT: config/settings.yml)'
|
20
|
+
c.action do |args, options|
|
21
|
+
|
22
|
+
LastfmPathFinder::Settings.source options.settings unless options.settings.blank?
|
23
|
+
|
24
|
+
from_name = args.first || ask("One artist: ")
|
25
|
+
to_name = args[1] || ask("Another artist: ")
|
26
|
+
|
27
|
+
from = LastfmPathFinder::Artist.new(:name => from_name)
|
28
|
+
to = LastfmPathFinder::Artist.new(:name => to_name)
|
29
|
+
path = LastfmPathFinder::Finder.find from, to
|
30
|
+
|
31
|
+
if path.found?
|
32
|
+
say "Path found! #{path.artists.values.join(" --> ")}"
|
33
|
+
else
|
34
|
+
say "No path found"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
command :similar do |c|
|
41
|
+
c.syntax = 'lastfm-path-finder similar ARTIST_NAME [ARTIST_NAME]* [options]'
|
42
|
+
c.summary = 'Shows similar artists to a given artist or common similar artists if more than one artis is given'
|
43
|
+
c.description = 'Shows similar artists to a given artist or common similar artists if more than one artis is given'
|
44
|
+
c.example 'Show artists similar to Pink Floyd', 'lastfm-path-finder similar "Pink Floyd"'
|
45
|
+
c.example 'Show artists similar to Pink Floyd AND Franz Ferdinand', 'lastfm-path-finder similar "Pink Floyd" "Franx Ferdinand"'
|
46
|
+
c.option '--settings SETTINGS_PATH', String, 'Path to the settings file (DEFAULT: config/settings.yml)'
|
47
|
+
c.action do |args, options|
|
48
|
+
|
49
|
+
LastfmPathFinder::Settings.source options.settings unless options.settings.blank?
|
50
|
+
|
51
|
+
args << ask("Please, give me at least one artist: ") if args.blank?
|
52
|
+
|
53
|
+
similar_artists_lists = []
|
54
|
+
|
55
|
+
args.each do |arg|
|
56
|
+
similar_artists_lists << LastfmPathFinder::Artist.new(:name => arg).related_artists
|
57
|
+
end
|
58
|
+
|
59
|
+
common_similar = []
|
60
|
+
|
61
|
+
similar_artists_lists.each do |similar_artists_list|
|
62
|
+
common_similar = common_similar.blank? ? similar_artists_list.members.reverse : (common_similar & similar_artists_list.members)
|
63
|
+
end
|
64
|
+
|
65
|
+
if common_similar.blank?
|
66
|
+
say "No #{'common ' if args.size > 1}similar artists found"
|
67
|
+
else
|
68
|
+
say "Similar artists found:"
|
69
|
+
say common_similar.map{|common| " --- #{common}: #{similar_artists_lists.map{|list| list.score(common)}.join(", ")}"}.join("\n")
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -2,11 +2,12 @@ require 'settingslogic'
|
|
2
2
|
require 'lastfm'
|
3
3
|
|
4
4
|
class LastfmPathFinder::Settings < Settingslogic
|
5
|
+
|
5
6
|
source "config/settings.yml"
|
6
|
-
|
7
|
+
|
7
8
|
def self.lastfm_api
|
8
9
|
@@lastfm ||= Lastfm.new(self["lastfm"]["api_key"], self["lastfm"]["api_secret"])
|
9
|
-
end
|
10
|
+
end
|
10
11
|
|
11
12
|
def self.redis_connection
|
12
13
|
Redis.current ||= Redis.new self["redis"]
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: lastfm-path-finder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.0.
|
5
|
+
version: 1.0.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- David J. Brenes
|
@@ -19,9 +19,9 @@ dependencies:
|
|
19
19
|
requirement: &id001 !ruby/object:Gem::Requirement
|
20
20
|
none: false
|
21
21
|
requirements:
|
22
|
-
- - "
|
22
|
+
- - "="
|
23
23
|
- !ruby/object:Gem::Version
|
24
|
-
version:
|
24
|
+
version: 1.7.0
|
25
25
|
type: :runtime
|
26
26
|
version_requirements: *id001
|
27
27
|
- !ruby/object:Gem::Dependency
|
@@ -30,9 +30,9 @@ dependencies:
|
|
30
30
|
requirement: &id002 !ruby/object:Gem::Requirement
|
31
31
|
none: false
|
32
32
|
requirements:
|
33
|
-
- - "
|
33
|
+
- - "="
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version:
|
35
|
+
version: 0.5.3
|
36
36
|
type: :runtime
|
37
37
|
version_requirements: *id002
|
38
38
|
- !ruby/object:Gem::Dependency
|
@@ -41,9 +41,9 @@ dependencies:
|
|
41
41
|
requirement: &id003 !ruby/object:Gem::Requirement
|
42
42
|
none: false
|
43
43
|
requirements:
|
44
|
-
- - "
|
44
|
+
- - "="
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version:
|
46
|
+
version: 2.0.8
|
47
47
|
type: :runtime
|
48
48
|
version_requirements: *id003
|
49
49
|
- !ruby/object:Gem::Dependency
|
@@ -52,15 +52,15 @@ dependencies:
|
|
52
52
|
requirement: &id004 !ruby/object:Gem::Requirement
|
53
53
|
none: false
|
54
54
|
requirements:
|
55
|
-
- - "
|
55
|
+
- - "="
|
56
56
|
- !ruby/object:Gem::Version
|
57
|
-
version:
|
57
|
+
version: 4.1.2
|
58
58
|
type: :runtime
|
59
59
|
version_requirements: *id004
|
60
60
|
description: Gem for finding paths between artists in Last.fm
|
61
61
|
email: davidjbrenes@gmail.com
|
62
|
-
executables:
|
63
|
-
|
62
|
+
executables:
|
63
|
+
- lastfm-path-finder
|
64
64
|
extensions: []
|
65
65
|
|
66
66
|
extra_rdoc_files:
|
@@ -71,7 +71,6 @@ files:
|
|
71
71
|
- README
|
72
72
|
- VERSION
|
73
73
|
- config/settings.example.yml
|
74
|
-
- lastfm-path-finder.rb
|
75
74
|
- lib/lastfm_path_finder.rb
|
76
75
|
- lib/lastfm_path_finder/artist.rb
|
77
76
|
- lib/lastfm_path_finder/finder.rb
|
@@ -81,6 +80,7 @@ files:
|
|
81
80
|
- spec/models/path.rb
|
82
81
|
- spec/spec_helper.rb
|
83
82
|
- LICENSE.txt
|
83
|
+
- bin/lastfm-path-finder
|
84
84
|
has_rdoc: true
|
85
85
|
homepage: http://github.com/brenes/lastfm-path-finder
|
86
86
|
licenses:
|
data/lastfm-path-finder.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require 'commander/import'
|
5
|
-
require 'lib/lastfm_path_finder'
|
6
|
-
|
7
|
-
program :version, "1.0"
|
8
|
-
program :description, 'Finding paths between artists in Lastfm since 1888'
|
9
|
-
|
10
|
-
default_command :find
|
11
|
-
|
12
|
-
command :find do |c|
|
13
|
-
c.syntax = 'lastfm-path-finder find [options]'
|
14
|
-
c.summary = 'Find paths between two artists'
|
15
|
-
c.description = 'Find paths between two artists in Last.fm'
|
16
|
-
c.example 'Search the path between Pink Floyd and Franz Ferdinand', 'lastfm-path-finder find "Pink Floyd" "Franz Ferdinand"'
|
17
|
-
c.action do |args, options|
|
18
|
-
|
19
|
-
from_name = args.first || ask("One artist: ")
|
20
|
-
to_name = args[1] || ask("Another artist: ")
|
21
|
-
|
22
|
-
from = LastfmPathFinder::Artist.new(:name => from_name)
|
23
|
-
to = LastfmPathFinder::Artist.new(:name => to_name)
|
24
|
-
path = LastfmPathFinder::Finder.find from, to
|
25
|
-
|
26
|
-
if path.found?
|
27
|
-
say "Path found! #{path.artists.values.join(" --> ")}"
|
28
|
-
else
|
29
|
-
say "No path found"
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|