propane 2.5.0-java → 2.6.0-java

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9533ddd2e6f1573ce40817c97356676069e9e2a4
4
- data.tar.gz: 7b2b891d044c4f98c85b5b1f286a60d1b77f5281
3
+ metadata.gz: 567aec3d6371ce62d0f6f92dd1f5b892d19d70b5
4
+ data.tar.gz: 03c137c744d27124dbf52a4fca6cbd78b02f1c11
5
5
  SHA512:
6
- metadata.gz: 7e9fec391db8b365247028e0a298329342e39fa716027a031402768cecb33c5e764fcd0fae5d96ed31dafa578bdbfa9d762cf1c6cb8549baeae01a345a7db623
7
- data.tar.gz: 0d251e46ec1a06f2bed2357a2ae178c6af0a67efe0cd5f869aea38287e9bc7232585018dd553a4041b971ee82e3e76b8299598c509a936d726bf04e61fda03d3
6
+ metadata.gz: 1d139c3005b7b43ccb8a9f063a459b9a036c45dcf466eb7827208a6ea9baaf2b22f7490d53499c9f369acddf7ef6b0ecd344bd07606fcdd8de2e1006b1ace02e
7
+ data.tar.gz: 61f7b3f865f49ac239ce886b59f0c336f37ab1b8fa456d238a4fd420088a613dfbc5d39b1226554c2e8a5e67b743c64de4ef9f28cb3799f0b74c882bafc3df98
data/.mvn/extensions.xml CHANGED
@@ -3,6 +3,6 @@
3
3
  <extension>
4
4
  <groupId>io.takari.polyglot</groupId>
5
5
  <artifactId>polyglot-ruby</artifactId>
6
- <version>0.1.19</version>
6
+ <version>0.2.0</version>
7
7
  </extension>
8
8
  </extensions>
data/CHANGELOG.md CHANGED
@@ -1,10 +1,14 @@
1
+ **v2.6.0** Reafactored `LibraryLoader` knows less about `Library` class. The library class _knows_ about paths, and checks that they exist. Features ability to load GLVideo library, that will surely be the future for video (supports gstreamer-1.0 instead of gstreamer-0.1.0 that has already been dropped by some linux distros).
2
+
3
+ **v2.5.5** Intermediate `refactored_library` loader, can be release if required but still not there as regards refactor goals.
4
+
1
5
  **v2.5.0** No need for `$app` we can replace with `Propane.app`
2
6
 
3
- **v2.4.1** Add post_initialize hoop to app.rb.
7
+ **v2.4.1** Add `post_initialize` hook to `app.rb`.
4
8
 
5
9
  **v2.4.0** Extend LibraryProxy to include mouseEvent and keyEvent.
6
10
 
7
- **v2.3.4** Simplify control_panel library (replacing `c.title = 'PaneTitle'` with `c.title('PaneTitle')`) also enable use of `block` with `button's`.
11
+ **v2.3.4** Simplify `control_panel` library (replacing `c.title = 'PaneTitle'` with `c.title('PaneTitle')`) also enable use of `block` with `button's`.
8
12
 
9
13
  **v2.3.3** Update to processing-3.3.4, and upgrade jruby-9.1.12.0 last in 9.1 series?
10
14
 
data/README.md CHANGED
@@ -28,7 +28,7 @@ rake javadoc
28
28
  ## Installation
29
29
  ```bash
30
30
  jgem install propane # from rubygems
31
- jgem install propane-2.5.0-java.gem # for local install
31
+ jgem install propane-2.6.0-java.gem # for local install
32
32
  ```
33
33
 
34
34
  ## Usage
data/lib/propane.rb CHANGED
@@ -1,8 +1,8 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  require 'java'
3
3
  unless defined? PROPANE_ROOT
4
4
  $LOAD_PATH << File.expand_path(File.dirname(__FILE__))
5
- PROPANE_ROOT = File.expand_path(File.dirname(__FILE__) + '/../')
5
+ PROPANE_ROOT = File.absolute_path(File.dirname(__dir__))
6
6
  end
7
7
  Dir["#{PROPANE_ROOT}/lib/*.jar"].each do |jar|
8
8
  require jar
@@ -0,0 +1,12 @@
1
+ require_relative 'sketch_writer'
2
+
3
+ class SketchFactory
4
+ NAMES = %w[One Two Three]
5
+ def initialize(argc)
6
+ NAMES.each do |name|
7
+ SketchWriter.new(File.basename(name, '.rb'), width: 300, height: 300).write
8
+ end
9
+ end
10
+ end
11
+
12
+ SketchFactory.new(File.join(ENV['HOME'], 'test'))
@@ -0,0 +1,69 @@
1
+ require_relative 'native_folder'
2
+ require_relative 'native_loader'
3
+ require 'pathname'
4
+
5
+ # This class knows where to find propane libraries
6
+ class Library
7
+ attr_reader :name, :path, :dir, :ppath
8
+
9
+ def initialize(name)
10
+ @name = name
11
+ @ruby = true
12
+ end
13
+
14
+ def locate
15
+ return if (@path = Pathname.new(
16
+ File.join(Propane::SKETCH_ROOT, 'library', name, "#{name}.rb")
17
+ )).exist?
18
+ return if (@path = Pathname.new(
19
+ File.join(PROPANE_ROOT, 'library', name, "#{name}.rb")
20
+ )).exist?
21
+ locate_java
22
+ end
23
+
24
+ def locate_java
25
+ @dir = Pathname.new(
26
+ File.join(Propane::SKETCH_ROOT, 'library', name)
27
+ )
28
+ locate_installed_java
29
+ end
30
+
31
+ def locate_installed_java
32
+ unless dir.directory?
33
+ @dir = Pathname.new(
34
+ File.join(ENV['HOME'], '.propane', 'libraries', name, 'library')
35
+ )
36
+ end
37
+ @path = dir.join(Pathname.new("#{name}.jar"))
38
+ end
39
+
40
+ def ruby?
41
+ path.extname == '.rb'
42
+ end
43
+
44
+ def exist?
45
+ path.exist?
46
+ end
47
+
48
+ def load_jars
49
+ Dir.glob("#{dir}/*.jar").each do |jar|
50
+ require jar
51
+ end
52
+ return true unless native_binaries?
53
+ add_binaries_to_classpath
54
+ end
55
+
56
+ def native_binaries?
57
+ native_folder = NativeFolder.new
58
+ native = native_folder.name
59
+ @ppath = File.join(dir, native)
60
+ File.directory?(ppath) &&
61
+ !Dir.glob(File.join(ppath, native_folder.extension)).empty?
62
+ end
63
+
64
+ def add_binaries_to_classpath
65
+ native_loader = NativeLoader.new
66
+ native_loader.add_native_path(ppath)
67
+ true
68
+ end
69
+ end
@@ -1,8 +1,13 @@
1
1
  # frozen_string_literal: false
2
+
2
3
  # The processing wrapper module
3
4
  module Propane
5
+ require_relative 'library'
6
+
4
7
  # Encapsulate library loader functionality as a class
5
8
  class LibraryLoader
9
+ attr_reader :library
10
+
6
11
  def initialize
7
12
  @loaded_libraries = Hash.new(false)
8
13
  end
@@ -13,103 +18,36 @@ module Propane
13
18
  end
14
19
 
15
20
  # Load a list of Ruby or Java libraries (in that order)
16
- # Usage: load_libraries :opengl, :boids
21
+ # Usage: load_libraries :video, :video_event
17
22
  #
18
23
  # If a library is put into a 'library' folder next to the sketch it will
19
- # be used instead of the library that ships with Propane.
24
+ # be used instead of an installed propane library.
20
25
  def load_libraries(*args)
21
26
  message = 'no such file to load -- %s'
22
27
  args.each do |lib|
23
- loaded = load_ruby_library(lib) || load_java_library(lib)
24
- fail(LoadError.new, format(message, lib)) unless loaded
28
+ loaded = loader(lib)
29
+ raise(LoadError.new, format(message, lib)) unless loaded
25
30
  end
26
31
  end
27
- alias_method :load_library, :load_libraries
28
-
29
- # For pure ruby libraries.
30
- # The library should have an initialization ruby file
31
- # of the same name as the library folder.
32
- def load_ruby_library(library_name)
33
- library_name = library_name.to_sym
34
- return true if @loaded_libraries.include?(library_name)
35
- path = get_library_paths(library_name, 'rb').first
36
- return false unless path
37
- @loaded_libraries[library_name] = (require path)
38
- end
32
+ alias load_library load_libraries
39
33
 
40
- # HACK: For pure java libraries, such as the ones that are available
41
- # on this page: http://processing.org/reference/libraries/index.html
42
- # that include native code, we mess with the 'Java ClassLoader', so that
43
- # you don't have to futz with your PATH. But it's probably bad juju.
44
- def load_java_library(library_name)
45
- library_name = library_name.to_sym
46
- return true if @loaded_libraries.include?(library_name)
47
- jpath = get_library_directory_path(library_name, 'jar')
48
- jars = get_library_paths(library_name, 'jar')
49
- return false if jars.empty?
50
- jars.each { |jar| require jar }
51
- platform_specific_library_paths = get_platform_specific_library_paths(jpath)
52
- platform_specific_library_paths = platform_specific_library_paths.select do |ppath|
53
- FileTest.directory?(ppath) && !Dir.glob(File.join(ppath, '*.{so,dll,jnilib}')).empty?
54
- end
55
- unless platform_specific_library_paths.empty?
56
- platform_specific_library_paths << java.lang.System.getProperty('java.library.path')
57
- new_library_path = platform_specific_library_paths.join(java.io.File.pathSeparator)
58
- java.lang.System.setProperty('java.library.path', new_library_path)
59
- field = java.lang.Class.for_name('java.lang.ClassLoader').get_declared_field('sys_paths')
60
- if field
61
- field.accessible = true
62
- field.set(java.lang.Class.for_name('java.lang.System').get_class_loader, nil)
63
- end
64
- end
65
- @loaded_libraries[library_name] = true
34
+ def loader(name)
35
+ return true if @loaded_libraries.include?(name)
36
+ fname = name.to_s
37
+ library = Library.new(fname)
38
+ library.locate
39
+ return require_library(library, name) if library.ruby?
40
+ warn("Not found library: #{fname}") unless library.exist?
41
+ load_jars(library, name)
66
42
  end
67
43
 
68
- def platform
69
- match = %w(mac linux windows).find do |os|
70
- java.lang.System.getProperty('os.name').downcase.index(os)
71
- end
72
- return 'other' unless match
73
- return match unless match =~ /mac/
74
- 'macosx'
44
+ def load_jars(lib, name)
45
+ lib.load_jars
46
+ @loaded_libraries[name] = true
75
47
  end
76
48
 
77
- def get_platform_specific_library_paths(basename)
78
- # for MacOSX, but does this even work, or does Mac return '64'?
79
- bits = 'universal'
80
- if java.lang.System.getProperty('sun.arch.data.model') == '32' ||
81
- java.lang.System.getProperty('java.vm.name').index('32')
82
- bits = '32'
83
- elsif java.lang.System.getProperty('sun.arch.data.model') == '64' ||
84
- java.lang.System.getProperty('java.vm.name').index('64')
85
- bits = '64' unless platform =~ /macosx/
86
- end
87
- [platform, platform + bits].map { |p| File.join(basename, p) }
88
- end
89
-
90
- def get_library_paths(library_name, extension = nil)
91
- dir = get_library_directory_path(library_name, extension)
92
- Dir.glob("#{dir}/*.{rb,jar}")
93
- end
94
-
95
- protected
96
-
97
- def get_library_directory_path(library_name, extension = nil)
98
- extensions = extension ? [extension] : %w(jar rb)
99
- extensions.each do |ext|
100
- [
101
- "#{SKETCH_ROOT}/library/#{library_name}",
102
- "#{PROPANE_ROOT}/library/#{library_name}",
103
- "#{PROPANE_ROOT}/library/#{library_name}/library",
104
- "#{PROPANE_ROOT}/library/#{library_name}",
105
- "#{ENV['HOME']}/.propane/libraries/#{library_name}/library"
106
- ].each do |jpath|
107
- if File.exist?(jpath) && !Dir.glob(format('%s/*.%s', jpath, ext)).empty?
108
- return jpath
109
- end
110
- end
111
- end
112
- nil
49
+ def require_library(lib, name)
50
+ @loaded_libraries[name] = require lib.path
113
51
  end
114
52
  end
115
53
  end
@@ -0,0 +1,33 @@
1
+ require 'rbconfig'
2
+
3
+ # Utility to load native binaries on Java CLASSPATH
4
+ class NativeFolder
5
+ attr_reader :os, :bit
6
+
7
+ WIN_FORMAT = 'windows%d'.freeze
8
+ LINUX_FORMAT = 'linux%d'.freeze
9
+ # WIN_PATTERNS = [
10
+ # /bccwin/i,
11
+ # /cygwin/i,
12
+ # /djgpp/i,
13
+ # /ming/i,
14
+ # /mswin/i,
15
+ # /wince/i
16
+ # ].freeze
17
+
18
+ def initialize
19
+ @os = RbConfig::CONFIG['host_os'].downcase
20
+ @bit = java.lang.System.get_property('os.arch') =~ /64/ ? 64 : 32
21
+ end
22
+
23
+ def name
24
+ return 'macosx' if os =~ /darwin/ || os =~ /mac/
25
+ # return format(WIN_FORMAT, bit) if WIN_PATTERNS.include? os
26
+ return format(LINUX_FORMAT, bit) if os =~ /linux/
27
+ end
28
+
29
+ def extension
30
+ return '*.so' if os =~ /linux/
31
+ '*.dylib' # MacOS
32
+ end
33
+ end
@@ -0,0 +1,27 @@
1
+ # This class knows how to dynamically set the 'java' native library path
2
+ # It might not work with java 9?
3
+ class NativeLoader
4
+ attr_reader :separator, :current_path
5
+
6
+ # This module wraps java_import with namespace JC
7
+ module JC
8
+ java_import 'java.lang.Class'
9
+ java_import 'java.lang.System'
10
+ java_import 'java.io.File'
11
+ end
12
+
13
+ def initialize
14
+ @separator = JC::File.pathSeparatorChar
15
+ @current_path = JC::System.getProperty('java.library.path')
16
+ end
17
+
18
+ def add_native_path(pth)
19
+ current_path << separator << pth
20
+ JC::System.setProperty('java.library.path', current_path)
21
+ field = JC::Class.for_name('java.lang.ClassLoader')
22
+ .get_declared_field('sys_paths')
23
+ return unless field
24
+ field.accessible = true # some jruby magic
25
+ field.set(JC::Class.for_name('java.lang.System').get_class_loader, nil)
26
+ end
27
+ end
@@ -40,7 +40,7 @@ module Propane
40
40
  end
41
41
 
42
42
  options[:install] = false
43
- message = '<Samples><Video><Sound> Install samples or library'
43
+ message = '<Samples><GLVideo><Video><Sound> Install samples or library'
44
44
  opts.on('-i', '--install', message) do
45
45
  options[:install] = true
46
46
  end
@@ -50,11 +50,6 @@ module Propane
50
50
  options[:create] = true
51
51
  end
52
52
 
53
- options[:example] = false
54
- opts.on('-e', '--example', 'Create new sketch outline') do
55
- options[:example] = true
56
- end
57
-
58
53
  # This displays the help screen, all programs are
59
54
  # assumed to have this option.
60
55
  opts.on('-h', '--help', 'Display this screen') do
@@ -68,11 +63,6 @@ module Propane
68
63
 
69
64
  def create
70
65
  require_relative 'creators/sketch_writer'
71
- SketchFactory.new(argc).write
72
- end
73
-
74
- def examples
75
- require_relative 'creators/sketch_factory'
76
66
  SketchWriter.new(File.basename(filename, '.rb'), argc).write
77
67
  end
78
68
 
@@ -83,7 +73,7 @@ module Propane
83
73
 
84
74
  def install(library)
85
75
  choice = library.downcase
86
- valid = Regexp.union('samples', 'sound', 'video')
76
+ valid = Regexp.union('samples', 'sound', 'video', 'glvideo')
87
77
  return warn format('No installer for %s', choice) unless valid =~ choice
88
78
  system "cd #{PROPANE_ROOT}/vendors && rake download_and_copy_#{choice}"
89
79
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Propane
3
- VERSION = '2.5.0'.freeze
3
+ VERSION = '2.6.0'.freeze
4
4
  end
data/pom.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'fileutils'
2
2
  project 'rp5extras', 'https://github.com/monkstone/propane' do
3
3
  model_version '4.0.0'
4
- id 'propane:propane', '2.5.0'
4
+ id 'propane:propane', '2.6.0'
5
5
  packaging 'jar'
6
6
  description 'rp5extras for propane'
7
7
  organization 'ruby-processing', 'https://ruby-processing.github.io'
data/pom.xml CHANGED
@@ -11,7 +11,7 @@ DO NOT MODIFIY - GENERATED CODE
11
11
  <modelVersion>4.0.0</modelVersion>
12
12
  <groupId>propane</groupId>
13
13
  <artifactId>propane</artifactId>
14
- <version>2.5.0</version>
14
+ <version>2.6.0</version>
15
15
  <name>rp5extras</name>
16
16
  <description>rp5extras for propane</description>
17
17
  <url>https://github.com/monkstone/propane</url>
data/vendors/Rakefile CHANGED
@@ -7,9 +7,10 @@ WARNING = <<-EOS
7
7
  EOS
8
8
  SOUND = 'sound.zip'.freeze
9
9
  SOUND_VERSION = 'v1.3.2' # version 1.3.2
10
+ GLVIDEO = 'processing-glvideo.zip'
10
11
  VIDEO = 'video-2.zip'
11
12
  VIDEO_VERSION = '2' # version 1.0.1
12
- EXAMPLES = '1.5'.freeze
13
+ EXAMPLES = '1.6'.freeze
13
14
  HOME_DIR = ENV['HOME']
14
15
  MAC_OR_LINUX = /linux|mac|darwin/ =~ RbConfig::CONFIG['host_os']
15
16
 
@@ -37,6 +38,9 @@ task download_and_copy_sound: [:download_sound, :copy_sound]
37
38
  desc 'download and copy video library to ~/.propane'
38
39
  task download_and_copy_video: [:download_video, :copy_video]
39
40
 
41
+ desc 'download and copy glvideo library to ~/.propane'
42
+ task download_and_copy_glvideo: [:download_glvideo, :copy_glvideo]
43
+
40
44
 
41
45
  desc 'download sound library'
42
46
  task :download_sound do
@@ -49,6 +53,17 @@ task :download_sound do
49
53
  end
50
54
  end
51
55
 
56
+ desc 'download glvideo library'
57
+ task :download_glvideo do
58
+ wget_base = 'wget https://github.com/gohai/processing-glvideo'
59
+ wget_string = [wget_base, 'releases/download/latest', GLVIDEO].join('/')
60
+ begin
61
+ sh wget_string
62
+ rescue
63
+ warn(WARNING)
64
+ end
65
+ end
66
+
52
67
  desc 'download video library'
53
68
  task :download_video do
54
69
  wget_base = 'wget https://github.com/processing/processing-video'
@@ -87,3 +102,11 @@ task :copy_video => VIDEO do
87
102
  sh "cp -r video #{HOME_DIR}/.propane/libraries/video"
88
103
  sh 'rm -r video'
89
104
  end
105
+
106
+ desc 'copy glvideo library'
107
+ task :copy_glvideo => GLVIDEO do
108
+ sh "unzip #{GLVIDEO}"
109
+ sh "rm -r #{HOME_DIR}/.propane/libraries/glvideo" if File.exist? "#{HOME_DIR}/.propane/libraries/glvideo"
110
+ sh "cp -r glvideo #{HOME_DIR}/.propane/libraries/glvideo"
111
+ sh 'rm -r glvideo'
112
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: propane
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.0
4
+ version: 2.6.0
5
5
  platform: java
6
6
  authors:
7
7
  - monkstone
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-15 00:00:00.000000000 Z
11
+ date: 2017-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -91,10 +91,14 @@ files:
91
91
  - lib/propane.rb
92
92
  - lib/propane/app.rb
93
93
  - lib/propane/creators/sketch_class.rb
94
+ - lib/propane/creators/sketch_factory.rb
94
95
  - lib/propane/creators/sketch_writer.rb
95
96
  - lib/propane/helper_methods.rb
96
97
  - lib/propane/helpers/numeric.rb
98
+ - lib/propane/library.rb
97
99
  - lib/propane/library_loader.rb
100
+ - lib/propane/native_folder.rb
101
+ - lib/propane/native_loader.rb
98
102
  - lib/propane/runner.rb
99
103
  - lib/propane/version.rb
100
104
  - library/boids/boids.rb