esruby 0.0.10 → 0.0.11
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 +4 -4
- data/README.md +1 -0
- data/lib/esruby.rb +1 -0
- data/lib/esruby/build.rb +12 -7
- data/lib/esruby/build/configuration.rb +22 -20
- data/resources/build_config.eruby +21 -7
- data/resources/project_template/config.rb +13 -13
- metadata +1 -2
- data/resources/rb/append.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d42dbf349bcea95903d0de6774803ab39bd5fe32
|
4
|
+
data.tar.gz: b1b862fa53cf9ffdfbc8e0dc6f339084551f1ac6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d654fe70e2d4d3e4a6ada3bc14c76a2913ac6ab3c1f9232b8344bb158ebcd5246d3eb276c260febc9e6a77afeb3bd76b41190babd2d9a7ec9e8c664932c452ba
|
7
|
+
data.tar.gz: 168b15df66a42ad1fd0f9254afe4dd74fea26e96643ea232650fbb58bf26d5da313592dc8183bcb4bb977bca21a618a7099d89e0e8bbb5b64020b4a4aa945256
|
data/README.md
CHANGED
@@ -30,6 +30,7 @@ to your `.bashrc` and `.profile`
|
|
30
30
|
# Try
|
31
31
|
* create a new esruby project with `esruby new project`
|
32
32
|
* `cd project`
|
33
|
+
* download the gem `https://github.com/robfors/esruby-esruby` and put it in `gems/`
|
33
34
|
* build the project with `esruby build config.rb`
|
34
35
|
* you will now have `www/app.js` and `www/index.html`
|
35
36
|
* a simple way to serve these files would be `ruby -run -e httpd www -p 4444`
|
data/lib/esruby.rb
CHANGED
data/lib/esruby/build.rb
CHANGED
@@ -13,7 +13,7 @@ module ESRuby
|
|
13
13
|
new_build
|
14
14
|
end
|
15
15
|
|
16
|
-
def_delegators :@configuration, :
|
16
|
+
def_delegators :@configuration, :project_directory, :build_directory,
|
17
17
|
:build_mode, :output, :mruby_directory, :gems
|
18
18
|
|
19
19
|
def initialize(&block)
|
@@ -23,9 +23,9 @@ module ESRuby
|
|
23
23
|
|
24
24
|
def build
|
25
25
|
FileUtils.mkdir_p(build_directory)
|
26
|
-
load_gems
|
27
26
|
build_mruby_config
|
28
27
|
build_mruby
|
28
|
+
load_gems
|
29
29
|
build_app
|
30
30
|
end
|
31
31
|
|
@@ -34,12 +34,18 @@ module ESRuby
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def load_gems
|
37
|
-
|
38
|
-
|
37
|
+
gem_paths = JSON.parse(File.read(gem_paths_file))
|
38
|
+
gem_paths.each do |gem_path|
|
39
|
+
esruby_spec_path = "#{gem_path}/esruby_gem"
|
40
|
+
load(esruby_spec_path) if File.file?(esruby_spec_path)
|
39
41
|
end
|
40
42
|
nil
|
41
43
|
end
|
42
44
|
|
45
|
+
def gem_paths_file
|
46
|
+
"#{build_directory}/gem_paths.json"
|
47
|
+
end
|
48
|
+
|
43
49
|
def prepended_js_sources
|
44
50
|
js_files = []
|
45
51
|
Gem::Specification.specifications.each do |specification|
|
@@ -66,13 +72,12 @@ module ESRuby
|
|
66
72
|
template = File.read("#{gem_directory}/resources/build_config.eruby")
|
67
73
|
eruby = Erubis::Eruby.new(template)
|
68
74
|
config = {}
|
69
|
-
config[:prepended_js_sources] = prepended_js_sources
|
70
|
-
config[:appended_js_sources] = appended_js_sources
|
71
75
|
config[:optimization_argument] = optimization_argument
|
72
76
|
config[:closure_argument] = closure_argument
|
73
77
|
config[:debug_argument] = debug_argument
|
74
78
|
config[:build_directory] = build_directory
|
75
79
|
config[:gems] = gems
|
80
|
+
config[:gem_paths_file] = gem_paths_file
|
76
81
|
new_output = eruby.result(config)
|
77
82
|
output_path = "#{build_directory}/build_config.rb"
|
78
83
|
old_output = File.read(output_path) if File.exists?(output_path)
|
@@ -114,7 +119,7 @@ module ESRuby
|
|
114
119
|
end
|
115
120
|
|
116
121
|
def build_app
|
117
|
-
mrbc = "#{
|
122
|
+
mrbc = "#{build_directory}/host/bin/mrbc"
|
118
123
|
js_arguments = prepended_js_sources.map { |path| "--pre-js #{path}" }.join(" ")
|
119
124
|
js_arguments += " "
|
120
125
|
js_arguments += appended_js_sources.map { |path| "--post-js #{path}" }.join(" ")
|
@@ -7,7 +7,7 @@ module ESRuby
|
|
7
7
|
:output
|
8
8
|
|
9
9
|
def initialize
|
10
|
-
@
|
10
|
+
@project_directory = nil
|
11
11
|
@mruby_directory = "#{ESRuby.gem_directory}/resources/mruby"
|
12
12
|
@output = 'output.js'
|
13
13
|
@ruby_sources = []
|
@@ -16,31 +16,31 @@ module ESRuby
|
|
16
16
|
@gems = []
|
17
17
|
end
|
18
18
|
|
19
|
-
def
|
20
|
-
raise "'
|
21
|
-
@
|
19
|
+
def project_directory
|
20
|
+
raise "'project_directory' not set" unless @project_directory
|
21
|
+
@project_directory
|
22
22
|
end
|
23
23
|
|
24
|
-
def
|
25
|
-
|
26
|
-
raise "'
|
27
|
-
@
|
24
|
+
def project_directory=(new_project_directory)
|
25
|
+
new_project_directory = File.expand_path(new_project_directory)
|
26
|
+
raise "'project_directory' not found" unless File.directory?(new_project_directory)
|
27
|
+
@project_directory = new_project_directory
|
28
28
|
end
|
29
29
|
|
30
30
|
def add_ruby_source(path)
|
31
|
-
@ruby_sources << File.expand_path(path,
|
31
|
+
@ruby_sources << File.expand_path(path, project_directory)
|
32
32
|
end
|
33
33
|
|
34
34
|
def add_prepended_js_source(path)
|
35
|
-
@prepended_js_sources << File.expand_path(path,
|
35
|
+
@prepended_js_sources << File.expand_path(path, project_directory)
|
36
36
|
end
|
37
37
|
|
38
38
|
def add_appended_js_source(path)
|
39
|
-
@appended_js_sources << File.expand_path(path,
|
39
|
+
@appended_js_sources << File.expand_path(path, project_directory)
|
40
40
|
end
|
41
41
|
|
42
42
|
def build_directory=(new_build_directory)
|
43
|
-
@build_directory = File.expand_path(new_build_directory,
|
43
|
+
@build_directory = File.expand_path(new_build_directory, project_directory)
|
44
44
|
end
|
45
45
|
|
46
46
|
def build_mode=(new_build_mode)
|
@@ -50,19 +50,21 @@ module ESRuby
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def output=(new_output)
|
53
|
-
@output = File.expand_path(new_output,
|
53
|
+
@output = File.expand_path(new_output, project_directory)
|
54
54
|
end
|
55
55
|
|
56
56
|
def mruby_directory=(new_mruby_directory)
|
57
|
-
|
58
|
-
raise "'mruby_directory' not found" unless File.directory?(
|
59
|
-
@mruby_directory =
|
57
|
+
new_mruby_directory = File.expand_path(new_mruby_directory, project_directory)
|
58
|
+
raise "'mruby_directory' not found" unless File.directory?(new_mruby_directory)
|
59
|
+
@mruby_directory = new_mruby_directory
|
60
60
|
end
|
61
61
|
|
62
|
-
def add_gem(
|
63
|
-
|
64
|
-
|
65
|
-
|
62
|
+
def add_gem(arg)
|
63
|
+
if arg.is_a?(String)
|
64
|
+
arg = File.expand_path(arg, project_directory)
|
65
|
+
raise "gem #{arg} not found" unless File.directory?(arg)
|
66
|
+
end
|
67
|
+
@gems << arg
|
66
68
|
end
|
67
69
|
|
68
70
|
end
|
@@ -34,21 +34,35 @@ MRuby::CrossBuild.new('app') do |conf|
|
|
34
34
|
c.flags << "-Wall"
|
35
35
|
c.flags << "-Wno-warn-absolute-paths"
|
36
36
|
c.flags << "--bind"
|
37
|
-
<% for path in prepended_js_sources %>
|
38
|
-
c.flags << "--pre-js <%= path %>"
|
39
|
-
<% end %>
|
40
|
-
<% for path in appended_js_sources %>
|
41
|
-
c.flags << "--post-js <%= path %>"
|
42
|
-
<% end %>
|
43
37
|
c.flags << "<%= optimization_argument %>"
|
44
38
|
c.flags << "<%= closure_argument %>"
|
45
39
|
c.flags << "<%= debug_argument %>"
|
46
40
|
end
|
47
41
|
|
48
42
|
conf.gembox('default')
|
49
|
-
|
43
|
+
conf.gem :github => 'robfors/esruby-esruby'
|
50
44
|
<% for gem in gems %>
|
51
45
|
conf.gem(<%= gem.inspect %>)
|
52
46
|
<% end %>
|
53
47
|
|
54
48
|
end
|
49
|
+
|
50
|
+
|
51
|
+
module MRuby
|
52
|
+
module Gem
|
53
|
+
class List
|
54
|
+
|
55
|
+
old_check = instance_method(:check)
|
56
|
+
define_method(:check) do |build|
|
57
|
+
return_value = old_check.bind(self).call(build)
|
58
|
+
if build.name == 'app'
|
59
|
+
gem_paths = map { |gem| gem.dir }
|
60
|
+
require 'json'
|
61
|
+
File.write("<%= gem_paths_file %>", gem_paths.to_json)
|
62
|
+
end
|
63
|
+
return return_value
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -1,37 +1,37 @@
|
|
1
1
|
# This file sets up the build environment for a webruby project.
|
2
2
|
ESRuby::Build.new do |conf|
|
3
3
|
|
4
|
-
conf.
|
4
|
+
conf.project_directory = File.dirname(__FILE__)
|
5
5
|
|
6
6
|
conf.add_ruby_source 'app/app.rb'
|
7
|
-
#conf.add_prepended_js_source 'app/
|
8
|
-
#conf.add_appended_js_source 'app/
|
7
|
+
#conf.add_prepended_js_source 'app/prepend.js'
|
8
|
+
#conf.add_appended_js_source 'app/append.js'
|
9
9
|
|
10
10
|
# By default, the build output directory is "build/"
|
11
11
|
conf.build_directory = 'build'
|
12
12
|
|
13
|
-
#
|
14
|
-
#
|
13
|
+
# note: dont change this yet
|
14
|
+
# Use :production for O2 mode build, and :development for O0 mode.
|
15
|
+
# Or you can not yet use '-O0', '-O1', '-O2', '-O3', etc. directly
|
16
|
+
# note :production mode is still having trouble working
|
15
17
|
#conf.build_mode = :production
|
16
18
|
conf.build_mode = :development
|
17
19
|
|
18
|
-
#
|
20
|
+
# set the final output file name
|
19
21
|
conf.output = "www/app.js"
|
20
22
|
|
23
|
+
# to override the mruby version, then specify your copy here
|
21
24
|
#conf.mruby_directory = 'mruby'
|
22
25
|
|
26
|
+
# note: dont change this yet
|
23
27
|
# We found that if memory init file is used, browsers will hang
|
24
28
|
# for a long time without response. As a result, we disable memory
|
25
29
|
# init file by default. However, you can test this yourself
|
26
30
|
# and re-enable it by commenting/removing the next line.
|
27
31
|
#conf.ldflags << "--memory-init-file 0"
|
28
32
|
|
29
|
-
# JavaScript
|
30
|
-
#
|
31
|
-
|
32
|
-
# for now you will need to download the gem
|
33
|
-
# https://github.com/robfors/esruby-esruby
|
34
|
-
# and add it here
|
35
|
-
conf.add_gem 'gems/esruby-esruby'
|
33
|
+
# JavaScript binding interface
|
34
|
+
# see: https://github.com/robfors/esruby-bind for more info
|
35
|
+
# conf.add_gem :github => 'robfors/esruby-bind'
|
36
36
|
|
37
37
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: esruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rob Fors
|
@@ -419,7 +419,6 @@ files:
|
|
419
419
|
- resources/project_template/app/app.rb
|
420
420
|
- resources/project_template/config.rb
|
421
421
|
- resources/project_template/www/index.html
|
422
|
-
- resources/rb/append.rb
|
423
422
|
homepage: https://github.com/robfors/esruby
|
424
423
|
licenses:
|
425
424
|
- MIT
|
data/resources/rb/append.rb
DELETED