pico_api 0.0.6 → 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: f7269c4d7be561c7d2d8d88cbb697532367ebc0eb01204b26a6fb52003bb9486
4
- data.tar.gz: 331dad6797d31af58a659183b294378686faff69829a10b077e4c97aaeb367cd
3
+ metadata.gz: 0ba0bd86009677fd541de7f33fa5e2ed40074b6b1b7e06e1ba9095e5113da435
4
+ data.tar.gz: 90131857e70c956228d93f9752a8d9db01163f99f0d452c1d316d902af708b10
5
5
  SHA512:
6
- metadata.gz: bf94c3bbb5dc17ad9a3713f0111c3f72712cfbfe80c87a16ba9729da28bdb145a7c8ab8494aeca59cc71d7df8387451c121dcc798e9882bfed5691a04a827dce
7
- data.tar.gz: 1288b2ff7bbc79635c4a4e6f56f04513bc52ec467db96c26e141851994ea33578a2ddfbc360f9cc58b4b8c70046cbb04bb91057459552b062e8dda712af0d48d
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.6'
4
+ VERSION = '0.1.0'
5
5
  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.6
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Avlonitis
@@ -169,11 +169,10 @@ files:
169
169
  - lib/pico_api/generators/commands/create_gemfile.rb
170
170
  - lib/pico_api/generators/commands/create_gitignore.rb
171
171
  - lib/pico_api/generators/commands/create_rakefile.rb
172
- - lib/pico_api/generators/erb_data_handler.rb
173
172
  - lib/pico_api/generators/file_copier.rb
174
173
  - lib/pico_api/generators/file_creator.rb
175
174
  - lib/pico_api/generators/generator.rb
176
- - lib/pico_api/generators/project_name_converter.rb
175
+ - lib/pico_api/generators/project_name_data_mapper.rb
177
176
  - lib/pico_api/generators/templates/.gitignore
178
177
  - lib/pico_api/generators/templates/Gemfile.erb
179
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