kompo 0.1.3 → 0.2.0

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
  SHA256:
3
- metadata.gz: 6cdffb0d1cbd44d52b0bb2f0b580d16a44dd2b9f09e8cad75b23ee1fe1eacef2
4
- data.tar.gz: 7e9850ae1d5c28dd61a3c1114ddb9e7a61c4e8722d2b2fca9ccf37bbbe09c26b
3
+ metadata.gz: 824cb5818444206e527f8a70d899c53b922f05a2ee44b1433b9103e2bc00dec9
4
+ data.tar.gz: bc82fea90c7f254f3f1e2221cadd4dedb9ec0e0c64ae4a68163e5784a0de35d1
5
5
  SHA512:
6
- metadata.gz: 0aade69b9fac9b8edf5e7cde1dab33f1491215cb26dab5980378c7907f168e12a03b84fb96c48b8b59aa36ad78e66306f320522875f7388ccd450eace50ca2d9
7
- data.tar.gz: 74dfd32c67932c14163049204566005182fdb24f29db5c207ecc5efc13677bc9aef3bbc173718059a01212599e01a57b2e41da4fa6db029fb5d7eac0e329ddf4
6
+ metadata.gz: 164750a94ce03e80d4dbdbd6c88a33ea76e92e5ddcd0a7ee2170aa76e2c24c3471616739a21adcd37724a49a0af93bb3805b73e14446159dc218cb514fb0fc9a
7
+ data.tar.gz: 7668b48ea202b6f21dccceb8a67097d1df27b6661295c36b756f9a537c09f5479ed326f86c0374b7bb5fef860d62f54a599c520212798a31b02c03ddb6bc295a
data/README.md CHANGED
@@ -1,17 +1,10 @@
1
1
  # Kompo
2
-
3
- TODO: Delete this and the text below, and describe your gem
4
-
5
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/kompo`. To experiment with that code, run `bin/console` for an interactive prompt.
2
+ A tool to pack Ruby and Ruby scripts in one binary. This tool is still under development.
6
3
 
7
4
  ## Installation
8
- Install the gem and add to the application's Gemfile by executing:
9
-
10
- $ bundle add kompo
11
-
12
- If bundler is not being used to manage dependencies, install the gem by executing:
13
-
14
- $ gem install kompo
5
+ ```sh
6
+ $ gem install kompo
7
+ ```
15
8
 
16
9
  ## Usage
17
10
 
@@ -24,19 +17,30 @@ $ brew tap ahogappa0613/kompo-vfs https://github.com/ahogappa0613/kompo-vfs.git
24
17
  $ brew install ahogappa0613/kompo-vfs/kompo-vfs
25
18
  ```
26
19
 
27
- ### Quick Start
28
- If you want to try it out, `cd` to the `sample/` directory and execute the following:
20
+ ### Building
21
+ To build komp-vfs, you need to have cargo installation.
29
22
  ```sh
30
- $ kompo
23
+ $ git clone https://github.com/ahogappa0613/kompo-vfs.git
24
+ $ cd kompo-vfs
25
+ $ cargo build --release
26
+ ```
27
+ Set environment variables
28
+ ```sh
29
+ $ KOMPO_CLI=/path/to/kompo-vfs/target/release/kompo-cli
30
+ $ LIB_KOMPO_DIR=/path/to/kompo-vfs/target/release
31
31
  ```
32
- This will read the Gemfile in the directory and create an executable file with `main.rb` as the entry point in the same directory as `./sample` in the same directory.
33
32
 
33
+ ## examples
34
34
 
35
+ * hello
36
+ * simple hello world script.
37
+ * sinatra_and_sqlite
38
+ * sinatra app with sqlite3 with Gemfile.
39
+ * rails
40
+ * 🚧
35
41
 
36
42
  ## Development
37
43
 
38
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
39
-
40
44
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
41
45
 
42
46
  ## Contributing
data/exe/kompo CHANGED
@@ -3,17 +3,7 @@
3
3
  require_relative '../lib/kompo'
4
4
  require 'optparse'
5
5
 
6
- option = Kompo::Option.new
7
-
8
- option.on('-e VAL', '--entrypoint=VAL') { |v| option.entrypoint = v }
9
- option.on('-o VAL', '--output=VAL') { |v| option.output = v }
10
- option.on('--[no-]gemfile') { |v| option.gemfile = v }
11
- option.on('--[no-]stdlib') { |v| option.stdlib = v }
12
- option.on('--dest-dir=VAL') { |v| option.dest_dir = v }
13
- option.on('--ruby-src-path=VAL') { |v| option.ruby_src_path = v }
14
- option.on('--cache-bundle-path=VAL') { |v| option.cache_bundle_path = v }
15
- option.on('--ruby-version=VAL') { |v| option.ruby_version = v }
16
- # option.on('--compress') { |v| option.compress = v }
6
+ option = Kompo::Option.default
17
7
 
18
8
  Kompo::Tasks.cd_work_dir(option) do |task|
19
9
  task.clone_ruby_src
data/lib/kompo/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kompo
4
- VERSION = "0.1.3"
4
+ VERSION = "0.2.0"
5
5
  end
data/lib/kompo.rb CHANGED
@@ -12,24 +12,43 @@ module Kompo
12
12
 
13
13
  class Option
14
14
  extend Forwardable
15
- attr_accessor :entrypoint, :output, :gemfile, :stdlib, :dest_dir, :ruby_src_path, :cache_bundle_path, :ruby_version, :compress, :context, :args
15
+ attr_accessor :entrypoint, :output, :gemfile, :ignore_stdlib, :dyn_link_lib, :dest_dir, :ruby_src_path, :cache_bundle_path, :ruby_version, :compress, :context, :args, :use_group
16
16
  delegate %i[on] => :@opt
17
17
 
18
18
  def initialize(dir = Dir.getwd, opt = OptionParser.new)
19
19
  @entrypoint = File.join(dir, 'main.rb')
20
20
  @output = File.basename(dir)
21
- @gemfile = true
22
- @stdlib = true
21
+ @gemfile = File.exist?(File.join(Dir.getwd, 'Gemfile'))
22
+ @ignore_stdlib = []
23
+ @dyn_link_lib = []
23
24
  @dest_dir = dir
24
25
  @ruby_src_path = nil
25
26
  @cache_bundle_path = nil
26
27
  @ruby_version = "v#{RUBY_VERSION.gsub('.', '_')}"
27
28
  @compress = false
29
+ @use_group = 'default'
28
30
 
29
31
  @context = dir
30
32
  @opt = opt
31
33
  end
32
34
 
35
+ def self.default
36
+ option = new
37
+ option.on('-e VAL', '--entrypoint=VAL', "File path to use for entry point. (default: \'./main.rb\')") { |v| option.entrypoint = v }
38
+ option.on('-o VAL', '--output=VAL', 'Name of the generated file. (default: current dir name)') { |v| option.output = v }
39
+ option.on('-g VAL', '--use-group=VAL', "Group name to use with \'bundle install\'. (default: \'default\')") { |v| option.use_group = v }
40
+ option.on('--[no-]gemfile', "Use gem in Gemfile. (default: automatically true if Gemfile is present)") { |v| option.gemfile = v }
41
+ option.on('--ignore-stdlib=VAL', Array, "Specify stdlibs not to include, separated by commas.") { |v| option.ignore_stdlib = v }
42
+ option.on('--dyn-link-lib=VAL', Array, "Specify libraries to be dynamic link, separated by commas.") { |v| option.dyn_link_lib = v }
43
+ option.on('--dest-dir=VAL', "Output directry path. (default: current dir)") { |v| option.dest_dir = v }
44
+ option.on('--ruby-src-path=VAL', "Your Ruby source directry. Must be compiled with \'--with-static-linked-ext\'.") { |v| option.ruby_src_path = v }
45
+ option.on('--cache-bundle-path=VAL', "Specify the directory created by \'bundle install --standalone\'.") { |v| option.cache_bundle_path = v }
46
+ option.on('--ruby-version=VAL', "Specify Ruby version. (default: current Ruby version)") { |v| option.ruby_version = v }
47
+ # option.on('--compress') { |v| option.compress = v }
48
+
49
+ option
50
+ end
51
+
33
52
  def build
34
53
  @opt.parse!(ARGV)
35
54
 
@@ -53,9 +72,9 @@ module Kompo
53
72
 
54
73
  class Tasks
55
74
  extend Forwardable
56
- attr_reader :task, :fs, :work_dir, :ruby_src_dir, :ruby_pc, :ruby_bin, :extinit_o, :encinit_o, :lib_ruby_static_dir, :bundle_setup, :bundle_ruby, :std_libs, :gem_libs
75
+ attr_reader :task, :fs, :work_dir, :ruby_src_dir, :ruby_pc, :ruby_bin, :extinit_o, :encinit_o, :lib_ruby_static_dir, :bundle_setup, :bundle_ruby, :std_libs, :gem_libs, :exts_libs
57
76
 
58
- delegate %i[entrypoint output gemfile stdlib dest_dir ruby_src_path cache_bundle_path ruby_version compress context args] => :@option
77
+ delegate %i[entrypoint output gemfile ignore_stdlib dyn_link_lib dest_dir ruby_src_path cache_bundle_path ruby_version compress context args use_group] => :@option
59
78
  delegate %i[komop_cli lib_kompo_dir] => :@fs
60
79
 
61
80
  def initialize(option, dir)
@@ -64,14 +83,27 @@ module Kompo
64
83
  @work_dir = dir
65
84
  @fs = Fs.new
66
85
 
67
- @ruby_pc = File.join(ruby_src_path || File.join(dir, 'dest_dir', 'lib', 'pkgconfig'), 'ruby.pc')
68
86
  @ruby_bin = File.join(ruby_src_path || File.join(dir, 'dest_dir', 'bin'), 'ruby')
87
+ @ruby_pc = File.join(ruby_src_path || File.join(dir, 'dest_dir', 'lib', 'pkgconfig'), get_ruby_pc_name)
69
88
  @extinit_o = File.join(ruby_src_dir, 'ext', 'extinit.o')
70
89
  @encinit_o = File.join(ruby_src_dir, 'enc', 'encinit.o')
71
90
  @lib_ruby_static_dir = ruby_src_path || File.join(dir, 'dest_dir', 'lib')
72
91
 
73
92
  @std_libs = []
74
93
  @gem_libs = []
94
+ @exts_libs = []
95
+ end
96
+
97
+ def get_ruby_pc_name
98
+ return 'ruby.pc' unless ruby_src_path
99
+
100
+ command = [
101
+ ruby_bin,
102
+ '-e',
103
+ "'puts RbConfig::CONFIG[\"ruby_pc\"]'",
104
+ ].join(' ')
105
+
106
+ exec_command command, 'get ruby.pc name', true
75
107
  end
76
108
 
77
109
  def valid?
@@ -108,7 +140,7 @@ module Kompo
108
140
  "--disable-install-capi",
109
141
  "--with-static-linked-ext",
110
142
  "--with-ruby-pc=ruby.pc",
111
- "--with-ext=#{get_exts_dir}"
143
+ "--with-ext=#{get_ruby_exts_dir}"
112
144
  ].join(' ')
113
145
  exec_command command, 'configure'
114
146
 
@@ -139,7 +171,7 @@ module Kompo
139
171
  command = [
140
172
  './bundler',
141
173
  'install',
142
- '--standalone'
174
+ "--standalone=#{use_group}",
143
175
  ].join(' ')
144
176
 
145
177
  exec_command command, 'bundle install'
@@ -165,33 +197,50 @@ module Kompo
165
197
  require 'erb'
166
198
 
167
199
  exts = []
168
- Dir.glob(File.join(bundle_ruby, get_semantic_ruby_version, 'gems/**/extconf.rb')).each do |makefile_dir|
169
- dir_name = File.dirname(makefile_dir)
170
- makefile = File.join(dir_name, 'Makefile')
171
- if File.exist?(cargo_toml = File.join(dir_name, 'Cargo.toml'))
172
- command = [
173
- 'cargo',
174
- 'rustc',
175
- '--release',
176
- '--crate-type=staticlib',
177
- '--target-dir',
178
- 'target',
179
- "--manifest-path=#{cargo_toml}",
180
- ].join(' ')
181
- exec_command command, 'cargo build'
182
- copy_targets = Dir.glob(File.join(dir_name, 'target/release/*.a'))
183
- else
184
- objs = File.read(makefile).scan(/OBJS = (.*\.o)/).join(' ')
185
- command = ['make', '-C', dir_name, objs, '--always-make'].join(' ')
186
- exec_command command, 'make'
187
- copy_targets = objs.split(' ').map { File.join(dir_name, _1) }
200
+ if gemfile
201
+ Dir.glob(File.join(bundle_ruby, get_semantic_ruby_version, 'gems/**/extconf.rb')).each do |makefile_dir|
202
+ dir_name = File.dirname(makefile_dir)
203
+ makefile = File.join(dir_name, 'Makefile')
204
+ if File.exist?(cargo_toml = File.join(dir_name, 'Cargo.toml'))
205
+ command = [
206
+ 'cargo',
207
+ 'rustc',
208
+ '--release',
209
+ '--crate-type=staticlib',
210
+ '--target-dir',
211
+ 'target',
212
+ "--manifest-path=#{cargo_toml}",
213
+ ].join(' ')
214
+ exec_command command, 'cargo build'
215
+ copy_targets = Dir.glob(File.join(dir_name, 'target/release/*.a'))
216
+ else
217
+ copy_targets = []
218
+ Dir.chdir(dir_name) {|path|
219
+ command = [
220
+ ruby_bin,
221
+ 'extconf.rb',
222
+ ].join(' ')
223
+
224
+ exec_command command, 'ruby extconf.rb'
225
+
226
+ objs = File.read('./Makefile').match(/OBJS = (.*\.o)/)[1]
227
+
228
+ command = ['make', objs, '--always-make'].join(' ')
229
+
230
+ exec_command command, 'make OBJS'
231
+
232
+ @exts_libs += File.read('./Makefile').match(/^libpath = (.*)/)[1].split(' ')
233
+
234
+ copy_targets = objs.split(' ').map { File.join(dir_name, _1) }
235
+ }
236
+ end
237
+
238
+ dir = FileUtils.mkdir_p('exts/' + File.basename(dir_name)).first
239
+ FileUtils.cp(copy_targets, dir)
240
+ prefix = File.read(makefile).scan(/target_prefix = (.*)/).join.delete_prefix('/')
241
+ target_name = File.read(makefile).scan(/TARGET_NAME = (.*)/).join
242
+ exts << [File.join(prefix, "#{target_name}.so").delete_prefix('/'), "Init_#{target_name}"]
188
243
  end
189
-
190
- dir = FileUtils.mkdir_p('exts/' + File.basename(dir_name)).first
191
- FileUtils.cp(copy_targets, dir)
192
- prefix = File.read(makefile).scan(/target_prefix = (.*)/).join.delete_prefix('/')
193
- target_name = File.read(makefile).scan(/TARGET_NAME = (.*)/).join
194
- exts << [File.join(prefix, "#{target_name}.so").delete_prefix('/'), "Init_#{target_name}"]
195
244
  end
196
245
 
197
246
  File.write("main.c", ERB.new(File.read(File.join(__dir__, 'main.c.erb'))).result(binding))
@@ -202,16 +251,19 @@ module Kompo
202
251
  'gcc',
203
252
  '-O3',
204
253
  '-Wall',
205
- 'main.c',
206
- 'exts/**/*.o',
207
- 'fs.o',
254
+ get_ruby_header,
208
255
  "#{lib_ruby_static_dir.nil? ? '' : '-L' + lib_ruby_static_dir}",
209
256
  "#{lib_kompo_dir.nil? ? '' : '-L' + lib_kompo_dir}",
210
- get_ruby_header,
211
- get_exts,
257
+ "#{exts_libs.uniq.select{_1.start_with?('/')}.map{"-L#{_1}"}.join(' ')}",
258
+ 'main.c',
259
+ '-Wl,--start-group',
260
+ Dir.glob('exts/**/*.o').join(' '),
261
+ 'fs.o',
262
+ get_ruby_exts,
212
263
  '-lkompo',
213
264
  '-lruby-static',
214
265
  get_libs,
266
+ '-Wl,--end-group',
215
267
  '-o',
216
268
  output
217
269
  ].join(' ')
@@ -241,16 +293,37 @@ module Kompo
241
293
  end
242
294
  end
243
295
 
244
- def get_exts
245
- ["#{extinit_o}", "#{encinit_o}", *Dir.glob("#{ruby_src_dir}/ext/**/*.a"), *Dir.glob("#{ruby_src_dir}/enc/**/*.a")].join(' ')
296
+ def get_ruby_exts
297
+ ["#{extinit_o}", "#{encinit_o}", *(Dir.glob("#{ruby_src_dir}/ext/**/*.a") - ignore_stdlib_archives), *Dir.glob("#{ruby_src_dir}/enc/**/*.a")].join(' ')
298
+ end
299
+
300
+ def ignore_stdlib_archives
301
+ if ruby_src_path
302
+ ignore_stdlib.map do |stdlib|
303
+ File.join(ruby_src_path, 'ext', stdlib, File.basename(stdlib) + '.a')
304
+ end
305
+ else
306
+ []
307
+ end
308
+ end
309
+
310
+ def extract_gem_libs
311
+ Dir.glob("bundle/ruby/#{get_semantic_ruby_version}/gems/*/ext/*/Makefile")
312
+ .flat_map{ File.read(_1)
313
+ .scan(/^LIBS = (.*)/)[0] }
314
+ .flat_map { _1.split(' ') }
315
+ .uniq
316
+ .flat_map { _1.start_with?("-l") ? _1 : "-l" + File.basename(_1, '.a').delete_prefix('lib') }
317
+ .join(" ")
246
318
  end
247
319
 
248
320
  def get_libs
249
321
  main_lib = get_mainlibs
250
322
  ext_libs = Dir.glob("#{ruby_src_dir}/ext/**/exts.mk").flat_map { File.read(_1).scan(/EXTLIBS = (.*)/) }.join(" ")
251
- gem_libs = Dir.glob("bundle/ruby/#{get_semantic_ruby_version}/gems/*/ext/*/Makefile").flat_map{ File.read(_1).scan(/LIBS = (.*)/)}.join(" ")
323
+ gem_libs = extract_gem_libs
324
+ dyn_link_libs = (['pthread', 'dl', 'm', 'c'] + dyn_link_lib).map { "-l" + _1 }
252
325
  dyn, static = eval("%W[#{main_lib} #{ext_libs} #{gem_libs}]").uniq
253
- .partition { _1 == "-lpthread" || _1 == "-ldl" || _1 == "-lm" || _1 == "-lc" }
326
+ .partition { dyn_link_libs.include?(_1) }
254
327
  dyn.unshift "-Wl,-Bdynamic"
255
328
  static.unshift "-Wl,-Bstatic"
256
329
 
@@ -275,24 +348,22 @@ module Kompo
275
348
  load_paths += gem_libs
276
349
  end
277
350
 
278
- if stdlib
279
- load_paths += std_libs
280
- end
351
+ load_paths += std_libs
281
352
 
282
353
  load_paths
283
354
  end
284
355
 
285
- def get_exts_dir
356
+ def get_ruby_exts_dir
286
357
  Dir.glob("#{ruby_src_dir}/**/extconf.rb")
287
358
  .reject { _1 =~ /-test-/ }
288
359
  .reject { _1 =~ /win32/ } # TODO
289
360
  .map { File.dirname(_1) }
290
361
  .map { _1.split("#{ruby_src_dir}/ext/")[1] }
362
+ .reject { ignore_stdlib.include?(_1) }
291
363
  .join(',')
292
364
  end
293
365
 
294
366
  def std_libs
295
- return [] unless stdlib
296
367
  return @std_libs unless @std_libs.empty?
297
368
 
298
369
  command = ["#{ruby_bin}", '-e', "'puts $:'"].join(' ')
data/lib/main.c.erb CHANGED
@@ -1,5 +1,4 @@
1
1
  #include <ruby.h>
2
- #include <string.h>
3
2
 
4
3
  extern char *get_kompo_patch(void);
5
4
  extern void ruby_init_ext(const char *name, void (*init)(void));
@@ -14,14 +13,21 @@ void Init_gems(void)
14
13
  ruby_init_ext("<%= so_path %>", <%= func %>);
15
14
  <% end %>
16
15
  }
16
+ <% ignore_stdlib.each do |stdlib|%>
17
+ void <%= "Init_#{stdlib.gsub('/', '_')}" %>(void){}
18
+ <% end %>
17
19
 
18
20
  int main(int argc, char **argv)
19
21
  {
20
- int c = 3;
22
+ int c = argc + 2;
23
+ char *argv2[c];
21
24
 
22
- // HACK: argv[0] is rewritten and reused by setproctitle()
23
- argv[1] = "-e";
24
- argv[2] = get_kompo_patch();
25
+ argv2[0] = argv[0];
26
+ argv2[1] = "-e";
27
+ argv2[2] = get_kompo_patch();
28
+ for (int i = 1; i < argc; i++) {
29
+ argv2[i + 2] = argv[i];
30
+ }
25
31
 
26
32
  ruby_sysinit(&c, &argv);
27
33
 
@@ -31,7 +37,7 @@ int main(int argc, char **argv)
31
37
  Init_kompo_fs();
32
38
  Init_gems();
33
39
 
34
- void *node = ruby_options(c, argv);
40
+ void *node = ruby_options(c, argv2);
35
41
 
36
42
  // set $0
37
43
  ruby_script(get_start_file_name());
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kompo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sho Hirano
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-04-21 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2024-05-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: mini_portile2
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  description: A tool to pack Ruby and Ruby scripts in one binary. This tool is still
14
28
  under development.
15
29
  email:
@@ -30,10 +44,6 @@ files:
30
44
  - lib/kompo/kompo_fs.rb
31
45
  - lib/kompo/version.rb
32
46
  - lib/main.c.erb
33
- - sample/Gemfile
34
- - sample/Gemfile.lock
35
- - sample/hello.rb
36
- - sample/main.rb
37
47
  - sig/kompo.rbs
38
48
  homepage: https://github.com/ahogappa0613/kompo
39
49
  licenses: []
data/sample/Gemfile DELETED
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source "https://rubygems.org"
4
-
5
- gem 'sinatra'
6
- gem 'sqlite3', force_ruby_platform: true
7
- gem 'puma'
8
- gem 'rackup'
data/sample/Gemfile.lock DELETED
@@ -1,48 +0,0 @@
1
- GEM
2
- remote: https://rubygems.org/
3
- specs:
4
- base64 (0.2.0)
5
- mini_portile2 (2.8.5)
6
- mustermann (3.0.0)
7
- ruby2_keywords (~> 0.0.1)
8
- nio4r (2.7.0)
9
- puma (6.4.2)
10
- nio4r (~> 2.0)
11
- rack (3.0.9.1)
12
- rack-protection (4.0.0)
13
- base64 (>= 0.1.0)
14
- rack (>= 3.0.0, < 4)
15
- rack-session (2.0.0)
16
- rack (>= 3.0.0)
17
- rackup (2.1.0)
18
- rack (>= 3)
19
- webrick (~> 1.8)
20
- ruby2_keywords (0.0.5)
21
- sinatra (4.0.0)
22
- mustermann (~> 3.0)
23
- rack (>= 3.0.0, < 4)
24
- rack-protection (= 4.0.0)
25
- rack-session (>= 2.0.0, < 3)
26
- tilt (~> 2.0)
27
- sqlite3 (1.7.2)
28
- mini_portile2 (~> 2.8.0)
29
- tilt (2.3.0)
30
- webrick (1.8.1)
31
-
32
- PLATFORMS
33
- aarch64-linux
34
- arm-linux
35
- arm64-darwin
36
- ruby
37
- x86-linux
38
- x86_64-darwin
39
- x86_64-linux
40
-
41
- DEPENDENCIES
42
- puma
43
- rackup
44
- sinatra
45
- sqlite3
46
-
47
- BUNDLED WITH
48
- 2.5.3
data/sample/hello.rb DELETED
@@ -1,3 +0,0 @@
1
- module Hello
2
- World = "Hello, World!"
3
- end
data/sample/main.rb DELETED
@@ -1,33 +0,0 @@
1
- require 'sqlite3'
2
- require 'sinatra'
3
-
4
- require_relative './hello'
5
-
6
- File.delete("sample.db") if File.exist?("sample.db")
7
-
8
- db = SQLite3::Database.new "sample.db"
9
-
10
- rows = db.execute <<-SQL
11
- create table numbers (
12
- name varchar(30),
13
- val int
14
- );
15
- SQL
16
-
17
- {
18
- "one" => 1,
19
- "two" => 2,
20
- }.each do |pair|
21
- db.execute "insert into numbers values ( ?, ? )", pair
22
- end
23
-
24
- set :bind, '0.0.0.0'
25
-
26
- get '/' do
27
- rows = db.execute 'select * from numbers;'
28
- rows.to_s
29
- end
30
-
31
- get '/hello' do
32
- Hello::World
33
- end