rocket_api 0.0.1.4 → 0.0.1.7
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 +4 -4
- data/README.md +7 -2
- data/bin/rocket_api +18 -16
- data/lib/rocket_api/commands/gems_dir.rb +11 -11
- data/lib/rocket_api/commands/helper.rb +25 -0
- data/lib/rocket_api/constants.rb +12 -6
- data/lib/rocket_api/errors.rb +0 -3
- data/lib/rocket_api/library/gem_repo_plain_text.rb +19 -0
- data/lib/rocket_api/library/helper_plain_text.rb +21 -0
- data/lib/rocket_api/rocket_commands.rb +18 -27
- data/lib/rocket_api/version.rb +1 -1
- data/lib/rocket_api.rb +1 -0
- data/rocket_api.gemspec +15 -15
- data/test/test_version.rb +1 -1
- metadata +12 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 37afe5384de38860240c2f361e0754b0f4c8a734be348f22979bab0d203ebf4a
|
4
|
+
data.tar.gz: 721db37f2bcc3a254def12a42938127da04d490dc5ac933198dbb23e37d14ea9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3aa07c310add8201f2016a2b10cd3ed5c41c95a402e86337446065d6f0a8cce5426ed88a92165a9814061dc3dab5b07bce9dd0f98c5efc926b7f702ac4bcaead
|
7
|
+
data.tar.gz: a65a88c575bb6def0000fe27764ac5ecfe415c1d1f9d1d3313fb2a461d910888c9cdbc09a6c82479bf98e656ab064dec1ec1e95947080309eb72983916182b5c
|
data/README.md
CHANGED
@@ -13,6 +13,11 @@ gem 'rubocop' '1.26'
|
|
13
13
|
gem install rocket_api
|
14
14
|
```
|
15
15
|
## How it works:
|
16
|
-
```sh
|
17
|
-
|
16
|
+
```sh
|
17
|
+
Availble commands:
|
18
|
+
- init
|
19
|
+
- gem [ project_name ]
|
20
|
+
In working directory:
|
21
|
+
|
22
|
+
user@bulkas ~/gem/new_dir rocket_api [ init ] [ gem ] [ project_name ]
|
18
23
|
```
|
data/bin/rocket_api
CHANGED
@@ -2,25 +2,27 @@
|
|
2
2
|
|
3
3
|
require "rocket_api"
|
4
4
|
|
5
|
-
base_command = ARGV[0]
|
6
|
-
sub_command
|
7
|
-
project_name = ARGV[2]
|
5
|
+
base_command = ARGV[0]&.gsub(RocketApi::REGEXP_VALID, '')&.downcase
|
6
|
+
sub_command = ARGV[1]&.gsub(RocketApi::REGEXP_VALID, '')&.downcase
|
7
|
+
project_name = ARGV[2]&.gsub(RocketApi::REGEXP_VALID, '')&.downcase
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
9
|
+
if [base_command, sub_command, project_name].map(&:nil?).any?
|
10
|
+
puts RocketApi::WRONG_RESPONSE
|
11
|
+
return
|
12
|
+
end
|
13
|
+
|
14
|
+
case
|
15
|
+
when RocketApi::AVAILABLE_COMMANDS.keys.include?(base_command&.to_sym)
|
16
|
+
if RocketApi::AVAILABLE_COMMANDS[base_command&.to_sym].keys.include?(sub_command&.to_sym)
|
17
|
+
RocketApi::AVAILABLE_COMMANDS[base_command&.to_sym][sub_command&.to_sym].each do |command|
|
18
|
+
RocketApi::RocketCommands.send(command, project_name: project_name)
|
19
|
+
rescue RocketApi::Error => e
|
20
|
+
puts "#{RocketApi::INIT_DIR_ERROR} #{e.message}"
|
21
|
+
return
|
20
22
|
end
|
21
23
|
else
|
22
|
-
puts RocketApi::
|
24
|
+
puts RocketApi::WRONG_RESPONSE
|
23
25
|
end
|
24
26
|
else
|
25
|
-
puts RocketApi::
|
27
|
+
puts RocketApi::WRONG_RESPONSE
|
26
28
|
end
|
@@ -2,30 +2,30 @@ module RocketApi
|
|
2
2
|
module Commands
|
3
3
|
module GemsDir
|
4
4
|
# @param [String] name
|
5
|
-
def
|
5
|
+
def gems_version!(name)
|
6
6
|
dir_name = "lib/#{name}"
|
7
7
|
create_dir(dir_name)
|
8
8
|
file_name = "#{dir_name}/version.rb"
|
9
|
-
create_single_file(
|
10
|
-
file_name,
|
11
|
-
plain_version_text(class_name_camel(name))
|
12
|
-
)
|
9
|
+
create_single_file(file_name, plain_version_text(class_name_camel(name)))
|
13
10
|
end
|
14
11
|
|
15
12
|
# @param [String] name
|
16
|
-
def
|
13
|
+
def gems_main_file!(name)
|
17
14
|
file_name = "lib/#{name}.rb"
|
18
15
|
text = "class #{class_name_camel(name)}; end"
|
19
16
|
create_single_file(file_name, text)
|
20
17
|
end
|
21
18
|
|
22
19
|
# @param [String] name
|
23
|
-
def
|
20
|
+
def gemspec!(name)
|
24
21
|
file_name = "#{name}.gemspec"
|
25
|
-
create_single_file(
|
26
|
-
|
27
|
-
|
28
|
-
|
22
|
+
create_single_file(file_name, plain_gemspec_text(name, class_name_camel(name)))
|
23
|
+
end
|
24
|
+
|
25
|
+
# @param [String] name
|
26
|
+
def gem_test!(name)
|
27
|
+
file_name = "test/test_version.rb"
|
28
|
+
create_single_file(file_name, plain_gem_test_version_text(name, class_name_camel(name)))
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module RocketApi
|
2
|
+
module Commands
|
3
|
+
module Helper
|
4
|
+
# @param [String] name
|
5
|
+
def bin!(name)
|
6
|
+
create_single_file("bin/#{name}", "", exe: true)
|
7
|
+
end
|
8
|
+
|
9
|
+
# @param [String] _name
|
10
|
+
def gitignore!(_name)
|
11
|
+
create_single_file(".gitignore", gitignore_text)
|
12
|
+
end
|
13
|
+
|
14
|
+
# @param [String] _name
|
15
|
+
def rake_file!(_name)
|
16
|
+
create_single_file("Rakefile", rake_text)
|
17
|
+
end
|
18
|
+
|
19
|
+
# @param [String] _name
|
20
|
+
def gem_file!(_name)
|
21
|
+
create_single_file("Gemfile", gemfile_text)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/rocket_api/constants.rb
CHANGED
@@ -1,19 +1,25 @@
|
|
1
1
|
module RocketApi
|
2
|
+
# Valid input
|
3
|
+
REGEXP_VALID = /[^0-9A-Za-z_-]/.freeze
|
4
|
+
|
2
5
|
# Dirs map
|
3
6
|
GEM_PROJECTS_DIR = %w[bin lib test].freeze
|
7
|
+
GEM_COMMANDS = %w[bin! gemspec! gems_main_file! gems_version! gem_test! rake_file! gitignore! gem_file!].freeze
|
8
|
+
AVAILABLE_COMMANDS = {
|
9
|
+
init: {
|
10
|
+
gem: %w[init_gem_dir init_gem_files]
|
11
|
+
}
|
12
|
+
}.freeze
|
4
13
|
|
5
14
|
# Ping
|
6
15
|
PONG = "PONG".freeze
|
7
16
|
|
8
|
-
# Commands
|
9
|
-
INIT = "init".freeze
|
10
|
-
BASE = "base".freeze
|
11
|
-
GEM = "gem".freeze
|
12
|
-
|
13
17
|
# Answers
|
18
|
+
INIT_DIR_ERROR = "Init directory error".freeze
|
19
|
+
GEM_DETECTED = "another one gem exist".freeze
|
14
20
|
FOLDER_EXIST = "folder exist:".freeze
|
15
21
|
FILE_EXIST = "file already exist:".freeze
|
16
|
-
|
22
|
+
WRONG_RESPONSE = "Wrong command".freeze
|
17
23
|
EMPTY_NAME = "Project name is empty".freeze
|
18
24
|
INIT_FAIL = "Init action fail:".freeze
|
19
25
|
CREATE_FAILED = "Create failed:".freeze
|
data/lib/rocket_api/errors.rb
CHANGED
@@ -30,8 +30,27 @@ module RocketApi
|
|
30
30
|
"\ts.email = 'AUTHOR_MAIL'",
|
31
31
|
"\ts.homepage = 'https://github.com/...'",
|
32
32
|
"\ts.files = `git ls-files`.split($RS)",
|
33
|
+
"\ts.add_dependency \"rubocop\"",
|
34
|
+
"\ts.add_dependency \"rubocop-rake\"",
|
33
35
|
"end"].join("\n")
|
34
36
|
end
|
37
|
+
|
38
|
+
def plain_gem_test_version_text(name, module_name)
|
39
|
+
["require 'minitest/autorun'",
|
40
|
+
"require '#{name}/version'\n",
|
41
|
+
"class TestVersion < Minitest::Test",
|
42
|
+
"\tinclude #{module_name}\n",
|
43
|
+
"\tdef test_ping",
|
44
|
+
"\t\tassert_equal(\"0.0.1\", #{module_name}::VERSION)",
|
45
|
+
"\tend",
|
46
|
+
"end"].join("\n")
|
47
|
+
end
|
48
|
+
|
49
|
+
def gemfile_text
|
50
|
+
["source 'https://rubygems.org/'",
|
51
|
+
"ruby 'RUBY_VERSION'",
|
52
|
+
"gemspec"].join("\n")
|
53
|
+
end
|
35
54
|
end
|
36
55
|
end
|
37
56
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module RocketApi
|
2
|
+
module Library
|
3
|
+
module HelperPlainText
|
4
|
+
def rake_text
|
5
|
+
["require 'rubygems'",
|
6
|
+
"require 'rake'\n",
|
7
|
+
"desc \"Run spec\"",
|
8
|
+
"task default: %i[test rubocop]\n",
|
9
|
+
"require 'rake/testtask'",
|
10
|
+
"Rake::TestTask.new do |test|",
|
11
|
+
"\ttest.libs << 'test'",
|
12
|
+
"end\n",
|
13
|
+
"require 'rubocop/rake_task'",
|
14
|
+
"RuboCop::RakeTask.new do |task|",
|
15
|
+
"\ttask.fail_on_error = true",
|
16
|
+
"\ttask.requires << 'rubocop-rake'",
|
17
|
+
"end"].join("\n")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -1,51 +1,42 @@
|
|
1
|
-
require "rocket_api/
|
1
|
+
require "rocket_api/commands/files"
|
2
|
+
require "rocket_api/commands/dirs"
|
3
|
+
require "rocket_api/commands/gems_dir"
|
4
|
+
require "rocket_api/commands/helper"
|
5
|
+
require "rocket_api/library/gem_repo_plain_text"
|
6
|
+
require "rocket_api/library/helper_plain_text"
|
2
7
|
|
3
8
|
module RocketApi
|
4
9
|
class RocketCommands
|
5
10
|
extend RocketApi::Commands::Files
|
6
11
|
extend RocketApi::Commands::Dirs
|
7
12
|
extend RocketApi::Commands::GemsDir
|
13
|
+
extend RocketApi::Commands::Helper
|
8
14
|
extend RocketApi::Library::GemRepoPlainText
|
15
|
+
extend RocketApi::Library::HelperPlainText
|
9
16
|
|
17
|
+
# @param [Hah] options
|
18
|
+
# ...
|
10
19
|
# @raise [RocketApi::CreateDirError]
|
11
|
-
def self.init_gem_dir
|
20
|
+
def self.init_gem_dir(**_options)
|
21
|
+
raise GEM_DETECTED unless Dir.glob("*.gemspec").empty?
|
22
|
+
|
12
23
|
create_repo(RocketApi::GEM_PROJECTS_DIR)
|
13
24
|
rescue StandardError => e
|
14
25
|
raise RocketApi::CreateDirError,
|
15
26
|
"#{RocketApi::CREATE_FAILED} #{e.message}"
|
16
27
|
end
|
17
28
|
|
18
|
-
# @param [
|
29
|
+
# @param [Hash] options
|
19
30
|
# ...
|
20
31
|
# @raise [RocketApi::InitFilesError] error
|
21
|
-
def self.init_gem_files(
|
22
|
-
raise RocketApi::EMPTY_NAME if project_name.nil?
|
32
|
+
def self.init_gem_files(**options)
|
33
|
+
raise RocketApi::EMPTY_NAME if options[:project_name].nil?
|
23
34
|
|
24
|
-
|
25
|
-
|
26
|
-
init_gems_main_file!(project_name)
|
27
|
-
init_gems_version!(project_name)
|
28
|
-
init_gitignore!
|
35
|
+
project_name = options[:project_name]
|
36
|
+
RocketApi::GEM_COMMANDS.each { |command| send(command, project_name) }
|
29
37
|
rescue StandardError => e
|
30
38
|
raise RocketApi::InitFilesError,
|
31
39
|
"#{RocketApi::INIT_FAIL} #{e.message}"
|
32
40
|
end
|
33
|
-
|
34
|
-
def self.init_bin!(name)
|
35
|
-
dir_name = "bin/#{name}"
|
36
|
-
create_single_file(
|
37
|
-
dir_name,
|
38
|
-
"",
|
39
|
-
exe: true
|
40
|
-
)
|
41
|
-
end
|
42
|
-
|
43
|
-
def self.init_gitignore!
|
44
|
-
file_name = ".gitignore"
|
45
|
-
create_single_file(
|
46
|
-
file_name,
|
47
|
-
gitignore_text
|
48
|
-
)
|
49
|
-
end
|
50
41
|
end
|
51
42
|
end
|
data/lib/rocket_api/version.rb
CHANGED
data/lib/rocket_api.rb
CHANGED
data/rocket_api.gemspec
CHANGED
@@ -1,26 +1,26 @@
|
|
1
1
|
lib = File.expand_path("lib", __dir__)
|
2
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
3
|
|
4
|
-
require
|
5
|
-
require
|
4
|
+
require "English"
|
5
|
+
require "rocket_api/version"
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.specification_version = 2 if s.respond_to? :specification_version=
|
9
9
|
if s.respond_to? :required_rubygems_version=
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0")
|
11
11
|
end
|
12
|
-
s.rubygems_version =
|
13
|
-
s.required_ruby_version =
|
14
|
-
s.name =
|
12
|
+
s.rubygems_version = "2.7"
|
13
|
+
s.required_ruby_version = ">=2.2"
|
14
|
+
s.name = "rocket_api"
|
15
15
|
s.version = RocketApi::VERSION
|
16
|
-
s.executables <<
|
17
|
-
s.license =
|
18
|
-
s.summary =
|
19
|
-
s.description = '
|
20
|
-
s.authors = [
|
21
|
-
s.email =
|
22
|
-
s.homepage =
|
16
|
+
s.executables << "rocket_api"
|
17
|
+
s.license = "MIT"
|
18
|
+
s.summary = "Create gem project structure and init main files in directory"
|
19
|
+
s.description = "Initialize directory with gem's structure.\n Include:\n*.gemspec\nlib/version\n.gitignore\nbin/*"
|
20
|
+
s.authors = ["Ilya Kondratev"]
|
21
|
+
s.email = "ilyafulleveline@gmail.com"
|
22
|
+
s.homepage = "https://github.com/ikondratev/rocket_api"
|
23
23
|
s.files = `git ls-files`.split($RS)
|
24
|
-
s.add_dependency
|
25
|
-
s.add_dependency
|
24
|
+
s.add_dependency "rubocop", "~> 1.26"
|
25
|
+
s.add_dependency "rubocop-rake"
|
26
26
|
end
|
data/test/test_version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rocket_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1.
|
4
|
+
version: 0.0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ilya Kondratev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-06-
|
11
|
+
date: 2022-06-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -38,7 +38,13 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
description:
|
41
|
+
description: |-
|
42
|
+
Initialize directory with gem's structure.
|
43
|
+
Include:
|
44
|
+
*.gemspec
|
45
|
+
lib/version
|
46
|
+
.gitignore
|
47
|
+
bin/*
|
42
48
|
email: ilyafulleveline@gmail.com
|
43
49
|
executables:
|
44
50
|
- rocket_api
|
@@ -57,9 +63,11 @@ files:
|
|
57
63
|
- lib/rocket_api/commands/dirs.rb
|
58
64
|
- lib/rocket_api/commands/files.rb
|
59
65
|
- lib/rocket_api/commands/gems_dir.rb
|
66
|
+
- lib/rocket_api/commands/helper.rb
|
60
67
|
- lib/rocket_api/constants.rb
|
61
68
|
- lib/rocket_api/errors.rb
|
62
69
|
- lib/rocket_api/library/gem_repo_plain_text.rb
|
70
|
+
- lib/rocket_api/library/helper_plain_text.rb
|
63
71
|
- lib/rocket_api/rocket_commands.rb
|
64
72
|
- lib/rocket_api/version.rb
|
65
73
|
- rocket_api.gemspec
|
@@ -86,5 +94,5 @@ requirements: []
|
|
86
94
|
rubygems_version: 3.1.4
|
87
95
|
signing_key:
|
88
96
|
specification_version: 2
|
89
|
-
summary: Create
|
97
|
+
summary: Create gem project structure and init main files in directory
|
90
98
|
test_files: []
|