rocket_api 0.0.1.3 → 0.0.1.6
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 +4 -2
- data/bin/rocket_api +18 -16
- data/lib/rocket_api/commands/dirs.rb +1 -2
- data/lib/rocket_api/commands/files.rb +2 -3
- data/lib/rocket_api/commands/gems_dir.rb +6 -4
- data/lib/rocket_api/commands/helper.rb +22 -0
- data/lib/rocket_api/constants.rb +14 -6
- data/lib/rocket_api/errors.rb +0 -3
- data/lib/rocket_api/rocket_commands.rb +15 -22
- data/lib/rocket_api/version.rb +1 -1
- data/lib/rocket_api.rb +1 -2
- data/rocket_api.gemspec +15 -15
- data/test/test_version.rb +9 -0
- metadata +12 -5
- data/test/test_ping.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a1022fcc23b0400dc2dd32da344613ddbf781a28943eeed0f4fb7a017ef713a1
|
4
|
+
data.tar.gz: c6d6eb54cdc3c48b5aaf1ca64844d79767ddd05c182a2275196ee5e61b41785b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65310b3e37e9d32996b8f307d9eb879fb712b24880522e6eb65330ac9063d1029bd5f7eda3b8c3d4421c858f8d4065e962d75647196347ae18acb2110776733f
|
7
|
+
data.tar.gz: 57a82a3489ffe10a8d32a4831bc803ec45e0bc1271dcca93695af43ac497cc1b51969e105f4a42cd36cbb2e2eb5a1090627469914ba599cf246397de645aafb7
|
data/README.md
CHANGED
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
|
@@ -1,7 +1,6 @@
|
|
1
1
|
module RocketApi
|
2
2
|
module Commands
|
3
3
|
module Dirs
|
4
|
-
# ...
|
5
4
|
# @param [Array] dirs
|
6
5
|
def create_repo(dirs)
|
7
6
|
dirs.each do |dir|
|
@@ -10,7 +9,7 @@ module RocketApi
|
|
10
9
|
puts "#{CREATE_FAILED} #{e.message}"
|
11
10
|
end
|
12
11
|
end
|
13
|
-
|
12
|
+
|
14
13
|
# @param [String] dir_name
|
15
14
|
# ...
|
16
15
|
# @raise [StandardError]
|
@@ -1,17 +1,16 @@
|
|
1
1
|
module RocketApi
|
2
2
|
module Commands
|
3
3
|
module Files
|
4
|
-
# ...
|
5
4
|
# @param [String] dir_name
|
6
5
|
def is_exist?(dir_name)
|
7
6
|
File.exist?(dir_name)
|
8
7
|
end
|
9
|
-
|
8
|
+
|
10
9
|
# @param [String] name
|
11
10
|
def class_name_camel(name)
|
12
11
|
name.split('_').map(&:capitalize).join
|
13
12
|
end
|
14
|
-
|
13
|
+
|
15
14
|
# @param [String] name
|
16
15
|
# @param [String] text
|
17
16
|
# @param [Hash] options
|
@@ -1,7 +1,6 @@
|
|
1
1
|
module RocketApi
|
2
2
|
module Commands
|
3
3
|
module GemsDir
|
4
|
-
# ...
|
5
4
|
# @param [String] name
|
6
5
|
def init_gems_version!(name)
|
7
6
|
dir_name = "lib/#{name}"
|
@@ -12,14 +11,17 @@ module RocketApi
|
|
12
11
|
plain_version_text(class_name_camel(name))
|
13
12
|
)
|
14
13
|
end
|
15
|
-
|
14
|
+
|
16
15
|
# @param [String] name
|
17
16
|
def init_gems_main_file!(name)
|
18
17
|
file_name = "lib/#{name}.rb"
|
19
18
|
text = "class #{class_name_camel(name)}; end"
|
20
|
-
create_single_file(
|
19
|
+
create_single_file(
|
20
|
+
file_name,
|
21
|
+
text
|
22
|
+
)
|
21
23
|
end
|
22
|
-
|
24
|
+
|
23
25
|
# @param [String] name
|
24
26
|
def init_gemspec!(name)
|
25
27
|
file_name = "#{name}.gemspec"
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module RocketApi
|
2
|
+
module Commands
|
3
|
+
module Helper
|
4
|
+
def init_bin!(name)
|
5
|
+
dir_name = "bin/#{name}"
|
6
|
+
create_single_file(
|
7
|
+
dir_name,
|
8
|
+
"",
|
9
|
+
exe: true
|
10
|
+
)
|
11
|
+
end
|
12
|
+
|
13
|
+
def init_gitignore!
|
14
|
+
file_name = ".gitignore"
|
15
|
+
create_single_file(
|
16
|
+
file_name,
|
17
|
+
gitignore_text
|
18
|
+
)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/rocket_api/constants.rb
CHANGED
@@ -1,20 +1,28 @@
|
|
1
1
|
module RocketApi
|
2
|
-
#
|
2
|
+
# Valid input
|
3
|
+
REGEXP_VALID = /[^0-9A-Za-z_-]/.freeze
|
4
|
+
|
3
5
|
# Dirs map
|
4
6
|
GEM_PROJECTS_DIR = %w[bin lib test].freeze
|
5
|
-
|
7
|
+
AVAILABLE_COMMANDS = {
|
8
|
+
init: {
|
9
|
+
gem: %w[init_gem_dir init_gem_files]
|
10
|
+
}
|
11
|
+
}.freeze
|
12
|
+
|
6
13
|
# Ping
|
7
14
|
PONG = "PONG".freeze
|
8
|
-
|
15
|
+
|
9
16
|
# Commands
|
10
|
-
INIT = "init".freeze
|
11
17
|
BASE = "base".freeze
|
12
18
|
GEM = "gem".freeze
|
13
|
-
|
19
|
+
|
14
20
|
# Answers
|
21
|
+
INIT_DIR_ERROR = "Init directory error".freeze
|
22
|
+
GEM_DETECTED = "another one gem exist".freeze
|
15
23
|
FOLDER_EXIST = "folder exist:".freeze
|
16
24
|
FILE_EXIST = "file already exist:".freeze
|
17
|
-
|
25
|
+
WRONG_RESPONSE = "Wrong command".freeze
|
18
26
|
EMPTY_NAME = "Project name is empty".freeze
|
19
27
|
INIT_FAIL = "Init action fail:".freeze
|
20
28
|
CREATE_FAILED = "Create failed:".freeze
|
data/lib/rocket_api/errors.rb
CHANGED
@@ -1,24 +1,34 @@
|
|
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
|
+
|
1
7
|
module RocketApi
|
2
8
|
class RocketCommands
|
3
9
|
extend RocketApi::Commands::Files
|
4
10
|
extend RocketApi::Commands::Dirs
|
5
11
|
extend RocketApi::Commands::GemsDir
|
12
|
+
extend RocketApi::Commands::Helper
|
6
13
|
extend RocketApi::Library::GemRepoPlainText
|
7
|
-
|
14
|
+
|
8
15
|
# @raise [RocketApi::CreateDirError]
|
9
|
-
def self.init_gem_dir
|
16
|
+
def self.init_gem_dir(**_options)
|
17
|
+
raise GEM_DETECTED unless Dir.glob("*.gemspec").empty?
|
18
|
+
|
10
19
|
create_repo(RocketApi::GEM_PROJECTS_DIR)
|
11
20
|
rescue StandardError => e
|
12
21
|
raise RocketApi::CreateDirError,
|
13
22
|
"#{RocketApi::CREATE_FAILED} #{e.message}"
|
14
23
|
end
|
15
|
-
|
24
|
+
|
16
25
|
# @param [String] project_name
|
17
26
|
# ...
|
18
27
|
# @raise [RocketApi::InitFilesError] error
|
19
|
-
def self.init_gem_files(
|
20
|
-
raise RocketApi::EMPTY_NAME if project_name.nil?
|
28
|
+
def self.init_gem_files(**options)
|
29
|
+
raise RocketApi::EMPTY_NAME if options[:project_name].nil?
|
21
30
|
|
31
|
+
project_name = options[:project_name]
|
22
32
|
init_bin!(project_name)
|
23
33
|
init_gemspec!(project_name)
|
24
34
|
init_gems_main_file!(project_name)
|
@@ -28,22 +38,5 @@ module RocketApi
|
|
28
38
|
raise RocketApi::InitFilesError,
|
29
39
|
"#{RocketApi::INIT_FAIL} #{e.message}"
|
30
40
|
end
|
31
|
-
|
32
|
-
def self.init_bin!(name)
|
33
|
-
dir_name = "bin/#{name}"
|
34
|
-
create_single_file(
|
35
|
-
dir_name,
|
36
|
-
"",
|
37
|
-
exe: true
|
38
|
-
)
|
39
|
-
end
|
40
|
-
|
41
|
-
def self.init_gitignore!
|
42
|
-
file_name = ".gitignore"
|
43
|
-
create_single_file(
|
44
|
-
file_name,
|
45
|
-
gitignore_text
|
46
|
-
)
|
47
|
-
end
|
48
41
|
end
|
49
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
|
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.6
|
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-19 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,13 +63,14 @@ 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
|
63
70
|
- lib/rocket_api/rocket_commands.rb
|
64
71
|
- lib/rocket_api/version.rb
|
65
72
|
- rocket_api.gemspec
|
66
|
-
- test/
|
73
|
+
- test/test_version.rb
|
67
74
|
homepage: https://github.com/ikondratev/rocket_api
|
68
75
|
licenses:
|
69
76
|
- MIT
|
@@ -86,5 +93,5 @@ requirements: []
|
|
86
93
|
rubygems_version: 3.1.4
|
87
94
|
signing_key:
|
88
95
|
specification_version: 2
|
89
|
-
summary: Create
|
96
|
+
summary: Create gem project structure and init main files in directory
|
90
97
|
test_files: []
|