stratify-itunes 0.1.0

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/spec/mongoid.yml ADDED
@@ -0,0 +1,3 @@
1
+ persist_in_safe_mode: true
2
+ host: localhost
3
+ database: stratify_itunes_test
@@ -0,0 +1,36 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'stratify-itunes'
5
+
6
+ # Requires supporting files with custom matchers and macros, etc,
7
+ # in ./support/ and its subdirectories.
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+
10
+ require 'database_cleaner'
11
+
12
+ RSpec.configure do |config|
13
+ config.color_enabled = true
14
+ config.formatter = :progress
15
+
16
+ # Configure RSpec to run focused specs, and also respect the alias 'fit' for focused specs
17
+ config.filter_run :focused => true
18
+ config.run_all_when_everything_filtered = true
19
+ config.alias_example_to :fit, :focused => true
20
+
21
+ # Configure RSpec to truncate the database before any spec tagged with ":database => true"
22
+ DatabaseCleaner.strategy = :truncation
23
+ DatabaseCleaner.orm = "mongoid"
24
+ config.before(:each, :database => true) do
25
+ DatabaseCleaner.clean
26
+ end
27
+
28
+ config.before(:suite) do
29
+ initialize_mongoid_configuration
30
+ end
31
+ end
32
+
33
+ def initialize_mongoid_configuration
34
+ mongoid_config = YAML::load_file(File.join(File.dirname(__FILE__), "mongoid.yml"))
35
+ Mongoid.from_hash(mongoid_config)
36
+ end
@@ -0,0 +1,76 @@
1
+ require 'spec_helper'
2
+
3
+ describe "stratify-itunes", :database => true do
4
+ before do
5
+ itunes_library_path = File.expand_path('../../fixtures/iTunes Music Library.xml', __FILE__)
6
+ collector = Stratify::ITunes::Collector.create!(:library_path => itunes_library_path)
7
+ collector.run
8
+ end
9
+
10
+ it "collects and stores recently-played music from iTunes" do
11
+ Stratify::ITunes::Activity.where(
12
+ :persistent_id => "83B3927542025FDC",
13
+ :name => "Smells Like Teen Spirit",
14
+ :album => "Nevermind",
15
+ :artist => "Nirvana",
16
+ :composer => "Kurt Cobain, David Grohl, Chris Novoselic",
17
+ :genre => "Rock",
18
+ :track_number => 1,
19
+ :year => 1991,
20
+ :created_at => Time.parse("2011-02-27T21:58:34Z")
21
+ ).should exist
22
+ end
23
+
24
+ it "collects and stores recently-played podcasts from iTunes" do
25
+ Stratify::ITunes::Activity.where(
26
+ :persistent_id => "90228FA50E9DF82D",
27
+ :name => "Tech News Today 186: Who Are Yooodle?",
28
+ :album => "Tech News Today",
29
+ :artist => "Tom Merritt, Becky Worley, Sarah Lane and Jason Howell",
30
+ :genre => "Podcast",
31
+ :track_number => 186,
32
+ :year => 2011,
33
+ :podcast => true,
34
+ :created_at => Time.parse("2011-02-27T21:52:35Z")
35
+ ).should exist
36
+ end
37
+
38
+ it "collects and stores recently-played TV shows from iTunes" do
39
+ Stratify::ITunes::Activity.where(
40
+ :persistent_id => "401802E7B506C475",
41
+ :name => "A No-Rough-Stuff Type Deal",
42
+ :album => "Breaking Bad, Season 1",
43
+ :artist => "Breaking Bad",
44
+ :genre => "Drama",
45
+ :season_number => 1,
46
+ :episode_number => 7,
47
+ :year => 2008,
48
+ :tv_show => true,
49
+ :created_at => Time.parse("2010-05-31T18:52:27Z")
50
+ ).should exist
51
+ end
52
+
53
+ it "collects and stores recently-played movies from iTunes" do
54
+ Stratify::ITunes::Activity.where(
55
+ :persistent_id => "3B7824E068FB05A6",
56
+ :name => "V for Vendetta",
57
+ :genre => "Action & Adventure",
58
+ :movie => true,
59
+ :created_at => Time.parse("2011-02-27T23:24:35Z")
60
+ ).should exist
61
+ end
62
+
63
+ it "collects and stores recently-played audiobooks from iTunes" do
64
+ Stratify::ITunes::Activity.where(
65
+ :persistent_id => "DB6F370B2A647633",
66
+ :name => "Born Standing Up: A Comic's Life (Unabridged)",
67
+ :artist => "Steve Martin",
68
+ :genre => "Biography & Memoir",
69
+ :created_at => Time.parse("2011-02-27T21:52:43Z")
70
+ ).should exist
71
+ end
72
+
73
+ it "does not collect unplayed items from iTunes" do
74
+ Stratify::ITunes::Activity.where(:persistent_id => "8780A3C7A0117B2B").should_not exist
75
+ end
76
+ end
@@ -0,0 +1,148 @@
1
+ require 'spec_helper'
2
+
3
+ describe Stratify::ITunes::Presenter do
4
+
5
+ context "audio track" do
6
+ before do
7
+ @activity = Stratify::ITunes::Activity.new(:name => "In Bloom", :artist => "Nirvana", :album => "Nevermind",
8
+ :year => 1999, :genre => "Rock")
9
+ @presenter = Stratify::ITunes::Presenter.new(@activity)
10
+ end
11
+
12
+ describe "summary" do
13
+ it "provides the track name and the artist name" do
14
+ @presenter.summary.should == "In Bloom \u2022 Nirvana"
15
+ end
16
+
17
+ it "provides only the track name when the artist is blank" do
18
+ @activity.artist = ""
19
+ @presenter.summary.should == "In Bloom"
20
+ end
21
+
22
+ it "provides 'Untitled' as the track name when the track name is blank" do
23
+ @activity.name = ""
24
+ @presenter.summary.should == "Untitled \u2022 Nirvana"
25
+ end
26
+ end
27
+
28
+ describe "details" do
29
+ it "provides the album, year, and genre" do
30
+ @presenter.details.should == "Nevermind \u2022 1999 \u2022 Rock"
31
+ end
32
+
33
+ it "omits the year if it is nil" do
34
+ @activity.year = nil
35
+ @presenter.details.should == "Nevermind \u2022 Rock"
36
+ end
37
+
38
+ it "omits the genre if it is blank" do
39
+ @activity.genre = ""
40
+ @presenter.details.should == "Nevermind \u2022 1999"
41
+ end
42
+
43
+ it "omits the album if it is blank" do
44
+ @activity.album = ""
45
+ @presenter.details.should == "1999 \u2022 Rock"
46
+ end
47
+ end
48
+ end
49
+
50
+ context "TV show" do
51
+ describe "episode_number" do
52
+ it "provides the episode number if it is present" do
53
+ activity = Stratify::ITunes::Activity.new(:tv_show => true, :episode_number => 4)
54
+ presenter = Stratify::ITunes::Presenter.new(activity)
55
+ presenter.episode_number.should == "Episode 4"
56
+ end
57
+
58
+ it "provides the track number if it is present and the episode number is nil" do
59
+ activity = Stratify::ITunes::Activity.new(:tv_show => true, :episode_number => nil, :track_number => 4)
60
+ presenter = Stratify::ITunes::Presenter.new(activity)
61
+ presenter.episode_number.should == "Episode 4"
62
+ end
63
+
64
+ it "returns nil if both the episode number and the track number are nil" do
65
+ activity = Stratify::ITunes::Activity.new(:tv_show => true, :episode_number => nil, :track_number => nil)
66
+ presenter = Stratify::ITunes::Presenter.new(activity)
67
+ presenter.episode_number.should == nil
68
+ end
69
+ end
70
+
71
+ describe "summary" do
72
+ before do
73
+ @activity = Stratify::ITunes::Activity.new(:tv_show => true, :name => "Crazy Handful of Nothin", :artist => "Breaking Bad")
74
+ @presenter = Stratify::ITunes::Presenter.new(@activity)
75
+ end
76
+
77
+ it "provides the episode name and the show name" do
78
+ @presenter.summary.should == "Crazy Handful of Nothin \u2022 Breaking Bad"
79
+ end
80
+
81
+ it "provides only the episode name when the show name is blank" do
82
+ @activity.artist = ""
83
+ @presenter.summary.should == "Crazy Handful of Nothin"
84
+ end
85
+
86
+ it "provides 'Untitled' as the episode name when the episode name is blank" do
87
+ @activity.name = ""
88
+ @presenter.summary.should == "Untitled \u2022 Breaking Bad"
89
+ end
90
+ end
91
+
92
+ describe "details" do
93
+ before do
94
+ @activity = Stratify::ITunes::Activity.new(:tv_show => true, :season_number => 1, :episode_number => 6, :year => 2008)
95
+ @presenter = Stratify::ITunes::Presenter.new(@activity)
96
+ end
97
+
98
+ it "provides the season number, episode number, and year" do
99
+ @presenter.details.should == "Season 1 \u2022 Episode 6 \u2022 2008"
100
+ end
101
+
102
+ it "omits the season number if it is nil" do
103
+ @activity.season_number = nil
104
+ @presenter.details.should == "Episode 6 \u2022 2008"
105
+ end
106
+
107
+ it "omits the episode number if it is nil" do
108
+ @activity.episode_number = nil
109
+ @presenter.details.should == "Season 1 \u2022 2008"
110
+ end
111
+
112
+ it "omits the year if it is nil" do
113
+ @activity.year = nil
114
+ @presenter.details.should == "Season 1 \u2022 Episode 6"
115
+ end
116
+ end
117
+ end
118
+
119
+ context "movie" do
120
+ before do
121
+ @activity = Stratify::ITunes::Activity.new(:movie => true, :name => "V for Vendetta", :artist => "James McTeigue",
122
+ :year => 2006, :genre => "Action & Adventure")
123
+ @presenter = Stratify::ITunes::Presenter.new(@activity)
124
+ end
125
+
126
+ describe "summary" do
127
+ it "provides the name" do
128
+ @presenter.summary.should == "V for Vendetta"
129
+ end
130
+ end
131
+
132
+ describe "details" do
133
+ it "provides the year and the genre" do
134
+ @presenter.details.should == "2006 \u2022 Action & Adventure"
135
+ end
136
+
137
+ it "omits the year if it is nil" do
138
+ @activity.year = nil
139
+ @presenter.details.should == "Action & Adventure"
140
+ end
141
+
142
+ it "omits the genre if it is nil" do
143
+ @activity.genre = nil
144
+ @presenter.details.should == "2006"
145
+ end
146
+ end
147
+ end
148
+ end
@@ -0,0 +1,28 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "stratify-itunes/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "stratify-itunes"
7
+ s.version = Stratify::ITunes::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Jason Rudolph"]
10
+ s.email = ["jason@jasonrudolph.com"]
11
+ s.homepage = "http://github.com/jasonrudolph/stratify/"
12
+ s.summary = "iTunes plugin for Stratify"
13
+ s.description = s.summary
14
+
15
+ s.rubyforge_project = "stratify-itunes"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+
22
+ s.add_runtime_dependency "railties", "~> 3.1.0.rc1"
23
+ s.add_runtime_dependency "stratify-base", "~> 0.1.0"
24
+ s.add_runtime_dependency "itunes-library", "~> 0.1.1"
25
+
26
+ s.add_development_dependency "database_cleaner", "~> 0.6.7"
27
+ s.add_development_dependency "rspec", "~> 2.6.0"
28
+ end
metadata ADDED
@@ -0,0 +1,134 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: stratify-itunes
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.1.0
6
+ platform: ruby
7
+ authors:
8
+ - Jason Rudolph
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-06-26 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: railties
17
+ prerelease: false
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ~>
22
+ - !ruby/object:Gem::Version
23
+ version: 3.1.0.rc1
24
+ type: :runtime
25
+ version_requirements: *id001
26
+ - !ruby/object:Gem::Dependency
27
+ name: stratify-base
28
+ prerelease: false
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ~>
33
+ - !ruby/object:Gem::Version
34
+ version: 0.1.0
35
+ type: :runtime
36
+ version_requirements: *id002
37
+ - !ruby/object:Gem::Dependency
38
+ name: itunes-library
39
+ prerelease: false
40
+ requirement: &id003 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 0.1.1
46
+ type: :runtime
47
+ version_requirements: *id003
48
+ - !ruby/object:Gem::Dependency
49
+ name: database_cleaner
50
+ prerelease: false
51
+ requirement: &id004 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ~>
55
+ - !ruby/object:Gem::Version
56
+ version: 0.6.7
57
+ type: :development
58
+ version_requirements: *id004
59
+ - !ruby/object:Gem::Dependency
60
+ name: rspec
61
+ prerelease: false
62
+ requirement: &id005 !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ~>
66
+ - !ruby/object:Gem::Version
67
+ version: 2.6.0
68
+ type: :development
69
+ version_requirements: *id005
70
+ description: iTunes plugin for Stratify
71
+ email:
72
+ - jason@jasonrudolph.com
73
+ executables: []
74
+
75
+ extensions: []
76
+
77
+ extra_rdoc_files: []
78
+
79
+ files:
80
+ - .gitignore
81
+ - .rvmrc
82
+ - Gemfile
83
+ - Gemfile.lock
84
+ - LICENSE
85
+ - README.md
86
+ - Rakefile
87
+ - app/assets/images/itunes-icon-16.png
88
+ - app/assets/images/itunes-icon-24.png
89
+ - lib/stratify-itunes.rb
90
+ - lib/stratify-itunes/activity.rb
91
+ - lib/stratify-itunes/collector.rb
92
+ - lib/stratify-itunes/engine.rb
93
+ - lib/stratify-itunes/presenter.rb
94
+ - lib/stratify-itunes/query.rb
95
+ - lib/stratify-itunes/version.rb
96
+ - spec/fixtures/iTunes Music Library.xml
97
+ - spec/mongoid.yml
98
+ - spec/spec_helper.rb
99
+ - spec/stratify-itunes/integration_spec.rb
100
+ - spec/stratify-itunes/presenter_spec.rb
101
+ - stratify-itunes.gemspec
102
+ homepage: http://github.com/jasonrudolph/stratify/
103
+ licenses: []
104
+
105
+ post_install_message:
106
+ rdoc_options: []
107
+
108
+ require_paths:
109
+ - lib
110
+ required_ruby_version: !ruby/object:Gem::Requirement
111
+ none: false
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: "0"
116
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
+ none: false
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: "0"
122
+ requirements: []
123
+
124
+ rubyforge_project: stratify-itunes
125
+ rubygems_version: 1.8.5
126
+ signing_key:
127
+ specification_version: 3
128
+ summary: iTunes plugin for Stratify
129
+ test_files:
130
+ - spec/fixtures/iTunes Music Library.xml
131
+ - spec/mongoid.yml
132
+ - spec/spec_helper.rb
133
+ - spec/stratify-itunes/integration_spec.rb
134
+ - spec/stratify-itunes/presenter_spec.rb