adambair-mounce 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,31 @@
1
+ = Mounce
2
+
3
+ The Music annOUNCEr for Presently. Mounce will post your current iTunes track to Presently, the ambient awareness tool by Intridea.
4
+
5
+ == Requirements
6
+
7
+ curl (with https support)
8
+
9
+ == Getting Started
10
+
11
+ gem install adambair-mounce --source=http://gems.github.com
12
+
13
+ Create ~/.mounce.yml and fill it with the following:
14
+
15
+ presently:
16
+ username: <username>
17
+ password: <password>
18
+ api: 'https://<account>.presentlyapp.com/api/twitter/statuses/update.xml'
19
+
20
+ You can see this help file by typing:
21
+
22
+ mounce --help
23
+
24
+ == Disclaimer
25
+
26
+ This gem is provided as is - therefore, the creators and contributors of this plugin are not responsible for any damages that may result from it's usage. Use at your own risk; backup your data.
27
+
28
+ == Resources
29
+
30
+ Created by Adam Bair (adam@intridea.com) of Intridea (http://www.intridea.com)
31
+
@@ -0,0 +1,47 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = 'mounce'
8
+ gem.authors = ['Adam Bair']
9
+ gem.email = 'adam@intridea.com'
10
+ gem.summary = 'Music annOUNCEr for Presently'
11
+ gem.homepage = 'http://www.github.com/adambair/mounce'
12
+ gem.description = 'Mounce will post your current itunes track to Presently.'
13
+ gem.add_dependency('rubyosa', '>= 0.4.0')
14
+ end
15
+ rescue LoadError
16
+ puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
17
+ end
18
+
19
+ require 'spec/rake/spectask'
20
+ Spec::Rake::SpecTask.new(:spec) do |spec|
21
+ spec.spec_opts = ['--options', "spec/spec.opts"]
22
+ spec.spec_files = FileList['spec/**/*_spec.rb']
23
+ end
24
+
25
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
26
+ spec.libs << 'lib' << 'spec'
27
+ spec.pattern = 'spec/**/*_spec.rb'
28
+ spec.rcov = true
29
+ end
30
+
31
+ task :default => :spec
32
+
33
+ require 'rake/rdoctask'
34
+ Rake::RDocTask.new do |rdoc|
35
+ if File.exist?('VERSION.yml')
36
+ config = YAML.load(File.read('VERSION.yml'))
37
+ version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
38
+ else
39
+ version = ""
40
+ end
41
+
42
+ rdoc.rdoc_dir = 'rdoc'
43
+ rdoc.title = "mounce #{version}"
44
+ rdoc.rdoc_files.include('README*')
45
+ rdoc.rdoc_files.include('lib/**/*.rb')
46
+ end
47
+
@@ -0,0 +1,4 @@
1
+ ---
2
+ :patch: 0
3
+ :major: 0
4
+ :minor: 0
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift(File.join(File.dirname(File.dirname(__FILE__)),'lib'))
4
+ begin; require 'rubygems'; rescue LoadError; end
5
+ require 'mounce'
6
+
7
+ if ARGV.include?('--help')
8
+ puts "usage: mounce #=> will post '#music artist - song' in presently"
9
+ puts ""
10
+ puts "Be sure to add your credentials to the mounce config file:"
11
+ puts "~/.mounce.yml"
12
+ puts " presently:"
13
+ puts " username: '...'"
14
+ puts " password: '...'"
15
+ puts " api: 'https://<account>.presentlyapp.com/api/twitter/statuses/update.xml'\n\n"
16
+ exit
17
+ end
18
+
19
+ mounce = Mounce.new
20
+ puts mounce.message
21
+ mounce.share!
22
+
@@ -0,0 +1,41 @@
1
+ require 'rubygems'
2
+ require 'rbosa'
3
+
4
+ class Mounce
5
+ attr_reader :artist, :track
6
+
7
+ def initialize(config_file='~/.mounce.yml')
8
+ config(File.expand_path(config_file))
9
+ @itunes = OSA.app('iTunes')
10
+ @artist, @track = find_song_information
11
+ end
12
+
13
+ def message(tag='#music')
14
+ text = [@artist, @track].compact.join(' - ')
15
+ "#{tag} #{text}"
16
+ end
17
+
18
+ def share!
19
+ `curl #{@config['api']} -u #{@config['username']}:#{@config['password']} -d status="#{message}"`
20
+ end
21
+
22
+ private
23
+
24
+ def config(config_file)
25
+ if File.exist?(config_file)
26
+ @config = YAML.load(open(config_file))['presently']
27
+ else
28
+ raise "Missing config file: ~/.mounce.yml (see 'mounce --help')"
29
+ end
30
+ end
31
+
32
+ def find_song_information
33
+ return @itunes.current_stream_title.split('-').map{|item| item.strip} if stream?
34
+ [@itunes.current_track.artist, @itunes.current_track.name]
35
+ end
36
+
37
+ def stream?
38
+ !!@itunes.current_stream_title
39
+ end
40
+ end
41
+
@@ -0,0 +1,4 @@
1
+ presently:
2
+ username: 'alagash'
3
+ password: 'password'
4
+ api: 'https://account.presentlyapp.com/api/twitter/statuses/update.xml'
@@ -0,0 +1,49 @@
1
+ require File.join(File.dirname(__FILE__),'spec_helper')
2
+
3
+ describe Mounce do
4
+ it "should require a config file" do
5
+ lambda{Mounce.new('spec/non-existant-config.yml')}.should raise_error(RuntimeError)
6
+ end
7
+
8
+ context 'Streaming music' do
9
+ before(:all) do
10
+ mock_osa = mock(:osa, :current_stream_title => 'Silverchair - Abuse Me')
11
+ OSA.stub!(:app).with('iTunes').and_return(mock_osa)
12
+ @mounce = Mounce.new('spec/mounce.yml')
13
+ end
14
+
15
+ it "should find the artist" do
16
+ @mounce.artist.should == 'Silverchair'
17
+ end
18
+
19
+ it "should find track" do
20
+ @mounce.track.should == 'Abuse Me'
21
+ end
22
+
23
+ it 'should tag the message' do
24
+ @mounce.message.should == '#music Silverchair - Abuse Me'
25
+ end
26
+ end
27
+
28
+ context 'Local music' do
29
+ before(:all) do
30
+ mock_track = mock(:track, :artist => 'Bush', :name => 'Greedy Fly')
31
+ mock_osa = mock(:osa, :current_stream_title => nil, :current_track => mock_track)
32
+ OSA.stub!(:app).with('iTunes').and_return(mock_osa)
33
+ @mounce = Mounce.new('spec/mounce.yml')
34
+ end
35
+
36
+ it 'should find the artist' do
37
+ @mounce.artist.should == 'Bush'
38
+ end
39
+
40
+ it 'should find the track' do
41
+ @mounce.track.should == 'Greedy Fly'
42
+ end
43
+
44
+ it 'should tag the message' do
45
+ @mounce.message.should == '#music Bush - Greedy Fly'
46
+ end
47
+ end
48
+ end
49
+
@@ -0,0 +1,5 @@
1
+ --colour
2
+ --format progress
3
+ --loadby mtime
4
+ --reverse
5
+
@@ -0,0 +1,8 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(File.dirname(__FILE__)),'lib'))
2
+ begin; require 'rubygems'; rescue LoadError; end
3
+ require 'spec'
4
+ require 'mounce'
5
+
6
+ Spec::Runner.configure do |config|
7
+ end
8
+
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: adambair-mounce
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Adam Bair
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-05-07 00:00:00 -07:00
13
+ default_executable: mounce
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rubyosa
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 0.4.0
24
+ version:
25
+ description: Mounce will post your current itunes track to Presently.
26
+ email: adam@intridea.com
27
+ executables:
28
+ - mounce
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - README.rdoc
33
+ files:
34
+ - README.rdoc
35
+ - Rakefile
36
+ - VERSION.yml
37
+ - bin/mounce
38
+ - lib/mounce.rb
39
+ - spec/mounce.yml
40
+ - spec/mounce_spec.rb
41
+ - spec/spec.opts
42
+ - spec/spec_helper.rb
43
+ has_rdoc: true
44
+ homepage: http://www.github.com/adambair/mounce
45
+ post_install_message:
46
+ rdoc_options:
47
+ - --charset=UTF-8
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: "0"
55
+ version:
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: "0"
61
+ version:
62
+ requirements: []
63
+
64
+ rubyforge_project:
65
+ rubygems_version: 1.2.0
66
+ signing_key:
67
+ specification_version: 2
68
+ summary: Music annOUNCEr for Presently
69
+ test_files:
70
+ - spec/mounce_spec.rb
71
+ - spec/spec_helper.rb