icemaker 0.1.0 → 0.1.1

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
  SHA1:
3
- metadata.gz: c9704bb75c9c106080a4816897bffb3c9edf9953
4
- data.tar.gz: 38727cf25913f22bb78e87b87ab3f10ad5549e38
3
+ metadata.gz: 2c4d35a2e92669d91e168cc3b143c76c66062354
4
+ data.tar.gz: 8dd4fa5b0b1414d7c2bea0d92ade18e80202f2aa
5
5
  SHA512:
6
- metadata.gz: c44e11e086d03248c277dc4cd5fcec8a0bda44c4afd2b1807c742f2ed131cfe85c5d9a588b52b0362e5b3d830e3b9bb04e763773230e4306b1ad17d595fdcc10
7
- data.tar.gz: 556f996c0971dbe5df781db0c90eb2ab548c58600f3e50bef48d5744be366ccbfad0416f4de99ebe7d30175f5c438700195e0be43ea4f5283f5e8164db9d4bce
6
+ metadata.gz: 29659ba44156e7887259f597177f2c177acdbeae965a63211ef9252898775a6b7a2c4cd04b5714ec9301d6e31d2755e4e719edf921cfa1785852e102d7fbe1e3
7
+ data.tar.gz: ec89388cec9787d6b89bcac3f034c190d9ba0a50f9cf42b951e4baa2912172bb774eb199f9814e3e7ce527fa56e79f8d37e6be97a841ba59860f5187edc304ab
data/README.md CHANGED
@@ -1,7 +1,9 @@
1
+ ![Gem Version](https://badge.fury.io/rb/icemaker.svg)
1
2
  # Icemaker
2
3
 
3
- Create playlists by applying customized search filters to a set of audio files.
4
+ `icemaker` is a small cli tool, written in Ruby, that applies search filters to the audio metadata of a set of files and writes any matches out to disk. It was created to write playlists for Ices/Icecast; hence the name.
4
5
 
6
+ Access to the metadata is provided via [taglib-ruby](https://rubygems.org/gems/taglib-ruby).
5
7
  ## Installation
6
8
 
7
9
  Add this line to your application's Gemfile:
@@ -20,14 +22,91 @@ Or install it yourself as:
20
22
 
21
23
  ## Usage
22
24
 
23
- TODO: Write usage instructions here
25
+ run `icemaker` in a directory containing an `Icefile`.
24
26
 
25
- ## Development
27
+ ```ruby
28
+ # An example Icefile
29
+
30
+ Icemaker::Playlist.make do |with|
31
+
32
+ # .sources, an array containing paths to the locations of the audio files we want to search
33
+ with.sources = ['/path/to/some/music']
34
+
35
+ # .is_recursive, if true, do a fully recursive search through the sources
36
+ with.is_recursive = true
37
+
38
+ # .verbose, if true, verbalize some status info during run, if false, remain silent
39
+ with.verbose = true
40
+
41
+ # .output_to_file, the name of the output file, if a full path is
42
+ # given, it will need to exist before writing out to the file.
43
+ with.output_to_file = 'playlist.txt'
44
+
45
+ # .formatter, the format string for the output
46
+ # the following is the default formatter for the playlist output and,
47
+ # as such, it's redundant to specify it in the Icefile its presence here is merely instructional
48
+ # with.formatter = lambda { |track| "#{track[:file]}" }
49
+
50
+ # an example of a custom formatter; the keys for the hash are any of the searchable fields
51
+ #with.formatter = lambda { |track| "#{track[:file]} genre: #{track[:genre]} length: #{track[:length]}"}
52
+
53
+ # .filters, the array of search filters applied to each track, they take the basic form:
54
+
55
+ # { search_field: { search_operator: search_term}}
56
+
57
+ # searchable fields are:
58
+ # :title
59
+ # :artist
60
+ # :album
61
+ # :genre
62
+ # :year
63
+ # :length
64
+ # :bitrate
65
+ # :channels
66
+ # :sample_rate
26
67
 
27
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
68
+ # available search operators (and their synonyms) are:
69
+ # :is (eq:)
70
+ # :has (contains:)
71
+ # :gt (greater_than:)
72
+ # :gte (greater_than_or_equal_to:)
73
+ # :lt (less_than:)
74
+ # :lte (less_than_or_equal_to:)
75
+ # :regx (satisfies:)
76
+
77
+ # all searches are case insensitive, however, case sensitive searches are available using the :regx search operator
78
+
79
+ # some examples:
80
+
81
+ with.filters << { genre: { is: "ambient" }}
82
+ with.filters << { album: { has: "air structures" }}
83
+ with.filters << { length: { gt: 200 }}
84
+ with.filters << { length: { lt: 800 }}
85
+ with.filters << { artist: { regx: /[Ff]ripp/}}
86
+
87
+ # compound search terms are given as a hash where the
88
+ # key represents a boolean operator (:or, :and) and the value
89
+ # is an array of terms to which the operator is applied.
90
+
91
+ # { search_field: { search_operator: { boolean_operator: [search_term_0, search_term_1,...] }}}
92
+
93
+ # some examples of compound search terms:
94
+
95
+ #with.filters << { artist: { has: { or: ["Aphex", "Cowboy"] }}}
96
+ #with.filters << { genre: { has: { and: ["Ambient", "Darkwave"] }}}
97
+
98
+ # synonyms for boolean_operators are:
99
+ # :intersection_of for :and
100
+ # :union_of for :or
101
+
102
+ #with.filters << { artist: { has: { union_of: ["Aphex", "Cowboy"] }}}
103
+ #with.filters << { genre: { has: { intersection_of: ["Ambient", "Darkwave"] }}}
104
+
105
+ end
106
+ ```
28
107
 
29
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
108
+ A much smaller example `Icefile` is available in the `/examples` directory.
30
109
 
31
110
  ## Contributing
32
111
 
33
- Bug reports and pull requests are welcome on GitHub at https://github.com/twocats/icemaker.
112
+ Bug reports are welcome on GitHub at https://github.com/twocats/icemaker.
data/examples/Icefile ADDED
@@ -0,0 +1,13 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ Icemaker::Playlist.make do |with|
5
+
6
+ with.sources = ['/path/to/some/music']
7
+ with.is_recursive = true
8
+ with.verbose = true
9
+ with.output_to_file = 'playlist.txt'
10
+
11
+ # with.filters << { album: { has: "air structures" }}
12
+
13
+ end
data/lib/icemaker.rb CHANGED
@@ -4,6 +4,15 @@ require 'icemaker/filter'
4
4
  require 'icemaker/query'
5
5
  require 'icemaker/icemaker'
6
6
 
7
+ module Icemaker
8
+ ALLOWED_MEDIA_EXTENSIONS = ['.mp3', '.ogg', '.flac']
9
+ DEFAULT_PLAYLIST_FILE = 'playlist.txt'
10
+ DEFAULT_FORMATTER = lambda { |track| "#{track[:file]}"}
11
+ DEFAULT_VERBOSE_VALUE = true
12
+ DEFAULT_RECURSIVE_VALUE = true
13
+ UNKNOWN_VALUE = 'unknown'
14
+ end
15
+
7
16
  class String
8
17
  def has(params)
9
18
  self.index params[:substring]
@@ -1,4 +1,4 @@
1
- module IceMaker
1
+ module Icemaker
2
2
 
3
3
  class Filter
4
4
 
@@ -26,7 +26,7 @@ module IceMaker
26
26
  def satisfies
27
27
  regx
28
28
  end
29
-
29
+
30
30
  def has
31
31
  if @value_to_test.instance_of? Hash then
32
32
 
@@ -1,7 +1,4 @@
1
- module IceMaker
2
-
3
- VALID_MEDIA_EXTENSIONS = [".mp3", ".ogg", ".flac"]
4
- UNKNOWN_VALUE = 'unknown'
1
+ module Icemaker
5
2
 
6
3
  class Playlist
7
4
 
@@ -51,10 +48,8 @@ module IceMaker
51
48
 
52
49
  end
53
50
 
54
- @@files.flatten!.map! { |file| "#{@@icefile.arbitrary_file_prefix}#{file}"}
55
-
56
- @@files.uniq! if @@icefile.unique
57
-
51
+ @@files.flatten!
52
+
58
53
  end
59
54
 
60
55
  def self.remove_non_audio_files
@@ -62,7 +57,7 @@ module IceMaker
62
57
  verbalize "#{@@files.length} total files found."
63
58
 
64
59
  @@files.reject! { |file|
65
- !(VALID_MEDIA_EXTENSIONS.include? (File.extname file).downcase) || (File.directory? file )
60
+ !(ALLOWED_MEDIA_EXTENSIONS.include? (File.extname file).downcase) || (File.directory? file )
66
61
  }
67
62
 
68
63
  verbalize "#{@@files.length} audio files found."
@@ -116,17 +111,15 @@ module IceMaker
116
111
 
117
112
  class Icefile
118
113
 
119
- attr_accessor :sources, :is_recursive, :unique, :verbose,
120
- :output_to_file, :arbitrary_file_prefix, :filters, :formatter
114
+ attr_accessor :sources, :is_recursive, :verbose, :output_to_file, :filters, :formatter
121
115
 
122
116
  def initialize
123
117
  @sources = []
124
118
  @filters = []
125
- @verbose = false
126
- @is_recursive = false
127
- @unique = true
128
- @arbitrary_file_prefix = ''
129
- @formatter = lambda { |track| "#{track[:file]}"}
119
+ @verbose = DEFAULT_VERBOSE_VALUE
120
+ @is_recursive = DEFAULT_RECURSIVE_VALUE
121
+ @formatter = DEFAULT_FORMATTER
122
+ @output_to_file = DEFAULT_PLAYLIST_FILE
130
123
  end
131
124
  end
132
125
  end
@@ -1,4 +1,4 @@
1
- module IceMaker
1
+ module Icemaker
2
2
 
3
3
  class Query
4
4
 
@@ -1,3 +1,3 @@
1
1
  module Icemaker
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: icemaker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - twocats
@@ -80,6 +80,7 @@ files:
80
80
  - README.md
81
81
  - Rakefile
82
82
  - bin/icemaker
83
+ - examples/Icefile
83
84
  - icemaker.gemspec
84
85
  - lib/icemaker.rb
85
86
  - lib/icemaker/filter.rb