musician_analytics 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,22 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
22
+ README.markdown.html
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 David Balatero <contact@opidmusic.com>
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.
@@ -0,0 +1,49 @@
1
+ musician_analytics
2
+ ==================
3
+
4
+ I wrote this quick library for aggregating analytics for my band, [Operation ID](http://opidmusic.com). I wanted to track Last.fm, Twitter, and Myspace interactions over time. You might want to do this too!
5
+
6
+ Coming soon: a small web app for storing/aggregating these stats.
7
+
8
+ Usage
9
+ -----
10
+
11
+ Here are some usage examples for the supported services.
12
+
13
+ Last.fm
14
+ -------
15
+
16
+ MusicianAnalytics::Lastfm.api_key = 'myapikey'
17
+ stats = MusicianAnalytics::Lastfm.get_stats('Operation ID')
18
+ puts stats['playcount']
19
+ puts stats['listeners']
20
+
21
+ Twitter
22
+ -------
23
+
24
+ stats = MusicianAnalytics::Twitter.get_stats('operationid')
25
+ puts stats['followers_count']
26
+ puts stats['friends_count']
27
+
28
+ Myspace
29
+ -------
30
+
31
+ stats = MusicianAnalytics::Myspace.get_stats('operationid')
32
+ puts stats['profile_views']
33
+
34
+
35
+ Note on Patches/Pull Requests
36
+ -----------------------------
37
+
38
+ * Fork the project.
39
+ * Make your feature addition or bug fix.
40
+ * Add tests for it. This is important so I don't break it in a
41
+ future version unintentionally.
42
+ * Commit, do not mess with rakefile, version, or history.
43
+ (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)
44
+ * Send me a pull request. Bonus points for topic branches.
45
+
46
+ Copyright
47
+ ---------
48
+
49
+ Copyright (c) 2010 David Balatero <contact@opidmusic.com>. See LICENSE for details.
@@ -0,0 +1,47 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "musician_analytics"
8
+ gem.summary = %Q{Provides tools for programmer/musicians to quickly collect stats about their band.}
9
+ gem.description = %Q{I wrote this quick library for aggregating analytics for my band, Operation ID. I wanted to track Last.fm, Twitter, and Myspace interactions over time. You might want to do this too!}
10
+ gem.email = "dbalatero@gmail.com"
11
+ gem.homepage = "http://github.com/dbalatero/musician_analytics"
12
+ gem.authors = ["David Balatero"]
13
+ gem.add_development_dependency "rspec", ">= 1.2.9"
14
+ gem.add_dependency 'monster_mash'
15
+ gem.add_dependency 'json'
16
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
17
+ end
18
+ Jeweler::GemcutterTasks.new
19
+ rescue LoadError
20
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
21
+ end
22
+
23
+ require 'spec/rake/spectask'
24
+ Spec::Rake::SpecTask.new(:spec) do |spec|
25
+ spec.libs << 'lib' << 'spec'
26
+ spec.spec_files = FileList['spec/**/*_spec.rb']
27
+ end
28
+
29
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
30
+ spec.libs << 'lib' << 'spec'
31
+ spec.pattern = 'spec/**/*_spec.rb'
32
+ spec.rcov = true
33
+ end
34
+
35
+ task :spec => :check_dependencies
36
+
37
+ task :default => :spec
38
+
39
+ require 'rake/rdoctask'
40
+ Rake::RDocTask.new do |rdoc|
41
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
42
+
43
+ rdoc.rdoc_dir = 'rdoc'
44
+ rdoc.title = "musician_analytics #{version}"
45
+ rdoc.rdoc_files.include('README*')
46
+ rdoc.rdoc_files.include('lib/**/*.rb')
47
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,12 @@
1
+ require 'monster_mash'
2
+ require 'json'
3
+
4
+ $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__)))
5
+
6
+ %w(lastfm myspace twitter).each do |file|
7
+ require "musician_analytics/#{file}"
8
+ end
9
+
10
+ module MusicianAnalytics
11
+ VERSION = File.read(File.dirname(__FILE__) + "/../VERSION").chomp
12
+ end
@@ -0,0 +1,28 @@
1
+ module MusicianAnalytics
2
+ class Lastfm < MonsterMash::Base
3
+ @api_key = nil
4
+ class << self
5
+ attr_accessor :api_key
6
+ end
7
+
8
+ defaults do
9
+ params :format => 'json'
10
+ end
11
+
12
+ get(:get_stats) do |artist|
13
+ uri "http://ws.audioscrobbler.com/2.0/"
14
+ params :method => 'artist.getInfo',
15
+ :artist => artist,
16
+ :api_key => MusicianAnalytics::Lastfm.api_key
17
+
18
+ handler do |response|
19
+ json = JSON.parse(response.body)
20
+ stats = json['artist']['stats']
21
+ stats.keys.each do |key|
22
+ stats[key] = stats[key].to_i
23
+ end
24
+ stats
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,13 @@
1
+ module MusicianAnalytics
2
+ class Myspace < MonsterMash::Base
3
+ get(:get_stats) do |myspace_username|
4
+ uri "http://www.myspace.com/#{myspace_username}"
5
+ handler do |response|
6
+ data = response.body.match(/Profile Views:.+?(\d+)/mi)
7
+ profile_views = data[1].to_i
8
+
9
+ { 'profile_views' => profile_views }
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,11 @@
1
+ module MusicianAnalytics
2
+ class Twitter < MonsterMash::Base
3
+ get(:get_stats) do |twitter_username|
4
+ uri "http://api.twitter.com/1/users/show.json"
5
+ params :screen_name => twitter_username
6
+ handler do |response|
7
+ JSON.parse(response.body)
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,69 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{musician_analytics}
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["David Balatero"]
12
+ s.date = %q{2010-06-04}
13
+ s.description = %q{I wrote this quick library for aggregating analytics for my band, Operation ID. I wanted to track Last.fm, Twitter, and Myspace interactions over time. You might want to do this too!}
14
+ s.email = %q{dbalatero@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.markdown",
18
+ "README.markdown.html"
19
+ ]
20
+ s.files = [
21
+ ".document",
22
+ ".gitignore",
23
+ "LICENSE",
24
+ "README.markdown",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "lib/musician_analytics.rb",
28
+ "lib/musician_analytics/lastfm.rb",
29
+ "lib/musician_analytics/myspace.rb",
30
+ "lib/musician_analytics/twitter.rb",
31
+ "musician_analytics.gemspec",
32
+ "spec/musician_analytics/lastfm_spec.rb",
33
+ "spec/musician_analytics/myspace_spec.rb",
34
+ "spec/musician_analytics/twitter_spec.rb",
35
+ "spec/spec.opts",
36
+ "spec/spec_helper.rb"
37
+ ]
38
+ s.homepage = %q{http://github.com/dbalatero/musician_analytics}
39
+ s.rdoc_options = ["--charset=UTF-8"]
40
+ s.require_paths = ["lib"]
41
+ s.rubygems_version = %q{1.3.6}
42
+ s.summary = %q{Provides tools for programmer/musicians to quickly collect stats about their band.}
43
+ s.test_files = [
44
+ "spec/musician_analytics/lastfm_spec.rb",
45
+ "spec/musician_analytics/myspace_spec.rb",
46
+ "spec/musician_analytics/twitter_spec.rb",
47
+ "spec/spec_helper.rb"
48
+ ]
49
+
50
+ if s.respond_to? :specification_version then
51
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
52
+ s.specification_version = 3
53
+
54
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
55
+ s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
56
+ s.add_runtime_dependency(%q<monster_mash>, [">= 0"])
57
+ s.add_runtime_dependency(%q<json>, [">= 0"])
58
+ else
59
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
60
+ s.add_dependency(%q<monster_mash>, [">= 0"])
61
+ s.add_dependency(%q<json>, [">= 0"])
62
+ end
63
+ else
64
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
65
+ s.add_dependency(%q<monster_mash>, [">= 0"])
66
+ s.add_dependency(%q<json>, [">= 0"])
67
+ end
68
+ end
69
+
@@ -0,0 +1,5 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe MusicianAnalytics::Lastfm do
4
+ it "should be tested"
5
+ end
@@ -0,0 +1,16 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe MusicianAnalytics::Myspace do
4
+ typhoeus_spec_cache('spec/cache/myspace/get_stats') do |hydra|
5
+ describe "#get_stats" do
6
+ before(:all) do
7
+ @result = MusicianAnalytics::Myspace.
8
+ get_stats('operationid')
9
+ end
10
+
11
+ it "should return a count of profile views" do
12
+ @result['profile_views'].should > 400
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,19 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe MusicianAnalytics::Twitter do
4
+ typhoeus_spec_cache('spec/cache/twitter/get_stats') do |hydra|
5
+ describe "#get_stats" do
6
+ before(:each) do
7
+ @result = MusicianAnalytics::Twitter.get_stats('operationid')
8
+ end
9
+
10
+ it "should get follower stats" do
11
+ @result['followers_count'].should >= 15
12
+ end
13
+
14
+ it "should get friends count" do
15
+ @result['friends_count'].should >= 15
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,11 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'musician_analytics'
4
+ require 'spec'
5
+ require 'spec/autorun'
6
+ require 'typhoeus_spec_cache'
7
+
8
+ Spec::Runner.configure do |config|
9
+ config.include(Typhoeus::SpecCacheMacros::InstanceMethods)
10
+ config.extend(Typhoeus::SpecCacheMacros::ClassMethods)
11
+ end
metadata ADDED
@@ -0,0 +1,120 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: musician_analytics
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 0
9
+ version: 0.1.0
10
+ platform: ruby
11
+ authors:
12
+ - David Balatero
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-06-04 00:00:00 -07:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: rspec
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 1
29
+ - 2
30
+ - 9
31
+ version: 1.2.9
32
+ type: :development
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: monster_mash
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ segments:
42
+ - 0
43
+ version: "0"
44
+ type: :runtime
45
+ version_requirements: *id002
46
+ - !ruby/object:Gem::Dependency
47
+ name: json
48
+ prerelease: false
49
+ requirement: &id003 !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ segments:
54
+ - 0
55
+ version: "0"
56
+ type: :runtime
57
+ version_requirements: *id003
58
+ description: I wrote this quick library for aggregating analytics for my band, Operation ID. I wanted to track Last.fm, Twitter, and Myspace interactions over time. You might want to do this too!
59
+ email: dbalatero@gmail.com
60
+ executables: []
61
+
62
+ extensions: []
63
+
64
+ extra_rdoc_files:
65
+ - LICENSE
66
+ - README.markdown
67
+ - README.markdown.html
68
+ files:
69
+ - .document
70
+ - .gitignore
71
+ - LICENSE
72
+ - README.markdown
73
+ - Rakefile
74
+ - VERSION
75
+ - lib/musician_analytics.rb
76
+ - lib/musician_analytics/lastfm.rb
77
+ - lib/musician_analytics/myspace.rb
78
+ - lib/musician_analytics/twitter.rb
79
+ - musician_analytics.gemspec
80
+ - spec/musician_analytics/lastfm_spec.rb
81
+ - spec/musician_analytics/myspace_spec.rb
82
+ - spec/musician_analytics/twitter_spec.rb
83
+ - spec/spec.opts
84
+ - spec/spec_helper.rb
85
+ - README.markdown.html
86
+ has_rdoc: true
87
+ homepage: http://github.com/dbalatero/musician_analytics
88
+ licenses: []
89
+
90
+ post_install_message:
91
+ rdoc_options:
92
+ - --charset=UTF-8
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ segments:
100
+ - 0
101
+ version: "0"
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ segments:
107
+ - 0
108
+ version: "0"
109
+ requirements: []
110
+
111
+ rubyforge_project:
112
+ rubygems_version: 1.3.6
113
+ signing_key:
114
+ specification_version: 3
115
+ summary: Provides tools for programmer/musicians to quickly collect stats about their band.
116
+ test_files:
117
+ - spec/musician_analytics/lastfm_spec.rb
118
+ - spec/musician_analytics/myspace_spec.rb
119
+ - spec/musician_analytics/twitter_spec.rb
120
+ - spec/spec_helper.rb