pico_api 0.0.3 → 0.0.5

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.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/Readme.md +3 -2
  3. data/bin/pico_api +1 -2
  4. data/bin/setup +0 -0
  5. data/lib/pico_api/generators/commands/create_basic_structure.rb +48 -0
  6. data/lib/pico_api/generators/commands/create_config_application.rb +21 -5
  7. data/lib/pico_api/generators/commands/create_config_boot.rb +21 -5
  8. data/lib/pico_api/generators/commands/create_config_configuration.rb +21 -5
  9. data/lib/pico_api/generators/commands/create_config_database_setup.rb +21 -5
  10. data/lib/pico_api/generators/commands/create_config_database_yml.rb +21 -5
  11. data/lib/pico_api/generators/commands/create_config_dotenv.rb +21 -5
  12. data/lib/pico_api/generators/commands/create_config_ru.rb +21 -5
  13. data/lib/pico_api/generators/commands/create_gemfile.rb +21 -5
  14. data/lib/pico_api/generators/commands/create_gitignore.rb +21 -5
  15. data/lib/pico_api/generators/commands/create_rakefile.rb +21 -5
  16. data/lib/pico_api/generators/erb_data_handler.rb +44 -0
  17. data/lib/pico_api/generators/file_copier.rb +37 -0
  18. data/lib/pico_api/generators/file_creator.rb +45 -0
  19. data/lib/pico_api/generators/generator.rb +14 -9
  20. data/lib/pico_api/generators/project_name_converter.rb +14 -0
  21. data/lib/pico_api/generators/templates/config/application.erb +1 -1
  22. data/lib/pico_api/generators/templates/config/boot.erb +1 -1
  23. data/lib/pico_api/generators/templates/config/configuration.erb +2 -2
  24. data/lib/pico_api/generators/templates/config.ru.erb +1 -1
  25. data/lib/pico_api/version.rb +1 -1
  26. data/pico_api.gemspec +2 -2
  27. metadata +9 -8
  28. data/lib/pico_api/generators/commands/base.rb +0 -45
  29. data/lib/pico_api/generators/commands/copy_template.rb +0 -19
  30. data/lib/pico_api/generators/commands/create_base.rb +0 -29
  31. 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: 6d1191a8f8d535570f78985bbcb8fbd72c1ca6dae18c22c22721aaae7749e50d
4
- data.tar.gz: ba4c1daa34d3f9dca5db1c2e3d2d617da6583b82394a62062cdbd919da7f34ab
3
+ metadata.gz: 80e0e5f0c73cd86d5cd7fa83de8873ffd03fbef19edcd858f1a88bfd9351d2df
4
+ data.tar.gz: ab141287771254c8ec7c00a8410f0edb0e83e679581ca468d072d1973b963879
5
5
  SHA512:
6
- metadata.gz: a886497c3c53c5ef5d9b7a64e0598ab397bb0409411f1463c4f45ae87a601cea58577a7daded0734ecb2fedbcb0aa8c746eb915e9775fe4a2b79352e6887a85e
7
- data.tar.gz: a1c7f3f41ccb615fde6814e30afeb7e88c26349e181e1d7316fb79a8129bf7a529259e29291800c29111b5ce5b69abfad694e64f76901318efe01f13c2b135dd
6
+ metadata.gz: 816b7ec9bd637f920faafb82a4c62307fbb1ea21b0f14ef5c87a1c6840701da6f942beef8251ee52094dbaca128967550adcdcd270ac38c9955a08c2f32d5290
7
+ data.tar.gz: f49ca276ea4d3e73f25ac0e54db431b189e91702463447b3a3ba6e17e862d5a8fb7d2897beaf8878b6db25fce00e08335e5fdecc7020e4b6f7f2726287915caa
data/Readme.md CHANGED
@@ -40,9 +40,9 @@ Migration info: https://rom-rb.org/5.0/learn/sql/migrations/
40
40
 
41
41
  ### Routing
42
42
 
43
- Routing info: https://github.com/jeremyevans/roda
43
+ Routing info: https://github.com/jeremyevans/roda
44
44
 
45
- Add routing info in `config/application.rb` file
45
+ Add routing info in `config/application.rb` file
46
46
 
47
47
  ## Development
48
48
  - [x] Create Database config
@@ -52,6 +52,7 @@ Add routing info in `config/application.rb` file
52
52
  - [ ] Create a testing environment
53
53
  - [x] Allow multiple db gateways in the config
54
54
  - [ ] Add irb/pry console script
55
+ - [ ] Seperate configs to different environments (dev, prod, etc..)
55
56
 
56
57
  ## Contributing
57
58
 
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,5 +1,5 @@
1
1
  require "pico_api"
2
- require "./config/dotenv" if ENV['PICO_API_ENV'] == "development"
2
+ require "./config/dotenv"
3
3
  require "./config/configuration"
4
4
  require "./config/database_setup"
5
5
  require "./config/application"
@@ -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.3'
4
+ VERSION = '0.0.5'
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
 
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.3
4
+ version: 0.0.5
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-06 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,7 @@ 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
+ description: A tiny Rack-based ruby template for building JSON-API REST APIs
126
126
  email:
127
127
  executables:
128
128
  - pico_api
@@ -144,9 +144,7 @@ files:
144
144
  - lib/pico_api/database.rb
145
145
  - lib/pico_api/entities/error.rb
146
146
  - 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
147
+ - lib/pico_api/generators/commands/create_basic_structure.rb
150
148
  - lib/pico_api/generators/commands/create_config_application.rb
151
149
  - lib/pico_api/generators/commands/create_config_boot.rb
152
150
  - lib/pico_api/generators/commands/create_config_configuration.rb
@@ -157,8 +155,11 @@ files:
157
155
  - lib/pico_api/generators/commands/create_gemfile.rb
158
156
  - lib/pico_api/generators/commands/create_gitignore.rb
159
157
  - lib/pico_api/generators/commands/create_rakefile.rb
160
- - lib/pico_api/generators/commands/create_template.rb
158
+ - lib/pico_api/generators/erb_data_handler.rb
159
+ - lib/pico_api/generators/file_copier.rb
160
+ - lib/pico_api/generators/file_creator.rb
161
161
  - lib/pico_api/generators/generator.rb
162
+ - lib/pico_api/generators/project_name_converter.rb
162
163
  - lib/pico_api/generators/templates/.gitignore
163
164
  - lib/pico_api/generators/templates/Gemfile.erb
164
165
  - lib/pico_api/generators/templates/Rakefile.erb
@@ -196,5 +197,5 @@ requirements: []
196
197
  rubygems_version: 3.1.6
197
198
  signing_key:
198
199
  specification_version: 4
199
- summary: A tiny Rack-based ruby template for APIs
200
+ summary: A tiny Rack-based ruby template for building JSON-API REST APIs
200
201
  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