mgem 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/mgem +129 -80
  3. data/lib/mgem.rb +14 -2
  4. metadata +4 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aff684b1b46f4cf20be41e70a3eea1fcb0c6f91d
4
- data.tar.gz: 805ea401404c9e967a7f1fda87ef242af759639b
3
+ metadata.gz: 6fcd5e06cd00d8ad8ac67574fc402ca628e552d6
4
+ data.tar.gz: c866f30bdc6da568e0dcf662ddca76f80d3882e9
5
5
  SHA512:
6
- metadata.gz: c3d32755ba98a56d7cf341af1a04c9d0cce8068d7d793d14054354961d7052bdd01b776e7001cc0405b33a10d815f6e516ff95d2d2da99ec8353863bbd4f156e
7
- data.tar.gz: afd0bf3783f5b994b462aab96a9567f1af8f162a67942e9fb5b3baabbace9f3864fd3b8a22d263965e62bb724ef4b2b28fb797cea227c8d3a44b2abff754a77e
6
+ metadata.gz: a0cc2be19c6f06cadd2d82fc1254edf15c2c78a9e11f8e6b04a0836d4e296c12e23306cd68cb0eb1e3670f6d4862ba61a6e4c837b7cceb1328dc3837ea8b4e3e
7
+ data.tar.gz: b49e93f42d03d550b3d1d51a8c2d8fda81e9489f5f1a95af0b36dbc034975177437941031fa87498adf864951e2836bcafda7b78a9def26f93bbc29637e708eb
data/bin/mgem CHANGED
@@ -3,11 +3,16 @@
3
3
  require "#{File.dirname(__FILE__)}/../lib/mgem"
4
4
  extend Mrbgem
5
5
 
6
- gems = load_gems unless ARGV[0] == 'help'
6
+ main_cmd = ARGV[0]
7
+ arg1 = ARGV[1]
8
+ arg2 = ARGV[2]
9
+
10
+ gems = load_gems unless main_cmd == 'help'
7
11
 
8
12
  info_proc = lambda do |obj|
9
13
  puts " #{obj.name.ljust(30)}#{obj.description}"
10
14
  end
15
+ r = lambda { |o| /^(#{1.upto(o.size).map{|x|o[0...(x)]}.join('|')})$/ }
11
16
 
12
17
  detail_info_proc = lambda do |obj|
13
18
  puts <<INFO
@@ -34,108 +39,120 @@ def get_toolchain
34
39
  puts <<__TOOLCHAIN_SELECT__
35
40
 
36
41
  Please choose your toolchain:
37
- 'gcc' for GNU Compiler Collection
38
- 'clang' for LLVM C Compiler
39
- 'vs' for Visual Studio 2012 on Windows
40
-
42
+ #{Mrbgem::TOOLCHAINS.map{|x| " '#{x[0]}' for #{Mrbgem::TOOLCHAINS[x[0]][:desc]}\n" }.join}
41
43
  __TOOLCHAIN_SELECT__
42
44
 
43
45
  print 'Toolchain: '
44
46
  STDOUT.flush
45
- toolchain = case STDIN.gets.chomp
46
- when 'vs'
47
- 'vs2012'
48
- when 'clang'
49
- 'clang'
50
- when 'gcc'
51
- 'gcc'
47
+ toolchain = STDIN.gets.chomp
48
+ if Mrbgem::TOOLCHAINS.has_key? toolchain
49
+ toolchain = Mrbgem::TOOLCHAINS[toolchain][:id]
52
50
  else
51
+ toolchain = 'gcc'
53
52
  puts <<__ERROR__
54
53
 
55
54
  Your input "#{toolchain}" wasn't valid.
56
55
  Fallback to GCC toolchain!
57
56
  __ERROR__
58
-
59
- 'gcc'
60
57
  end
61
58
 
62
59
  toolchain
63
60
  end
64
61
 
65
- def get_binaries
66
- puts
67
- print 'Compile mrbc? (Y/n): '
68
- mrbc = STDIN.gets.chomp
69
-
70
- binaries = []
71
- binaries << 'mrbc' unless mrbc == 'n'
72
-
73
- binaries.join ' '
74
- end
75
-
76
62
  CORE_GEMS = {
77
- 'irb Executable' => 'bin-mirb',
78
- 'mruby Executable' => 'bin-mruby',
79
- 'Array ext' => 'array-ext',
80
- 'Enumeration ext' => 'enum-ext',
63
+ 'Interactive Shell [mirb]' => 'bin-mirb',
64
+ 'Interpreter [mruby]' => 'bin-mruby',
65
+ 'Compiler [mrbc]' => 'bin-mrbc',
66
+ 'Configurator [mruby-config]' => 'bin-mruby-config',
67
+ 'Debugger [mrdb]' => 'bin-debugger',
68
+
69
+ 'Array Extensions' => 'array-ext',
70
+ 'Enumerator' => 'enumerator',
71
+ 'Enumerator Lazy' => 'enum-lazy',
72
+ 'Enumerator Extensions' => 'enum-ext',
81
73
  'eval' => 'eval',
82
74
  'exit' => 'exit',
83
75
  'Fiber' => 'fiber',
84
- 'Hash ext' => 'hash-ext',
76
+ 'Hash Extensions' => 'hash-ext',
77
+ 'Kernel Extensions' => 'kernel-ext',
85
78
  'Math' => 'math',
86
- 'Numeric ext' => 'numeric-ext',
87
- 'Object ext' => 'object-ext',
79
+ 'Numeric Extensions' => 'numeric-ext',
80
+ 'Object Extensions' => 'object-ext',
88
81
  'ObjectSpace' => 'objectspace',
89
82
  'print' => 'print',
90
- 'Proc ext' => 'proc-ext',
83
+ 'Proc Extensions' => 'proc-ext',
91
84
  'random' => 'random',
92
- 'Range ext' => 'range-ext',
85
+ 'Range Extensions' => 'range-ext',
93
86
  'sprintf' => 'sprintf',
94
- 'String ext' => 'string-ext',
95
- 'String UTF8' => 'string-utf8',
87
+ 'String Extensions' => 'string-ext',
96
88
  'Struct' => 'struct',
97
- 'Symbol ext' => 'symbol-ext',
89
+ 'Symbol Extensions' => 'symbol-ext',
98
90
  'Time' => 'time',
99
- 'Toplevel ext' => 'toplevel-ext'
91
+ 'Toplevel Extensions' => 'toplevel-ext'
92
+ }
93
+
94
+ COMPILE_OPTIONS = {
95
+ 'bin-debugger' => [
96
+ 'conf.cc.defines = %w(MRB_ENABLE_DEBUG_HOOK)'
97
+ ],
98
+ 'test' => [
99
+ 'conf.enable_bintest',
100
+ 'conf.enable_test'
101
+ ],
102
+ 'debug' => [
103
+ 'enable_debug'
104
+ ]
100
105
  }
101
106
 
107
+ DEFAULT_NO = ['bin-debugger', 'bin-mruby-config']
108
+
102
109
  def get_default_gems
103
110
  puts
104
111
  gems = []
105
112
  CORE_GEMS.each do |gem, path|
106
- print "Include '#{gem}' GEM? (Y/n): "
113
+ y_n = 'Y/n'
114
+ y_n = 'y/N' if DEFAULT_NO.include? path
115
+ print "Include '#{gem}' GEM? (#{y_n}): "
107
116
  question = STDIN.gets.chomp
108
- unless question == 'n'
109
- gems << path
117
+
118
+ if DEFAULT_NO.include? path
119
+ if question == 'y'
120
+ gems << path
121
+ end
122
+ else
123
+ unless question == 'n'
124
+ gems << path
125
+ end
110
126
  end
111
127
  end
112
128
  gems
113
129
  end
114
130
 
115
- if ARGV[0] == 'info' or ARGV[0] == 'detail'
116
- puts "Detail information of '#{ARGV[1]}':"
117
- gems.search(ARGV[1], :name).each {|gem| detail_info_proc.call(gem) }
118
- elsif ARGV[0] == 'size'
131
+ case main_cmd
132
+ when r.('info'), r.('detail')
133
+ puts "Detail information of '#{arg1}':"
134
+ gems.search(arg1, :name).each {|gem| detail_info_proc.call(gem) }
135
+ when r.('size')
119
136
  puts "Total # of GEMs: #{gems.size}"
120
- elsif ARGV[0] == 'list'
121
- if ARGV[1] == 'active'
137
+ when r.('list')
138
+ if arg1 =~ r.('active')
122
139
  list_active_gems(gems)
123
140
  else
124
141
  puts "List of all GEMs:"
125
142
  gems.each { |gem| info_proc.call(gem) }
126
143
  end
127
- elsif ARGV[0] == 'add'
128
- gems.activate(ARGV[1])
144
+ when r.('add')
145
+ gems.activate(arg1)
129
146
  puts
130
147
  list_active_gems(gems)
131
- elsif ARGV[0] == 'rm'
132
- gems.deactivate(ARGV[1])
148
+ when r.('rm')
149
+ gems.deactivate(arg1)
133
150
  puts
134
151
  list_active_gems(gems)
135
- elsif ARGV[0] == 'search'
136
- puts "Search result for '#{ARGV[1]}':"
137
- gems.search(ARGV[1]).each {|gem| info_proc.call(gem) }
138
- elsif ARGV[0] == 'update'
152
+ when r.('find'), 'search'
153
+ puts "Search result for '#{arg1}':"
154
+ gems.search(arg1).each {|gem| info_proc.call(gem) }
155
+ when r.('update')
139
156
  puts 'Update list of GEMs...'
140
157
  amount = gems.size
141
158
  gems.update!
@@ -148,33 +165,54 @@ elsif ARGV[0] == 'update'
148
165
  else
149
166
  puts "No new GEM"
150
167
  end
151
- elsif ARGV[0] == 'config'
152
- if ARGV[1] == 'default'
153
- toolchain = 'gcc'
154
- binaries = 'mrbc'
168
+ when r.('config')
169
+ test_env = ' # Deactivated!'
170
+ debug_flags = ' # Deactivated!'
171
+ toolchain = 'gcc'
172
+ if arg1 =~ r.('default')
155
173
  default_gems = CORE_GEMS.each_value.to_a
174
+ default_gem_command = " conf.gembox 'default'"
156
175
  else
157
176
  toolchain = get_toolchain
158
- binaries = get_binaries
159
- default_gems = get_default_gems
160
- end
161
177
 
162
- default_gem_command = default_gems.map do |g|
163
- " conf.gem 'mrbgems/mruby-#{g}'"
164
- end.join("\n")
165
- if default_gem_command == ''
166
- default_gem_command = ' # No GEMs activated'
178
+ puts
179
+ print "Build testing environment [mrbtest]? (y/N): "
180
+ question = STDIN.gets.chomp
181
+ if question =~ r.('yes')
182
+ test_env = "#{COMPILE_OPTIONS['test'].map {|o| " #{o}"}.join("\n")}\n"
183
+ end
184
+
185
+ puts
186
+ print "Enable debug flags? (y/N): "
187
+ question = STDIN.gets.chomp
188
+ if question =~ r.('yes')
189
+ debug_flags = "#{COMPILE_OPTIONS['debug'].map {|o| " #{o}"}.join("\n")}\n"
190
+ end
191
+
192
+ default_gem_command = get_default_gems.map do |g|
193
+ opt = ''
194
+ if COMPILE_OPTIONS.include? g
195
+ opt = "#{COMPILE_OPTIONS[g].map {|o| " #{o}"}.join("\n")}\n"
196
+ end
197
+ "#{opt} conf.gem :core => 'mruby-#{g}'"
198
+ end.join("\n")
199
+ if default_gem_command == ''
200
+ default_gem_command = ' # No GEMs activated!'
201
+ end
167
202
  end
168
203
 
204
+ write_file = nil
205
+ [arg1, arg2].each {|x| write_file ||= x =~ r.('write')}
206
+
169
207
  gem_command = gems.active.map do |g|
170
208
  options = ", :options => \'#{g.repooptions}\'" unless g.repooptions.nil?
171
209
  " conf.gem :git => \'#{g.repository}\'#{options}"
172
210
  end.join("\n")
173
211
  if gem_command == ''
174
- gem_command = ' # No GEMs activated'
212
+ gem_command = ' # No GEMs activated!'
175
213
  end
176
214
 
177
- puts <<__CONFIG__
215
+ build_config = <<__CONFIG__
178
216
 
179
217
  ############################
180
218
  # Start of your build_config
@@ -182,32 +220,43 @@ elsif ARGV[0] == 'config'
182
220
  MRuby::Build.new do |conf|
183
221
  toolchain :#{toolchain}
184
222
 
185
- conf.bins = %w(#{binaries})
186
-
187
223
  # mruby's Core GEMs
188
224
  #{default_gem_command}
189
225
 
190
226
  # user-defined GEMs
191
227
  #{gem_command}
228
+
229
+ # Testing environment
230
+ #{test_env}
231
+
232
+ # Debug Flags
233
+ #{debug_flags}
192
234
  end
193
235
 
194
236
  # End of your build_config
195
237
  ############################
196
238
  __CONFIG__
239
+
240
+ if write_file
241
+ open('./build_config.rb', 'w') {|f| f.puts build_config}
242
+ else
243
+ puts build_config
244
+ end
197
245
  else
198
246
  puts <<INFO
199
247
  mgem (Version #{Mrbgem::MGEM_VERSION}) is a library manager for mruby
200
248
 
201
249
  Usage:
202
- mgem size How many GEMs are available?
203
- mgem list [active] List GEMs
204
- mgem info *pattern* Show detail information about a GEM
205
- mgem add *name* Activate a GEM
206
- mgem rm *name* De-Activate a GEM
207
- mgem search *pattern* Search for GEMs
208
- mgem config Generate a mruby build config including all active GEMs
209
- mgem config default Same as 'mgem config' but w/o interactive questions
210
- mgem update Update the list of GEMs
250
+ mgem size How many GEMs are available?
251
+ mgem list active List GEMs
252
+ mgem info *pattern* Show detail information about a GEM
253
+ mgem add *name* Activate a GEM
254
+ mgem rm *name* De-Activate a GEM
255
+ mgem find *pattern* Search for GEMs
256
+ mgem config Generate a mruby build config including all active GEMs
257
+ default Same as 'mgem config' but w/o interactive questions
258
+ write Same as 'mgem config' but writes to build_config.rb
259
+ mgem update Update the list of GEMs
211
260
 
212
261
  Website:
213
262
  https://github.com/bovi/mgem
data/lib/mgem.rb CHANGED
@@ -3,7 +3,7 @@ require 'fileutils'
3
3
  require "stringio"
4
4
 
5
5
  module Mrbgem
6
- MGEM_VERSION = '0.2.0'
6
+ MGEM_VERSION = '0.3.0'
7
7
 
8
8
  MGEM_HOME = ENV['MGEM_HOME'] ||= ENV['HOME']
9
9
  MGEM_DIR = '.mgem'
@@ -11,6 +11,16 @@ module Mrbgem
11
11
  GEMS_LIST = 'mgem-list'
12
12
  GEMS_REPO = 'https://github.com/mruby/mgem-list.git'
13
13
 
14
+ TOOLCHAINS = {
15
+ 'gcc' => {:desc => 'GNU Compiler Collection', :id => 'gcc'},
16
+ 'clang' => {:desc => 'LLVM C Compiler', :id => 'clang'},
17
+ 'vc' => {:desc => 'Visual C++', :id => 'visualcpp'},
18
+ 'wrt' => {:desc => 'OpenWRT Build environment', :id => 'openwrt'},
19
+ 'ndk' => {:desc => 'Android NDK', :id => 'android'}
20
+ }
21
+
22
+ include Enumerable
23
+
14
24
  def load_gems
15
25
  config = {}
16
26
  config[:mgem_dir] = [ENV["MGEM_HOME"], MGEM_DIR].join File::SEPARATOR
@@ -25,7 +35,8 @@ module Mrbgem
25
35
  def initialize_mgem_list(config = {})
26
36
  unless File.exists? config[:mgem_list]
27
37
  puts "Loading fresh GEM list..."
28
- `git clone #{GEMS_REPO} #{config[:mgem_list]}`
38
+ cmd = %Q(git clone "#{GEMS_REPO}" "#{config[:mgem_list]}")
39
+ `#{cmd}`
29
40
  puts "done!"
30
41
  end
31
42
 
@@ -65,6 +76,7 @@ class MrbgemData
65
76
  def protocol; @gem_data["protocol"]; end
66
77
  def repository; @gem_data["repository"]; end
67
78
  def repooptions; @gem_data["repooptions"]; end
79
+ def dependencies; @gem_data['dependencies']; end
68
80
 
69
81
  def method_missing(method_name)
70
82
  err = "Mrbgem Field \"#{method_name}\" doesn't exist!"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mgem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Bovensiepen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-15 00:00:00.000000000 Z
11
+ date: 2016-02-12 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: mgem helps you search and find GEMs specifically written for mruby. It
14
14
  also supports by creating a mruby build configuration.
@@ -40,8 +40,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
40
40
  version: '0'
41
41
  requirements: []
42
42
  rubyforge_project:
43
- rubygems_version: 2.0.3
43
+ rubygems_version: 2.0.14
44
44
  signing_key:
45
45
  specification_version: 4
46
46
  summary: A program to manage GEMs for mruby.
47
47
  test_files: []
48
+ has_rdoc: