ikura 0.1.1 → 0.1.3

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: 1bb2349181cc4df0d6b283dd60cad31479b35fa9aaa4fd2706857e05ffe6aec8
4
- data.tar.gz: 42630b8463ae9d1831526b6d848bf02e203efb7c56cc9ab6d2cd11345d05426a
3
+ metadata.gz: 27ea4f15f5d757982da5a10c5ba6db1beb33f513a7c5d090620ef394d94b5809
4
+ data.tar.gz: 2d5715f538c5a17c280d5e835b7e595e26c66c61b9fbd0a9cb802841910035cb
5
5
  SHA512:
6
- metadata.gz: 1e69c4800ad5ab641ce70548356e9d83119b7b88d7bce07bae3dd6475f4921d64d4783bef0db92a8ff855265bf70ca63cbe41bba2fc2f0ca43062654e52a3479
7
- data.tar.gz: 24cbd3a99b3c9505bd9d4ca0c77155e206ae000ffdc35014245e564f9ae1fee17b6cdde1dbbccc8d442e9b253b888ed914a4347a12cc9697de8133a26c4e63c2
6
+ metadata.gz: 0e46675b168bc8742dd70c8b8f8e95eabc7c14ff6956b57f4bf8c16d9077203174dace70dbd5067a021b3b0f450cfe80de8bd1d461955531464d1383f9710519
7
+ data.tar.gz: c763414b5806929473ddea510a120b673e8381c17ed4d14486b026fbe6f945531c4416e43f1912ba6f9753d4c9df6f129d15eb9be7f2fc1fef662856332ee026
data/CHANGELOG.md CHANGED
@@ -1,6 +1,34 @@
1
1
  # Changelog
2
2
 
3
- ## [0.1.0] - 2026-04-04
3
+ ## [0.1.3] - 2026-04-21
4
+
5
+ ### Added
6
+
7
+ - Auto-open browser when the server starts
8
+
9
+ ## [0.1.2] - 2026-04-21
10
+
11
+ ### Changed
12
+
13
+ - Rename `COORDS`/`coord` to `IKURA_POINTS`/`ikura_point` for clarity
14
+ - Adjust `IKURA_POINTS` coordinates and randomization range for better placement
15
+
16
+ ### Fixed
17
+
18
+ - Remove `pointer-events` from gunkan/gunkan-top styles so clicks register correctly
19
+
20
+ ## [0.1.1] - 2026-04-04
21
+
22
+ ### Added
23
+
24
+ - MIT license
25
+ - Clickable URL in server output for quick access to the local server
26
+
27
+ ### Changed
28
+
29
+ - Clean up gemspec and update gem description/metadata for RubyGems release
30
+
31
+ ## [0.1.0] - 2026-04-02
4
32
 
5
33
  ### Added
6
34
 
data/lib/ikura/server.rb CHANGED
@@ -12,12 +12,13 @@ module Ikura
12
12
  new(port:).run
13
13
  end
14
14
 
15
- COORDS = [
15
+ IKURA_POINTS = [
16
16
  [50, 50], [35, 50], [65, 50], [20, 50], [80, 50],
17
17
  [50, 15], [35, 22], [65, 22], [20, 35], [80, 35],
18
- [50, 85], [35, 78], [65, 78], [20, 65], [80, 65],
19
- [10, 50], [90, 50],
20
- [50, 30], [50, 70], [28, 38], [72, 38], [28, 62], [72, 62],
18
+ [50, 8], [42, 12], [58, 12], [28, 18], [72, 18],
19
+ [12, 28], [88, 28], [50, 85], [35, 78], [65, 78],
20
+ [20, 65], [80, 65], [10, 50], [90, 50], [72, 62],
21
+ [50, 30], [50, 70], [28, 38], [72, 38], [28, 62],
21
22
  ].freeze
22
23
 
23
24
  def initialize(port: 8080)
@@ -28,8 +29,10 @@ module Ikura
28
29
  def run
29
30
  server = TCPServer.new(@port)
30
31
  $stdout.sync = true
31
- puts "🍣 http://localhost:#{@port}"
32
+ url = "http://localhost:#{@port}"
33
+ puts "🍣 #{terminal_link(url)}"
32
34
  puts " (Ctrl+C to stop)\n\n"
35
+ system("open", url) if RUBY_PLATFORM.include?("darwin")
33
36
 
34
37
  loop do
35
38
  client = server.accept
@@ -47,18 +50,24 @@ module Ikura
47
50
 
48
51
  private
49
52
 
53
+ def terminal_link(url, label = url)
54
+ return label unless $stdout.tty?
55
+
56
+ "\e]8;;#{url}\a#{label}\e]8;;\a"
57
+ end
58
+
50
59
  def handle(client, req)
51
60
  case [req[:method], req[:path]]
52
61
  in ["GET", "/"]
53
62
  respond(client, type: "text/html; charset=utf-8", body: html_page)
54
63
  in ["POST", "/ikura"]
55
- coord_idx = parse_form(req[:body])["coord"]&.to_i || 0
56
- x, y = COORDS[coord_idx] || [50, 50]
64
+ ikura_point_idx = parse_form(req[:body])["ikura_point"]&.to_i || 0
65
+ x, y = IKURA_POINTS[ikura_point_idx] || [50, 50]
57
66
  id = @ikura_count
58
67
  @ikura_count += 1
59
68
 
60
- jx = (x + rand(-8..8)).clamp(5, 95)
61
- jy = (y + rand(-8..8)).clamp(5, 95)
69
+ jx = (x + rand(-10..10))
70
+ jy = (y + rand(-10..10))
62
71
 
63
72
  respond(client,
64
73
  type: "text/vnd.turbo-stream.html; charset=utf-8",
@@ -72,8 +81,8 @@ module Ikura
72
81
  end
73
82
 
74
83
  def html_page
75
- coords_html = COORDS.each_with_index.map { |(x, y), i|
76
- "<div class='coord' style='left:#{x}%;top:#{y}%'></div>"
84
+ ikura_points_html = IKURA_POINTS.each_with_index.map { |(x, y), i|
85
+ "<div class='ikura_point' style='left:#{x}%;top:#{y}%'></div>"
77
86
  }.join("\n")
78
87
 
79
88
  ERB.new(File.read(TEMPLATE_PATH)).result(binding)
@@ -7,11 +7,10 @@
7
7
  import { DefaultRubyVM } from "https://cdn.jsdelivr.net/npm/@ruby/wasm-wasi@2.8.1/dist/browser/+esm";
8
8
  const res = await fetch("https://cdn.jsdelivr.net/npm/@ruby/4.0-wasm-wasi@2.8.1/dist/ruby+stdlib.wasm");
9
9
  const { vm } = await DefaultRubyVM(await WebAssembly.compileStreaming(res));
10
- window.rubyVM = vm;
11
10
  vm.eval(`
12
11
  require "js"
13
12
  doc = JS.global[:document]
14
- nodes = doc.call(:querySelectorAll, ".coord")
13
+ nodes = doc.call(:querySelectorAll, ".ikura_point")
15
14
  nodes[:length].to_i.times do |i|
16
15
  node = nodes.call(:item, i)
17
16
  node[:style][:opacity] = "1"
@@ -19,7 +18,7 @@ nodes[:length].to_i.times do |i|
19
18
  opts = JS.eval("return {
20
19
  method: 'POST',
21
20
  headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
22
- body: 'coord=#{i}'
21
+ body: 'ikura_point=#{i}'
23
22
  }")
24
23
  JS.global.fetch("/ikura", opts).call(:then, ->(response) {
25
24
  response.text().call(:then, ->(text) {
@@ -61,7 +60,6 @@ end
61
60
  border-radius: 50% / 20%;
62
61
  box-shadow: inset 0 -10px 20px rgba(0,0,0,0.5);
63
62
  z-index: 10;
64
- pointer-events: none;
65
63
  }
66
64
  .gunkan-top {
67
65
  position: absolute;
@@ -71,12 +69,11 @@ end
71
69
  border-radius: 50%;
72
70
  }
73
71
 
74
- .coord {
72
+ .ikura_point {
75
73
  position: absolute;
76
74
  transform: translate(-50%, -50%);
77
75
  width: 16px; height: 16px;
78
76
  cursor: crosshair;
79
- pointer-events: all;
80
77
  opacity: 0;
81
78
  }
82
79
 
@@ -104,11 +101,10 @@ end
104
101
  <div id="board">
105
102
  <div class="gunkan">
106
103
  <div class="gunkan-top">
107
- <%= coords_html %>
104
+ <%= ikura_points_html %>
108
105
  <ul id="ikura-layer"></ul>
109
106
  </div>
110
107
  </div>
111
108
  </div>
112
-
113
109
  </body>
114
110
  </html>
data/lib/ikura/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ikura
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ikura
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - haruna-tsujita