ruby-processing 2.6.7 → 2.6.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 66a5c0578c17ec6e9ace637abb2626d7c4907549
4
- data.tar.gz: 711c1d6afedd64b8ca08956f7fd86a76db6841ea
3
+ metadata.gz: f86e1e9a4937a12e054537a3a11d87bd4d80ca8d
4
+ data.tar.gz: d9504d46543bf9467603fd6f0b3b8b25ddcfc366
5
5
  SHA512:
6
- metadata.gz: 3d8d40e8e3a1b996de6071faf63b0b8f9b2ac912a7d8564c93bb94c18ccea8641f67e019cc7090fd879539de2649554070318d7a090620bda3c59b59ef81f1e8
7
- data.tar.gz: a193bb65ae7813300bc723a478d543e457a9b4fedd6c97e1e5d506c78ee43eebfbc543962ccdc6ea3504090ad1c5b170bda7c07e654d7a568b17165fb23e0904
6
+ metadata.gz: 7618164b1440aa65fb4d8361392fcfde54588741e1f48fcd983c079bfcd936c6a8d1dd32f3a38e56cf63428022df0733641b4ccf0ce462d6377360d7ccbaf734
7
+ data.tar.gz: a00bd119873be49f403a5b606e82f98a84a7e10c52a4ab2a5fd741fbbce4d324616e8d3658a2d71743e09b065c245421f3b45779ee915ccb041d0ef18d72503a
Binary file
@@ -8,9 +8,10 @@ require_relative '../ruby-processing/helpers/string_extra'
8
8
  require_relative '../ruby-processing/library_loader'
9
9
  require_relative '../ruby-processing/config'
10
10
 
11
- Dir["#{Processing::RP_CONFIG['PROCESSING_ROOT']}/core/library/\*.jar"].each do
12
- |jar|
13
- require jar
11
+ jars = Dir["#{Processing::RP_CONFIG['PROCESSING_ROOT']}/core/library/\*.jar"]
12
+ # We don't seem need to load the native jars so perhaps we shouldn't
13
+ jars.reject { |jar| jar =~ /native/ }.each do |jar|
14
+ require jar
14
15
  end
15
16
 
16
17
  module Processing
@@ -48,19 +49,6 @@ module Processing
48
49
  alias_method :rgb, :color
49
50
  alias_method :gray, :color
50
51
 
51
- # When certain special methods get added to the sketch, we need to let
52
- # Processing call them by their expected Java names.
53
- def self.method_added(method_name) #:nodoc:
54
- if METHODS_TO_ALIAS.key?(method_name)
55
- alias_method METHODS_TO_ALIAS[method_name], method_name
56
- end
57
- end
58
-
59
- # Handy getters and setters on the class go here:
60
- class << self
61
- attr_accessor :sketch_class
62
- end
63
-
64
52
  def sketch_class
65
53
  self.class.sketch_class
66
54
  end
@@ -72,23 +60,33 @@ module Processing
72
60
  @sketch_class = subclass
73
61
  end
74
62
 
75
- @@library_loader = LibraryLoader.new
76
63
  class << self
64
+ # Handy getters and setters on the class go here:
65
+ attr_accessor :sketch_class, :library_loader
66
+
77
67
  def load_libraries(*args)
78
- @@library_loader.load_library(*args)
68
+ library_loader ||= LibraryLoader.new
69
+ library_loader.load_library(*args)
79
70
  end
80
71
  alias_method :load_library, :load_libraries
81
72
 
82
73
  def library_loaded?(library_name)
83
- @@library_loader.library_loaded?(library_name)
74
+ library_loader.library_loaded?(library_name)
84
75
  end
85
76
 
86
77
  def load_ruby_library(*args)
87
- @@library_loader.load_ruby_library(*args)
78
+ library_loader.load_ruby_library(*args)
88
79
  end
89
80
 
90
81
  def load_java_library(*args)
91
- @@library_loader.load_java_library(*args)
82
+ library_loader.load_java_library(*args)
83
+ end
84
+
85
+ # When certain special methods get added to the sketch, we need to let
86
+ # Processing call them by their expected Java names.
87
+ def method_added(method_name) #:nodoc:
88
+ return unless METHODS_TO_ALIAS.key?(method_name)
89
+ alias_method METHODS_TO_ALIAS[method_name], method_name
92
90
  end
93
91
  end
94
92
 
@@ -172,7 +170,7 @@ module Processing
172
170
  java_import "processing.opengl.#{klass}"
173
171
  end
174
172
  end
175
-
173
+
176
174
  def run_sketch(options = {})
177
175
  args = []
178
176
  @width, @height = options[:width], options[:height]
@@ -206,9 +204,7 @@ module Processing
206
204
  unwanted -= %w(width height cursor create_image background size resize)
207
205
  methods = Processing::App.public_instance_methods
208
206
  methods.reject do |m|
209
- unwanted.include?(m) ||
210
- bad_method.match(m) ||
211
- inner_class.method_defined?(m)
207
+ unwanted.include?(m) || bad_method.match(m) || inner_class.method_defined?(m)
212
208
  end
213
209
  end
214
210
 
@@ -19,7 +19,7 @@ module Processing
19
19
  def export!(sketch)
20
20
  # Check to make sure that the main file exists
21
21
  @main_file_path, @main_file, @main_folder = *get_main_file(sketch)
22
- usage(@main_file_path && File.exist?(@main_file_path))
22
+ usage(@main_file_path && FileTest.exist?(@main_file_path))
23
23
 
24
24
  extract_information
25
25
 
@@ -49,7 +49,7 @@ module Processing
49
49
  @necessary_files += @real_requires
50
50
  NECESSARY_FOLDERS.each do |folder|
51
51
  resource_path = File.join(@main_folder, folder)
52
- @necessary_files << resource_path if File.exist?(resource_path)
52
+ @necessary_files << resource_path if FileTest.exist?(resource_path)
53
53
  end
54
54
  @necessary_files.uniq!
55
55
  cp_r(@necessary_files, File.join(@dest, @prefix))
@@ -119,7 +119,7 @@ module Processing
119
119
  end
120
120
 
121
121
  def wipe_and_recreate_destination
122
- remove_entry_secure @dest if File.exist?(@dest)
122
+ remove_entry_secure @dest if FileTest.exist?(@dest)
123
123
  mkdir_p @dest
124
124
  end
125
125
 
@@ -74,7 +74,7 @@ module Processing
74
74
  def already_exist(path)
75
75
  underscore = StringExtra.new(path).underscore
76
76
  new_file = "#{File.dirname(path)}/#{underscore}.rb"
77
- return if !File.exist?(path) && !File.exist?(new_file)
77
+ return if !FileTest.exist?(path) && !FileTest.exist?(new_file)
78
78
  puts 'That file already exists!'
79
79
  exit
80
80
  end
@@ -1,9 +1,10 @@
1
1
  module Processing
2
+ # Encapsulate library loader functionality as a class
2
3
  class LibraryLoader
3
4
  attr_reader :sketchbook_library_path
4
5
 
5
6
  def initialize
6
- @sketchbook_library_path = File.join(find_sketchbook_path || '', 'libraries')
7
+ @sketchbook_library_path = File.join(find_sketchbook_path, 'libraries')
7
8
  @loaded_libraries = Hash.new(false)
8
9
  end
9
10
 
@@ -18,9 +19,10 @@ module Processing
18
19
  # If a library is put into a 'library' folder next to the sketch it will
19
20
  # be used instead of the library that ships with Ruby-Processing.
20
21
  def load_libraries(*args)
22
+ message = 'no such file to load -- %s'
21
23
  args.each do |lib|
22
24
  loaded = load_ruby_library(lib) || load_java_library(lib)
23
- fail(LoadError.new, "no such file to load -- #{lib}") unless loaded
25
+ fail(LoadError.new, format(message, lib)) unless loaded
24
26
  end
25
27
  end
26
28
  alias_method :load_library, :load_libraries
@@ -30,7 +32,7 @@ module Processing
30
32
  # of the same name as the library folder.
31
33
  def load_ruby_library(library_name)
32
34
  library_name = library_name.to_sym
33
- return true if @loaded_libraries[library_name]
35
+ return true if @loaded_libraries.include?(library_name)
34
36
  if Processing.exported?
35
37
  begin
36
38
  return @loaded_libraries[library_name] = (require_relative "../library/#{library_name}")
@@ -43,15 +45,13 @@ module Processing
43
45
  @loaded_libraries[library_name] = (require path)
44
46
  end
45
47
 
46
- # For pure java libraries, such as the ones that are available
48
+ # HACK: For pure java libraries, such as the ones that are available
47
49
  # on this page: http://processing.org/reference/libraries/index.html
48
- #
49
- # P.S. -- Loading libraries which include native code needs to
50
- # hack the 'Java ClassLoader', so that you don't have to
51
- # futz with your PATH. But it's probably bad juju.
50
+ # that include native code, we mess with the 'Java ClassLoader', so that
51
+ # you don't have to futz with your PATH. But it's probably bad juju.
52
52
  def load_java_library(library_name)
53
53
  library_name = library_name.to_sym
54
- return true if @loaded_libraries[library_name]
54
+ return true if @loaded_libraries.include?(library_name)
55
55
  jpath = get_library_directory_path(library_name, 'jar')
56
56
  jars = get_library_paths(library_name, 'jar')
57
57
  return false if jars.empty?
@@ -60,7 +60,6 @@ module Processing
60
60
  platform_specific_library_paths = platform_specific_library_paths.select do |ppath|
61
61
  test(?d, ppath) && !Dir.glob(File.join(ppath, '*.{so,dll,jnilib}')).empty?
62
62
  end
63
-
64
63
  unless platform_specific_library_paths.empty?
65
64
  platform_specific_library_paths << java.lang.System.getProperty('java.library.path')
66
65
  new_library_path = platform_specific_library_paths.join(java.io.File.pathSeparator)
@@ -73,23 +72,23 @@ module Processing
73
72
  end
74
73
  @loaded_libraries[library_name] = true
75
74
  end
76
-
75
+
77
76
  def platform
78
- match = %w(Mac Linux Windows).find do |os|
79
- java.lang.System.getProperty('os.name').index(os)
77
+ match = %w(mac linux windows).find do |os|
78
+ java.lang.System.getProperty('os.name').downcase.index(os)
80
79
  end
81
80
  return 'other' unless match
82
- return match.downcase unless match =~ /Mac/
83
- return 'macosx'
81
+ return match unless match =~ /mac/
82
+ 'macosx'
84
83
  end
85
84
 
86
85
  def get_platform_specific_library_paths(basename)
87
86
  bits = 'universal' # for MacOSX, but does this even work, or does Mac return '64'?
88
87
  if java.lang.System.getProperty('sun.arch.data.model') == '32' ||
89
- java.lang.System.getProperty('java.vm.name').index('32')
88
+ java.lang.System.getProperty('java.vm.name').index('32')
90
89
  bits = '32'
91
90
  elsif java.lang.System.getProperty('sun.arch.data.model') == '64' ||
92
- java.lang.System.getProperty('java.vm.name').index('64')
91
+ java.lang.System.getProperty('java.vm.name').index('64')
93
92
  bits = '64' unless platform =~ /macosx/
94
93
  end
95
94
  [platform, platform + bits].map { |p| File.join(basename, p) }
@@ -105,14 +104,13 @@ module Processing
105
104
  def get_library_directory_path(library_name, extension = nil)
106
105
  extensions = extension ? [extension] : %w(jar rb)
107
106
  extensions.each do |ext|
108
- [ "#{SKETCH_ROOT}/library/#{library_name}",
109
- "#{Processing::RP_CONFIG['PROCESSING_ROOT']}/modes/java/libraries/#{library_name}/library",
110
- "#{RP5_ROOT}/library/#{library_name}/library",
111
- "#{RP5_ROOT}/library/#{library_name}",
112
- "#{@sketchbook_library_path}/#{library_name}/library",
113
- "#{@sketchbook_library_path}/#{library_name}"
107
+ ["#{SKETCH_ROOT}/library/#{library_name}",
108
+ "#{Processing::RP_CONFIG['PROCESSING_ROOT']}/modes/java/libraries/#{library_name}/library",
109
+ "#{RP5_ROOT}/library/#{library_name}/library",
110
+ "#{RP5_ROOT}/library/#{library_name}",
111
+ "#{@sketchbook_library_path}/#{library_name}/library"
114
112
  ].each do |jpath|
115
- if File.exist?(jpath) && !Dir.glob(jpath + "/*.#{ext}").empty?
113
+ if File.exist?(jpath) && !Dir.glob(format('%s/*.%s', jpath, ext)).empty?
116
114
  return jpath
117
115
  end
118
116
  end
@@ -123,32 +121,21 @@ module Processing
123
121
  def find_sketchbook_path
124
122
  preferences_paths = []
125
123
  sketchbook_paths = []
126
- if sketchbook_path = Processing::RP_CONFIG['sketchbook_path']
127
- return File.expand_path(sketchbook_path)
124
+ if sketchbook_path = Processing::RP_CONFIG.fetch('sketchbook_path', false)
125
+ return sketchbook_path
128
126
  else
129
127
  ["'Application Data/Processing'", 'AppData/Roaming/Processing',
130
- 'Library/Processing', 'Documents/Processing',
131
- '.processing', 'sketchbook'].each do |prefix|
132
- spath = "#{ENV['HOME']}/#{prefix}"
133
- pref_path = spath + '/preferences.txt'
134
- if test(?f, pref_path)
135
- preferences_paths << pref_path
136
- end
137
- if test(?d, spath)
138
- sketchbook_paths << spath
139
- end
128
+ 'Library/Processing', 'Documents/Processing',
129
+ '.processing', 'sketchbook'].each do |prefix|
130
+ spath = format('%s/%s', ENV['HOME'], prefix)
131
+ pref_path = format('%s/preferences.txt', spath)
132
+ preferences_paths << pref_path if test(?f, pref_path)
133
+ sketchbook_paths << spath if test(?d, spath)
140
134
  end
141
- if preferences_paths.empty?
142
- sketchbook_path = sketchbook_paths.first
143
- else
144
- lines = File.readlines(preferences_paths.first)
145
- regex1 = /^sketchbook\.path=(.+)/ # processing-2.0
146
- regex2 = /^sketchbook\.path\.three=(.+)/ # processing-3.0
147
- matched_lines = lines.grep(regex1) { $1 } unless $1 == ''
148
- matched_lines = lines.grep(regex2) { $1 } unless $1 == ''
149
- sketchbook_path = matched_lines.first
150
- end
151
- return sketchbook_path
135
+ return sketchbook_paths.first if preferences_paths.empty?
136
+ lines = IO.readlines(preferences_paths.first)
137
+ matchedline = lines.grep(/^sketchbook/).first
138
+ matchedline[/=(.+)/].gsub('=', '')
152
139
  end
153
140
  end
154
141
  end
@@ -47,7 +47,7 @@ module Processing
47
47
  /bccwin/i,
48
48
  /cygwin/i,
49
49
  /djgpp/i,
50
- /mingw/i,
50
+ /ming/i,
51
51
  /mswin/i,
52
52
  /wince/i
53
53
  ]
@@ -124,10 +124,10 @@ module Processing
124
124
  end
125
125
 
126
126
  def setup(choice)
127
- proc_root = File.exist?("#{ENV['HOME']}/.rp5rc")
127
+ proc_root = FileTest.exist?("#{ENV['HOME']}/.rp5rc")
128
128
  case choice
129
129
  when /check/
130
- check(proc_root, File.exist?("#{RP5_ROOT}/lib/ruby/jruby-complete.jar"))
130
+ check(proc_root, FileTest.exist?("#{RP5_ROOT}/lib/ruby/jruby-complete.jar"))
131
131
  when /install/
132
132
  install(proc_root)
133
133
  when /unpack_samples/
@@ -206,7 +206,7 @@ module Processing
206
206
  arg_file = "#{File.dirname(sketch)}/data/java_args.txt"
207
207
  args = []
208
208
  args += dock_icon
209
- if File.exist?(arg_file)
209
+ if FileTest.exist?(arg_file)
210
210
  args += File.read(arg_file).split(/\s+/)
211
211
  elsif Processing::RP_CONFIG['java_args']
212
212
  args += Processing::RP_CONFIG['java_args'].split(/\s+/)
@@ -218,12 +218,12 @@ module Processing
218
218
  # NB: we really do require 'and' not '&&' to get message returned
219
219
 
220
220
  def ensure_exists(sketch)
221
- puts "Couldn't find: #{sketch}" and exit unless File.exist?(sketch)
221
+ puts "Couldn't find: #{sketch}" and exit unless FileTest.exist?(sketch)
222
222
  end
223
223
 
224
224
  def jruby_complete
225
225
  rcomplete = File.join(RP5_ROOT, 'lib/ruby/jruby-complete.jar')
226
- return rcomplete if File.exist?(rcomplete)
226
+ return rcomplete if FileTest.exist?(rcomplete)
227
227
  warn "#{rcomplete} does not exist\nTry running `rp5 setup install`"
228
228
  exit
229
229
  end
@@ -5,6 +5,7 @@ module Processing
5
5
  # the feedback between code and effect.
6
6
  class Watcher
7
7
  # Sic a new Processing::Watcher on the sketch
8
+ SLEEP_TIME = 0.2
8
9
  def initialize
9
10
  reload_files_to_watch
10
11
  @time = Time.now
@@ -16,7 +17,7 @@ module Processing
16
17
  def start_watching
17
18
  start_runner
18
19
  Kernel.loop do
19
- if @files.find { |file| File.exist?(file) && File.stat(file).mtime > @time }
20
+ if @files.find { |file| FileTest.exist?(file) && File.stat(file).mtime > @time }
20
21
  puts 'reloading sketch...'
21
22
  $app && $app.close
22
23
  @time = Time.now
@@ -24,7 +25,7 @@ module Processing
24
25
  start_runner
25
26
  reload_files_to_watch
26
27
  end
27
- sleep 0.33
28
+ sleep SLEEP_TIME
28
29
  end
29
30
  end
30
31
 
@@ -1,3 +1,3 @@
1
1
  module RubyProcessing
2
- VERSION = '2.6.7'
2
+ VERSION = '2.6.8'
3
3
  end
@@ -1,5 +1,9 @@
1
1
  require 'rpextras'
2
2
 
3
+ # HACK: required for exported applications, comment out or replace first line
4
+ # with next line (create a lib folder here and move rpextras.jar there.
5
+ # require_relative 'lib/rpextras'
6
+
3
7
  Java::ProcessingVecmathArcball::ArcballLibrary.new.load(JRuby.runtime, false)
4
8
  Java::ProcessingVecmathVec2::Vec2Library.new.load(JRuby.runtime, false)
5
9
  Java::ProcessingVecmathVec3::Vec3Library.new.load(JRuby.runtime, false)
@@ -75,6 +75,7 @@ task :copy_examples => file_name do
75
75
  else
76
76
  sh "tar xzvf #{EXAMPLES}.tar.gz"
77
77
  end
78
+ sh "rm -r #{HOME_DIR}/rp_samples" if File.exist? "#{HOME_DIR}/rp_samples"
78
79
  sh "cp -r Example-Sketches-#{EXAMPLES} #{HOME_DIR}/rp_samples"
79
80
  sh "rm -r Example-Sketches-#{EXAMPLES}"
80
81
  end
metadata CHANGED
@@ -1,24 +1,22 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-processing
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.7
4
+ version: 2.6.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Ashkenas
8
- - Peter Gassner
9
- - Martin Stannard
10
- - Andrew Nanton
8
+ - Peter Gassner Martin Stannard Andrew Nanton
11
9
  - Marc Chung
12
10
  - Peter Krenn
13
11
  - Florian Jenett
14
12
  - Andreas Haller
15
- - Juris Galang
16
- - Guillaume Pierronnet
13
+ - Juris
14
+ - Galang Guillaume Pierronne
17
15
  - Martin Prout
18
16
  autorequire:
19
17
  bindir: bin
20
18
  cert_chain: []
21
- date: 2015-01-30 00:00:00.000000000 Z
19
+ date: 2015-04-03 00:00:00.000000000 Z
22
20
  dependencies:
23
21
  - !ruby/object:Gem::Dependency
24
22
  requirement: !ruby/object:Gem::Requirement
@@ -152,7 +150,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
152
150
  requirements:
153
151
  - - '>='
154
152
  - !ruby/object:Gem::Version
155
- version: '0'
153
+ version: 1.9.3
156
154
  required_rubygems_version: !ruby/object:Gem::Requirement
157
155
  requirements:
158
156
  - - '>='