mrb 0.0.6 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/README.md +2 -0
- data/Rakefile +5 -2
- data/assets/templates/gem/build_config.rb.erb +12 -0
- data/lib/mrb.rb +1 -1
- data/lib/mrb/cli.rb +122 -3
- data/lib/mrb/config.rb +34 -0
- data/lib/mrb/template.rb +4 -0
- data/lib/mrb/util.rb +6 -0
- data/lib/mrb/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 264963a85561a0e0380b8e1f69e482b604736f9a
|
4
|
+
data.tar.gz: 0e1793cde02af8d35089381430bd64822ddeaee7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10dbbb0bf347eb158f1f4ea805a328ca0f35d977ab479c4b8c95eabe8822bd17b8db7d8d076038ca54e2f55f83b675535ca42dfb87ee3169d4a857da64b38fca
|
7
|
+
data.tar.gz: 5547fff79796c3be317564ca26188cc02e399351ef43ec36c0fac1e00c1ce03b845f55a60e4d131bdee3756eeea4d556d97cf06edf24ffde699c350e1df4187e
|
data/Gemfile
CHANGED
data/README.md
CHANGED
data/Rakefile
CHANGED
data/lib/mrb.rb
CHANGED
data/lib/mrb/cli.rb
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
require 'thor'
|
2
|
-
require 'erb'
|
3
2
|
require 'fileutils'
|
4
3
|
require 'yaml'
|
4
|
+
require "mrb/version"
|
5
|
+
require "mrb/config"
|
5
6
|
|
6
7
|
module Mrb
|
7
8
|
class CLI < Thor
|
9
|
+
MRB_CONFIG_PATH = ".mrb"
|
10
|
+
|
8
11
|
desc "get", "get mruby source code"
|
9
12
|
def get()
|
10
13
|
%x{git clone https://github.com/mruby/mruby.git}
|
@@ -18,10 +21,21 @@ module Mrb
|
|
18
21
|
FileUtils.mkdir_p full_name
|
19
22
|
puts "Creating gem '#{full_name}'..."
|
20
23
|
|
24
|
+
FileUtils.mkdir_p "#{full_name}/#{MRB_CONFIG_PATH}"
|
25
|
+
|
26
|
+
config = nil
|
27
|
+
if File.exist? "#{full_name}/#{MRB_CONFIG_PATH}/config"
|
28
|
+
config = Config.load "#{full_name}/#{MRB_CONFIG_PATH}/config"
|
29
|
+
else
|
30
|
+
config = Config.create "#{full_name}/#{MRB_CONFIG_PATH}/config"
|
31
|
+
end
|
32
|
+
|
21
33
|
File.write "#{full_name}/README.md", Mrb::Template.render_readme(variables)
|
22
34
|
puts " create #{full_name}/README.md"
|
23
35
|
File.write "#{full_name}/mrbgem.rake", Mrb::Template.render_mrbgem(variables)
|
24
36
|
puts " create #{full_name}/mrbgem.rake"
|
37
|
+
File.write "#{full_name}/mrb-build_config.rb", Mrb::Template.render_mrb_build_config(variables)
|
38
|
+
puts " create #{full_name}/mrb-build_config.rb"
|
25
39
|
|
26
40
|
FileUtils.mkdir_p "#{full_name}/src"
|
27
41
|
File.write "#{full_name}/src/example.c", Mrb::Template.render_example_c(variables)
|
@@ -96,9 +110,114 @@ module Mrb
|
|
96
110
|
end
|
97
111
|
end
|
98
112
|
|
99
|
-
desc "
|
113
|
+
desc "install", "install mruby"
|
114
|
+
option :list, :aliases => :l
|
115
|
+
def install(version = "")
|
116
|
+
available_versions = %w(1.0.0 1.1.0 1.2.0 1.3.0 1.4.0 master)
|
117
|
+
|
118
|
+
if options[:list]
|
119
|
+
puts "available versions:"
|
120
|
+
available_versions.each {|v| puts " #{v}"}
|
121
|
+
return
|
122
|
+
end
|
123
|
+
|
124
|
+
unless available_versions.include?(version)
|
125
|
+
$stderr.puts "Error: Not supported version. version=#{version}"
|
126
|
+
return
|
127
|
+
end
|
128
|
+
|
129
|
+
config = Config.load "#{MRB_CONFIG_PATH}/config"
|
130
|
+
|
131
|
+
if File.directory? "#{MRB_CONFIG_PATH}/#{version}"
|
132
|
+
$stderr.puts "Error: already exists path=#{MRB_CONFIG_PATH}/#{version}"
|
133
|
+
return
|
134
|
+
end
|
135
|
+
|
136
|
+
config["current"]["version"] = version
|
137
|
+
config["current"]["installed"] << version unless config["current"]["installed"].include? version
|
138
|
+
Config.save "#{MRB_CONFIG_PATH}/config", config
|
139
|
+
|
140
|
+
system Util.git_clone_command(config["mruby"]["url"], version, MRB_CONFIG_PATH)
|
141
|
+
invoke :rake, "", {}
|
142
|
+
end
|
143
|
+
|
144
|
+
desc "uninstall", "uninstall a specific mruby"
|
145
|
+
def uninstall(version)
|
146
|
+
config = Config.load "#{MRB_CONFIG_PATH}/config"
|
147
|
+
unless config["current"]["installed"].include? version
|
148
|
+
$stderr.puts "Error: not found. version=#{version}"
|
149
|
+
return
|
150
|
+
end
|
151
|
+
|
152
|
+
print "Are you sure you want to remove mruby? (y/n): "
|
153
|
+
answer = STDIN.gets.chomp
|
154
|
+
unless answer == "y"
|
155
|
+
$stderr.puts "cancel"
|
156
|
+
return
|
157
|
+
end
|
158
|
+
|
159
|
+
config["current"]["version"] = "" if config["current"]["version"] == version
|
160
|
+
config["current"]["installed"] = config["current"]["installed"].delete_if {|v| v == version }
|
161
|
+
Config.save "#{MRB_CONFIG_PATH}/config", config
|
162
|
+
|
163
|
+
FileUtils.rm_rf "#{MRB_CONFIG_PATH}/#{version}"
|
164
|
+
puts "done."
|
165
|
+
end
|
166
|
+
|
167
|
+
desc "versions", "list installed mruby version"
|
168
|
+
def versions()
|
169
|
+
config = Config.load "#{MRB_CONFIG_PATH}/config"
|
170
|
+
current_version = config["current"]["version"]
|
171
|
+
config["current"]["installed"].each do |version|
|
172
|
+
if current_version == version
|
173
|
+
print "* "
|
174
|
+
else
|
175
|
+
print " "
|
176
|
+
end
|
177
|
+
puts "#{version} (set by #{MRB_CONFIG_PATH}/#{version})"
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
desc "version", "show current mruby version"
|
100
182
|
def version()
|
101
|
-
|
183
|
+
config = Config.load "#{MRB_CONFIG_PATH}/config"
|
184
|
+
version = config["current"]["version"]
|
185
|
+
|
186
|
+
puts "#{version} (set by #{MRB_CONFIG_PATH}/#{version})"
|
187
|
+
end
|
188
|
+
|
189
|
+
desc "use", "switch mruby version"
|
190
|
+
def use(version)
|
191
|
+
config = Config.load "#{MRB_CONFIG_PATH}/config"
|
192
|
+
unless config["current"]["installed"].include? version
|
193
|
+
$stderr.puts "Error: not found. version=#{version}"
|
194
|
+
return
|
195
|
+
end
|
196
|
+
|
197
|
+
config["current"]["version"] = version
|
198
|
+
Config.save "#{MRB_CONFIG_PATH}/config", config
|
199
|
+
|
200
|
+
invoke :version, [], {}
|
201
|
+
end
|
202
|
+
|
203
|
+
desc "test", "execute mruby test"
|
204
|
+
def test()
|
205
|
+
invoke :rake, ["test"], {}
|
206
|
+
end
|
207
|
+
|
208
|
+
desc "clean", "clean up build files"
|
209
|
+
def clean()
|
210
|
+
invoke :rake, ["clean"], {}
|
211
|
+
end
|
212
|
+
|
213
|
+
desc "rake", "execute mruby minirake task"
|
214
|
+
def rake(task = "")
|
215
|
+
config = Config.load "#{MRB_CONFIG_PATH}/config"
|
216
|
+
version = config["current"]["version"]
|
217
|
+
|
218
|
+
Dir.chdir("#{MRB_CONFIG_PATH}/#{version}") do
|
219
|
+
system "MRUBY_CONFIG=../../mrb-build_config.rb ./minirake #{task}"
|
220
|
+
end
|
102
221
|
end
|
103
222
|
end
|
104
223
|
end
|
data/lib/mrb/config.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require "yaml"
|
2
|
+
|
3
|
+
module Mrb
|
4
|
+
class Config
|
5
|
+
DEFAULT_CONFIG = {
|
6
|
+
"mruby" => {
|
7
|
+
"url" => "https://github.com/mruby/mruby.git",
|
8
|
+
"tag" => []
|
9
|
+
},
|
10
|
+
"current" => {
|
11
|
+
"version" => "",
|
12
|
+
"installed" => []
|
13
|
+
}
|
14
|
+
}
|
15
|
+
|
16
|
+
def self.create(config_path)
|
17
|
+
File.open(config_path, "w") do |fout|
|
18
|
+
YAML.dump(DEFAULT_CONFIG, fout)
|
19
|
+
end
|
20
|
+
DEFAULT_CONFIG
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.load(config_path)
|
24
|
+
YAML.load_file(config_path)
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.save(config_path, config)
|
28
|
+
File.open(config_path, "w") do |fout|
|
29
|
+
YAML.dump(config, fout)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
data/lib/mrb/template.rb
CHANGED
@@ -24,6 +24,10 @@ module Mrb
|
|
24
24
|
render('gem/mrbgem.rake.erb', variables)
|
25
25
|
end
|
26
26
|
|
27
|
+
def self.render_mrb_build_config(variables)
|
28
|
+
render('gem/build_config.rb.erb', variables)
|
29
|
+
end
|
30
|
+
|
27
31
|
def self.render_example_c(variables)
|
28
32
|
render('gem/example.c.erb', variables)
|
29
33
|
end
|
data/lib/mrb/util.rb
CHANGED
@@ -15,5 +15,11 @@ module Mrb
|
|
15
15
|
:name => name,
|
16
16
|
}
|
17
17
|
end
|
18
|
+
|
19
|
+
def self.git_clone_command(mruby_repo_url, version, mrb_config_path)
|
20
|
+
git_cone_cmd = "git clone --depth=1 "
|
21
|
+
git_cone_cmd << " -b #{version} " unless version.casecmp("master") == 0
|
22
|
+
git_cone_cmd << " #{mruby_repo_url} #{mrb_config_path}/#{version}"
|
23
|
+
end
|
18
24
|
end
|
19
25
|
end
|
data/lib/mrb/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mrb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- qtakamitsu
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-04-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -86,6 +86,7 @@ files:
|
|
86
86
|
- assets/templates/config/build_config_crossbuild.erb
|
87
87
|
- assets/templates/config/build_config_host.erb
|
88
88
|
- assets/templates/gem/README.md.erb
|
89
|
+
- assets/templates/gem/build_config.rb.erb
|
89
90
|
- assets/templates/gem/example.c.erb
|
90
91
|
- assets/templates/gem/mrbgem.rake.erb
|
91
92
|
- assets/templates/gem/test_example.c.erb
|
@@ -95,6 +96,7 @@ files:
|
|
95
96
|
- exe/mrb
|
96
97
|
- lib/mrb.rb
|
97
98
|
- lib/mrb/cli.rb
|
99
|
+
- lib/mrb/config.rb
|
98
100
|
- lib/mrb/template.rb
|
99
101
|
- lib/mrb/util.rb
|
100
102
|
- lib/mrb/version.rb
|