runa 0.1.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: 0a644cf437951c516a29f5c014f909dd97aa2dc29e3ab955dd66964b43eb1e32
4
- data.tar.gz: 80ec546ad6eda45bfc4b52f78cb4103b93d08dd93a417670dc28a8999dfdc6f5
3
+ metadata.gz: fe8ddbd576436a3027eab72ac6c6dd8b06abd9478b79db9e770f6b35f7c046fa
4
+ data.tar.gz: 53446e3a8c1d0ad7e2036b89bf8916ffb47f67b34c725b6b86745dba46947de8
5
5
  SHA512:
6
- metadata.gz: cb5fcbc25e03d3a5c896c73cc363ddb1e4ecfdc0df52e44fe6404f04e3601ffa6ab127ffa8d0c8a557fe9fc1ac695201f6eb7f8ac950e3bef8206e2f9eba301e
7
- data.tar.gz: f69d6620ce222401370c20b3bb70eb1857cbee9843d97eb00eecf015464d1b2fc219f4112bd29a78334baff4d66f5c911034026d766b35f26de700ff576ce00b
6
+ metadata.gz: 7ec89be51ba7b7f6e3f8dab32857a25ac84e0c2c45c147ce31505bf4fd97bcb421355836927177ad8c5756189708c7e6eb01ad343494d40c0533aacfa9635fc3
7
+ data.tar.gz: dc9d62f052f7fbdf8a8781b18d4d3e1b80b438f4373a768054b68afab1fd2633861f4c7eadf99e49c7eb6c010f1ffe0698d98b56f3a4491c395676b5ae5c1606
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
- ## [Unreleased]
1
+ ## [0.3.0] - 2023-06-13
2
+ - Rename release command to generate(gen)
3
+ - Support Mac/Linux/WSL
4
+
5
+ ## [0.2.0] - 2023-05-29
6
+ - Add subcommand release
2
7
 
3
8
  ## [0.1.0] - 2023-05-16
4
9
 
5
10
  - Initial release
11
+ - Add subcommands new, instal, and run
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/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2023 ongaeshi
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,31 +1,65 @@
1
1
  # Runa
2
2
 
3
- TODO: Delete this and the text below, and describe your gem
3
+ Runa is a command line interface for easily creating Ruby applications.
4
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/runa`. To experiment with that code, run `bin/console` for an interactive prompt.
5
+ ## Install
6
6
 
7
- ## Installation
7
+ ```
8
+ $ gem install runa
9
+ ```
8
10
 
9
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
11
+ ## Usage
10
12
 
11
- Install the gem and add to the application's Gemfile by executing:
13
+ Create a new application.
12
14
 
13
- $ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
15
+ ```
16
+ $ runa new runa_app
17
+ $ cd runa_app
18
+ ```
14
19
 
15
- If bundler is not being used to manage dependencies, install the gem by executing:
20
+ If you need a gem, Write it in the `Gemfile`.
16
21
 
17
- $ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
22
+ ```
23
+ $ code Gemfile
24
+ $ runa install
25
+ ```
18
26
 
19
- ## Usage
27
+ Run application.
28
+
29
+ ```
30
+ $ runa run
31
+ Hello, World!
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
+ ```
20
50
 
21
- TODO: Write usage instructions here
51
+ Windows
22
52
 
23
- ## Development
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.
24
58
 
25
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test-unit` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
59
+ PS> cp .runa\runa_app.bat path\to\bin
26
60
 
27
- 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).
61
+ PS> runa_app
62
+ Hello, world!
63
+ ```
28
64
 
29
- ## Contributing
30
65
 
31
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/runa.
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")
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"
@@ -40,6 +44,56 @@ class RunaCli < Thor
40
44
  system("bundle exec ruby -Ilib main.rb #{args.join(" ")}")
41
45
  end
42
46
  map "run" => "run_command"
47
+
48
+ desc "generate", "Generate scripts for production execution"
49
+ def generate
50
+ root_dir = File.expand_path(".")
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."
57
+ end
58
+ map "gen" => "generate"
59
+
60
+ private
61
+
62
+ RUNA_DIR = ".runa"
63
+
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
85
+
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}'"
90
+ end
91
+
92
+ def load_path_script
93
+ str = `bundle exec ruby -e 'puts \$LOAD_PATH.grep(/vendor\\/bundle/)'`
94
+ paths = str.split("\n").map { |e| "\"#{e}\"" }.join(",")
95
+ "$LOAD_PATH.unshift(#{paths})\n"
96
+ end
43
97
  end
44
98
 
45
99
  RunaCli.start(ARGV)
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.1.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.1.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-15 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
@@ -36,6 +36,7 @@ files:
36
36
  - CHANGELOG.md
37
37
  - Gemfile
38
38
  - Gemfile.lock
39
+ - LICENSE.txt
39
40
  - README.md
40
41
  - Rakefile
41
42
  - exe/runa