mounce 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/MIT-LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ Copyright (c) 2009 Adam Bair
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
data/README.rdoc ADDED
@@ -0,0 +1,42 @@
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
+ * itunes/osx
8
+ * rubyosa
9
+ * curl (with https support)
10
+
11
+ == Getting Started
12
+
13
+ gem install adambair-mounce --source=http://gems.github.com
14
+
15
+ Create ~/.mounce.yml and fill it with the following:
16
+
17
+ presently:
18
+ username: <username>
19
+ password: <password>
20
+ api: 'https://<account>.presentlyapp.com/api/twitter/statuses/update.xml'
21
+
22
+ You can see this help file by typing:
23
+
24
+ mounce --help
25
+
26
+ == Todo
27
+
28
+ * Ability to add custom text to the message
29
+ * Album artwork as an attachment (when the api allows)
30
+ * Links to Songza or Grooveshark or Something
31
+ * Evernote integration?
32
+ * Add twitter instructions to readme
33
+ * Add --pretend argument
34
+
35
+ == Disclaimer
36
+
37
+ 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.
38
+
39
+ == Resources
40
+
41
+ Created by Adam Bair (adam@intridea.com) of Intridea (http://www.intridea.com)
42
+
data/Rakefile ADDED
@@ -0,0 +1,53 @@
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.executable = "mounce"
14
+ gem.add_dependency('pbosetti-rubyosa', '>= 0.5.3')
15
+ gem.files = FileList["[A-Z]*", "{bin,generators,lib,test}/**/*", 'lib/jeweler/templates/.gitignore']
16
+ end
17
+
18
+ Jeweler::GemcutterTasks.new
19
+
20
+ rescue LoadError
21
+ puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
22
+ end
23
+
24
+
25
+ require 'spec/rake/spectask'
26
+ Spec::Rake::SpecTask.new(:spec) do |spec|
27
+ spec.spec_opts = ['--options', "spec/spec.opts"]
28
+ spec.spec_files = FileList['spec/**/*_spec.rb']
29
+ end
30
+
31
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
32
+ spec.libs << 'lib' << 'spec'
33
+ spec.pattern = 'spec/**/*_spec.rb'
34
+ spec.rcov = true
35
+ end
36
+
37
+ task :default => :spec
38
+
39
+ require 'rake/rdoctask'
40
+ Rake::RDocTask.new do |rdoc|
41
+ if File.exist?('VERSION.yml')
42
+ config = YAML.load(File.read('VERSION.yml'))
43
+ version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
44
+ else
45
+ version = ""
46
+ end
47
+
48
+ rdoc.rdoc_dir = 'rdoc'
49
+ rdoc.title = "mounce #{version}"
50
+ rdoc.rdoc_files.include('README*')
51
+ rdoc.rdoc_files.include('lib/**/*.rb')
52
+ end
53
+
data/VERSION.yml ADDED
@@ -0,0 +1,5 @@
1
+ ---
2
+ :minor: 1
3
+ :build:
4
+ :patch: 0
5
+ :major: 0
data/bin/mounce ADDED
@@ -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
+
data/lib/mounce.rb ADDED
@@ -0,0 +1,38 @@
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}" -d source="mounce"`
20
+ end
21
+
22
+ private
23
+
24
+ def config(config_file)
25
+ raise "Missing config file: #{config_file} (see 'mounce --help')" unless File.exist?(config_file)
26
+ @config = YAML.load(open(config_file))['presently']
27
+ end
28
+
29
+ def find_song_information
30
+ return @itunes.current_stream_title.split('-').map{|item| item.strip} if stream?
31
+ [@itunes.current_track.artist, @itunes.current_track.name]
32
+ end
33
+
34
+ def stream?
35
+ @itunes.current_stream_title
36
+ end
37
+ end
38
+
@@ -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,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,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mounce
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 0
9
+ version: 0.1.0
10
+ platform: ruby
11
+ authors:
12
+ - Adam Bair
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-05-27 00:00:00 -04:00
18
+ default_executable: mounce
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: pbosetti-rubyosa
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ - 5
30
+ - 3
31
+ version: 0.5.3
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ description: Mounce will post your current itunes track to Presently.
35
+ email: adam@intridea.com
36
+ executables:
37
+ - mounce
38
+ extensions: []
39
+
40
+ extra_rdoc_files:
41
+ - README.rdoc
42
+ files:
43
+ - MIT-LICENSE
44
+ - README.rdoc
45
+ - Rakefile
46
+ - VERSION.yml
47
+ - bin/mounce
48
+ - lib/mounce.rb
49
+ has_rdoc: true
50
+ homepage: http://www.github.com/adambair/mounce
51
+ licenses: []
52
+
53
+ post_install_message:
54
+ rdoc_options:
55
+ - --charset=UTF-8
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ segments:
63
+ - 0
64
+ version: "0"
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ segments:
70
+ - 0
71
+ version: "0"
72
+ requirements: []
73
+
74
+ rubyforge_project:
75
+ rubygems_version: 1.3.6
76
+ signing_key:
77
+ specification_version: 3
78
+ summary: Music annOUNCEr for Presently
79
+ test_files:
80
+ - spec/mounce_spec.rb
81
+ - spec/spec_helper.rb