audiostream 0.1.7 → 0.1.8

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: 91bb9abb8f77c5e4cce40fae06ee69aff60c8e3d
4
- data.tar.gz: c9224b6199762bbcf8514e8f659071505a1a9d40
3
+ metadata.gz: c76ce7ce91f92c5f5b9e06fa2cc90d62379f0187
4
+ data.tar.gz: 48bc3170cd2b410f3497a62ca48e877375c04e54
5
5
  SHA512:
6
- metadata.gz: a535d1e9f3e3f9e80d0f7bd6326a31bf2f6493cd73dca9f8e26f27fd5406dd7f60ef137320178326b2db48ed002cb9045b0fb8a50a43e87a53d70578c3026e8a
7
- data.tar.gz: f86a58d9de5fda1d4d8ad3f56952d0896510caa05efe01e0489e6b11789faf4267a80cf3de1d066ef8726a316e0b54f5fab102d49086aa9a65f3740b9846fa0b
6
+ metadata.gz: 576cc41f4e5667bf39ef4c68dfc26f437d0a4ffa8fabd0ade01a5c7cfab56af0267beaec3f8f0466753248580fa328e9ab3436f710c5ad509282ac942bb9096d
7
+ data.tar.gz: 15369b20a72e08ec2e368bc766d2e0857b1228c7a6ab6d1d0ec1bd6e813f0ddf01d5c8242298fcc25c0004c7a9cfb62c3a688110915ff6871f11393f2242e4b8
@@ -1,8 +1,7 @@
1
- require 'mp3info'
2
- require 'iconv'
3
-
4
1
  require "audiostream/version"
5
2
  require "audiostream/cli"
3
+ require "audiostream/helpers"
6
4
 
7
5
  module AudioStream
6
+ include AudioStream::Helpers
8
7
  end
@@ -1,3 +1,4 @@
1
+ require 'audiostream/time'
1
2
  require 'thor'
2
3
 
3
4
  module AudioStream
@@ -21,43 +22,9 @@ Licenced for usage and distribution under a BSD version 2 Licence.
21
22
 
22
23
  desc "version", "Display the application version."
23
24
  def version
24
- puts self.VERSION
25
+ puts AudioStream::VERSION
25
26
  end
26
27
 
27
- desc "time", "Display the play time of an audio file."
28
- method_option :playlist, :aliases => "-p", :desc => "m3u playlist to parse"
29
-
30
- def time
31
-
32
- help(:time) if options[:playlist].nil?
33
- @filepath = "#{options[:playlist]}"
34
-
35
- if File.exists?(@filepath) then
36
- File.open(@filepath).each do |item|
37
- @item=item.chomp
38
-
39
- next if /^#EXT(M3U|INF:).*$/.match(@item)
40
- puts "Reading #{@item}"
41
-
42
- if File.exists?(@item) then
43
- puts "#{@item}: #{playtime(@item)}"
44
- else
45
- puts "Error: File #{@item} not found"
46
- end
47
- end
48
- else
49
- puts "Playlist could not be loaded."
50
- end
51
- end
52
-
53
- private
54
-
55
- def playtime(path)
56
- Time.at(mp3(path).length).gmtime.strftime('%R:%S')
57
- end
58
-
59
- def mp3(path)
60
- return Mp3Info.new path
61
- end
28
+ include AudioStream::Time
62
29
  end
63
30
  end
@@ -0,0 +1,10 @@
1
+ require 'mp3info'
2
+ require 'iconv'
3
+
4
+ module AudioStream
5
+ module Helpers
6
+ def mp3(path)
7
+ return Mp3Info.new path
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,36 @@
1
+ module AudioStream
2
+ module Time
3
+ include Helpers
4
+
5
+ desc "time", "Display the play time of an audio file."
6
+ method_option :playlist, :aliases => "-p", :desc => "m3u playlist to parse"
7
+
8
+ def time
9
+
10
+ help(:time) if options[:playlist].nil?
11
+ @filepath = "#{options[:playlist]}"
12
+
13
+ if File.exists?(@filepath) then
14
+ File.open(@filepath).each do |item|
15
+ @item=item.chomp
16
+
17
+ next if /^#EXT(M3U|INF:).*$/.match(@item)
18
+ if File.exists?(@item) then
19
+ @total_time << playtime(@item)
20
+ puts "#{@item}: #{playtime(@item)}"
21
+ else
22
+ puts "Error: File #{@item} not found"
23
+ end
24
+ end
25
+ else
26
+ puts "Playlist could not be loaded."
27
+ end
28
+ end
29
+
30
+ private
31
+
32
+ def playtime(path)
33
+ Time.at(self.mp3(path).length).gmtime.strftime('%R:%S')
34
+ end
35
+ end
36
+ end
@@ -2,7 +2,7 @@ module Audiostream
2
2
  module VERSION
3
3
  MAJOR = 0
4
4
  MINOR = 1
5
- TINY = 7
5
+ TINY = 8
6
6
 
7
7
  def self.to_s
8
8
  [MAJOR, MINOR, TINY].join(".")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: audiostream
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dwight Spencer
@@ -114,6 +114,8 @@ files:
114
114
  - data/test.m3u
115
115
  - lib/audiostream.rb
116
116
  - lib/audiostream/cli.rb
117
+ - lib/audiostream/helpers.rb
118
+ - lib/audiostream/time.rb
117
119
  - lib/audiostream/version.rb
118
120
  homepage: ''
119
121
  licenses: