movewin 1.5 → 1.6

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.
Files changed (4) hide show
  1. checksums.yaml +15 -0
  2. data/ext/movewin/extconf.rb +83 -8
  3. data/lib/movewin.rb +1 -1
  4. metadata +24 -43
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YmU4MmIyMzIxZGZiYjY4ODQ2NTQ4NDIxYWQ4ZjJlNTIwMjJhNmQyZA==
5
+ data.tar.gz: !binary |-
6
+ NWIxMjcyMDY0MzMxMzkzOTg0ZTI0MzI4ZmMxYmI5NjA0YTg0Mzk1Yg==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ NmNkNmNhMWRiYmM2YTBhYTNhZTYwMGE2ZTZlYWU1YTJkMmRhNjY1MTljMDhh
10
+ MjUxODk1ODhkZTljODNhOGUyNzZmNzIxNDJiZmE4ZDI5ODRmYmQ0MDQ3ZDdl
11
+ YTI5MjE5ZDNmZDM0M2Y3ZTE3YmRiOGQzYWQwMTEyZDQ0NDZkNmY=
12
+ data.tar.gz: !binary |-
13
+ YWJmNjUyNWM0ODc0MTMwMGRlNWYzNzY4NGNkMmNlNjI1ZDQ0MzY0YmQ1YTMy
14
+ ZDBjZWE4MWNkNWM1MWIwOWU2ZjAzYjhkNjZmYjg4ODg3NDMwN2FkMjc3OWE1
15
+ ZWExN2JlNmY5MzhiZDYwZGMwNGYzODVlZjYwMWUxMTc1MGQzNDI=
@@ -1,13 +1,88 @@
1
+ #!/usr/bin/env ruby
2
+
1
3
  require 'mkmf'
4
+ require 'rubygems'
5
+
6
+ def main(argv = [])
7
+ $CFLAGS = '-Wall'
8
+ $LDFLAGS = '-Wall -framework Carbon'
9
+
10
+ # No have_framework() in mkmf that ships with Ruby versions earlier than 1.9
11
+ if ruby_older_than?('1.9')
12
+ have_header('Carbon/Carbon.h')
13
+ else
14
+ have_framework('Carbon')
15
+ end
16
+
17
+ # On Yosemite or newer, fix bug in Carbon header that breaks under gcc
18
+ if yosemite_or_newer? && using_gcc?
19
+ fix_dispatch_object_header!
20
+ end
21
+
22
+ create_makefile('movewin/movewin_ext')
23
+ end
24
+
25
+ # Return true if current Ruby version is older than given version
26
+ def ruby_older_than?(version)
27
+ Gem::Version.new(RUBY_VERSION) < Gem::Version.new(version)
28
+ end
2
29
 
3
- # No have_framework() in mkmf that ships with Ruby versions earlier than 1.9
4
- RUBY_VERSIONS = RUBY_VERSION.split('.').collect { |s| s.to_i }
5
- unless RUBY_VERSIONS[0] < 1 || (RUBY_VERSIONS[0] == 1 && RUBY_VERSIONS[1] < 9)
6
- have_framework('Carbon')
30
+ # Return true if this is OS X 10.10 (Yosemite) or newer
31
+ def yosemite_or_newer?
32
+ Gem::Version.new(`sw_vers -productVersion`) >= Gem::Version.new('10.10')
7
33
  end
8
- have_header('Carbon/Carbon.h')
9
34
 
10
- $CFLAGS = '-Wall'
11
- $LDFLAGS = '-Wall -framework Carbon'
35
+ # Return true if our compiler is GCC (not clang), as for RVM installed Ruby
36
+ def using_gcc?
37
+ true # TODO: make this really work
38
+ end
39
+
40
+ # Building with GCC on Yosemite (OS X 10.10) results in an error
41
+ # (https://github.com/andrewgho/movewin-ruby/issues/1).
42
+ # Patch header file to work around this issue.
43
+ def fix_dispatch_object_header!
44
+ srcfile = find_header_file('dispatch/object.h')
45
+ tmpfile = "#{File.dirname(__FILE__)}/dispatch/object.h.tmp.#{$$}"
46
+ begin
47
+ patched = false
48
+ File.open(tmpfile, 'w') do |tmpfh|
49
+ File.open(srcfile, 'r').each do |srcline|
50
+ patched ||= srcline.sub!(
51
+ /\Atypedef void \(\^dispatch_block_t\)\(void\);/,
52
+ 'typedef void* dispatch_block_t;'
53
+ )
54
+ tmpfh.print(srcline)
55
+ end
56
+ end
57
+ if patched
58
+ destfile = "#{File.dirname(__FILE__)}/dispatch/object.h"
59
+ File.rename(tmpfile, destfile)
60
+ if $CFLAGS.nil? || $CFLAGS.empty?
61
+ $CFLAGS = "-I#{File.dirname(__FILE__)}"
62
+ else
63
+ $CFLAGS += " -I#{File.dirname(__FILE__)}"
64
+ end
65
+ set_constant!(:CLEANINGS, "CLEANFILES += dispatch/object.h\n" + CLEANINGS)
66
+ end
67
+ ensure
68
+ File.unlink(tmpfile) if File.exists?(tmpfile)
69
+ end
70
+ end
71
+
72
+ # Given an #include <foo/bar.h>, return actual filename /path/to/foo/bar.h
73
+ def find_header_file(header)
74
+ # TODO: really crawl through cpp include path to find this
75
+ "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/#{header}"
76
+ end
77
+
78
+ # Redefine constant without warning (http://stackoverflow.com/q/3375360)
79
+ class Object
80
+ def set_constant!(const, value)
81
+ mod = self.is_a?(Module) ? self : self.class
82
+ mod.send(:remove_const, const) if mod.const_defined?(const)
83
+ mod.const_set(const, value)
84
+ end
85
+ end
12
86
 
13
- create_makefile('movewin/movewin_ext')
87
+ # Run main loop and exit
88
+ exit(main(ARGV))
data/lib/movewin.rb CHANGED
@@ -36,7 +36,7 @@
36
36
  require 'movewin/movewin_ext'
37
37
 
38
38
  module MoveWin
39
- VERSION = '1.5'
39
+ VERSION = '1.6'
40
40
 
41
41
  # Individual accessors for display size components
42
42
  def self.display_width; MoveWin.display_size[0]; end
metadata CHANGED
@@ -1,68 +1,49 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: movewin
3
- version: !ruby/object:Gem::Version
4
- hash: 5
5
- prerelease:
6
- segments:
7
- - 1
8
- - 5
9
- version: "1.5"
3
+ version: !ruby/object:Gem::Version
4
+ version: '1.6'
10
5
  platform: ruby
11
- authors:
6
+ authors:
12
7
  - Andrew Ho
13
8
  autorequire:
14
9
  bindir: bin
15
10
  cert_chain: []
16
-
17
- date: 2014-10-31 00:00:00 Z
11
+ date: 2014-11-01 00:00:00.000000000 Z
18
12
  dependencies: []
19
-
20
13
  description: List and move OS X windows from Ruby via the OS X accessibility APIs.
21
14
  email: andrew@zeuscat.com
22
15
  executables: []
23
-
24
- extensions:
16
+ extensions:
25
17
  - ext/movewin/extconf.rb
26
18
  extra_rdoc_files: []
27
-
28
- files:
29
- - lib/movewin.rb
19
+ files:
20
+ - ext/movewin/extconf.rb
30
21
  - ext/movewin/movewin_ext.c
31
22
  - ext/movewin/winutils.c
32
23
  - ext/movewin/winutils.h
33
- - ext/movewin/extconf.rb
24
+ - lib/movewin.rb
34
25
  homepage: https://github.com/andrewgho/movewin-ruby
35
- licenses:
26
+ licenses:
36
27
  - BSD-3-Clause
28
+ metadata: {}
37
29
  post_install_message:
38
30
  rdoc_options: []
39
-
40
- require_paths:
31
+ require_paths:
41
32
  - lib
42
- required_ruby_version: !ruby/object:Gem::Requirement
43
- none: false
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- hash: 3
48
- segments:
49
- - 0
50
- version: "0"
51
- required_rubygems_version: !ruby/object:Gem::Requirement
52
- none: false
53
- requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- hash: 3
57
- segments:
58
- - 0
59
- version: "0"
33
+ required_ruby_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ required_rubygems_version: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ! '>='
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
60
43
  requirements: []
61
-
62
44
  rubyforge_project:
63
- rubygems_version: 1.8.10
45
+ rubygems_version: 2.4.2
64
46
  signing_key:
65
- specification_version: 3
47
+ specification_version: 4
66
48
  summary: List and move OS X windows from Ruby
67
49
  test_files: []
68
-