runa 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 260b2cf570fb222aa1a71e6bd9eb44bd08194b878f11c9f58a80267e8fd49a58
4
- data.tar.gz: 9c8ed4bc10a3013ea7d04bacdbb3eb039dc6503f6d2b3e58226ee698b11d36bd
3
+ metadata.gz: fe8ddbd576436a3027eab72ac6c6dd8b06abd9478b79db9e770f6b35f7c046fa
4
+ data.tar.gz: 53446e3a8c1d0ad7e2036b89bf8916ffb47f67b34c725b6b86745dba46947de8
5
5
  SHA512:
6
- metadata.gz: ff244c05be35715fa140c7b9f5e800e295d07ac33c57cffe19ee9fd6f485bda88118dffedbfb4b9ed8d90e6a33c931331a40dd8449b2baa5dd3a5e7b89ac6971
7
- data.tar.gz: 81ffcabaa804a8654966790ce260aabe41ee044587bdc33e10184062dfa0ed5063ebb2911e065afb3af2645e2071921eba533f28c63fa64ba98227f7c703eaef
6
+ metadata.gz: 7ec89be51ba7b7f6e3f8dab32857a25ac84e0c2c45c147ce31505bf4fd97bcb421355836927177ad8c5756189708c7e6eb01ad343494d40c0533aacfa9635fc3
7
+ data.tar.gz: dc9d62f052f7fbdf8a8781b18d4d3e1b80b438f4373a768054b68afab1fd2633861f4c7eadf99e49c7eb6c010f1ffe0698d98b56f3a4491c395676b5ae5c1606
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [0.3.0] - 2023-06-13
2
+ - Rename release command to generate(gen)
3
+ - Support Mac/Linux/WSL
4
+
1
5
  ## [0.2.0] - 2023-05-29
2
6
  - Add subcommand release
3
7
 
data/Gemfile CHANGED
@@ -10,3 +10,5 @@ gem "rake", "~> 13.0"
10
10
  gem "test-unit", "~> 3.0"
11
11
 
12
12
  gem "standard", "~> 1.3"
13
+
14
+ gem "os", "~> 1.1"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- runa (0.1.0)
4
+ runa (0.2.0)
5
5
  thor
6
6
 
7
7
  GEM
@@ -11,6 +11,7 @@ GEM
11
11
  json (2.6.3)
12
12
  language_server-protocol (3.17.0.3)
13
13
  lint_roller (1.0.0)
14
+ os (1.1.4)
14
15
  parallel (1.23.0)
15
16
  parser (3.2.2.1)
16
17
  ast (~> 2.4.1)
@@ -53,8 +54,10 @@ GEM
53
54
 
54
55
  PLATFORMS
55
56
  x64-mingw-ucrt
57
+ x86_64-linux
56
58
 
57
59
  DEPENDENCIES
60
+ os (~> 1.1)
58
61
  rake (~> 13.0)
59
62
  runa!
60
63
  standard (~> 1.3)
data/README.md CHANGED
@@ -28,4 +28,38 @@ Run application.
28
28
 
29
29
  ```
30
30
  $ runa run
31
+ Hello, World!
31
32
  ```
33
+
34
+ Generate scripts for production execution.
35
+
36
+ Mac/Linux/WSL
37
+
38
+ ```
39
+ $ runa gen
40
+ Generate '.runa/runa_app'
41
+ '.runa/runa_app' is the script to run. Copy it to any location and use it.
42
+
43
+ $ chmod +x .runa/runa_app
44
+
45
+ $ cp .runa/runa_app path/to/bin
46
+
47
+ $ runa_app
48
+ Hello, World!
49
+ ```
50
+
51
+ Windows
52
+
53
+ ```
54
+ PS> runa gen
55
+ Generate '.runa/runa_load_path.rb'
56
+ Generate '.runa/runa_app.bat'
57
+ '.runa/runa_app.bat' is the script to run. Copy it to any location and use it.
58
+
59
+ PS> cp .runa\runa_app.bat path\to\bin
60
+
61
+ PS> runa_app
62
+ Hello, world!
63
+ ```
64
+
65
+
data/exe/runa CHANGED
@@ -3,6 +3,7 @@
3
3
  require "runa"
4
4
  require "thor"
5
5
  require "fileutils"
6
+ require "os"
6
7
 
7
8
  class RunaCli < Thor
8
9
  def self.exit_on_failure?
@@ -19,12 +20,14 @@ class RunaCli < Thor
19
20
 
20
21
  FileUtils.mkdir_p(name)
21
22
  Dir.chdir(name) do
23
+ FileUtils.mkdir_p(RUNA_DIR)
24
+ File.write("#{RUNA_DIR}/.gitkeep", "")
22
25
  FileUtils.mkdir_p(".bundle")
23
26
  File.write(".bundle/config", "---\nBUNDLE_PATH: \"vendor/bundle\"\n")
24
27
  FileUtils.mkdir_p("lib/#{name}")
25
28
  File.write("lib/#{name}.rb", "require \"#{name}/lib\"\n")
26
29
  File.write("lib/#{name}/lib.rb", "module #{module_name}\nend\n")
27
- File.write(".gitignore", "/vendor/\n/.runa/\n")
30
+ File.write(".gitignore", "/vendor/\n/.runa/*\n!/.runa/.gitkeep\n")
28
31
  File.write("Gemfile", "# frozen_string_literal: true\n\nsource \"https://rubygems.org\"\n\n# gem \"rails\"\n")
29
32
  File.write("main.rb", "require \"#{name}\"\n\nputs \"Hello, world!\"")
30
33
  end
@@ -33,6 +36,7 @@ class RunaCli < Thor
33
36
  desc "install", "Install gems"
34
37
  def install
35
38
  system("bundle install")
39
+ generate_load_path_script
36
40
  end
37
41
 
38
42
  desc "run [ARGS]", "Run application with arguments"
@@ -41,33 +45,48 @@ class RunaCli < Thor
41
45
  end
42
46
  map "run" => "run_command"
43
47
 
44
- desc "release", "Release scripts for production execution"
45
- def release
48
+ desc "generate", "Generate scripts for production execution"
49
+ def generate
46
50
  root_dir = File.expand_path(".")
47
- release_script_name = File.basename(root_dir)
48
- FileUtils.mkdir_p(RUNA_DIR)
49
- Dir.chdir(RUNA_DIR) do
50
- File.write("runa_load_path.rb", load_path_script)
51
- path = "#{release_script_name}.bat"
52
- File.write(path, release_script(root_dir))
53
- puts "'#{File.join(root_dir, RUNA_DIR, path)}' generated. It can be copied to any location."
54
- end
51
+ generate_script_name = File.basename(root_dir)
52
+ generate_load_path_script
53
+ path = File.join(RUNA_DIR, generate_script_name)
54
+ path += ".bat" if OS.windows?
55
+ File.write(path, generate_script(root_dir))
56
+ puts "Generate '#{path}'\n'#{path}' is the script to run. Copy it to any location and use it."
55
57
  end
58
+ map "gen" => "generate"
56
59
 
57
60
  private
58
61
 
59
62
  RUNA_DIR = ".runa"
60
63
 
61
- def release_script(root_dir)
62
- # TODO: Linux
63
- lib_dir = File.join(root_dir, "lib").tr("/", "\\")
64
- runa_dir = File.join(root_dir, RUNA_DIR).tr("/", "\\")
65
- main_rb = File.join(root_dir, "main.rb").tr("/", "\\")
64
+ def generate_script(root_dir)
65
+ lib_dir = File.join(root_dir, "lib")
66
+ runa_dir = File.join(root_dir, RUNA_DIR)
67
+ main_rb = File.join(root_dir, "main.rb")
68
+
69
+ if OS.windows?
70
+ lib_dir = lib_dir.tr("/", "\\")
71
+ runa_dir = runa_dir.tr("/", "\\")
72
+ main_rb = main_rb.tr("/", "\\")
73
+
74
+ <<~EOS
75
+ @ECHO OFF
76
+ @ruby -I"#{lib_dir}" -I"#{runa_dir}" -rruna_load_path #{main_rb} %*
77
+ EOS
78
+ else
79
+ <<~EOS
80
+ #!/bin/sh
81
+ ruby -I"#{lib_dir}" -I"#{runa_dir}" -rruna_load_path #{main_rb} $@
82
+ EOS
83
+ end
84
+ end
66
85
 
67
- <<~EOS
68
- @ECHO OFF
69
- @ruby -I"#{lib_dir}" -I"#{runa_dir}" -rruna_load_path #{main_rb} %*"
70
- EOS
86
+ def generate_load_path_script
87
+ path = "#{RUNA_DIR}/runa_load_path.rb"
88
+ File.write(path, load_path_script)
89
+ puts "Generate '#{path}'"
71
90
  end
72
91
 
73
92
  def load_path_script
data/lib/runa/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Runa
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runa
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
  - ongaeshi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-05-28 00:00:00.000000000 Z
11
+ date: 2023-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor