apple_music_library 0.13.0 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8a7c56a173f838819c8b5e9fe672030b2d592571367e4d98ea5898deff6b26c1
4
- data.tar.gz: 0c7941388118cb202ff0e1d0483f0bc5d0241380ed5ba816db6f838aa01d8a33
3
+ metadata.gz: 702e772f48f00a2a330d975bd5fa2b819fe3722168842cddc7cb49017cc7f05c
4
+ data.tar.gz: 8d153ea65affd199ab2df4e1f05784323c5fd4307391439ba6d7ed9af988a780
5
5
  SHA512:
6
- metadata.gz: 1780aa02d02a2511d3c5147e25366a0b2075fd65d0bbb7a8afd516adc29321aa9ea13ded93528f6e63d9e90b10bf060ecc87a644eee408bc69de2cab579c26f4
7
- data.tar.gz: eedebe0a903e4c46554589b2e6ab8a418032186ee83f87346b31797883624e81279460dfc703eb81320eba4bc1ef5c256f28382f68d95312aa08cd32d438285b
6
+ metadata.gz: c29ec02ca2fe5b18121f991fd6850799ec7916c395047eae8dbbe89c75ca823982224d352299ed4aee81d9e1ddc70000a6fe7ca926e97e70ee9a0c6d6944d033
7
+ data.tar.gz: ef204ee8dc66c2018df611bc5a54ad26029697745c1621a22dd056629c993e1f5eef72a4de4664040f9e005cbf232282b72c97de7b9de81a5d12ffb0319f747e
data/CHANGELOG.md CHANGED
@@ -3,6 +3,18 @@
3
3
  ## [Unreleased]
4
4
  - Ability to print out playlist folder hierarchy
5
5
 
6
+ ## 0.14.0 - 2022-04-03
7
+ ### Added
8
+ - Added Century model to retrieve track and album info per century (useful if you set classical pieces to their year of authorship rather than year of release)
9
+
10
+ ## 0.13.2 - 2022-03-16
11
+ ### Fixed
12
+ - Fixed bug where tracks with empty artist names would throw an exception
13
+
14
+ ## 0.13.1 - 2022-03-16
15
+ ### Fixed
16
+ - Now strips leading/trailing whitespace from artist and track names
17
+
6
18
  ## 0.13.0 - 2022-03-26
7
19
  ### Added
8
20
  - Added handling for system verses user-created playlists
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- apple_music_library (0.13.0)
4
+ apple_music_library (0.14.0)
5
5
  facets (~> 3.1)
6
6
  plist (~> 3.6)
7
7
 
data/README.md CHANGED
@@ -112,6 +112,13 @@ end
112
112
  library.decades_report
113
113
 
114
114
 
115
+ # Print a report on all centuries in the library
116
+ # This is a personal edge case for people who, like me, set the year of any classical piece to the year it was written
117
+ # rather than the year of hte recording.
118
+ # 1800's - 336 tracks on 10 albums
119
+ # 1900's - 816 tracks on 16 albums
120
+ library.decades_report
121
+
115
122
 
116
123
  ```
117
124
  All stored attributes are available via snake_cased methods on `Track` and `Playlist`. However, note that `#artist`, `#album`, and `#genre` are special cases, returning Ruby objects rather than their associated string values. Methods to return the string versions of these track attributes are provided as `track.artist_name`, `track.album_name`, and `track.genre_name`.
@@ -6,7 +6,7 @@ module AppleMusicLibrary
6
6
  @@artists = {}
7
7
 
8
8
  def initialize(name)
9
- @name = name
9
+ @name = name&.strip
10
10
  @albums = []
11
11
  @tracks = []
12
12
  end
@@ -0,0 +1,25 @@
1
+ require_relative 'track_collection'
2
+
3
+ module AppleMusicLibrary
4
+ class Century < TrackCollection
5
+
6
+ def self.report
7
+ self.all.sort_by{|c| c.name}.each do |century|
8
+ puts "#{century.name} - #{century.track_count} tracks on #{century.album_count} albums"
9
+ end
10
+ end
11
+
12
+ def self.find_or_create_for(century_name)
13
+ century_start_year = century_name.to_i - (century_name.to_i % 100)
14
+ century_stop_year = century_start_year + 99
15
+ century_name = "#{century_start_year}'s"
16
+
17
+ self.find_or_create(century_name)
18
+ end
19
+
20
+ def self.token
21
+ :century
22
+ end
23
+
24
+ end
25
+ end
@@ -91,6 +91,14 @@ module AppleMusicLibrary
91
91
  Decade.report
92
92
  end
93
93
 
94
+ def centuries
95
+ @centuries ||= Century.all
96
+ end
97
+
98
+ def centuries_report
99
+ Century.report
100
+ end
101
+
94
102
  def valid?
95
103
  has_tracks?
96
104
  end
@@ -2,7 +2,7 @@ require 'facets'
2
2
 
3
3
  module AppleMusicLibrary
4
4
  class Track
5
- attr_reader :artist, :album, :genre
5
+ attr_reader :artist, :album, :genre, :info
6
6
 
7
7
  # 'Artist', The #artist, #album, and #genre methods return objects rather than strings and have methods like #artist_name to retrieve the strings.
8
8
  # 'Album',
@@ -49,6 +49,9 @@ module AppleMusicLibrary
49
49
 
50
50
  @decade = Decade.find_or_create_for(year_name)
51
51
  @decade.add_track(self)
52
+
53
+ @century = Century.find_or_create_for(year_name)
54
+ @century.add_track(self)
52
55
  end
53
56
 
54
57
  @artist.add_track(self)
@@ -105,7 +108,7 @@ module AppleMusicLibrary
105
108
 
106
109
  ATTRIBUTES.each do |track_attribute|
107
110
  define_method(track_attribute.to_s.snakecase) do
108
- @info[track_attribute]
111
+ @info[track_attribute].class.name == 'String' ? @info[track_attribute].strip : @info[track_attribute]
109
112
  end
110
113
  end
111
114
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AppleMusicLibrary
4
- VERSION = "0.13.0"
4
+ VERSION = "0.14.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apple_music_library
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
4
+ version: 0.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Todd Gehman
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-03-26 00:00:00.000000000 Z
11
+ date: 2022-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: awesome_print
@@ -126,6 +126,7 @@ files:
126
126
  - lib/apple_music_library.rb
127
127
  - lib/apple_music_library/album.rb
128
128
  - lib/apple_music_library/artist.rb
129
+ - lib/apple_music_library/century.rb
129
130
  - lib/apple_music_library/decade.rb
130
131
  - lib/apple_music_library/genre.rb
131
132
  - lib/apple_music_library/library.rb