pico_api 0.0.5 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 80e0e5f0c73cd86d5cd7fa83de8873ffd03fbef19edcd858f1a88bfd9351d2df
4
- data.tar.gz: ab141287771254c8ec7c00a8410f0edb0e83e679581ca468d072d1973b963879
3
+ metadata.gz: 0ba0bd86009677fd541de7f33fa5e2ed40074b6b1b7e06e1ba9095e5113da435
4
+ data.tar.gz: 90131857e70c956228d93f9752a8d9db01163f99f0d452c1d316d902af708b10
5
5
  SHA512:
6
- metadata.gz: 816b7ec9bd637f920faafb82a4c62307fbb1ea21b0f14ef5c87a1c6840701da6f942beef8251ee52094dbaca128967550adcdcd270ac38c9955a08c2f32d5290
7
- data.tar.gz: f49ca276ea4d3e73f25ac0e54db431b189e91702463447b3a3ba6e17e862d5a8fb7d2897beaf8878b6db25fce00e08335e5fdecc7020e4b6f7f2726287915caa
6
+ metadata.gz: 4231577107ebeb6f5f3617d9919f126fea9e966d67399682d44aafd1d0e43b8afa036de98bfb842203b17a112b2da24cb46375164af3038e8901f7c0753fb239
7
+ data.tar.gz: ea1f261db930a1fc23a49cf82ca01bc91d1dc08229467d04164184fc5de9c377a94a78467dbf73c54ac666e9c3fef44ff6c193ae79c96b81127fd33ce6d20cf7
@@ -7,14 +7,14 @@ module PicoApi
7
7
  module Commands
8
8
  class CreateBasicStructure
9
9
  def self.call(project_name)
10
- project_name_converter =
11
- ::PicoApi::Generators::ProjectNameConverter.new(project_name)
10
+ project_name_data_mapper =
11
+ ::PicoApi::Generators::ProjectNameDataMapper.new(project_name)
12
12
 
13
- new(project_name_converter).call
13
+ new(project_name_data_mapper).call
14
14
  end
15
15
 
16
- def initialize(project_name_converter)
17
- @project_name_converter = project_name_converter
16
+ def initialize(project_name_data_mapper)
17
+ @project_name_data_mapper = project_name_data_mapper
18
18
  end
19
19
 
20
20
  def call
@@ -25,7 +25,7 @@ module PicoApi
25
25
 
26
26
  private
27
27
 
28
- attr_reader :project_name_converter
28
+ attr_reader :project_name_data_mapper
29
29
 
30
30
  def create_bin_folder
31
31
  FileUtils.mkdir_p("#{snakecased_name}/bin")
@@ -40,7 +40,7 @@ module PicoApi
40
40
  end
41
41
 
42
42
  def snakecased_name
43
- project_name_converter.snakecased
43
+ project_name_data_mapper.snakecased
44
44
  end
45
45
  end
46
46
  end
@@ -6,13 +6,13 @@ module PicoApi
6
6
  module Generators
7
7
  class FileCopier
8
8
  def self.build(project_name)
9
- project_name_converter = ProjectNameConverter.new(project_name)
9
+ project_name_data_mapper = ProjectNameDataMapper.new(project_name)
10
10
 
11
- new(project_name_converter)
11
+ new(project_name_data_mapper)
12
12
  end
13
13
 
14
- def initialize(project_name_converter)
15
- @project_name_converter = project_name_converter
14
+ def initialize(project_name_data_mapper)
15
+ @project_name_data_mapper = project_name_data_mapper
16
16
  end
17
17
 
18
18
  def copy(template_file_path, destination_path)
@@ -23,10 +23,10 @@ module PicoApi
23
23
 
24
24
  private
25
25
 
26
- attr_reader :project_name_converter
26
+ attr_reader :project_name_data_mapper
27
27
 
28
28
  def snakecased_name
29
- project_name_converter.snakecased
29
+ project_name_data_mapper.snakecased
30
30
  end
31
31
 
32
32
  def template_full_file_path(template_relative_path)
@@ -1,40 +1,42 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'fileutils'
4
+ require 'erb'
4
5
 
5
6
  module PicoApi
6
7
  module Generators
7
8
  class FileCreator
8
9
  def self.build(project_name)
9
- project_name_converter = ProjectNameConverter.new(project_name)
10
- erb_data_handler = ErbDataHandler.build(project_name_converter)
10
+ project_name_data_mapper = ProjectNameDataMapper.new(project_name)
11
11
 
12
- new(project_name_converter, erb_data_handler)
12
+ new(project_name_data_mapper)
13
13
  end
14
14
 
15
- def initialize(project_name_converter, erb_data_handler)
16
- @project_name_converter = project_name_converter
17
- @erb_data_handler = erb_data_handler
15
+ def initialize(project_name_data_mapper)
16
+ @project_name_data_mapper = project_name_data_mapper
18
17
  end
19
18
 
20
19
  def create(template_file_path, destination_path)
21
20
  File.open("#{snakecased_name}#{destination_path}", 'w') do |file|
22
- create_interpolated_erb_file(template_file_path, file)
21
+ file.write(template(template_file_path))
23
22
  end
24
23
  end
25
24
 
26
25
  private
27
26
 
28
- attr_reader :project_name_converter, :erb_data_handler
27
+ attr_reader :project_name_data_mapper
29
28
 
30
29
  def snakecased_name
31
- project_name_converter.snakecased
30
+ project_name_data_mapper.snakecased
32
31
  end
33
32
 
34
- def create_interpolated_erb_file(template_file_path, file)
35
- source_path = template_full_file_path(template_file_path)
33
+ def template(template_file_path)
34
+ erb(template_file_path).result(project_name_data_mapper.get_binding)
35
+ end
36
36
 
37
- erb_data_handler.write_to_file(source_path, file)
37
+ def erb(template_file_path)
38
+ source_file = File.read(template_full_file_path(template_file_path))
39
+ ERB.new(source_file)
38
40
  end
39
41
 
40
42
  def template_full_file_path(template_relative_path)
@@ -2,13 +2,17 @@
2
2
 
3
3
  module PicoApi
4
4
  module Generators
5
- class ProjectNameConverter
5
+ class ProjectNameDataMapper
6
6
  attr_reader :camelcased, :snakecased
7
7
 
8
8
  def initialize(project_name)
9
9
  @camelcased = project_name.camelize
10
10
  @snakecased = project_name.underscore
11
11
  end
12
+
13
+ def get_binding
14
+ binding
15
+ end
12
16
  end
13
17
  end
14
18
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PicoApi
4
- VERSION = '0.0.5'
4
+ VERSION = '0.1.0'
5
5
  end
data/pico_api.gemspec CHANGED
@@ -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,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pico_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Avlonitis
@@ -122,6 +122,20 @@ dependencies:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: '2.6'
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
125
139
  description: A tiny Rack-based ruby template for building JSON-API REST APIs
126
140
  email:
127
141
  executables:
@@ -155,11 +169,10 @@ files:
155
169
  - lib/pico_api/generators/commands/create_gemfile.rb
156
170
  - lib/pico_api/generators/commands/create_gitignore.rb
157
171
  - lib/pico_api/generators/commands/create_rakefile.rb
158
- - lib/pico_api/generators/erb_data_handler.rb
159
172
  - lib/pico_api/generators/file_copier.rb
160
173
  - lib/pico_api/generators/file_creator.rb
161
174
  - lib/pico_api/generators/generator.rb
162
- - lib/pico_api/generators/project_name_converter.rb
175
+ - lib/pico_api/generators/project_name_data_mapper.rb
163
176
  - lib/pico_api/generators/templates/.gitignore
164
177
  - lib/pico_api/generators/templates/Gemfile.erb
165
178
  - lib/pico_api/generators/templates/Rakefile.erb
@@ -1,44 +0,0 @@
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