appifier 0.1.0 → 0.1.2

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 (39) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +56 -2
  3. data/Gemfile +3 -1
  4. data/Rakefile +27 -15
  5. data/VERSION +1 -1
  6. data/appifier.gemspec +20 -19
  7. data/bin/console +4 -3
  8. data/config/appifier.registry +9 -0
  9. data/config/settings.yml +59 -0
  10. data/exe/appifier +2 -1
  11. data/lib/appifier/actors/collector.rb +67 -0
  12. data/lib/appifier/actors/generator.rb +92 -100
  13. data/lib/appifier/actors/init.rb +3 -1
  14. data/lib/appifier/actors/retriever.rb +35 -35
  15. data/lib/appifier/cli/configuration.rb +13 -14
  16. data/lib/appifier/cli/templates.rb +28 -8
  17. data/lib/appifier/cli.rb +108 -49
  18. data/lib/appifier/components/Appifile.rb +35 -0
  19. data/lib/appifier/components/init.rb +3 -0
  20. data/lib/appifier/components/templates.rb +34 -0
  21. data/lib/appifier/helpers/archives.rb +29 -31
  22. data/lib/appifier/helpers/datasets.rb +36 -0
  23. data/lib/appifier/helpers/gem.rb +31 -30
  24. data/lib/appifier/helpers/init.rb +3 -1
  25. data/lib/appifier/helpers/user.rb +29 -31
  26. data/lib/appifier/services/finisher.rb +52 -0
  27. data/lib/appifier/services/init.rb +3 -0
  28. data/lib/appifier/setup.rb +11 -7
  29. data/lib/appifier/version.rb +2 -0
  30. data/lib/appifier.rb +34 -23
  31. data/samples/dummy/Appifile +12 -0
  32. data/samples/{skeleton → dummy/skeleton}/%%APPNAME.downcase%%/.rspec +0 -0
  33. data/samples/{skeleton → dummy/skeleton}/%%APPNAME.downcase%%/Rakefile +0 -0
  34. data/samples/{skeleton → dummy/skeleton}/%%APPNAME.downcase%%/config.ru +0 -0
  35. data/samples/{skeleton → dummy/skeleton}/%%APPNAME.downcase%%/exe/%%APPNAME.downcase%% +0 -0
  36. data/samples/{skeleton → dummy/skeleton}/%%APPNAME.downcase%%/lib/%%APPNAME.downcase%%.rb +0 -0
  37. data/samples/{skeleton → dummy/skeleton}/%%APPNAME.downcase%%/spec/%%APPNAME.downcase%%_spec.rb +0 -0
  38. data/samples/dummy.tgz +0 -0
  39. metadata +53 -30
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f84489d520ea8b155b2b509e2cffbb77fd2bed0a1a7c526f496687196e751bb8
4
- data.tar.gz: e44f047a7a1185ef8fa48abcf91a5124f2770ace0d0a6f51ceb166187a93752d
3
+ metadata.gz: aeea227ea8e3eaa87c58fcbd7333297f73b7e2c82f7ba51da9b8bccb4f979f05
4
+ data.tar.gz: 3121f0753db7fbc4b8d68f2acfaf141cf9ee9785f5abfc5edca2b5a645faa942
5
5
  SHA512:
6
- metadata.gz: e97e31f134e240f3ac3237b858d01b09a145e7881d89a44fa990787f61d345906189643d68368e5bab7176efdfe18a397a0365c62fbee9201b813045ab8b862e
7
- data.tar.gz: 4edce23e19c9c350d17ea21b07988daa50daf116495fc6e491b2c63b8a775cebc04c3906903aedfc8feb50d6fe890619b0cadb120617306d503864a9ed319f9b
6
+ metadata.gz: d7aceeba188e836380bd52eebdfb87839c6227f79282e2ae90fe12d1486d03c4dbb53147c61abb84d4aab172bca8e10b8d7aa419b214e0f0bb151bbd30e4a17c
7
+ data.tar.gz: 90fa233237110cfc8c815e6d3002dbc831eaf08b9979d9f0d499f9d08228768c87e519f212fde8241ee9c944f158d90cadbe9924fc4031bd8a8eaa42a6165873
data/.rubocop.yml CHANGED
@@ -1,9 +1,11 @@
1
+
2
+
1
3
  AllCops:
2
4
  NewCops: enable
3
5
  SuggestExtensions: false
4
6
  Exclude:
5
- - 'spec/template_spec.rb'
6
-
7
+ - 'samples/**/*'
8
+ - 'spec/**/*'
7
9
 
8
10
 
9
11
  # definitive :
@@ -28,3 +30,55 @@ Metrics/MethodLength:
28
30
  Enabled: false
29
31
  Metrics/PerceivedComplexity:
30
32
  Enabled: false
33
+
34
+
35
+
36
+ # Offense count: 2
37
+ # Configuration parameters: AllowKeywordBlockArguments.
38
+ Lint/UnderscorePrefixedVariableName:
39
+ Exclude:
40
+ - 'lib/appifier/helpers/gem.rb'
41
+
42
+ # Offense count: 1
43
+ Lint/UselessAssignment:
44
+ Exclude:
45
+ - 'lib/appifier.rb'
46
+
47
+ # Offense count: 1
48
+ # Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros.
49
+ # NamePrefix: is_, has_, have_
50
+ # ForbiddenPrefixes: is_, has_, have_
51
+ # AllowedMethods: is_a?
52
+ # MethodDefinitionMacros: define_method, define_singleton_method
53
+ Naming/PredicateName:
54
+ Exclude:
55
+
56
+ - 'lib/appifier/helpers/user.rb'
57
+
58
+ # Offense count: 1
59
+ Security/Open:
60
+ Exclude:
61
+ - 'lib/appifier/helpers/archives.rb'
62
+
63
+ # Offense count: 12
64
+ # Configuration parameters: AllowedConstants.
65
+ Style/Documentation:
66
+ Exclude:
67
+ - 'spec/**/*'
68
+ - 'test/**/*'
69
+ - 'lib/appifier.rb'
70
+ - 'lib/appifier/actors/generator.rb'
71
+ - 'lib/appifier/actors/retriever.rb'
72
+ - 'lib/appifier/cli/configuration.rb'
73
+ - 'lib/appifier/cli/templates.rb'
74
+ - 'lib/appifier/helpers/archives.rb'
75
+ - 'lib/appifier/helpers/gem.rb'
76
+ - 'lib/appifier/helpers/templates.rb'
77
+ - 'lib/appifier/helpers/user.rb'
78
+ - 'lib/appifier/setup.rb'
79
+
80
+ # Offense count: 2
81
+ Style/MixinUsage:
82
+ Exclude:
83
+ - 'exe/appifier'
84
+ - 'lib/appifier.rb'
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
- source "https://rubygems.org"
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
2
4
 
3
5
  gemspec
data/Rakefile CHANGED
@@ -1,35 +1,47 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
- require "version"
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+ require 'version'
4
6
  require 'rake/version_task'
5
7
  require 'code_statistics'
6
8
  require 'yard'
7
- require 'yard/rake/yardoc_task.rb'
9
+ require 'yard/rake/yardoc_task'
8
10
  require 'rubocop/rake_task'
9
- require "carioca/rake/manage"
11
+ require 'carioca/rake/manage'
10
12
 
11
13
  RuboCop::RakeTask.new
12
14
 
13
-
14
15
  Rake::VersionTask.new
15
16
 
16
17
  RSpec::Core::RakeTask.new(:spec)
17
18
 
18
-
19
- task :default => :spec
19
+ task default: :spec
20
20
 
21
21
  YARD::Rake::YardocTask.new do |t|
22
- t.files = [ 'lib/**/*.rb', '-', 'doc/**/*','spec/**/*_spec.rb']
23
- t.options += ['-o', "yardoc"]
22
+ t.files = ['lib/**/*.rb', '-', 'doc/**/*', 'spec/**/*_spec.rb']
23
+ t.options += ['-o', 'yardoc']
24
24
  end
25
25
 
26
26
  YARD::Config.load_plugin('yard-rspec')
27
27
 
28
28
  namespace :yardoc do
29
- task :clobber do
30
- rm_r "yardoc" rescue nil
31
- rm_r ".yardoc" rescue nil
32
- rm_r "pkg" rescue nil
29
+ task :clobber do
30
+ begin
31
+ rm_r 'yardoc'
32
+ rescue StandardError
33
+ nil
34
+ end
35
+ begin
36
+ rm_r '.yardoc'
37
+ rescue StandardError
38
+ nil
39
+ end
40
+ begin
41
+ rm_r 'pkg'
42
+ rescue StandardError
43
+ nil
33
44
  end
45
+ end
34
46
  end
35
- task :clobber => "yardoc:clobber"
47
+ task clobber: 'yardoc:clobber'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.2
data/appifier.gemspec CHANGED
@@ -1,39 +1,40 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  Gem::Specification.new do |spec|
3
- spec.name = "appifier"
4
+ spec.name = 'appifier'
4
5
  spec.version = `cat VERSION`.chomp
5
- spec.authors = ["Camille Paquet", "Romain GEORGES"]
6
- spec.email = ["gems@ultragreen.net"]
6
+ spec.authors = ['Camille Paquet', 'Romain GEORGES']
7
+ spec.email = ['gems@ultragreen.net']
7
8
 
8
- spec.summary = "Appifier : Applications templating and management tools "
9
- spec.description = "Appifier : Applications templating and management tools "
10
- spec.homepage = "https://github.com/Ultragreen/appifier"
11
- spec.license = "MIT"
12
- spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
9
+ spec.summary = 'Appifier : Applications templating and management tools '
10
+ spec.description = 'Appifier : Applications templating and management tools '
11
+ spec.homepage = 'https://github.com/Ultragreen/appifier'
12
+ spec.license = 'MIT'
13
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.6.0')
13
14
 
14
- spec.metadata["homepage_uri"] = spec.homepage
15
+ spec.metadata['homepage_uri'] = spec.homepage
15
16
  spec.metadata['source_code_uri'] = spec.homepage
16
17
  spec.metadata['changelog_uri'] = spec.homepage
17
18
 
18
19
  # Specify which files should be added to the gem when it is released.
19
20
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
20
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
21
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
21
22
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
22
23
  end
23
- spec.bindir = "exe"
24
+ spec.bindir = 'exe'
24
25
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
- spec.require_paths = ["lib"]
26
+ spec.require_paths = ['lib']
26
27
 
28
+ spec.add_development_dependency 'code_statistics', '~> 0.2.13'
27
29
  spec.add_development_dependency 'rake', '~> 12.0'
30
+ spec.add_development_dependency 'roodi', '~> 5.0'
28
31
  spec.add_development_dependency 'rspec', '~> 3.0'
29
32
  spec.add_development_dependency 'rubocop', '~> 1.32'
30
- spec.add_development_dependency "roodi", "~> 5.0"
31
- spec.add_development_dependency 'code_statistics', '~> 0.2.13'
32
- spec.add_development_dependency "yard", "~> 0.9.27"
33
- spec.add_development_dependency "yard-rspec", "~> 0.1"
34
33
  spec.add_development_dependency 'version', '~> 1.1'
34
+ spec.add_development_dependency 'yard', '~> 0.9.27'
35
+ spec.add_development_dependency 'yard-rspec', '~> 0.1'
35
36
  spec.metadata['rubygems_mfa_required'] = 'false'
36
- spec.add_dependency "carioca", "~> 2.0"
37
- spec.add_dependency "thor", "~> 1.2"
38
-
37
+ spec.add_dependency 'carioca', '~> 2.0.9'
38
+ spec.add_dependency 'thor', '~> 1.2'
39
+ spec.add_dependency 'tty-prompt', '~> 0.23.1'
39
40
  end
data/bin/console CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require "bundler/setup"
4
- require "appifier"
4
+ require 'bundler/setup'
5
+ require 'appifier'
5
6
 
6
7
  # You can add fixtures and/or initialization code here to make experimenting
7
8
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +11,5 @@ require "appifier"
10
11
  # require "pry"
11
12
  # Pry.start
12
13
 
13
- require "irb"
14
+ require 'irb'
14
15
  IRB.start(__FILE__)
@@ -0,0 +1,9 @@
1
+ ---
2
+ :finisher:
3
+ :type: :internal
4
+ :description: The Finisher service
5
+ :service: Appifier::Services::Finisher
6
+ :depends:
7
+ - :configuration
8
+ - :logger
9
+ - :output
data/config/settings.yml CHANGED
@@ -6,3 +6,62 @@
6
6
  :test: {}
7
7
  :default:
8
8
  :test: 'Romain'
9
+ :exit_cases:
10
+ :not_root:
11
+ :message: This operation need to be run as root (use sudo or rvmsudo)
12
+ :code: 10
13
+ :options_incompatibility:
14
+ :message: Options incompatibility
15
+ :code: 40
16
+ :service_dependence_missing:
17
+ :message: Appifier Service dependence missing
18
+ :code: 60
19
+ :config_required:
20
+ :message: Specific configuration required
21
+ :code: 30
22
+ :setup_error:
23
+ :message: Setup terminated unsuccessfully
24
+ :code: 25
25
+ :setup_success:
26
+ :message: Setup terminated successfully
27
+ :code: 0
28
+ :sanitycheck_error:
29
+ :messagee: Sanitycheck terminated unsuccessfully
30
+ :code: 20
31
+ :sanitycheck_success:
32
+ :message: Sanitycheck terminated successfully
33
+ :code: 0
34
+ :configuration_error:
35
+ :message: Configuration Error
36
+ :code: 50
37
+
38
+
39
+ # global
40
+ :quiet_exit:
41
+ :code: 0
42
+ :error_exit:
43
+ :code: 99
44
+ :message: Operation failure
45
+
46
+ # events
47
+ :interrupt:
48
+ :message: User operation interrupted
49
+ :code: 33
50
+
51
+ # request
52
+ :not_found:
53
+ :message: Object not found
54
+ :code: 44
55
+ :already_exist:
56
+ :message: Object already exist
57
+ :code: 48
58
+
59
+ # daemon
60
+ :status_ok:
61
+ :message: Status OK
62
+ :code: 0
63
+ :status_ko:
64
+ :message: Status KO
65
+ :code: 31
66
+
67
+
data/exe/appifier CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'appifier'
4
5
 
@@ -6,4 +7,4 @@ require 'appifier/cli'
6
7
 
7
8
  include Appifier::CLI
8
9
 
9
- Command.start(ARGV)
10
+ MainCommand.start(ARGV)
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+ require "tty-prompt"
3
+
4
+ module Appifier
5
+ module Actors
6
+ class Collector
7
+
8
+ extend Carioca::Injector
9
+ inject service: :output
10
+
11
+ attr_accessor :dataset
12
+ attr_reader :template
13
+
14
+ def initialize(template: ,dataset: nil,force: false )
15
+ @force = force
16
+ @template = template
17
+ get_defined_dataset(dataset)
18
+ end
19
+
20
+
21
+ def collect
22
+
23
+ appifilename = "#{File.expand_path(Appifier::DEFAULT_TEMPLATES_PATH)}/#{template}/Appifile"
24
+ appifile = Appifier::Components::Appifile::new path: appifilename
25
+ prompt = TTY::Prompt.new
26
+ @dataset = {}
27
+ appifile.dataset_rules.each do |name, rule|
28
+ default = (rule[:default])? rule[:default] : ""
29
+ @dataset[name] = prompt.ask("Give #{rule[:description]} : ", default: default) do |q|
30
+ q.required true
31
+ q.validate Regexp.new(rule[:format]) if rule[:format]
32
+ end
33
+ end
34
+ write_dataset template: @template, data: @dataset
35
+ @collected = true
36
+ output.info "Dataset recorded for #{@template}"
37
+
38
+ end
39
+
40
+ def collected?
41
+ return @collected
42
+ end
43
+
44
+ private
45
+ def get_defined_dataset(newdataset=nil)
46
+ if check_dataset_defined? template: @template then
47
+ @dataset = open_dataset template: @template
48
+ if @force
49
+ @dataset = newdataset
50
+ write_dataset template: @template, data: @dataset
51
+ else
52
+ raise "Dataset already collect for template : #{@template}"
53
+ end
54
+ @collected = true
55
+ elsif newdataset
56
+ @dataset = newdataset
57
+ write_dataset template: @template, data: @dataset
58
+ @collected = true
59
+ else
60
+ @dataset = nil
61
+ @collected = false
62
+ end
63
+ end
64
+ end
65
+
66
+ end
67
+ end
@@ -1,105 +1,97 @@
1
+ # frozen_string_literal: true
1
2
 
2
- module Appifier
3
-
4
- module Actors
5
- class Generator
6
-
7
- attr_reader :src_paths
8
- attr_reader :src_files
9
- attr_reader :src_folders
10
- attr_reader :target_folders
11
- attr_reader :target_files
12
-
13
-
14
- def initialize(src_root: , target_root:)
15
- @src_root = src_root
16
- @target_root = target_root
17
- @target_folders = []
18
- @target_files = []
19
- @data = {appname: 'test'}
20
- @src_paths = Dir.glob("#{@src_root}/**/*", File::FNM_DOTMATCH)
21
- @src_paths.delete_if {|file| file =~ /\/\.$/}
22
- @src_folders = @src_paths.select{|item| File::directory? item }
23
- @src_files = @src_paths.select{|item| File::file? item }
24
- end
25
-
26
-
27
- def generate(dry_run: false, force: false )
28
- puts 'Running in dry_run' if dry_run
29
- calculate
30
- if check_folder_already_exist and !force
31
- puts 'Folders and files already exist'
32
- return false
33
- end
34
- FileUtils.rm_rf("#{@target_root}/#{@target_folders.first}") if force
35
- puts 'Generate folders'
36
- generate_folders dry_run: dry_run
37
- puts 'Generate files'
38
- generate_files dry_run: dry_run
39
- end
40
-
41
- def calculate
42
- calculate_target type: :folder
43
- calculate_target type: :file
44
- end
45
-
46
- private
47
-
48
- def check_folder_already_exist
49
- File.directory?("#{@target_root}/#{@target_folders.first}")
50
- end
51
-
52
- def generate_folders(dry_run:)
53
- puts "Target path to create in #{@target_root} :"
54
- @target_folders.each do |path|
55
- action = (dry_run)? '[SKIPPED]' : '[OK]'
56
- FileUtils.mkdir_p "#{@target_root}/#{path}", noop: dry_run
57
- puts "#{action} #{path}"
58
- end
59
- end
60
-
61
- def generate_files(dry_run:)
62
- puts "Target files to create in #{@target_root} :"
63
- @src_files.each_with_index do |path, index|
64
- if dry_run
65
- result = "[SKIPPED]"
66
- else
67
- begin
68
- template = Template::new strict:false,
69
- list_token: @data.keys,
70
- template_file: path
71
- template.map(@data)
72
- content = template.output
73
- File.open("#{@target_root}/#{@target_files[index]}", 'w') { |file| file.write(content) }
74
- result = "[OK]"
75
- rescue InvalidTokenList, NotAToken, NoTemplateFile
76
- result = "[KO]"
77
- end
78
- end
79
- puts "#{result} #{@target_files[index]}"
80
- end
81
- end
82
-
83
-
84
- def calculate_target(type:)
85
- if type == :folder then
86
- target = @target_folders
87
- src = @src_folders
88
- else
89
- target = @target_files
90
- src = @src_files
91
- end
92
- src.each do |folder|
93
- template = Template::new strict:false,
94
- list_token: @data.keys,
95
- template_content: folder.delete_prefix("#{@src_root}/" )
96
- template.map(@data)
97
- output = template.output
98
- target.push output unless target.include? output
99
- end
100
-
3
+ module Appifier
4
+ module Actors
5
+ class Generator
6
+ attr_reader :src_paths, :src_files, :src_folders, :target_folders, :target_files
7
+
8
+ extend Carioca::Injector
9
+ inject service: :output
10
+
11
+
12
+ def initialize(src_root:, target_root:, dataset: )
13
+ @src_root = src_root
14
+ @target_root = target_root
15
+ @target_folders = []
16
+ @target_files = []
17
+ @data = dataset
18
+ @src_paths = Dir.glob("#{@src_root}/**/*", File::FNM_DOTMATCH)
19
+ @src_paths.delete_if { |file| file =~ %r{/\.$} }
20
+ @src_folders = @src_paths.select { |item| File.directory? item }
21
+ @src_files = @src_paths.select { |item| File.file? item }
22
+ raise 'Application template not found' unless File.exist?(src_root)
23
+ end
24
+
25
+ def generate(dry_run: false, force: false)
26
+ output.info 'Running in dry_run (operation will be SKIPPED)' if dry_run
27
+ calculate
28
+ raise 'Folders and files already exist' if check_folder_already_exist && !force
29
+ FileUtils.rm_rf("#{@target_root}/#{@target_folders.first}") if force
30
+ output.info 'Generate folders'
31
+ generate_folders dry_run: dry_run
32
+ output.info 'Generate files'
33
+ generate_files dry_run: dry_run
34
+ end
35
+
36
+ def calculate
37
+ calculate_target type: :folder
38
+ calculate_target type: :file
39
+ end
40
+
41
+ private
42
+
43
+ def check_folder_already_exist
44
+ File.directory?("#{@target_root}/#{@target_folders.first}")
45
+ end
46
+
47
+ def generate_folders(dry_run:)
48
+ output.info "Target path to create in #{@target_root} :"
49
+ @target_folders.each do |path|
50
+ action = dry_run ? :skipped : :ok
51
+ FileUtils.mkdir_p "#{@target_root}/#{path}", noop: dry_run
52
+ output.send action, "#{path}"
53
+ end
54
+ end
55
+
56
+ def generate_files(dry_run:)
57
+ output.info "Target files to create in #{@target_root} :"
58
+ @src_files.each_with_index do |path, index|
59
+ if dry_run
60
+ result = :skipped
61
+ else
62
+ begin
63
+ template = Template.new strict: false,
64
+ list_token: @data.keys,
65
+ template_file: path
66
+ template.map(@data)
67
+ content = template.output
68
+ File.write("#{@target_root}/#{@target_files[index]}", content)
69
+ result = :ok
70
+ rescue InvalidTokenList, NotAToken, NoTemplateFile
71
+ result = :ko
101
72
  end
102
-
73
+ end
74
+ output.send result,"#{@target_files[index]}"
75
+ end
76
+ end
77
+
78
+ def calculate_target(type:)
79
+ if type == :folder
80
+ target = @target_folders
81
+ src = @src_folders
82
+ else
83
+ target = @target_files
84
+ src = @src_files
85
+ end
86
+ src.each do |folder|
87
+ template = Template.new strict: false,
88
+ list_token: @data.keys,
89
+ template_content: folder.delete_prefix("#{@src_root}/")
90
+ template.map(@data)
91
+ output = template.output
92
+ target.push output unless target.include? output
103
93
  end
94
+ end
104
95
  end
96
+ end
105
97
  end
@@ -1 +1,3 @@
1
- Dir[File.dirname(__FILE__) + '/*.rb'].each {|file| require file unless File.basename(file) == 'init.rb'}
1
+ # frozen_string_literal: true
2
+
3
+ Dir["#{File.dirname(__FILE__)}/*.rb"].sort.each { |file| require file unless File.basename(file) == 'init.rb' }
@@ -1,38 +1,38 @@
1
- module Appifier
2
-
3
- module Actors
4
-
5
- module Retrivers
6
- class Git
7
- def self.get(origin:, destination:)
8
-
9
- end
10
- end
11
-
12
- class Archive
13
- def self.get(origin:, destination:)
14
- untar_gz archive: origin, destination: destination
15
- end
16
- end
17
-
1
+ # frozen_string_literal: false
2
+
3
+ module Appifier
4
+ module Actors
5
+ module Retrivers
6
+ class Git
7
+ def self.get(origin:, destination:);
8
+ raise 'not yest implemented'
18
9
  end
19
-
20
- class Retriever
21
-
22
- TYPE = {:archive => Appifier::Actors::Retrivers::Archive, :git => Appifier::Actors::Retrivers::Git}
23
-
24
- def initialize(type: :archive, origin:, destination: File.expand_path(Appifier::DEFAULT_TEMPLATES_PATH ))
25
- @origin = origin
26
- @type = type
27
- @destination = destination
28
- puts "retrieving template from #{origin}"
29
- end
30
-
31
- def get
32
- TYPE[@type].get origin: @origin , destination: @destination
33
- end
34
-
10
+ end
11
+
12
+ class Archive
13
+ def self.get(origin:, destination:)
14
+ raise "Archive : #{origin} not found" unless File::exist? origin
15
+ untar_gz archive: origin, destination: destination
35
16
  end
36
-
17
+ end
37
18
  end
38
- end
19
+
20
+ class Retriever
21
+ extend Carioca::Injector
22
+ inject service: :output
23
+
24
+ TYPE = { archive: Appifier::Actors::Retrivers::Archive, git: Appifier::Actors::Retrivers::Git }
25
+
26
+ def initialize(origin:, type: :archive, destination: File.expand_path(Appifier::DEFAULT_TEMPLATES_PATH))
27
+ @origin = origin
28
+ @type = type
29
+ @destination = destination
30
+ output.info "retrieving template from #{origin}"
31
+ end
32
+
33
+ def get
34
+ TYPE[@type].get origin: @origin, destination: @destination
35
+ end
36
+ end
37
+ end
38
+ end