pico_api 0.0.4 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/bin/pico_api +1 -2
  3. data/bin/setup +0 -0
  4. data/lib/pico_api/generators/commands/create_basic_structure.rb +48 -0
  5. data/lib/pico_api/generators/commands/create_config_application.rb +21 -5
  6. data/lib/pico_api/generators/commands/create_config_boot.rb +21 -5
  7. data/lib/pico_api/generators/commands/create_config_configuration.rb +21 -5
  8. data/lib/pico_api/generators/commands/create_config_database_setup.rb +21 -5
  9. data/lib/pico_api/generators/commands/create_config_database_yml.rb +21 -5
  10. data/lib/pico_api/generators/commands/create_config_dotenv.rb +21 -5
  11. data/lib/pico_api/generators/commands/create_config_ru.rb +21 -5
  12. data/lib/pico_api/generators/commands/create_gemfile.rb +21 -5
  13. data/lib/pico_api/generators/commands/create_gitignore.rb +21 -5
  14. data/lib/pico_api/generators/commands/create_rakefile.rb +21 -5
  15. data/lib/pico_api/generators/erb_data_handler.rb +44 -0
  16. data/lib/pico_api/generators/file_copier.rb +37 -0
  17. data/lib/pico_api/generators/file_creator.rb +45 -0
  18. data/lib/pico_api/generators/generator.rb +14 -9
  19. data/lib/pico_api/generators/project_name_converter.rb +14 -0
  20. data/lib/pico_api/generators/templates/config/application.erb +1 -1
  21. data/lib/pico_api/generators/templates/config/configuration.erb +2 -2
  22. data/lib/pico_api/generators/templates/config.ru.erb +1 -1
  23. data/lib/pico_api/version.rb +1 -1
  24. data/pico_api.gemspec +3 -2
  25. metadata +23 -8
  26. data/lib/pico_api/generators/commands/base.rb +0 -45
  27. data/lib/pico_api/generators/commands/copy_template.rb +0 -19
  28. data/lib/pico_api/generators/commands/create_base.rb +0 -29
  29. data/lib/pico_api/generators/commands/create_template.rb +0 -21
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e00987197e956e77af63d09b3d1d458e335857f6a376076824c0f35da7154295
4
- data.tar.gz: 4bed688ad8bd088af9bc9c4532b2b1fde95f215a1da74c8bb161980f5a3a5e64
3
+ metadata.gz: f7269c4d7be561c7d2d8d88cbb697532367ebc0eb01204b26a6fb52003bb9486
4
+ data.tar.gz: 331dad6797d31af58a659183b294378686faff69829a10b077e4c97aaeb367cd
5
5
  SHA512:
6
- metadata.gz: 5cb58169f60fd534f1f1dc79beccdc36c698dab9fcd2b3300783ba2e627a4f68db2eb70f2bdfb26217d11747d4c5837a202218209edbc05a12dafb9e77204d2d
7
- data.tar.gz: 41e81c723e248df1d4cadaf0055f63ae662025113137f5b2fd57889eba9ca6336c63b825afe8158c53bed903faa6ee40120c2f7d3e7fe1ed607d106ed1fcf849
6
+ metadata.gz: bf94c3bbb5dc17ad9a3713f0111c3f72712cfbfe80c87a16ba9729da28bdb145a7c8ab8494aeca59cc71d7df8387451c121dcc798e9882bfed5691a04a827dce
7
+ data.tar.gz: 1288b2ff7bbc79635c4a4e6f56f04513bc52ec467db96c26e141851994ea33578a2ddfbc360f9cc58b4b8c70046cbb04bb91057459552b062e8dda712af0d48d
data/bin/pico_api CHANGED
@@ -1,4 +1,3 @@
1
-
2
1
  #!/usr/bin/env ruby
3
2
 
4
3
  require 'optparse'
@@ -6,7 +5,7 @@ require 'pico_api'
6
5
 
7
6
  options = {}
8
7
  OptionParser.new do |opts|
9
- opts.banner = "Usage: pico_api [options]"
8
+ opts.banner = 'Usage: pico_api [options]'
10
9
 
11
10
  opts.on('-n', '--new project_name') { |o| options[:project_name] = o }
12
11
  end.parse!
data/bin/setup CHANGED
File without changes
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'fileutils'
4
+
5
+ module PicoApi
6
+ module Generators
7
+ module Commands
8
+ class CreateBasicStructure
9
+ def self.call(project_name)
10
+ project_name_converter =
11
+ ::PicoApi::Generators::ProjectNameConverter.new(project_name)
12
+
13
+ new(project_name_converter).call
14
+ end
15
+
16
+ def initialize(project_name_converter)
17
+ @project_name_converter = project_name_converter
18
+ end
19
+
20
+ def call
21
+ create_bin_folder
22
+ create_lib_folder
23
+ create_config_folder
24
+ end
25
+
26
+ private
27
+
28
+ attr_reader :project_name_converter
29
+
30
+ def create_bin_folder
31
+ FileUtils.mkdir_p("#{snakecased_name}/bin")
32
+ end
33
+
34
+ def create_lib_folder
35
+ FileUtils.mkdir_p("#{snakecased_name}/lib/#{snakecased_name}")
36
+ end
37
+
38
+ def create_config_folder
39
+ FileUtils.mkdir_p("#{snakecased_name}/config")
40
+ end
41
+
42
+ def snakecased_name
43
+ project_name_converter.snakecased
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -3,16 +3,32 @@
3
3
  module PicoApi
4
4
  module Generators
5
5
  module Commands
6
- class CreateConfigApplication < CreateTemplate
7
- private
6
+ class CreateConfigApplication
7
+ def self.call(project_name)
8
+ file_creator = ::PicoApi::Generators::FileCreator.build(project_name)
8
9
 
9
- def destination_path
10
- '/config/application.rb'
10
+ new(file_creator).call
11
+ end
12
+
13
+ def initialize(file_creator)
14
+ @file_creator = file_creator
15
+ end
16
+
17
+ def call
18
+ file_creator.create(template_file_path, destination_path)
11
19
  end
12
20
 
13
- def template_relative_path
21
+ private
22
+
23
+ attr_reader :file_creator
24
+
25
+ def template_file_path
14
26
  '/generators/templates/config/application.erb'
15
27
  end
28
+
29
+ def destination_path
30
+ '/config/application.rb'
31
+ end
16
32
  end
17
33
  end
18
34
  end
@@ -3,16 +3,32 @@
3
3
  module PicoApi
4
4
  module Generators
5
5
  module Commands
6
- class CreateConfigBoot < CopyTemplate
7
- private
6
+ class CreateConfigBoot
7
+ def self.call(project_name)
8
+ file_copier = ::PicoApi::Generators::FileCopier.build(project_name)
8
9
 
9
- def destination_path
10
- '/config/boot.rb'
10
+ new(file_copier).call
11
+ end
12
+
13
+ def initialize(file_copier)
14
+ @file_copier = file_copier
15
+ end
16
+
17
+ def call
18
+ file_copier.copy(template_file_path, destination_path)
11
19
  end
12
20
 
13
- def template_relative_path
21
+ private
22
+
23
+ attr_reader :file_copier
24
+
25
+ def template_file_path
14
26
  '/generators/templates/config/boot.erb'
15
27
  end
28
+
29
+ def destination_path
30
+ '/config/boot.rb'
31
+ end
16
32
  end
17
33
  end
18
34
  end
@@ -3,16 +3,32 @@
3
3
  module PicoApi
4
4
  module Generators
5
5
  module Commands
6
- class CreateConfigConfiguration < CreateTemplate
7
- private
6
+ class CreateConfigConfiguration
7
+ def self.call(project_name)
8
+ file_creator = ::PicoApi::Generators::FileCreator.build(project_name)
8
9
 
9
- def destination_path
10
- '/config/configuration.rb'
10
+ new(file_creator).call
11
+ end
12
+
13
+ def initialize(file_creator)
14
+ @file_creator = file_creator
15
+ end
16
+
17
+ def call
18
+ file_creator.create(template_file_path, destination_path)
11
19
  end
12
20
 
13
- def template_relative_path
21
+ private
22
+
23
+ attr_reader :file_creator
24
+
25
+ def template_file_path
14
26
  '/generators/templates/config/configuration.erb'
15
27
  end
28
+
29
+ def destination_path
30
+ '/config/configuration.rb'
31
+ end
16
32
  end
17
33
  end
18
34
  end
@@ -3,16 +3,32 @@
3
3
  module PicoApi
4
4
  module Generators
5
5
  module Commands
6
- class CreateConfigDatabaseSetup < CopyTemplate
7
- private
6
+ class CreateConfigDatabaseSetup
7
+ def self.call(project_name)
8
+ file_copier = ::PicoApi::Generators::FileCopier.build(project_name)
8
9
 
9
- def destination_path
10
- '/config/database_setup.rb'
10
+ new(file_copier).call
11
+ end
12
+
13
+ def initialize(file_copier)
14
+ @file_copier = file_copier
15
+ end
16
+
17
+ def call
18
+ file_copier.copy(template_file_path, destination_path)
11
19
  end
12
20
 
13
- def template_relative_path
21
+ private
22
+
23
+ attr_reader :file_copier
24
+
25
+ def template_file_path
14
26
  '/generators/templates/config/database_setup.erb'
15
27
  end
28
+
29
+ def destination_path
30
+ '/config/database_setup.rb'
31
+ end
16
32
  end
17
33
  end
18
34
  end
@@ -3,16 +3,32 @@
3
3
  module PicoApi
4
4
  module Generators
5
5
  module Commands
6
- class CreateConfigDatabaseYml < CopyTemplate
7
- private
6
+ class CreateConfigDatabaseYml
7
+ def self.call(project_name)
8
+ file_copier = ::PicoApi::Generators::FileCopier.build(project_name)
8
9
 
9
- def destination_path
10
- '/config/database.yml'
10
+ new(file_copier).call
11
+ end
12
+
13
+ def initialize(file_copier)
14
+ @file_copier = file_copier
15
+ end
16
+
17
+ def call
18
+ file_copier.copy(template_file_path, destination_path)
11
19
  end
12
20
 
13
- def template_relative_path
21
+ private
22
+
23
+ attr_reader :file_copier
24
+
25
+ def template_file_path
14
26
  '/generators/templates/config/database.yml'
15
27
  end
28
+
29
+ def destination_path
30
+ '/config/database.yml'
31
+ end
16
32
  end
17
33
  end
18
34
  end
@@ -3,16 +3,32 @@
3
3
  module PicoApi
4
4
  module Generators
5
5
  module Commands
6
- class CreateConfigDotenv < CopyTemplate
7
- private
6
+ class CreateConfigDotenv
7
+ def self.call(project_name)
8
+ file_copier = ::PicoApi::Generators::FileCopier.build(project_name)
8
9
 
9
- def destination_path
10
- '/config/dotenv.rb'
10
+ new(file_copier).call
11
+ end
12
+
13
+ def initialize(file_copier)
14
+ @file_copier = file_copier
15
+ end
16
+
17
+ def call
18
+ file_copier.copy(template_file_path, destination_path)
11
19
  end
12
20
 
13
- def template_relative_path
21
+ private
22
+
23
+ attr_reader :file_copier
24
+
25
+ def template_file_path
14
26
  '/generators/templates/config/dotenv.erb'
15
27
  end
28
+
29
+ def destination_path
30
+ '/config/dotenv.rb'
31
+ end
16
32
  end
17
33
  end
18
34
  end
@@ -3,16 +3,32 @@
3
3
  module PicoApi
4
4
  module Generators
5
5
  module Commands
6
- class CreateConfigRu < CreateTemplate
7
- private
6
+ class CreateConfigRu
7
+ def self.call(project_name)
8
+ file_creator = ::PicoApi::Generators::FileCreator.build(project_name)
8
9
 
9
- def destination_path
10
- '/config.ru'
10
+ new(file_creator).call
11
+ end
12
+
13
+ def initialize(file_creator)
14
+ @file_creator = file_creator
15
+ end
16
+
17
+ def call
18
+ file_creator.create(template_file_path, destination_path)
11
19
  end
12
20
 
13
- def template_relative_path
21
+ private
22
+
23
+ attr_reader :file_creator
24
+
25
+ def template_file_path
14
26
  '/generators/templates/config.ru.erb'
15
27
  end
28
+
29
+ def destination_path
30
+ '/config.ru'
31
+ end
16
32
  end
17
33
  end
18
34
  end
@@ -3,16 +3,32 @@
3
3
  module PicoApi
4
4
  module Generators
5
5
  module Commands
6
- class CreateGemfile < CopyTemplate
7
- private
6
+ class CreateGemfile
7
+ def self.call(project_name)
8
+ file_copier = ::PicoApi::Generators::FileCopier.build(project_name)
8
9
 
9
- def destination_path
10
- '/Gemfile'
10
+ new(file_copier).call
11
+ end
12
+
13
+ def initialize(file_copier)
14
+ @file_copier = file_copier
15
+ end
16
+
17
+ def call
18
+ file_copier.copy(template_file_path, destination_path)
11
19
  end
12
20
 
13
- def template_relative_path
21
+ private
22
+
23
+ attr_reader :file_copier
24
+
25
+ def template_file_path
14
26
  '/generators/templates/Gemfile.erb'
15
27
  end
28
+
29
+ def destination_path
30
+ '/Gemfile'
31
+ end
16
32
  end
17
33
  end
18
34
  end
@@ -3,16 +3,32 @@
3
3
  module PicoApi
4
4
  module Generators
5
5
  module Commands
6
- class CreateGitignore < CopyTemplate
7
- private
6
+ class CreateGitignore
7
+ def self.call(project_name)
8
+ file_copier = ::PicoApi::Generators::FileCopier.build(project_name)
8
9
 
9
- def destination_path
10
- '/.gitignore'
10
+ new(file_copier).call
11
+ end
12
+
13
+ def initialize(file_copier)
14
+ @file_copier = file_copier
15
+ end
16
+
17
+ def call
18
+ file_copier.copy(template_file_path, destination_path)
11
19
  end
12
20
 
13
- def template_relative_path
21
+ private
22
+
23
+ attr_reader :file_copier
24
+
25
+ def template_file_path
14
26
  '/generators/templates/.gitignore'
15
27
  end
28
+
29
+ def destination_path
30
+ '/.gitignore'
31
+ end
16
32
  end
17
33
  end
18
34
  end
@@ -3,16 +3,32 @@
3
3
  module PicoApi
4
4
  module Generators
5
5
  module Commands
6
- class CreateRakefile < CopyTemplate
7
- private
6
+ class CreateRakefile
7
+ def self.call(project_name)
8
+ file_copier = ::PicoApi::Generators::FileCopier.build(project_name)
8
9
 
9
- def destination_path
10
- '/Rakefile'
10
+ new(file_copier).call
11
+ end
12
+
13
+ def initialize(file_copier)
14
+ @file_copier = file_copier
15
+ end
16
+
17
+ def call
18
+ file_copier.copy(template_file_path, destination_path)
11
19
  end
12
20
 
13
- def template_relative_path
21
+ private
22
+
23
+ attr_reader :file_copier
24
+
25
+ def template_file_path
14
26
  '/generators/templates/Rakefile.erb'
15
27
  end
28
+
29
+ def destination_path
30
+ '/Rakefile'
31
+ end
16
32
  end
17
33
  end
18
34
  end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'fileutils'
4
+ require 'erb'
5
+
6
+ module PicoApi
7
+ module Generators
8
+ class ErbDataMapper
9
+ def initialize(project_name_converter)
10
+ @snakecased_name = project_name_converter.snakecased
11
+ @camelcased_name = project_name_converter.camelcased
12
+ end
13
+
14
+ def get_binding
15
+ binding
16
+ end
17
+ end
18
+
19
+ class ErbDataHandler
20
+ def self.build(project_name_converter)
21
+ new(ErbDataMapper.new(project_name_converter))
22
+ end
23
+
24
+ def initialize(erb_data_mapper)
25
+ @erb_data_mapper = erb_data_mapper
26
+ end
27
+
28
+ def write_to_file(template_full_file_path, file)
29
+ file.write(
30
+ erb_template_file(template_full_file_path)
31
+ .result(erb_data_mapper.get_binding)
32
+ )
33
+ end
34
+
35
+ private
36
+
37
+ attr_reader :erb_data_mapper
38
+
39
+ def erb_template_file(template_full_file_path)
40
+ ERB.new(File.read(template_full_file_path))
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'fileutils'
4
+
5
+ module PicoApi
6
+ module Generators
7
+ class FileCopier
8
+ def self.build(project_name)
9
+ project_name_converter = ProjectNameConverter.new(project_name)
10
+
11
+ new(project_name_converter)
12
+ end
13
+
14
+ def initialize(project_name_converter)
15
+ @project_name_converter = project_name_converter
16
+ end
17
+
18
+ def copy(template_file_path, destination_path)
19
+ source_path = template_full_file_path(template_file_path)
20
+
21
+ FileUtils.cp(source_path, "#{snakecased_name}#{destination_path}")
22
+ end
23
+
24
+ private
25
+
26
+ attr_reader :project_name_converter
27
+
28
+ def snakecased_name
29
+ project_name_converter.snakecased
30
+ end
31
+
32
+ def template_full_file_path(template_relative_path)
33
+ File.join(PicoApi.lib_path, template_relative_path)
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'fileutils'
4
+
5
+ module PicoApi
6
+ module Generators
7
+ class FileCreator
8
+ def self.build(project_name)
9
+ project_name_converter = ProjectNameConverter.new(project_name)
10
+ erb_data_handler = ErbDataHandler.build(project_name_converter)
11
+
12
+ new(project_name_converter, erb_data_handler)
13
+ end
14
+
15
+ def initialize(project_name_converter, erb_data_handler)
16
+ @project_name_converter = project_name_converter
17
+ @erb_data_handler = erb_data_handler
18
+ end
19
+
20
+ def create(template_file_path, destination_path)
21
+ File.open("#{snakecased_name}#{destination_path}", 'w') do |file|
22
+ create_interpolated_erb_file(template_file_path, file)
23
+ end
24
+ end
25
+
26
+ private
27
+
28
+ attr_reader :project_name_converter, :erb_data_handler
29
+
30
+ def snakecased_name
31
+ project_name_converter.snakecased
32
+ end
33
+
34
+ def create_interpolated_erb_file(template_file_path, file)
35
+ source_path = template_full_file_path(template_file_path)
36
+
37
+ erb_data_handler.write_to_file(source_path, file)
38
+ end
39
+
40
+ def template_full_file_path(template_relative_path)
41
+ File.join(PicoApi.lib_path, template_relative_path)
42
+ end
43
+ end
44
+ end
45
+ end
@@ -5,20 +5,25 @@ module PicoApi
5
5
  class Generator
6
6
  class << self
7
7
  def call(project_name)
8
- commands = load_commands
9
- new(project_name, commands).call
8
+ new(project_name, loaded_commands).call
10
9
  end
11
10
 
12
- def load_commands
13
- skip_commands = %w[base copytemplate createtemplate]
14
-
15
- Dir[File.join(PicoApi.lib_path, '/generators/commands/*.rb')].sort.map do |file_path|
16
- file_name = file_path.split('/').last.gsub('.rb', '').camelize
17
- next if skip_commands.include?(file_name.downcase)
18
-
11
+ def loaded_commands
12
+ command_files.sort.map do |file_path|
13
+ file_name = camelized_file_name(file_path)
19
14
  "PicoApi::Generators::Commands::#{file_name}".constantize
20
15
  end.compact
21
16
  end
17
+
18
+ private
19
+
20
+ def command_files
21
+ Dir[File.join(PicoApi.lib_path, '/generators/commands/*.rb')]
22
+ end
23
+
24
+ def camelized_file_name(file_path)
25
+ file_path.split('/').last.gsub('.rb', '').camelize
26
+ end
22
27
  end
23
28
 
24
29
  def initialize(project_name, commands = [])
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PicoApi
4
+ module Generators
5
+ class ProjectNameConverter
6
+ attr_reader :camelcased, :snakecased
7
+
8
+ def initialize(project_name)
9
+ @camelcased = project_name.camelize
10
+ @snakecased = project_name.underscore
11
+ end
12
+ end
13
+ end
14
+ end
@@ -1,4 +1,4 @@
1
- module <%= @project_name_camelcased %>
1
+ module <%= @camelcased_name %>
2
2
  class Application < PicoApi::Application
3
3
  # Add routing instructions here. https://github.com/jeremyevans/roda
4
4
  end
@@ -1,9 +1,9 @@
1
1
  PicoApi.configure do |config|
2
2
  ## the base namespace of your app
3
- config.namespace = "<%= @project_name_camelcased %>"
3
+ config.namespace = "<%= @camelcased_name %>"
4
4
 
5
5
  ## the root directory where all the business logic resides
6
- config.lib_path = "lib/<%= @project_name_snakecased %>"
6
+ config.lib_path = "lib/<%= @snakecased_name %>"
7
7
 
8
8
  config.logger = Logger.new(STDOUT) if ENV['LOG_TO_STDOUT'] == 'true'
9
9
 
@@ -1,3 +1,3 @@
1
1
  require './config/boot'
2
2
 
3
- run <%= @project_name_camelcased %>::Application.freeze.app
3
+ run <%= @camelcased_name %>::Application.freeze.app
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PicoApi
4
- VERSION = '0.0.4'
4
+ VERSION = '0.0.6'
5
5
  end
data/pico_api.gemspec CHANGED
@@ -7,8 +7,8 @@ Gem::Specification.new do |spec|
7
7
  spec.version = PicoApi::VERSION
8
8
  spec.authors = ['Alex Avlonitis']
9
9
 
10
- spec.summary = 'A tiny Rack-based ruby template for APIs'
11
- spec.description = 'A tiny Rack-based ruby template for APIs'
10
+ spec.summary = 'A tiny Rack-based ruby template for building JSON-API REST APIs'
11
+ spec.description = 'A tiny Rack-based ruby template for building JSON-API REST APIs'
12
12
  spec.homepage = 'https://github.com/alexavlonitis/pico_api'
13
13
  spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
14
14
 
@@ -30,4 +30,5 @@ Gem::Specification.new do |spec|
30
30
  spec.add_runtime_dependency 'rom', '~> 5'
31
31
  spec.add_runtime_dependency 'rom-sql', '~> 3.5'
32
32
  spec.add_runtime_dependency 'zeitwerk', '~> 2.6'
33
+ spec.add_runtime_dependency 'activesupport', '~> 7.0.8'
33
34
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pico_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Avlonitis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-10 00:00:00.000000000 Z
11
+ date: 2023-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: erb
@@ -122,7 +122,21 @@ dependencies:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: '2.6'
125
- description: A tiny Rack-based ruby template for APIs
125
+ - !ruby/object:Gem::Dependency
126
+ name: activesupport
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: 7.0.8
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: 7.0.8
139
+ description: A tiny Rack-based ruby template for building JSON-API REST APIs
126
140
  email:
127
141
  executables:
128
142
  - pico_api
@@ -144,9 +158,7 @@ files:
144
158
  - lib/pico_api/database.rb
145
159
  - lib/pico_api/entities/error.rb
146
160
  - lib/pico_api/entities/errors.rb
147
- - lib/pico_api/generators/commands/base.rb
148
- - lib/pico_api/generators/commands/copy_template.rb
149
- - lib/pico_api/generators/commands/create_base.rb
161
+ - lib/pico_api/generators/commands/create_basic_structure.rb
150
162
  - lib/pico_api/generators/commands/create_config_application.rb
151
163
  - lib/pico_api/generators/commands/create_config_boot.rb
152
164
  - lib/pico_api/generators/commands/create_config_configuration.rb
@@ -157,8 +169,11 @@ files:
157
169
  - lib/pico_api/generators/commands/create_gemfile.rb
158
170
  - lib/pico_api/generators/commands/create_gitignore.rb
159
171
  - lib/pico_api/generators/commands/create_rakefile.rb
160
- - lib/pico_api/generators/commands/create_template.rb
172
+ - lib/pico_api/generators/erb_data_handler.rb
173
+ - lib/pico_api/generators/file_copier.rb
174
+ - lib/pico_api/generators/file_creator.rb
161
175
  - lib/pico_api/generators/generator.rb
176
+ - lib/pico_api/generators/project_name_converter.rb
162
177
  - lib/pico_api/generators/templates/.gitignore
163
178
  - lib/pico_api/generators/templates/Gemfile.erb
164
179
  - lib/pico_api/generators/templates/Rakefile.erb
@@ -196,5 +211,5 @@ requirements: []
196
211
  rubygems_version: 3.1.6
197
212
  signing_key:
198
213
  specification_version: 4
199
- summary: A tiny Rack-based ruby template for APIs
214
+ summary: A tiny Rack-based ruby template for building JSON-API REST APIs
200
215
  test_files: []
@@ -1,45 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'fileutils'
4
- require 'erb'
5
-
6
- module PicoApi
7
- module Generators
8
- module Commands
9
- class Base
10
- def self.call(project_name)
11
- new(project_name).call
12
- end
13
-
14
- def initialize(project_name)
15
- @project_name_camelcased = project_name.camelize
16
- @project_name_snakecased = project_name.underscore
17
- end
18
-
19
- def call
20
- NotImplementError
21
- end
22
-
23
- def get_binding
24
- binding
25
- end
26
-
27
- private
28
-
29
- attr_reader :project_name_camelised, :project_name_snakecased
30
-
31
- def erb
32
- ERB.new(File.read(template_full_path))
33
- end
34
-
35
- def template_full_path
36
- File.join(PicoApi.lib_path, template_relative_path)
37
- end
38
-
39
- def template_relative_path
40
- ''
41
- end
42
- end
43
- end
44
- end
45
- end
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module PicoApi
4
- module Generators
5
- module Commands
6
- class CopyTemplate < Base
7
- def call
8
- copy_file
9
- end
10
-
11
- private
12
-
13
- def copy_file
14
- FileUtils.cp(template_full_path, "#{project_name_snakecased}#{destination_path}")
15
- end
16
- end
17
- end
18
- end
19
- end
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module PicoApi
4
- module Generators
5
- module Commands
6
- class CreateBase < Base
7
- def call
8
- create_bin_folder
9
- create_lib_folder
10
- create_config_folder
11
- end
12
-
13
- private
14
-
15
- def create_bin_folder
16
- FileUtils.mkdir_p("#{project_name_snakecased}/bin")
17
- end
18
-
19
- def create_lib_folder
20
- FileUtils.mkdir_p("#{project_name_snakecased}/lib/#{project_name_snakecased}")
21
- end
22
-
23
- def create_config_folder
24
- FileUtils.mkdir_p("#{project_name_snakecased}/config")
25
- end
26
- end
27
- end
28
- end
29
- end
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module PicoApi
4
- module Generators
5
- module Commands
6
- class CreateTemplate < Base
7
- def call
8
- create_file
9
- end
10
-
11
- private
12
-
13
- def create_file
14
- File.open("#{project_name_snakecased}#{destination_path}", 'w') do |f|
15
- f.write(erb.result(get_binding))
16
- end
17
- end
18
- end
19
- end
20
- end
21
- end