rocket_api 0.0.1.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 546ea307031df1d56b8a5c8d64e3e118cc96c7f5bc211973d3411ef535a90870
4
+ data.tar.gz: 28781e6b14d6d40f7c76082b707b517ddc1958cd8b606bc01a6b7313b165d501
5
+ SHA512:
6
+ metadata.gz: 8584d5cbbd3e0a56b3c8c1ed587ad4ee29a47f21f3b8bde1ceca031192edf2682cee519844d1ffa234fe8437af2d4cca354cb19582dd0f5e4fa92746fd695401
7
+ data.tar.gz: f9deffa396fe77975ff02e314a033348019cdd8a973a2e72d9a76fc78ab2494238825a97d89fd108b9a1b28f45964baf0288ad0efc10c9e07658dac2fa4f3b6a
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ .idea/
2
+ Gemfile.lock
3
+ *.gem
data/.rubocop.yml ADDED
@@ -0,0 +1,73 @@
1
+ AllCops:
2
+ Exclude:
3
+ - Gemfile
4
+ - test/*
5
+ - Rakefile
6
+ - rocket_api.gemspec
7
+ - bin/*
8
+
9
+ Style/FrozenStringLiteralComment:
10
+ Enabled: false
11
+
12
+ Metrics/LineLength:
13
+ Max: 190
14
+
15
+ Style/Documentation:
16
+ Enabled: false
17
+
18
+ Style/StringLiterals:
19
+ Enabled: false
20
+
21
+ Style/GlobalVars:
22
+ Enabled: false
23
+
24
+ Metrics/MethodLength:
25
+ Max: 77
26
+
27
+ Metrics/BlockLength:
28
+ Max: 177
29
+
30
+ Naming/PredicateName:
31
+ Enabled: false
32
+
33
+ Style/GuardClause:
34
+ Enabled: false
35
+
36
+ Metrics/AbcSize:
37
+ Enabled: false
38
+
39
+ Style/MixinUsage:
40
+ Enabled: false
41
+
42
+ Lint/AmbiguousOperator:
43
+ Enabled: false
44
+
45
+ Naming/MemoizedInstanceVariableName:
46
+ Enabled: false
47
+
48
+ Naming/VariableNumber:
49
+ Enabled: false
50
+
51
+ Layout/DefEndAlignment:
52
+ Enabled: false
53
+
54
+ Style/MultilineIfModifier:
55
+ Enabled: false
56
+
57
+ Style/RaiseArgs:
58
+ Enabled: false
59
+
60
+ Style/IdenticalConditionalBranches:
61
+ Enabled: false
62
+
63
+ Style/ExplicitBlockArgument:
64
+ Enabled: false
65
+
66
+ Style/RedundantFreeze:
67
+ Enabled: false
68
+
69
+ Style/RedundantInterpolation:
70
+ Enabled: false
71
+
72
+ Style/NumericLiteralPrefix:
73
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.7.2
4
+ branches:
5
+ only:
6
+ - master
7
+ script:
8
+ - rake
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org/'
2
+ ruby '2.7.2'
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 kIlya
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,18 @@
1
+ # rocket_api
2
+ Start creating gems with rocket_api
3
+ - Add structure of gem repo by one commands
4
+ - Init gems repo by files
5
+ ## Dependencies:
6
+ ```sh
7
+ ruby '2.7.2'
8
+ ...
9
+ gem 'rubocop' '1.26'
10
+ ```
11
+ ## Install:
12
+ ```sh
13
+ gem install rocket_api
14
+ ```
15
+ ## How it works:
16
+ ```sh
17
+ rocket_api init gem name_gem
18
+ ```
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ desc "Run spec"
5
+ task default: %i[test rubocop]
6
+
7
+ require 'rake/testtask'
8
+ Rake::TestTask.new do |test|
9
+ test.libs << 'test'
10
+ end
11
+
12
+ require 'rubocop/rake_task'
13
+ RuboCop::RakeTask.new do |task|
14
+ task.fail_on_error = true
15
+ task.requires << 'rubocop-rake'
16
+ end
data/bin/rocket_api ADDED
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require './rocket_api/rocket_commands'
4
+ require './rocket_api/constants'
5
+
6
+ base_command = ARGV[0]
7
+ sub_command = ARGV[1]
8
+ project_name = ARGV[2]
9
+
10
+ case base_command
11
+ when RocketApi::INIT
12
+ case sub_command
13
+ when RocketApi::BASE
14
+ # TODO: implement me
15
+ when RocketApi::GEM
16
+ RocketApi::RocketCommands.init_gem_dir
17
+ RocketApi::RocketCommands.init_gem_files project_name&.downcase
18
+ else
19
+ puts RocketApi::WRONG_ANSWER
20
+ end
21
+ else
22
+ puts RocketApi::WRONG_ANSWER
23
+ end
@@ -0,0 +1,18 @@
1
+ module RocketApi
2
+ module Commands
3
+ module Dirs
4
+ def create_repo(dirs)
5
+ dirs.each { |dir| create_dir(dir) }
6
+ end
7
+
8
+ def create_dir(dir_name)
9
+ raise "#{RocketApi::FOLDER_EXIST} #{dir_name}" if is_exist?(dir_name)
10
+
11
+ system 'mkdir', '-p', "#{dir_name}"
12
+ puts "#{RocketApi::CREATE_SUCCESS} #{dir_name}"
13
+ rescue StandardError => e
14
+ puts "#{RocketApi::CREATE_FAILED} #{dir_name} err: #{e.message}"
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,26 @@
1
+ module RocketApi
2
+ module Commands
3
+ module Files
4
+ def is_exist?(dir_name)
5
+ File.exist?(dir_name)
6
+ end
7
+
8
+ def class_name_camel(name)
9
+ name.split('_').map(&:capitalize).join
10
+ end
11
+
12
+ def create_single_file(name, text, **options)
13
+ raise "#{RocketApi::FILE_EXIST} #{name}" if is_exist?(name)
14
+
15
+ out_file = File.new(name, "w")
16
+ out_file.chmod(001) if options[:exe]
17
+ out_file.puts(text)
18
+ out_file.close
19
+
20
+ puts "#{RocketApi::CREATE_SUCCESS} #{name}"
21
+ rescue StandardError => e
22
+ puts "#{RocketApi::CREATE_FAILED} #{name} err: #{e.message}"
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,21 @@
1
+ module RocketApi
2
+ GEM_PROJECTS_DIR = %w[bin lib test].freeze
3
+
4
+ # ...
5
+ # Ping
6
+ PONG = "PONG".freeze
7
+ # ...
8
+ # Commands
9
+ INIT = "init".freeze
10
+ BASE = "base".freeze
11
+ GEM = "gem".freeze
12
+ # ...
13
+ # Answers
14
+ FOLDER_EXIST = "folder exist:".freeze
15
+ FILE_EXIST = "file already exist:".freeze
16
+ WRONG_ANSWER = "Wrong command".freeze
17
+ EMPTY_NAME = "Project name is empty".freeze
18
+ INIT_FAIL = "Init action fail:".freeze
19
+ CREATE_FAILED = "Create failed:".freeze
20
+ CREATE_SUCCESS = "Successfully created:".freeze
21
+ end
@@ -0,0 +1,33 @@
1
+ module RocketApi
2
+ module Library
3
+ module GemRepoPlainText
4
+ def plain_version_text(module_name)
5
+ "module #{module_name}\n\tVERSION = \"0.0.1\".freeze\nend"
6
+ end
7
+
8
+ def plain_gemspec_text(name, module_name)
9
+ ["lib = File.expand_path(\"lib\", __dir__)",
10
+ "$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)\n",
11
+ "require 'English'",
12
+ "require '#{name}/version'\n",
13
+ "Gem::Specification.new do |s|",
14
+ "\ts.specification_version = 2 if s.respond_to? :specification_version=",
15
+ "\tif s.respond_to? :required_rubygems_version=",
16
+ "\t\ts.required_rubygems_version = Gem::Requirement.new('>= 0')",
17
+ "\tend",
18
+ "\ts.rubygems_version = 'RUBY_VERSION'",
19
+ "\ts.required_ruby_version = 'RUBY_VERSION'",
20
+ "\ts.name = '#{name}'",
21
+ "\ts.version = #{module_name}::VERSION",
22
+ "\ts.executables << '#{name}'",
23
+ "\ts.summary = 'PUT_SUMMARY'",
24
+ "\ts.description = 'PUT_DESCRIPTION'",
25
+ "\ts.authors = ['AUTHOR']",
26
+ "\ts.email = 'AUTHOR_MAIL'",
27
+ "\ts.homepage = 'https://github.com/...'",
28
+ "\ts.files = `git ls-files`.split($RS)",
29
+ "end"].join("\n")
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,68 @@
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'
5
+
6
+ module RocketApi
7
+ class RocketCommands
8
+ extend RocketApi::Commands::Files
9
+ extend RocketApi::Commands::Dirs
10
+ extend RocketApi::Library::GemRepoPlainText
11
+
12
+ def self.init_gem_dir
13
+ create_repo(RocketApi::GEM_PROJECTS_DIR)
14
+ end
15
+
16
+ def self.init_gem_files(project_name)
17
+ raise RocketApi::EMPTY_NAME if project_name.nil?
18
+
19
+ init_bin!(project_name)
20
+ init_gemspec!(project_name)
21
+ init_main_file!(project_name)
22
+ init_version!(project_name)
23
+ init_gitignore!
24
+ rescue StandardError => e
25
+ puts "#{RocketApi::INIT_FAIL} #{e.message}"
26
+ end
27
+
28
+ def self.init_bin!(name)
29
+ dir_name = "bin/#{name}"
30
+ create_single_file(
31
+ dir_name,
32
+ "",
33
+ exe: true
34
+ )
35
+ end
36
+
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
+ def self.init_gitignore!
55
+ 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
+ create_single_file(
63
+ file_name,
64
+ plain_gemspec_text(name, class_name_camel(name))
65
+ )
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,3 @@
1
+ module RocketApi
2
+ VERSION = "0.0.1.1".freeze
3
+ end
data/lib/rocket_api.rb ADDED
@@ -0,0 +1,7 @@
1
+ require './rocket_api/constants'
2
+
3
+ module RocketApi
4
+ def ping
5
+ RocketApi::PONG
6
+ end
7
+ end
@@ -0,0 +1,26 @@
1
+ lib = File.expand_path("lib", __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+
4
+ require 'English'
5
+ require 'rocket_api/version'
6
+
7
+ Gem::Specification.new do |s|
8
+ s.specification_version = 2 if s.respond_to? :specification_version=
9
+ if s.respond_to? :required_rubygems_version=
10
+ s.required_rubygems_version = Gem::Requirement.new('>= 0')
11
+ end
12
+ s.rubygems_version = '2.7'
13
+ s.required_ruby_version = '>=2.2'
14
+ s.name = 'rocket_api'
15
+ s.version = RocketApi::VERSION
16
+ s.executables << 'rocket_api'
17
+ s.license = 'MIT'
18
+ s.summary = 'Create working structure'
19
+ s.description = 'Create working structure.'
20
+ s.authors = ['Ilya Kondratev']
21
+ s.email = 'ilyafulleveline@gmail.com'
22
+ s.homepage = 'https://github.com/ikondratev/rocket_api'
23
+ s.files = `git ls-files`.split($RS)
24
+ s.add_dependency 'rubocop', '~> 1.26'
25
+ s.add_dependency 'rubocop-rake'
26
+ end
data/test/test_ping.rb ADDED
@@ -0,0 +1,9 @@
1
+ require 'minitest/autorun'
2
+ require 'rocket_api'
3
+
4
+ class TestPing < Minitest::Test
5
+ include RocketApi
6
+ def test_ping
7
+ assert_equal("PONG", ping)
8
+ end
9
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rocket_api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Ilya Kondratev
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-06-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rubocop
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.26'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.26'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rubocop-rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Create working structure.
42
+ email: ilyafulleveline@gmail.com
43
+ executables:
44
+ - rocket_api
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - ".rubocop.yml"
50
+ - ".travis.yml"
51
+ - Gemfile
52
+ - LICENSE
53
+ - README.md
54
+ - Rakefile
55
+ - bin/rocket_api
56
+ - lib/rocket_api.rb
57
+ - lib/rocket_api/commands/dirs.rb
58
+ - lib/rocket_api/commands/files.rb
59
+ - lib/rocket_api/constants.rb
60
+ - lib/rocket_api/library/gem_repo_plain_text.rb
61
+ - lib/rocket_api/rocket_commands.rb
62
+ - lib/rocket_api/version.rb
63
+ - rocket_api.gemspec
64
+ - test/test_ping.rb
65
+ homepage: https://github.com/ikondratev/rocket_api
66
+ licenses:
67
+ - MIT
68
+ metadata: {}
69
+ post_install_message:
70
+ rdoc_options: []
71
+ require_paths:
72
+ - lib
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '2.2'
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ requirements: []
84
+ rubygems_version: 3.1.4
85
+ signing_key:
86
+ specification_version: 2
87
+ summary: Create working structure
88
+ test_files: []