rocket_api 0.0.1.5 → 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/gems_dir.rb +4 -1
- data/lib/rocket_api/commands/helper.rb +22 -0
- data/lib/rocket_api/constants.rb +11 -2
- data/lib/rocket_api/errors.rb +0 -3
- data/lib/rocket_api/rocket_commands.rb +8 -20
- 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 +11 -4
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
|
@@ -16,7 +16,10 @@ module RocketApi
|
|
16
16
|
def init_gems_main_file!(name)
|
17
17
|
file_name = "lib/#{name}.rb"
|
18
18
|
text = "class #{class_name_camel(name)}; end"
|
19
|
-
create_single_file(
|
19
|
+
create_single_file(
|
20
|
+
file_name,
|
21
|
+
text
|
22
|
+
)
|
20
23
|
end
|
21
24
|
|
22
25
|
# @param [String] name
|
@@ -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,19 +1,28 @@
|
|
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
|
+
AVAILABLE_COMMANDS = {
|
8
|
+
init: {
|
9
|
+
gem: %w[init_gem_dir init_gem_files]
|
10
|
+
}
|
11
|
+
}.freeze
|
4
12
|
|
5
13
|
# Ping
|
6
14
|
PONG = "PONG".freeze
|
7
15
|
|
8
16
|
# Commands
|
9
|
-
INIT = "init".freeze
|
10
17
|
BASE = "base".freeze
|
11
18
|
GEM = "gem".freeze
|
12
19
|
|
13
20
|
# Answers
|
21
|
+
INIT_DIR_ERROR = "Init directory error".freeze
|
22
|
+
GEM_DETECTED = "another one gem exist".freeze
|
14
23
|
FOLDER_EXIST = "folder exist:".freeze
|
15
24
|
FILE_EXIST = "file already exist:".freeze
|
16
|
-
|
25
|
+
WRONG_RESPONSE = "Wrong command".freeze
|
17
26
|
EMPTY_NAME = "Project name is empty".freeze
|
18
27
|
INIT_FAIL = "Init action fail:".freeze
|
19
28
|
CREATE_FAILED = "Create failed:".freeze
|
data/lib/rocket_api/errors.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require "rocket_api/commands/files"
|
2
2
|
require "rocket_api/commands/dirs"
|
3
3
|
require "rocket_api/commands/gems_dir"
|
4
|
+
require "rocket_api/commands/helper"
|
4
5
|
require "rocket_api/library/gem_repo_plain_text"
|
5
6
|
|
6
7
|
module RocketApi
|
@@ -8,10 +9,13 @@ module RocketApi
|
|
8
9
|
extend RocketApi::Commands::Files
|
9
10
|
extend RocketApi::Commands::Dirs
|
10
11
|
extend RocketApi::Commands::GemsDir
|
12
|
+
extend RocketApi::Commands::Helper
|
11
13
|
extend RocketApi::Library::GemRepoPlainText
|
12
14
|
|
13
15
|
# @raise [RocketApi::CreateDirError]
|
14
|
-
def self.init_gem_dir
|
16
|
+
def self.init_gem_dir(**_options)
|
17
|
+
raise GEM_DETECTED unless Dir.glob("*.gemspec").empty?
|
18
|
+
|
15
19
|
create_repo(RocketApi::GEM_PROJECTS_DIR)
|
16
20
|
rescue StandardError => e
|
17
21
|
raise RocketApi::CreateDirError,
|
@@ -21,9 +25,10 @@ module RocketApi
|
|
21
25
|
# @param [String] project_name
|
22
26
|
# ...
|
23
27
|
# @raise [RocketApi::InitFilesError] error
|
24
|
-
def self.init_gem_files(
|
25
|
-
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?
|
26
30
|
|
31
|
+
project_name = options[:project_name]
|
27
32
|
init_bin!(project_name)
|
28
33
|
init_gemspec!(project_name)
|
29
34
|
init_gems_main_file!(project_name)
|
@@ -33,22 +38,5 @@ module RocketApi
|
|
33
38
|
raise RocketApi::InitFilesError,
|
34
39
|
"#{RocketApi::INIT_FAIL} #{e.message}"
|
35
40
|
end
|
36
|
-
|
37
|
-
def self.init_bin!(name)
|
38
|
-
dir_name = "bin/#{name}"
|
39
|
-
create_single_file(
|
40
|
-
dir_name,
|
41
|
-
"",
|
42
|
-
exe: true
|
43
|
-
)
|
44
|
-
end
|
45
|
-
|
46
|
-
def self.init_gitignore!
|
47
|
-
file_name = ".gitignore"
|
48
|
-
create_single_file(
|
49
|
-
file_name,
|
50
|
-
gitignore_text
|
51
|
-
)
|
52
|
-
end
|
53
41
|
end
|
54
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.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,6 +63,7 @@ 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
|
@@ -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: []
|