rubyosa19 0.5.4 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,34 @@
1
+ /**********************************************************************
2
+
3
+ ruby.h -
4
+
5
+ $Author$
6
+ created at: Sun 10 12:06:15 Jun JST 2007
7
+
8
+ Copyright (C) 2007-2008 Yukihiro Matsumoto
9
+
10
+ **********************************************************************/
11
+
12
+ #ifndef RUBY_H
13
+ #define RUBY_H 1
14
+
15
+ #define HAVE_RUBY_DEFINES_H 1
16
+ #define HAVE_RUBY_ENCODING_H 1
17
+ #define HAVE_RUBY_INTERN_H 1
18
+ #define HAVE_RUBY_IO_H 1
19
+ #define HAVE_RUBY_MISSING_H 1
20
+ #define HAVE_RUBY_ONIGURUMA_H 1
21
+ #define HAVE_RUBY_RE_H 1
22
+ #define HAVE_RUBY_REGEX_H 1
23
+ #define HAVE_RUBY_RUBY_H 1
24
+ #define HAVE_RUBY_ST_H 1
25
+ #define HAVE_RUBY_UTIL_H 1
26
+ #define HAVE_RUBY_VERSION_H 1
27
+ #define HAVE_RUBY_VM_H 1
28
+ #ifdef _WIN32
29
+ #define HAVE_RUBY_WIN32_H 1
30
+ #endif
31
+
32
+ #include "ruby/ruby.h"
33
+
34
+ #endif /* RUBY_H */
@@ -27,7 +27,7 @@
27
27
  */
28
28
 
29
29
  #include "rbosa.h"
30
- #include <st.h>
30
+ #include <ruby/st.h>
31
31
 
32
32
  static VALUE mOSA;
33
33
  static VALUE cOSAElement;
@@ -161,13 +161,8 @@ rbosa_element_new (VALUE self, VALUE type, VALUE value)
161
161
  }
162
162
  else {
163
163
  Check_Type (value, T_STRING);
164
- #ifdef RUBY_19
165
164
  c_value = RSTRING_PTR(value);
166
165
  c_value_size = RSTRING_LEN(value);
167
- #else
168
- c_value = RSTRING (value)->ptr;
169
- c_value_size = RSTRING (value)->len;
170
- #endif
171
166
  }
172
167
 
173
168
  error = AECreateDesc (ffc_type, c_value, c_value_size, &desc);
@@ -232,9 +227,6 @@ __rbosa_raise_potential_app_error (AEDesc *reply)
232
227
  return;
233
228
  }
234
229
 
235
- if (errorNum == noErr)
236
- return;
237
-
238
230
  /* The reply is an application error. */
239
231
 
240
232
  errorMsg = error_code_to_string(errorNum);
@@ -295,32 +287,18 @@ rbosa_app_send_event (VALUE self, VALUE event_class, VALUE event_id, VALUE param
295
287
  if (!NIL_P (params)) {
296
288
  unsigned i;
297
289
 
298
- #ifdef RUBY_19
299
- for (i = 0; i < RARRAY_LEN(params); i++) {
300
- #else
301
- for (i = 0; i < RARRAY (params)->len; i++) {
302
- #endif
290
+ for (i = 0; i < RARRAY_LEN(params); i++) {
303
291
  VALUE ary;
304
292
  VALUE type;
305
293
  VALUE element;
306
294
  FourCharCode code;
307
295
 
308
- #ifdef RUBY_19
309
- ary = RARRAY_PTR(params)[i];
310
- if (NIL_P (ary) || RARRAY_LEN(ary) != 2)
311
- #else
312
- ary = RARRAY (params)->ptr[i];
313
- if (NIL_P (ary) || RARRAY (ary)->len != 2)
314
- #endif
296
+ ary = RARRAY_PTR(params)[i];
297
+ if (NIL_P (ary) || RARRAY_LEN(ary) != 2)
315
298
  continue;
316
299
 
317
- #ifdef RUBY_19
318
300
  type = RARRAY_PTR(ary)[0];
319
301
  element = RARRAY_PTR(ary)[1];
320
- #else
321
- type = RARRAY (ary)->ptr[0];
322
- element = RARRAY (ary)->ptr[1];
323
- #endif
324
302
  code = RVAL2FOURCHAR (type);
325
303
 
326
304
  if (code == '----')
@@ -579,13 +557,8 @@ rbosa_elementlist_new (int argc, VALUE *argv, VALUE self)
579
557
  error_code_to_string (error), error);
580
558
 
581
559
  if (!NIL_P (ary)) {
582
- #ifdef RUBY_19
583
560
  for (i = 0; i < RARRAY_LEN(ary); i++)
584
561
  __rbosa_elementlist_add (&list, RARRAY_PTR(ary)[i], i + 1);
585
- #else
586
- for (i = 0; i < RARRAY (ary)->len; i++)
587
- __rbosa_elementlist_add (&list, RARRAY (ary)->ptr[i], i + 1);
588
- #endif
589
562
  }
590
563
 
591
564
  return rbosa_element_make (self, &list, Qnil);
@@ -29,7 +29,7 @@
29
29
  #ifndef __RBOSA_H_
30
30
  #define __RBOSA_H_
31
31
 
32
- #include <ruby.h>
32
+ #include "osx_ruby.h"
33
33
  #include <Carbon/Carbon.h>
34
34
  #include <sys/param.h>
35
35
 
@@ -43,15 +43,9 @@ rbobj_to_fourchar (VALUE obj)
43
43
  obj = rb_obj_as_string (obj);
44
44
 
45
45
  if (rb_obj_is_kind_of (obj, rb_cString)) {
46
- #ifdef RUBY_19
47
46
  if (RSTRING_LEN(obj) != 4)
48
47
  rb_raise (rb_eArgError, USAGE_MSG);
49
48
  result = *(FourCharCode*)(RSTRING_PTR(obj));
50
- #else
51
- if (RSTRING (obj)->len != 4)
52
- rb_raise (rb_eArgError, USAGE_MSG);
53
- result = *(FourCharCode*)(RSTRING (obj)->ptr);
54
- #endif
55
49
  result = CFSwapInt32HostToBig (result);
56
50
  }
57
51
  else {
@@ -81,14 +75,9 @@ rbobj_to_alias_handle (VALUE obj, AliasHandle *alias)
81
75
  Check_Type (obj, T_STRING);
82
76
  *alias = NULL;
83
77
 
84
- URL = CFURLCreateFromFileSystemRepresentation (kCFAllocatorDefault,
85
- #ifdef RUBY_19
86
- (const UInt8 *)RSTRING_PTR(obj),
87
- RSTRING_LEN(obj),
88
- #else
89
- (const UInt8 *)RSTRING (obj)->ptr,
90
- RSTRING (obj)->len,
91
- #endif
78
+ URL = CFURLCreateFromFileSystemRepresentation (kCFAllocatorDefault,
79
+ (const UInt8 *)RSTRING_PTR (obj),
80
+ RSTRING_LEN(obj),
92
81
  0 /* XXX: normally passing 0 even if it's a directory should
93
82
  not hurt, as we are just getting the FSRef. */);
94
83
  if (URL == NULL)
@@ -99,18 +88,10 @@ rbobj_to_alias_handle (VALUE obj, AliasHandle *alias)
99
88
  error = FSNewAlias (NULL, &ref, alias);
100
89
  if (error != noErr)
101
90
  rb_raise (rb_eArgError, "Cannot create alias handle for given filename '%s' : %s (%d)",
102
- #ifdef RUBY_19
103
- RSTRING_PTR(obj), GetMacOSStatusErrorString (error), error);
104
- #else
105
- RSTRING (obj)->ptr, GetMacOSStatusErrorString (error), error);
106
- #endif
91
+ RSTRING_PTR(obj), GetMacOSStatusErrorString (error), error);
107
92
  }
108
93
  else {
109
94
  rb_raise (rb_eArgError, "Cannot obtain the filesystem reference for given filename '%s'",
110
- #ifdef RUBY_19
111
- RSTRING_PTR(obj));
112
- #else
113
- RSTRING (obj)->ptr);
114
- #endif
95
+ RSTRING_PTR(obj));
115
96
  }
116
97
  }
File without changes
@@ -331,20 +331,12 @@ rbosa_scripting_info (VALUE self, VALUE hash)
331
331
  remote = CSTR2RVAL (c_remote);
332
332
  }
333
333
 
334
- #ifdef RUBY_19
335
334
  if (RHASH_TBL(hash)->num_entries > 0) {
336
- #else
337
- if (RHASH (hash)->tbl->num_entries > 0) {
338
- #endif
339
335
  VALUE keys;
340
336
 
341
337
  keys = rb_funcall (hash, rb_intern ("keys"), 0);
342
338
  rb_raise (rb_eArgError, "inappropriate argument(s): %s",
343
- #ifdef RUBY_19
344
339
  RSTRING_PTR(rb_inspect (keys)));
345
- #else
346
- RSTRING (rb_inspect (keys))->ptr);
347
- #endif
348
340
  }
349
341
 
350
342
  if (NIL_P (remote)) {
@@ -24,23 +24,53 @@
24
24
  # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25
25
  # POSSIBILITY OF SUCH DAMAGE.
26
26
 
27
- unless RUBY_VERSION =~ /^1.9/ then
28
- $KCODE = 'u' # we will use UTF-8 strings
29
- end
30
-
31
- require 'osa'
32
27
  require 'date'
33
28
  require 'uri'
34
- require 'iconv'
35
- require 'xml'
29
+ # require 'iconv'
30
+
31
+ # Try to load RubyGems first, libxml-ruby may have been installed by it.
32
+ begin require 'rubygems'; rescue LoadError; end
33
+
34
+ # If libxml-ruby is not present, switch to REXML.
35
+ USE_LIBXML = begin
36
+ require 'xml/libxml'
37
+
38
+ # libxml-ruby bug workaround.
39
+ class XML::Node
40
+ alias_method :old_cmp, :==
41
+ def ==(x)
42
+ (x != nil and old_cmp(x))
43
+ end
44
+ end
45
+ true
46
+ rescue LoadError
47
+ require 'rexml/document'
48
+
49
+ # REXML -> libxml-ruby compatibility layer.
50
+ class REXML::Element
51
+ alias_method :old_find, :find
52
+ def find(path=nil, &block)
53
+ if path.nil? and block
54
+ old_find { |*x| block.call(*x) }
55
+ else
56
+ list = []
57
+ ::REXML::XPath.each(self, path) { |e| list << e }
58
+ list
59
+ end
60
+ end
61
+ def [](attr)
62
+ attributes[attr]
63
+ end
64
+ def find_first(path)
65
+ ::REXML::XPath.first(self, path)
66
+ end
67
+ end
68
+ false
69
+ end
36
70
 
37
71
  class String
38
72
  def to_4cc
39
- if RUBY_VERSION =~ /^1.9/ then
40
- OSA.__four_char_code__(Iconv.iconv('MACROMAN', 'UTF-8', self)[0].to_s)
41
- else
42
- OSA.__four_char_code__(Iconv.iconv('MACROMAN', 'UTF-8', self).to_s)
43
- end
73
+ OSA.__four_char_code__(self.encode('MACROMAN').to_s)
44
74
  end
45
75
  end
46
76
 
@@ -433,7 +463,12 @@ module OSA
433
463
 
434
464
  def self.__load_sdef__(sdef, target, app_module, merge_only=false, app_class=nil)
435
465
  # Load the sdef.
436
- doc = XML::Parser.string(sdef).parse
466
+ doc = if USE_LIBXML
467
+ parser = XML::Parser.string(sdef)
468
+ parser.parse
469
+ else
470
+ REXML::Document.new(sdef)
471
+ end
437
472
 
438
473
  # Retrieves and creates enumerations.
439
474
  enum_group_codes = {}
@@ -617,13 +652,13 @@ module OSA
617
652
  has_result = result != nil
618
653
 
619
654
  code = element['code']
620
- begin
621
- code = Iconv.iconv('MACROMAN', 'UTF-8', code).to_s
622
- rescue Iconv::IllegalSequence
623
- # We can't do more...
624
- STDERR.puts "unrecognized command code encoding '#{code}', skipping..." if $DEBUG
625
- next
626
- end
655
+ # begin
656
+ code = code.encode('MACROMAN').to_s
657
+ # rescue Iconv::IllegalSequence
658
+ # # We can't do more...
659
+ # STDERR.puts "unrecognized command code encoding '#{code}', skipping..." if $DEBUG
660
+ # next
661
+ # end
627
662
 
628
663
  classes_to_define = []
629
664
  forget_direct_parameter = true
@@ -1003,5 +1038,3 @@ OSA.add_conversion_to_osa('color') do |values|
1003
1038
  ary = values.map { |i| OSA::Element.__new__('long', [i].pack('l')) }
1004
1039
  OSA::ElementList.__new__(ary)
1005
1040
  end
1006
-
1007
- require 'rbosa_properties'
File without changes
data/lib/rubyosa.rb ADDED
@@ -0,0 +1,18 @@
1
+ # encoding: utf-8
2
+ #
3
+ # Copyright (C) 2012 Paolo Bosetti <p4010@me.com>
4
+ #
5
+ # This program is distributed under the terms of the MIT license.
6
+ # See the included MIT-LICENSE file for the terms of this license.
7
+ #
8
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
9
+ # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
10
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
11
+ # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
12
+ # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
13
+ # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
14
+ # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15
+
16
+ require "rubyosa/osa"
17
+ require "rubyosa/rbosa"
18
+ require "rubyosa/rbosa_properties"
metadata CHANGED
@@ -1,96 +1,63 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: rubyosa19
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.6.0
4
5
  prerelease:
5
- version: 0.5.4
6
6
  platform: ruby
7
- authors:
8
- - Laurent Sansonetti
9
- - Paolo Bosetti (adapting for 1.9)
7
+ authors:
8
+ - Alain Hoang
9
+ - Jan Dvorak
10
+ - Minh Thu Vo
11
+ - James Adam
12
+ - Paolo Bosetti
10
13
  autorequire:
11
14
  bindir: bin
12
15
  cert_chain: []
13
-
14
- date: 2011-03-03 00:00:00 -08:00
15
- default_executable:
16
- dependencies:
17
- - !ruby/object:Gem::Dependency
18
- name: libxml-ruby
19
- prerelease: false
20
- requirement: &id001 !ruby/object:Gem::Requirement
21
- none: false
22
- requirements:
23
- - - ">="
24
- - !ruby/object:Gem::Version
25
- version: 1.1.3
26
- type: :runtime
27
- version_requirements: *id001
28
- description: RubyOSA is a bridge that connects Ruby to the Apple Event Manager, automatically populating the API according to the target application's scriptable definition. This version is 1.9.2 compatible!
16
+ date: 2012-04-19 00:00:00.000000000 Z
17
+ dependencies: []
18
+ description: This is a modernization of the glorious but unmaintained rubyosa version,
19
+ aimed at making it compatible with ruby 1.9.x series. At the moment, it successfully
20
+ compiles on OS X Lion.
29
21
  email: p4010@me.com
30
- executables:
31
- - rdoc-osa
32
- extensions:
33
- - extconf.rb
22
+ executables: []
23
+ extensions:
24
+ - ext/rubyosa/extconf.rb
34
25
  extra_rdoc_files: []
35
-
36
- files:
37
- - README.markdown
38
- - COPYRIGHT
39
- - AUTHORS
40
- - extconf.rb
41
- - src/rbosa.c
42
- - src/rbosa.h
43
- - src/rbosa_conv.c
44
- - src/rbosa_sdef.c
45
- - src/rbosa_err.c
46
- - src/lib/rbosa.rb
47
- - src/lib/rbosa_properties.rb
48
- - sample/Finder/show_desktop.rb
49
- - sample/iChat/uptime.rb
50
- - sample/iTunes/control.rb
51
- - sample/iTunes/fade_volume.rb
52
- - sample/iTunes/inspect.rb
53
- - sample/QuickTime/play_all.rb
54
- - sample/misc/sdef.rb
55
- - sample/BBEdit/unix_script.rb
56
- - sample/TextEdit/hello_world.rb
57
- - sample/iChat/image.rb
58
- - sample/iTunes/artwork.rb
59
- - sample/Mail/get_selected_mail.rb
60
- - sample/AddressBook/inspect.rb
61
- - sample/iTunes/tag_genre_lastfm.rb
62
- - data/rubyosa/rdoc_html.rb
63
- - sample/Photoshop/new_doc.rb
64
- - sample/Photoshop/new_doc_with_text.rb
65
- - sample/iTunes/name_that_tune.rb
66
- - bin/rdoc-osa
67
- has_rdoc: true
68
- homepage: http://github.com/pbosetti/rubyosa
26
+ files:
27
+ - lib/rubyosa/rbosa.rb
28
+ - lib/rubyosa/rbosa_properties.rb
29
+ - lib/rubyosa.rb
30
+ - ext/rubyosa/rbosa.c
31
+ - ext/rubyosa/rbosa_conv.c
32
+ - ext/rubyosa/rbosa_err.c
33
+ - ext/rubyosa/rbosa_sdef.c
34
+ - ext/rubyosa/osx_intern.h
35
+ - ext/rubyosa/osx_ruby.h
36
+ - ext/rubyosa/rbosa.h
37
+ - ext/rubyosa/extconf.rb
38
+ homepage: http://github.com/pbosetti/rubyosa19
69
39
  licenses: []
70
-
71
40
  post_install_message:
72
41
  rdoc_options: []
73
-
74
- require_paths:
42
+ require_paths:
75
43
  - lib
76
- required_ruby_version: !ruby/object:Gem::Requirement
44
+ required_ruby_version: !ruby/object:Gem::Requirement
77
45
  none: false
78
- requirements:
79
- - - ">="
80
- - !ruby/object:Gem::Version
81
- version: "0"
82
- required_rubygems_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ! '>='
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ required_rubygems_version: !ruby/object:Gem::Requirement
83
51
  none: false
84
- requirements:
85
- - - ">="
86
- - !ruby/object:Gem::Version
87
- version: "0"
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
88
56
  requirements: []
89
-
90
- rubyforge_project: rubyosa
91
- rubygems_version: 1.5.2
57
+ rubyforge_project: rubyosa19
58
+ rubygems_version: 1.8.21
92
59
  signing_key:
93
60
  specification_version: 3
94
- summary: A Ruby/AppleEvent bridge.
61
+ summary: Ruby 1.9.x OSA script interface
95
62
  test_files: []
96
-
63
+ has_rdoc: false
data/AUTHORS DELETED
@@ -1,16 +0,0 @@
1
- Maintainer & Author:
2
- Laurent Sansonetti <lsansonetti@apple.com>
3
-
4
- Contributors:
5
- Aaron Patterson <aaron.patterson@gmail.com>
6
- Carlos Villela <carlos.villela@gmail.com>
7
- James MacAulay <jmacaulay@gmail.com>
8
- Justin Palmer <encytemedia@gmail.com>
9
- Michael Pruett <michael@68k.org>
10
- Michail Pishchagin <mblsha@gmail.com>
11
- Mike Naberezny <mike@maintainable.com>
12
- Sebastian Delmont <sd@notso.net>
13
- Stefan Saasen <s@juretta.com>
14
- Terry Donoghue <donoghue@apple.com>
15
- Vincent Isambart <vincent.isambart@gmail.com>
16
- Wes Rogers <wesrog@gmail.com>
data/COPYRIGHT DELETED
@@ -1,25 +0,0 @@
1
- Copyright (c) 2006-2007, Apple Inc. All rights reserved.
2
-
3
- Redistribution and use in source and binary forms, with or without
4
- modification, are permitted provided that the following conditions
5
- are met:
6
- 1. Redistributions of source code must retain the above copyright
7
- notice, this list of conditions and the following disclaimer.
8
- 2. Redistributions in binary form must reproduce the above copyright
9
- notice, this list of conditions and the following disclaimer in the
10
- documentation and/or other materials provided with the distribution.
11
- 3. Neither the name of Apple Inc. ("Apple") nor the names of
12
- its contributors may be used to endorse or promote products derived
13
- from this software without specific prior written permission.
14
-
15
- THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND
16
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18
- ARE DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR
19
- ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21
- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22
- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
23
- STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24
- IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25
- POSSIBILITY OF SUCH DAMAGE.
data/README.markdown DELETED
@@ -1,61 +0,0 @@
1
- Introduction
2
- ============
3
-
4
- RubyOSA is a bridge that connects Ruby to the Apple Event Manager
5
- infrastructure.
6
-
7
- It automatically populates the API (classes, methods, constants) according
8
- to the target application's scriptable definition.
9
-
10
- RubyOSA is an alternative to RubyAEOSA, and meant to replace it.
11
-
12
- RubyOSA is licensied under a BSD license, see the COPYRIGHT file for more
13
- information.
14
-
15
- More information on the [project home page](http://rubyosa.rubyforge.org).
16
-
17
- Requirements
18
- ============
19
-
20
- * Mac OS X 10.4.X or greater
21
- * ruby 1.8.X or greater
22
- * libxml-ruby 0.3.8 or greater
23
-
24
- Install
25
- =======
26
- The plain old way:
27
-
28
- $ ruby extconf.rb
29
- $ make
30
- $ sudo make install
31
- $ sudo make install-extras
32
-
33
- `make install` will only install the core of the bridge, while
34
- `make install-extras` will install some additional tools such as the rdoc-osa
35
- utility.
36
-
37
- Otherwise, if you are reading GitHub, use the gem:
38
-
39
- sudo gem install sstephenson-rubyosa
40
-
41
- or
42
-
43
- sudo gem install pbosetti-rubyosa
44
-
45
- Support
46
- =======
47
-
48
- A tutorial is available online at [http://rubyosa.rubyforge.org/tutorial.html](http://rubyosa.rubyforge.org/tutorial.html).
49
-
50
- Sample code is available in the `sample' sub-directory.
51
-
52
- The rdoc-osa tool can be used to generate API reference documentation
53
- for the given application. See its --help flag for more information
54
- about how to use it.
55
-
56
- Feel free to send feedback to rubyosa-discuss@rubyforge.org.
57
-
58
- You can also file bugs, patches and feature requests to [the tracker](http://rubyforge.org/tracker/?group_id=1845.)
59
-
60
- When reporting a bug, please set the AEDebugSends and AEDebugReceives
61
- environment variables to 1 and attach the logs.