active_mac 0.0.1
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/History.txt +5 -0
- data/Manifest.txt +14 -0
- data/PostInstall.txt +7 -0
- data/README.rdoc +47 -0
- data/Rakefile +25 -0
- data/active_mac.gemspec +41 -0
- data/lib/active_mac.rb +15 -0
- data/lib/active_mac/app.rb +12 -0
- data/lib/active_mac/object.rb +53 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/test/test_active_mac.rb +11 -0
- data/test/test_helper.rb +3 -0
- metadata +102 -0
data/History.txt
ADDED
data/Manifest.txt
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
History.txt
|
2
|
+
Manifest.txt
|
3
|
+
PostInstall.txt
|
4
|
+
README.rdoc
|
5
|
+
Rakefile
|
6
|
+
active_mac.gemspec
|
7
|
+
lib/active_mac.rb
|
8
|
+
lib/active_mac/app.rb
|
9
|
+
lib/active_mac/object.rb
|
10
|
+
script/console
|
11
|
+
script/destroy
|
12
|
+
script/generate
|
13
|
+
test/test_active_mac.rb
|
14
|
+
test/test_helper.rb
|
data/PostInstall.txt
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
= active_mac
|
2
|
+
|
3
|
+
* http://github.com/rmatei/active_mac
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
Provides an ORM interface to the data of any AppleScript-enabled application. Useful for querying and scripting any Mac application in an intuitive way - you can pretend your iTunes library is a relational database, for instance.
|
8
|
+
|
9
|
+
== INSTALL:
|
10
|
+
|
11
|
+
sudo gem install active_mac --source "http://gemcutter.org"
|
12
|
+
|
13
|
+
== USE:
|
14
|
+
|
15
|
+
require 'active_mac'
|
16
|
+
app("iTunes").selection.each { |track| track.name = track.name.titleize }
|
17
|
+
app("iTunes").play
|
18
|
+
|
19
|
+
== REQUIREMENTS:
|
20
|
+
|
21
|
+
* Mac OS X
|
22
|
+
* rb-appscript
|
23
|
+
|
24
|
+
== LICENSE:
|
25
|
+
|
26
|
+
(The MIT License)
|
27
|
+
|
28
|
+
Copyleft 2009 Robert Cezar Matei
|
29
|
+
|
30
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
31
|
+
a copy of this software and associated documentation files (the
|
32
|
+
'Software'), to deal in the Software without restriction, including
|
33
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
34
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
35
|
+
permit persons to whom the Software is furnished to do so, subject to
|
36
|
+
the following conditions:
|
37
|
+
|
38
|
+
The above copyright notice and this permission notice shall be
|
39
|
+
included in all copies or substantial portions of the Software.
|
40
|
+
|
41
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
42
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
43
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
44
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
45
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
46
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
47
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
gem 'hoe', '>= 2.1.0'
|
3
|
+
require 'hoe'
|
4
|
+
require 'fileutils'
|
5
|
+
require './lib/active_mac'
|
6
|
+
|
7
|
+
Hoe.plugin :newgem
|
8
|
+
# Hoe.plugin :website
|
9
|
+
# Hoe.plugin :cucumberfeatures
|
10
|
+
|
11
|
+
# Generate all the Rake tasks
|
12
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
13
|
+
$hoe = Hoe.spec 'active_mac' do
|
14
|
+
self.developer 'Robert Matei', 'rmatei@gmail.com'
|
15
|
+
self.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
|
16
|
+
self.rubyforge_name = self.name # TODO this is default value
|
17
|
+
self.extra_deps = [['rb-appscript','>= 0.5.3'], ['activesupport', '>= 2.2.2']]
|
18
|
+
end
|
19
|
+
|
20
|
+
require 'newgem/tasks'
|
21
|
+
Dir['tasks/**/*.rake'].each { |t| load t }
|
22
|
+
|
23
|
+
# TODO - want other tests/tasks run by default? Add them to the list
|
24
|
+
# remove_task :default
|
25
|
+
# task :default => [:spec, :features]
|
data/active_mac.gemspec
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{active_mac}
|
5
|
+
s.version = "0.0.1"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Robert Matei"]
|
9
|
+
s.date = %q{2009-11-13}
|
10
|
+
s.description = %q{Provides an ORM interface to the data of any AppleScript-enabled application. Useful for querying and scripting any Mac application in an intuitive way - you can pretend your iTunes library is a relational database, for instance.}
|
11
|
+
s.email = ["rmatei@gmail.com"]
|
12
|
+
s.extra_rdoc_files = ["History.txt", "Manifest.txt", "PostInstall.txt"]
|
13
|
+
s.files = ["History.txt", "Manifest.txt", "PostInstall.txt", "README.rdoc", "Rakefile", "lib/active_mac.rb", "script/console", "script/destroy", "script/generate", "test/test_active_mac.rb", "test/test_helper.rb"]
|
14
|
+
s.homepage = %q{http://github.com/rmatei/active_mac}
|
15
|
+
s.post_install_message = %q{PostInstall.txt}
|
16
|
+
s.rdoc_options = ["--main", "README.rdoc"]
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
s.rubyforge_project = %q{active_mac}
|
19
|
+
s.rubygems_version = %q{1.3.5}
|
20
|
+
s.summary = %q{Provides an ORM interface to the data of any AppleScript-enabled application}
|
21
|
+
s.test_files = ["test/test_active_mac.rb", "test/test_helper.rb"]
|
22
|
+
|
23
|
+
if s.respond_to? :specification_version then
|
24
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
25
|
+
s.specification_version = 3
|
26
|
+
|
27
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
28
|
+
s.add_runtime_dependency(%q<rb-appscript>, [">= 0.5.3"])
|
29
|
+
s.add_runtime_dependency(%q<activesupport>, [">= 2.2.2"])
|
30
|
+
s.add_development_dependency(%q<hoe>, [">= 2.3.3"])
|
31
|
+
else
|
32
|
+
s.add_dependency(%q<rb-appscript>, [">= 0.5.3"])
|
33
|
+
s.add_dependency(%q<activesupport>, [">= 2.2.2"])
|
34
|
+
s.add_dependency(%q<hoe>, [">= 2.3.3"])
|
35
|
+
end
|
36
|
+
else
|
37
|
+
s.add_dependency(%q<rb-appscript>, [">= 0.5.3"])
|
38
|
+
s.add_dependency(%q<activesupport>, [">= 2.2.2"])
|
39
|
+
s.add_dependency(%q<hoe>, [">= 2.3.3"])
|
40
|
+
end
|
41
|
+
end
|
data/lib/active_mac.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__)) unless
|
2
|
+
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
3
|
+
|
4
|
+
require 'appscript'
|
5
|
+
require 'activesupport'
|
6
|
+
require 'ruby-debug'
|
7
|
+
Dir["#{File.dirname(__FILE__)}/active_mac/*.rb"].sort.each { |lib| require lib }
|
8
|
+
|
9
|
+
module ActiveMac
|
10
|
+
VERSION = '0.0.1'
|
11
|
+
end
|
12
|
+
|
13
|
+
def app(application = "iTunes")
|
14
|
+
ActiveMac::App.find(application)
|
15
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module ActiveMac
|
2
|
+
|
3
|
+
class Object
|
4
|
+
|
5
|
+
# Holds a reference to the original AppleScript object
|
6
|
+
attr_accessor :reference
|
7
|
+
|
8
|
+
# Create a new object from an AppleScript reference, complete with accessors based on dictionary
|
9
|
+
def initialize(applescript_reference)
|
10
|
+
# raise ArgumentError, "Objects must be initialized from an Appscript::Reference" unless applescript_reference.instance_of? Appscript::Reference
|
11
|
+
self.reference = applescript_reference
|
12
|
+
build_properties
|
13
|
+
build_commands
|
14
|
+
end
|
15
|
+
|
16
|
+
# These methods should carry over from the reference
|
17
|
+
[:properties, :elements, :commands, :keywords].each do |method|
|
18
|
+
define_method method do
|
19
|
+
self.reference.send method
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def build_properties
|
26
|
+
properties.each do |property|
|
27
|
+
|
28
|
+
# Readers
|
29
|
+
self.class.send(:define_method, property) do
|
30
|
+
returning reference.send(property).get do |result|
|
31
|
+
result.map! { |element| Object.new(element) } if result.class == Array
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# Writers
|
36
|
+
self.class.send(:define_method, "#{property}=") do |value|
|
37
|
+
reference.send(property).set value
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def build_commands
|
44
|
+
commands.each do |command|
|
45
|
+
self.class.send(:define_method, command) do |*arguments|
|
46
|
+
reference.send(command, arguments.first)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
data/script/console
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# File: script/console
|
3
|
+
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
|
4
|
+
|
5
|
+
libs = " -r irb/completion"
|
6
|
+
# Perhaps use a console_lib to store any extra methods I may want available in the cosole
|
7
|
+
# libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
|
8
|
+
libs << " -r #{File.dirname(__FILE__) + '/../lib/active_mac.rb'}"
|
9
|
+
puts "Loading active_mac gem"
|
10
|
+
exec "#{irb} #{libs} --simple-prompt"
|
data/script/destroy
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/destroy'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Destroy.new.run(ARGV)
|
data/script/generate
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/generate'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Generate.new.run(ARGV)
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: active_mac
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Robert Matei
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-11-16 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rb-appscript
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.5.3
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: activesupport
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.2.2
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: hoe
|
37
|
+
type: :development
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 2.3.3
|
44
|
+
version:
|
45
|
+
description: Provides an ORM interface to the data of any AppleScript-enabled application. Useful for querying and scripting any Mac application in an intuitive way - you can pretend your iTunes library is a relational database, for instance.
|
46
|
+
email:
|
47
|
+
- rmatei@gmail.com
|
48
|
+
executables: []
|
49
|
+
|
50
|
+
extensions: []
|
51
|
+
|
52
|
+
extra_rdoc_files:
|
53
|
+
- History.txt
|
54
|
+
- Manifest.txt
|
55
|
+
- PostInstall.txt
|
56
|
+
files:
|
57
|
+
- History.txt
|
58
|
+
- Manifest.txt
|
59
|
+
- PostInstall.txt
|
60
|
+
- README.rdoc
|
61
|
+
- Rakefile
|
62
|
+
- active_mac.gemspec
|
63
|
+
- lib/active_mac.rb
|
64
|
+
- lib/active_mac/app.rb
|
65
|
+
- lib/active_mac/object.rb
|
66
|
+
- script/console
|
67
|
+
- script/destroy
|
68
|
+
- script/generate
|
69
|
+
- test/test_active_mac.rb
|
70
|
+
- test/test_helper.rb
|
71
|
+
has_rdoc: true
|
72
|
+
homepage: http://github.com/rmatei/active_mac
|
73
|
+
licenses: []
|
74
|
+
|
75
|
+
post_install_message: PostInstall.txt
|
76
|
+
rdoc_options:
|
77
|
+
- --main
|
78
|
+
- README.rdoc
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: "0"
|
86
|
+
version:
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: "0"
|
92
|
+
version:
|
93
|
+
requirements: []
|
94
|
+
|
95
|
+
rubyforge_project: active_mac
|
96
|
+
rubygems_version: 1.3.5
|
97
|
+
signing_key:
|
98
|
+
specification_version: 3
|
99
|
+
summary: Provides an ORM interface to the data of any AppleScript-enabled application
|
100
|
+
test_files:
|
101
|
+
- test/test_active_mac.rb
|
102
|
+
- test/test_helper.rb
|