propane 0.4.0.pre-java → 0.5.0-java

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: 8be45e7e7dceb0061a4af4af3044de8e277d0ace
4
- data.tar.gz: d9477ff46ea8cac2ed39cf486d7a9556a9312aae
3
+ metadata.gz: 1ce0539eb503a2238662e89c13413096a9432e0d
4
+ data.tar.gz: 72c8c27180b18e1160a5e4d1bb67f2230be092cd
5
5
  SHA512:
6
- metadata.gz: b5e216855d9d126045ae5d2ec0eb0962bd83861c58d1c1cbe740f56bcf43a192bdb6464bfcbfc811e340a7dcb47c304cf69db5e21fded92c094d5f06f0a789a0
7
- data.tar.gz: 4e514eb57e7fbf78bb861d4e156063fe2a85f39ab21f4a348b02da0e6e56edbe225c61792179de7c05b0c56d608b6bb702ef6947714d6a0225be89d4dab48263
6
+ metadata.gz: d6ab0d0df27aa665df986025dc02f056a9a512c70fb31dc719a15b37715d5765f531d12487d9b631980bf4ea68715bd6d0c9d654fb4605b8136f2fa47b2fdf9b
7
+ data.tar.gz: af7361a4fbd3427fed659086521529451117b20eaf83dafb209bb013459b2717c1a0822f30c19f96609e0489da9f8ca950424e4e1f34b644670e64a9653b4ea0
data/CHANGELOG.md CHANGED
@@ -1,5 +1,7 @@
1
1
 
2
- **v0.4.0.pre** Inclusion of jogl-all.jar should fix 3D if install fails try getting rid of previous versions of gem (especially if you had done local installs, foxed me first) 3D still only for linux64 and macosx, any Windows developers are welocme to extens to windows (should be easy).
2
+ **v0.5.0** Includes a a sketch creator utility 3D still only for linux64 and macosx, any Windows developers are welcome to extend to windows (should be easy).
3
+
4
+ **v0.4.0.pre** Inclusion of jogl-all.jar should fix 3D if install fails try getting rid of previous versions of gem (especially if you had done local installs, foxed me first) 3D still only for linux64 and macosx, any Windows developers are welcome to extend to windows (should be easy).
3
5
 
4
6
  **v0.3.0.pre** First pre-release of propane.gem turns out 3D was not working because of missing jar in gem (3D was only going to work on macosx and linux64 OS anyways.
5
7
 
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  A slim layer to communicate with Processing from JRuby, features a polyglot maven build, this started out as a non serious project by Phillip Cunningam called ribiprocessing. It has now morphed into an experimental project for ruby-processing so we can now "Cook with Gas". We have created a configuration free version of ruby processing, albeit tied to processing-2.2.1, where we get processing core from maven central (and opengl currently testing on linux64/mac). These jars are small enough to include in the gem distribution, and hence we should not require configuration. This has created a mainly scriptable version, ie files get run direct from jruby. However (as with ruby-processing/JRubyArt) certain sketches need to call jruby via jruby-complete, for this we have created an executable `propane` that can also be used to install `jruby-complete` as well as run sketches (maybe export?, possibly watch).
5
5
  ## Requirements
6
6
 
7
- - jdk7+
7
+ - jdk7+ possibly jdk8+ in near future
8
8
  - jruby-9.0.5.0+
9
9
  - mvn-3.3.1+ (development only)
10
10
 
@@ -18,7 +18,8 @@ rake javadoc
18
18
 
19
19
  ## Installation
20
20
  ```bash
21
- jgem install propane-{version}-java.gem
21
+ jgem install propane-{version}-java.gem # local install
22
+ jgem install propane --pre # from rubygems.org, drop --pre once there is a regular released version
22
23
  ```
23
24
 
24
25
  ## Usage
@@ -61,7 +62,15 @@ Many sketches will run just using an installed jruby, but shader sketches must b
61
62
  ```bash
62
63
  propane --install
63
64
  ```
64
- To run sketches using the installed jruby-complete
65
+ There is a handy sketch creator tool
66
+ ```bash
67
+ propane -c my_sketch 200 200 # for default renderer
68
+ propane -c my_sketch 200 200 p2d # for opengl 2D renderer
69
+ propane -c my_sketch 200 200 p3d # for opengl 3D renderer
70
+ ```
71
+ NB: will not overwrite existing sketch with the same name eg `my_sketch.rb` above
72
+
73
+ To run sketches using the installed jruby-complete, you can also use shortform `-r`
65
74
  ```bash
66
75
  propane --run my_sketch.rb # or
67
76
  jruby -S propane --run my_sketch.rb # belt and braces version
data/Rakefile CHANGED
@@ -22,7 +22,7 @@ end
22
22
  desc 'Install'
23
23
  task :install do
24
24
  sh 'mvn dependency:copy'
25
- sh 'mv target/rpextras.jar lib'
25
+ sh 'mv target/propane.jar lib'
26
26
  end
27
27
 
28
28
  desc 'Gem'
@@ -0,0 +1,136 @@
1
+ # encoding: utf-8
2
+ # frozen_string_literal: false
3
+
4
+ BASIC = <<-CODE
5
+ # encoding: utf-8
6
+ # frozen_string_literal: false
7
+ require 'propane'
8
+
9
+ class %s < Propane::App
10
+ def setup
11
+ size %s, %s
12
+ end
13
+
14
+ def draw
15
+
16
+ end
17
+ end
18
+
19
+ %s.new title: '%s'
20
+ CODE
21
+
22
+ MODE = <<-CODE
23
+ # encoding: utf-8
24
+ # frozen_string_literal: false
25
+ require 'propane'
26
+
27
+ class %s < Propane::App
28
+ def setup
29
+ size %s, %s, %s
30
+ end
31
+
32
+ def draw
33
+
34
+ end
35
+ end
36
+
37
+ %s.new title: '%s'
38
+ CODE
39
+
40
+ INNER = <<-CODE
41
+ # encoding: utf-8
42
+ # frozen_string_literal: false
43
+ class %s
44
+ include Propane::Proxy
45
+
46
+ end
47
+ CODE
48
+
49
+ # processing wrapper module
50
+ module Propane
51
+ require_relative '../helpers/string_extra'
52
+ # Write file to disk
53
+ class SketchWriter
54
+ attr_reader :file
55
+ def initialize(path)
56
+ underscore = StringExtra.new(path).underscore
57
+ @file = "#{File.dirname(path)}/#{underscore}.rb"
58
+ end
59
+
60
+ def save(template)
61
+ File.open(file, 'w+') do |f|
62
+ f.write(template)
63
+ end
64
+ end
65
+ end
66
+
67
+ # An abstract class providing common methods for real creators
68
+ class Creator
69
+ ALL_DIGITS = /\A\d+\Z/
70
+
71
+ def already_exist(path)
72
+ underscore = StringExtra.new(path).underscore
73
+ new_file = "#{File.dirname(path)}/#{underscore}.rb"
74
+ return if !FileTest.exist?(path) && !FileTest.exist?(new_file)
75
+ puts 'That file already exists!'
76
+ exit
77
+ end
78
+
79
+ # Show the help/usage message for create.
80
+ def usage
81
+ puts <<-USAGE
82
+
83
+ Usage: propane --create <sketch_to_generate> <width> <height> <mode>
84
+ optional mode can be P2D / P3D.
85
+ Use --inner to generated a ruby version of 'java' Inner class
86
+ Examples: propane --create app 800 600
87
+ propane --create app 800 600 p3d
88
+ propane --create inner_class --inner
89
+
90
+ USAGE
91
+ end
92
+ end
93
+
94
+ # This class creates bare sketches, with an optional render mode
95
+ class BasicSketch < Creator
96
+ def template_default
97
+ format(BASIC, @name, @width, @height, @name, @title)
98
+ end
99
+
100
+ def template_mode
101
+ format(MODE, @name, @width, @height, @mode, @name, @title)
102
+ end
103
+ # Create a class wrapped sketch, given a path.
104
+ def create!(path, args)
105
+ return usage if /\?/ =~ path || /--help/ =~ path
106
+ main_file = File.basename(path, '.rb') # allow uneeded extension input
107
+ # Check to make sure that the main file doesn't exist already
108
+ already_exist(path)
109
+ @name = StringExtra.new(main_file).camelize
110
+ writer = SketchWriter.new(main_file)
111
+ @title = StringExtra.new(main_file).titleize
112
+ @width, @height = args[0], args[1]
113
+ @mode = args[2].upcase unless args[2].nil?
114
+ template = @mode.nil? ? template_default : template_mode
115
+ writer.save(template)
116
+ end
117
+ end
118
+
119
+ # This class creates a pseudo 'java inner class' of the sketch
120
+ class Inner < Creator
121
+ def inner_class_template
122
+ format(INNER, @name)
123
+ end
124
+ # Create a pseudo inner class, given a path.
125
+ def create!(path, _args_)
126
+ return usage if /\?/ =~ path || /--help/ =~ path
127
+ main_file = File.basename(path, '.rb') # allow uneeded extension input
128
+ # Check to make sure that the main file doesn't exist already
129
+ already_exist(path)
130
+ @name = main_file.camelize
131
+ writer = SketchWriter.new(main_file)
132
+ template = inner_class_template
133
+ writer.save(template)
134
+ end
135
+ end
136
+ end
@@ -0,0 +1,45 @@
1
+ # encoding: utf-8
2
+ # frozen_string_literal: false
3
+
4
+ require 'forwardable'
5
+
6
+ # String utility for creating titles and class-names
7
+ class StringExtra
8
+ extend Forwardable
9
+ def_delegators :@str, :upcase, :capitalize, :length, :downcase, :gsub, :tr
10
+ def initialize(str)
11
+ @str = str
12
+ end
13
+
14
+ def titleize
15
+ gsub(/::/, '/')
16
+ .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
17
+ .gsub(/([a-z\d])([A-Z])/, '\1_\2')
18
+ .tr('-', '_')
19
+ .downcase
20
+ .gsub(/_id$/, '')
21
+ .tr('_', ' ').capitalize
22
+ .gsub(/\b([a-z])/) { Regexp.last_match[1].capitalize }
23
+ end
24
+
25
+ def humanize
26
+ gsub(/_id$/, '').tr(/_/, ' ').capitalize
27
+ end
28
+
29
+ def underscore
30
+ gsub(/::/, '/')
31
+ .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
32
+ .gsub(/([a-z\d])([A-Z])/, '\1_\2')
33
+ .sub('-', '_')
34
+ .downcase
35
+ end
36
+
37
+ def camelize(first_letter_in_uppercase = true)
38
+ if first_letter_in_uppercase
39
+ @str.gsub(%r{/(.?)}) { '::' + Regexp.last_match[1].upcase }
40
+ .gsub(/(^|_)(.)/) { Regexp.last_match[2].upcase }
41
+ else
42
+ @str[0] + camelize[1..-1]
43
+ end
44
+ end
45
+ end
@@ -8,7 +8,7 @@ module Propane
8
8
  # Utility class to handle the different commands that the 'rp5' command
9
9
  # offers. Able to run, watch, live, create, app, and unpack
10
10
  class Runner
11
- attr_reader :options, :name
11
+ attr_reader :options, :argc, :filename
12
12
 
13
13
  def initialize
14
14
  @options = {}
@@ -26,6 +26,7 @@ module Propane
26
26
  show_help if options.empty?
27
27
  show_version if options[:version]
28
28
  run_sketch if options[:run]
29
+ create if options[:create]
29
30
  install if options[:install]
30
31
  end
31
32
 
@@ -51,6 +52,11 @@ module Propane
51
52
  opts.on('-r', '--run', 'Run the sketch using jruby-complete') do
52
53
  options[:run] = true
53
54
  end
55
+
56
+ options[:create] = false
57
+ opts.on('-c', '--create', 'Create new sketch outline') do
58
+ options[:create] = true
59
+ end
54
60
 
55
61
  # This displays the help screen, all programs are
56
62
  # assumed to have this option.
@@ -59,12 +65,13 @@ module Propane
59
65
  exit
60
66
  end
61
67
  end
62
- @name = opt_parser.parse(args)
68
+ @argc = opt_parser.parse(args)
69
+ @filename = argc.shift
63
70
  end
64
71
 
65
72
  def run_sketch
66
- root = File.absolute_path(File.dirname(ARGV.shift))
67
- sketch = File.join(root, name)
73
+ root = File.absolute_path(File.dirname(filename))
74
+ sketch = File.join(root, filename)
68
75
  warn_format = 'File %s does not not Exist!'
69
76
  return warn(format(warn_format, sketch)) unless File.exist?(sketch)
70
77
  command = [
@@ -76,9 +83,15 @@ module Propane
76
83
  ].flatten
77
84
  exec(*command)
78
85
  end
86
+
87
+ def create
88
+ require_relative 'creators/creator'
89
+ Propane::BasicSketch.new.create!(filename, argc)
90
+ end
79
91
 
80
92
  def show_version
81
- puts format('Propane version %s', Propane::VERSION)
93
+ v_format = "Propane version %s\nJRuby version %s"
94
+ puts format(v_format, Propane::VERSION, JRUBY_VERSION)
82
95
  end
83
96
 
84
97
  def install
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
  # frozen_string_literal: true
3
3
  module Propane
4
- VERSION = '0.4.0.pre'.freeze
4
+ VERSION = '0.5.0'.freeze
5
5
  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:rp5extras', '0.4.0.pre'
4
+ id 'propane:rp5extras', '0.5.0'
5
5
  packaging 'jar'
6
6
  description 'rp5extras for propane'
7
7
  organization 'ruby-processing', 'https://ruby-processing.github.io'
@@ -108,6 +108,6 @@ project 'rp5extras', 'https://github.com/monkstone/propane' do
108
108
  build do
109
109
  default_goal 'package'
110
110
  source_directory 'src'
111
- final_name 'rpextras'
111
+ final_name 'propane'
112
112
  end
113
113
  end
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>rp5extras</artifactId>
14
- <version>0.4.0.pre</version>
14
+ <version>0.5.0</version>
15
15
  <name>rp5extras</name>
16
16
  <description>rp5extras for propane</description>
17
17
  <url>https://github.com/monkstone/propane</url>
@@ -91,7 +91,7 @@ DO NOT MODIFIY - GENERATED CODE
91
91
  <build>
92
92
  <sourceDirectory>src</sourceDirectory>
93
93
  <defaultGoal>package</defaultGoal>
94
- <finalName>rpextras</finalName>
94
+ <finalName>propane</finalName>
95
95
  <pluginManagement>
96
96
  <plugins>
97
97
  <plugin>
data/propane.gemspec CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |gem|
13
13
  gem.summary = %q{A really slim layer between Ruby and Processing-2.2.1.}
14
14
  gem.homepage = 'https://github.com/monkstone/propane'
15
15
  gem.files = `git ls-files`.split($/)
16
- gem.files << 'lib/rpextras.jar'
16
+ gem.files << 'lib/propane.jar'
17
17
  gem.files << 'lib/core-2.2.1.jar'
18
18
  gem.files << 'lib/gluegen-rt-2.1.5-01.jar'
19
19
  gem.files << 'lib/jogl-all-2.1.5-01.jar'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: propane
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0.pre
4
+ version: 0.5.0
5
5
  platform: java
6
6
  authors:
7
7
  - filib
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-03-26 00:00:00.000000000 Z
12
+ date: 2016-04-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: arcball
@@ -87,15 +87,17 @@ files:
87
87
  - lib/jogl-all-2.1.5-01-natives-linux-amd64.jar
88
88
  - lib/jogl-all-2.1.5-01-natives-macosx-universal.jar
89
89
  - lib/jogl-all-2.1.5-01.jar
90
+ - lib/propane.jar
90
91
  - lib/propane.rb
91
92
  - lib/propane/app.rb
93
+ - lib/propane/creators/creator.rb
92
94
  - lib/propane/helper_methods.rb
93
95
  - lib/propane/helpers/numeric.rb
96
+ - lib/propane/helpers/string_extra.rb
94
97
  - lib/propane/library_loader.rb
95
98
  - lib/propane/runner.rb
96
99
  - lib/propane/underscorer.rb
97
100
  - lib/propane/version.rb
98
- - lib/rpextras.jar
99
101
  - library/boids/boids.rb
100
102
  - library/control_panel/control_panel.rb
101
103
  - pom.rb
@@ -128,9 +130,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
128
130
  version: '0'
129
131
  required_rubygems_version: !ruby/object:Gem::Requirement
130
132
  requirements:
131
- - - ">"
133
+ - - ">="
132
134
  - !ruby/object:Gem::Version
133
- version: 1.3.1
135
+ version: '0'
134
136
  requirements: []
135
137
  rubyforge_project:
136
138
  rubygems_version: 2.5.2