rocket_api 0.0.1.1 → 0.0.1.2
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/.rubocop.yml +3 -0
- data/bin/rocket_api +9 -4
- data/lib/rocket_api/commands/dirs.rb +12 -3
- data/lib/rocket_api/commands/files.rb +11 -3
- data/lib/rocket_api/commands/gems_dir.rb +33 -0
- data/lib/rocket_api/constants.rb +2 -1
- data/lib/rocket_api/errors.rb +11 -0
- data/lib/rocket_api/library/gem_repo_plain_text.rb +4 -0
- data/lib/rocket_api/rocket_commands.rb +20 -33
- data/lib/rocket_api/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5cb81f2bc9a560412bf417b9b470d7815f119dc47adf7c6f97292d339fce7081
|
4
|
+
data.tar.gz: '08bf18cc0bea116a3b8cd26e9fda39633661c18261b7c3107cbb31e4332769c4'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 698f1a860a570343be71fc332ba97998e1532547d59459aced50eeb59f2cd19eca4906739102e57b4a814b335c2a13cde3a39f1e339d8d2d1226114971fe26b1
|
7
|
+
data.tar.gz: 9e70b1c80171e3d9d2efcc9db12f8615be9362ae7d0af3996b9c26040fe3b6ea8e2ea2672f6883f9a4e87c8c2111f085c04e101b9a8b0ce132ee653f82739fd5
|
data/.rubocop.yml
CHANGED
data/bin/rocket_api
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require './rocket_api/rocket_commands'
|
4
|
-
require './rocket_api/constants'
|
3
|
+
require './lib/rocket_api/rocket_commands'
|
4
|
+
require './lib/rocket_api/constants'
|
5
|
+
require './lib/rocket_api/errors'
|
5
6
|
|
6
7
|
base_command = ARGV[0]
|
7
8
|
sub_command = ARGV[1]
|
@@ -13,8 +14,12 @@ when RocketApi::INIT
|
|
13
14
|
when RocketApi::BASE
|
14
15
|
# TODO: implement me
|
15
16
|
when RocketApi::GEM
|
16
|
-
|
17
|
-
|
17
|
+
begin
|
18
|
+
RocketApi::RocketCommands.init_gem_dir
|
19
|
+
RocketApi::RocketCommands.init_gem_files project_name&.downcase
|
20
|
+
rescue RocketApi::Error => e
|
21
|
+
puts "Init directory error: #{e.message}"
|
22
|
+
end
|
18
23
|
else
|
19
24
|
puts RocketApi::WRONG_ANSWER
|
20
25
|
end
|
@@ -1,17 +1,26 @@
|
|
1
1
|
module RocketApi
|
2
2
|
module Commands
|
3
3
|
module Dirs
|
4
|
+
# ...
|
5
|
+
# @param [Array] dirs
|
4
6
|
def create_repo(dirs)
|
5
|
-
dirs.each
|
7
|
+
dirs.each do |dir|
|
8
|
+
create_dir(dir)
|
9
|
+
rescue StandardError => e
|
10
|
+
puts "#{CREATE_FAILED} #{e.message}"
|
11
|
+
end
|
6
12
|
end
|
7
|
-
|
13
|
+
# ...
|
14
|
+
# @param [String] dir_name
|
15
|
+
# ...
|
16
|
+
# @raise [StandardError]
|
8
17
|
def create_dir(dir_name)
|
9
18
|
raise "#{RocketApi::FOLDER_EXIST} #{dir_name}" if is_exist?(dir_name)
|
10
19
|
|
11
20
|
system 'mkdir', '-p', "#{dir_name}"
|
12
21
|
puts "#{RocketApi::CREATE_SUCCESS} #{dir_name}"
|
13
22
|
rescue StandardError => e
|
14
|
-
|
23
|
+
raise e, "#{dir_name} err: #{e.message}"
|
15
24
|
end
|
16
25
|
end
|
17
26
|
end
|
@@ -1,14 +1,22 @@
|
|
1
1
|
module RocketApi
|
2
2
|
module Commands
|
3
3
|
module Files
|
4
|
+
# ...
|
5
|
+
# @param [String] dir_name
|
4
6
|
def is_exist?(dir_name)
|
5
7
|
File.exist?(dir_name)
|
6
8
|
end
|
7
|
-
|
9
|
+
# ...
|
10
|
+
# @param [String] name
|
8
11
|
def class_name_camel(name)
|
9
12
|
name.split('_').map(&:capitalize).join
|
10
13
|
end
|
11
|
-
|
14
|
+
# ...
|
15
|
+
# @param [String] name
|
16
|
+
# @param [String] text
|
17
|
+
# @param [Hash] options
|
18
|
+
# ...
|
19
|
+
# @raise [StandardError] error
|
12
20
|
def create_single_file(name, text, **options)
|
13
21
|
raise "#{RocketApi::FILE_EXIST} #{name}" if is_exist?(name)
|
14
22
|
|
@@ -19,7 +27,7 @@ module RocketApi
|
|
19
27
|
|
20
28
|
puts "#{RocketApi::CREATE_SUCCESS} #{name}"
|
21
29
|
rescue StandardError => e
|
22
|
-
|
30
|
+
raise e, "#{name} err: #{e.message}"
|
23
31
|
end
|
24
32
|
end
|
25
33
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module RocketApi
|
2
|
+
module Commands
|
3
|
+
module GemsDir
|
4
|
+
# ...
|
5
|
+
# @param [String] name
|
6
|
+
def init_gems_version!(name)
|
7
|
+
dir_name = "lib/#{name}"
|
8
|
+
create_dir(dir_name)
|
9
|
+
file_name = "#{dir_name}/version.rb"
|
10
|
+
create_single_file(
|
11
|
+
file_name,
|
12
|
+
plain_version_text(class_name_camel(name))
|
13
|
+
)
|
14
|
+
end
|
15
|
+
# ...
|
16
|
+
# @param [String] name
|
17
|
+
def init_gems_main_file!(name)
|
18
|
+
file_name = "lib/#{name}.rb"
|
19
|
+
text = "class #{class_name_camel(name)}; end"
|
20
|
+
create_single_file(file_name, text)
|
21
|
+
end
|
22
|
+
# ...
|
23
|
+
# @param [String] name
|
24
|
+
def init_gemspec!(name)
|
25
|
+
file_name = "#{name}.gemspec"
|
26
|
+
create_single_file(
|
27
|
+
file_name,
|
28
|
+
plain_gemspec_text(name, class_name_camel(name))
|
29
|
+
)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/rocket_api/constants.rb
CHANGED
@@ -1,28 +1,38 @@
|
|
1
|
-
require './rocket_api/constants'
|
2
|
-
require './rocket_api/commands/files'
|
3
|
-
require './rocket_api/commands/dirs'
|
4
|
-
require './rocket_api/library/gem_repo_plain_text'
|
1
|
+
require './lib/rocket_api/constants'
|
2
|
+
require './lib/rocket_api/commands/files'
|
3
|
+
require './lib/rocket_api/commands/dirs'
|
4
|
+
require './lib/rocket_api/library/gem_repo_plain_text'
|
5
|
+
require './lib/rocket_api/commands/gems_dir'
|
5
6
|
|
6
7
|
module RocketApi
|
7
8
|
class RocketCommands
|
8
9
|
extend RocketApi::Commands::Files
|
9
10
|
extend RocketApi::Commands::Dirs
|
11
|
+
extend RocketApi::Commands::GemsDir
|
10
12
|
extend RocketApi::Library::GemRepoPlainText
|
11
|
-
|
13
|
+
# ...
|
14
|
+
# @raise [RocketApi::CreateDirError]
|
12
15
|
def self.init_gem_dir
|
13
16
|
create_repo(RocketApi::GEM_PROJECTS_DIR)
|
17
|
+
rescue StandardError => e
|
18
|
+
raise RocketApi::CreateDirError,
|
19
|
+
"#{RocketApi::CREATE_FAILED} #{e.message}"
|
14
20
|
end
|
15
|
-
|
21
|
+
# ...
|
22
|
+
# @param [String] project_name
|
23
|
+
# ...
|
24
|
+
# @raise [RocketApi::InitFilesError] error
|
16
25
|
def self.init_gem_files(project_name)
|
17
26
|
raise RocketApi::EMPTY_NAME if project_name.nil?
|
18
27
|
|
19
28
|
init_bin!(project_name)
|
20
29
|
init_gemspec!(project_name)
|
21
|
-
|
22
|
-
|
30
|
+
init_gems_main_file!(project_name)
|
31
|
+
init_gems_version!(project_name)
|
23
32
|
init_gitignore!
|
24
33
|
rescue StandardError => e
|
25
|
-
|
34
|
+
raise RocketApi::InitFilesError,
|
35
|
+
"#{RocketApi::INIT_FAIL} #{e.message}"
|
26
36
|
end
|
27
37
|
|
28
38
|
def self.init_bin!(name)
|
@@ -34,34 +44,11 @@ module RocketApi
|
|
34
44
|
)
|
35
45
|
end
|
36
46
|
|
37
|
-
def self.init_version!(name)
|
38
|
-
dir_name = "lib/#{name}"
|
39
|
-
create_dir(dir_name)
|
40
|
-
|
41
|
-
file_name = "#{dir_name}/version.rb"
|
42
|
-
create_single_file(
|
43
|
-
file_name,
|
44
|
-
plain_version_text(class_name_camel(name))
|
45
|
-
)
|
46
|
-
end
|
47
|
-
|
48
|
-
def self.init_main_file!(name)
|
49
|
-
file_name = "lib/#{name}.rb"
|
50
|
-
text = "class #{class_name_camel(name)}; end"
|
51
|
-
create_single_file(file_name, text)
|
52
|
-
end
|
53
|
-
|
54
47
|
def self.init_gitignore!
|
55
48
|
file_name = ".gitignore"
|
56
|
-
text = ".idea/\nGemfile.lock\n*.gem"
|
57
|
-
create_single_file(file_name, text)
|
58
|
-
end
|
59
|
-
|
60
|
-
def self.init_gemspec!(name)
|
61
|
-
file_name = "#{name}.gemspec"
|
62
49
|
create_single_file(
|
63
50
|
file_name,
|
64
|
-
|
51
|
+
gitignore_text
|
65
52
|
)
|
66
53
|
end
|
67
54
|
end
|
data/lib/rocket_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ilya Kondratev
|
@@ -56,7 +56,9 @@ files:
|
|
56
56
|
- lib/rocket_api.rb
|
57
57
|
- lib/rocket_api/commands/dirs.rb
|
58
58
|
- lib/rocket_api/commands/files.rb
|
59
|
+
- lib/rocket_api/commands/gems_dir.rb
|
59
60
|
- lib/rocket_api/constants.rb
|
61
|
+
- lib/rocket_api/errors.rb
|
60
62
|
- lib/rocket_api/library/gem_repo_plain_text.rb
|
61
63
|
- lib/rocket_api/rocket_commands.rb
|
62
64
|
- lib/rocket_api/version.rb
|