]> git.r.bdr.sh - rbdr/lyricli.rb/blobdiff - lib/lyricli/sources/itunes.rb
Finish first wave of documentation.
[rbdr/lyricli.rb] / lib / lyricli / sources / itunes.rb
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..2bfe471f1c3e3ec291f9e29a35998b0f10e31f86 100644 (file)
@@ -0,0 +1,41 @@
+module Lyricli
+  module Sources
+    # The source for iTunes
+    class Itunes
+
+      class << self
+        attr_accessor :name
+      end
+
+      @name = "itunes"
+
+      # The enable method should run all of the tasks needed to validate
+      # the source. In the case of Rdio it has to authenticate with OAuth.
+      def self.enable
+        # Nothing to do
+      end
+
+      # Instantiates everything it needs to run.
+      def initialize
+        @config = Configuration.instance
+        @script = "current_song.scpt"
+      end
+
+      # The current_track method should return the name of the current
+      # artist and song.
+      # @return [Hash] A hash containing the current `:song` and `:artist`.
+      def current_track
+        path_root = File.expand_path(File.dirname(__FILE__))
+        path = File.join(path_root, @script)
+        current = `osascript #{path}`
+        current = current.split("<-SEP->")
+        {artist: current[0], song: current[1]}
+      end
+
+      # The reset method resets any configurations it may have
+      def self.reset
+        # Nothing to do
+      end
+    end
+  end
+end