siba 0.5.6 → 0.5.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. data/README.md +3 -3
  2. data/Rakefile +6 -6
  3. data/lib/siba/backup.rb +2 -2
  4. data/lib/siba/console.rb +13 -13
  5. data/lib/siba/generator.rb +4 -5
  6. data/lib/siba/helpers/file_helper.rb +6 -6
  7. data/lib/siba/helpers/password_strength.rb +5 -5
  8. data/lib/siba/helpers/security_helper.rb +9 -9
  9. data/lib/siba/helpers/test/extend_test.rb +7 -7
  10. data/lib/siba/helpers/test/helper.rb +3 -3
  11. data/lib/siba/logger_plug.rb +1 -1
  12. data/lib/siba/plugins/archive/tar/archive.rb +8 -8
  13. data/lib/siba/plugins/archive/tar/init.rb +3 -3
  14. data/lib/siba/plugins/destination/dir/dest_dir.rb +7 -7
  15. data/lib/siba/plugins/destination/dir/init.rb +2 -2
  16. data/lib/siba/plugins/encryption/gpg/encryption.rb +10 -10
  17. data/lib/siba/plugins/encryption/gpg/init.rb +1 -1
  18. data/lib/siba/plugins/installed_plugins.rb +10 -6
  19. data/lib/siba/plugins/plugin_loader.rb +6 -5
  20. data/lib/siba/plugins/source/files/files.rb +7 -7
  21. data/lib/siba/plugins/source/files/init.rb +2 -2
  22. data/lib/siba/restore.rb +5 -5
  23. data/lib/siba/scaffold.rb +17 -17
  24. data/lib/siba/siba_check.rb +3 -3
  25. data/lib/siba/siba_file.rb +6 -6
  26. data/lib/siba/siba_logger.rb +11 -11
  27. data/lib/siba/tasks/siba_task.rb +1 -1
  28. data/lib/siba/tasks/siba_tasks.rb +7 -7
  29. data/lib/siba/test_files.rb +4 -4
  30. data/lib/siba/tmp_dir.rb +4 -4
  31. data/lib/siba/version.rb +1 -1
  32. data/scaffolds/archive.rb +3 -3
  33. data/scaffolds/destination.rb +4 -4
  34. data/scaffolds/encryption.rb +3 -3
  35. data/scaffolds/project/siba-c6y-demo.gemspec +2 -2
  36. data/scaffolds/project/test/helper/require_integration.rb +1 -1
  37. data/scaffolds/project/test/integration/i9n_init.rb +4 -4
  38. data/scaffolds/project/test/unit/test_init.rb +8 -8
  39. data/scaffolds/shared/examples.rb +4 -4
  40. data/scaffolds/source.rb +4 -4
  41. data/siba.gemspec +1 -1
  42. data/test/integration/helpers/i9n_file_helper.rb +1 -1
  43. data/test/integration/i9n_backup.rb +1 -1
  44. data/test/integration/i9n_scaffold.rb +1 -1
  45. data/test/integration/i9n_test_unicode_files.rb +1 -1
  46. data/test/integration/i9n_tmp_dir.rb +2 -2
  47. data/test/integration/plugins/destination/dir/i9n_dest_dir.rb +1 -1
  48. data/test/integration/plugins/encryption/gpg/i9n_encryption.rb +4 -4
  49. data/test/integration/plugins/source/files/i9n_files.rb +6 -6
  50. data/test/integration/tasks/i9n_siba_tasks.rb +2 -2
  51. data/test/unit/helpers/test_encoding_helper.rb +1 -1
  52. data/test/unit/helpers/test_gem_helper.rb +1 -1
  53. data/test/unit/helpers/test_security_helper.rb +1 -1
  54. data/test/unit/helpers/test_string_helper.rb +1 -1
  55. data/test/unit/plugins/archive/tar/test_archive.rb +2 -2
  56. data/test/unit/plugins/archive/tar/test_init.rb +2 -2
  57. data/test/unit/plugins/destination/dir/test_dest_dir.rb +1 -1
  58. data/test/unit/plugins/destination/dir/test_init.rb +1 -1
  59. data/test/unit/plugins/encryption/gpg/test_encryption.rb +2 -14
  60. data/test/unit/plugins/encryption/gpg/test_init.rb +3 -3
  61. data/test/unit/plugins/source/files/test_files.rb +2 -2
  62. data/test/unit/plugins/source/files/test_init.rb +3 -3
  63. data/test/unit/plugins/source/files/test_path_match.rb +6 -6
  64. data/test/unit/plugins/test_installed_plugins.rb +4 -0
  65. data/test/unit/plugins/test_plugin_loader.rb +6 -3
  66. data/test/unit/tasks/test_siba_task.rb +2 -2
  67. data/test/unit/tasks/test_siba_tasks.rb +3 -3
  68. data/test/unit/test_backup.rb +2 -2
  69. data/test/unit/test_console.rb +5 -5
  70. data/test/unit/test_generator.rb +1 -1
  71. data/test/unit/test_globals.rb +1 -1
  72. data/test/unit/test_log_message.rb +1 -1
  73. data/test/unit/test_logger_plug.rb +1 -1
  74. data/test/unit/test_options_backup.rb +1 -1
  75. data/test/unit/test_options_loader.rb +27 -39
  76. data/test/unit/test_password_strength.rb +14 -14
  77. data/test/unit/test_restore.rb +2 -2
  78. data/test/unit/test_siba_logger.rb +18 -18
  79. data/test/unit/test_tmp_dir.rb +1 -1
  80. metadata +5 -5
@@ -7,10 +7,10 @@ module Siba::Archive
7
7
  DefaultCompression = "gzip"
8
8
  CompressionTypes = ["gzip", "bzip2", "none"]
9
9
 
10
- class Init
10
+ class Init
11
11
  include Siba::LoggerPlug
12
12
 
13
- attr_accessor :archive
13
+ attr_accessor :archive
14
14
 
15
15
  def initialize(options)
16
16
  options = options
@@ -31,7 +31,7 @@ module Siba::Archive
31
31
  # No return value is expected.
32
32
  def restore(path_to_archive, to_dir)
33
33
  logger.info "Extracting 'tar' archive, compression: '#{archive.compression}'"
34
- @archive.extract path_to_archive, to_dir
34
+ @archive.extract path_to_archive, to_dir
35
35
  end
36
36
  end
37
37
  end
@@ -1,7 +1,7 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  module Siba::Destination
4
- module Dir
4
+ module Dir
5
5
  class DestDir
6
6
  include Siba::FilePlug
7
7
  include Siba::LoggerPlug
@@ -19,9 +19,9 @@ module Siba::Destination
19
19
  raise Siba::Error, "Backup file '#{path_to_backup}' does not exist"
20
20
  end
21
21
  unless siba_file.file_directory? dir
22
- raise Siba::Error, "Destination directory '#{dir}' does not exist"
22
+ raise Siba::Error, "Destination directory '#{dir}' does not exist"
23
23
  end
24
- siba_file.file_utils_cp(path_to_backup, dir)
24
+ siba_file.file_utils_cp(path_to_backup, dir)
25
25
  end
26
26
  end
27
27
 
@@ -36,7 +36,7 @@ module Siba::Destination
36
36
  siba_file.file_utils_cp path_to_backup, to_dir
37
37
  end
38
38
  end
39
-
39
+
40
40
  def test_dir_access
41
41
  siba_file.run_this "test dir access" do
42
42
  # create dest dir
@@ -48,7 +48,7 @@ module Siba::Destination
48
48
  end
49
49
 
50
50
  # copy a test file to dest dir
51
- begin
51
+ begin
52
52
  test_file = Siba::TestFiles.prepare_test_file "destination_dir", dir
53
53
  raise "Can not find the test file." unless siba_file.file_file? test_file
54
54
  siba_file.file_utils_remove_entry_secure test_file
@@ -66,7 +66,7 @@ module Siba::Destination
66
66
  siba_file.run_this do
67
67
  Siba::FileHelper.entries(dir).select do |f|
68
68
  f =~ /^#{backup_name}/
69
- end.map do |f|
69
+ end.map do |f|
70
70
  mtime = siba_file.file_mtime File.join dir, f
71
71
  [f, mtime]
72
72
  end
@@ -74,4 +74,4 @@ module Siba::Destination
74
74
  end
75
75
  end
76
76
  end
77
- end
77
+ end
@@ -3,8 +3,8 @@
3
3
  require 'siba/plugins/destination/dir/dest_dir'
4
4
 
5
5
  module Siba::Destination
6
- module Dir
7
- class Init
6
+ module Dir
7
+ class Init
8
8
  attr_accessor :dest_dir
9
9
 
10
10
  def initialize(options)
@@ -2,11 +2,11 @@
2
2
 
3
3
  module Siba::Encryption
4
4
  module Gpg
5
- class Encryption
5
+ class Encryption
6
6
  include Siba::LoggerPlug
7
7
  include Siba::FilePlug
8
8
 
9
- DEFAULT_CIPHER = "AES256"
9
+ DEFAULT_CIPHER = "AES256"
10
10
 
11
11
  attr_accessor :passphrase, :cipher
12
12
 
@@ -21,7 +21,7 @@ module Siba::Encryption
21
21
  path_to_encrypted_backup = "#{path_to_archive}.gpg"
22
22
  siba_file.run_this("encrypt") do
23
23
  if siba_file.file_file? path_to_encrypted_backup
24
- raise Siba::Error, "Encrypted file #{path_to_encrypted_backup} already exists"
24
+ raise Siba::Error, "Encrypted file #{path_to_encrypted_backup} already exists"
25
25
  end
26
26
  passphare_for_command = passphrase.gsub('"','\\"')
27
27
  gpg_homedir = Siba::TestFiles.mkdir_in_tmp_dir "gpg-homedir"
@@ -29,17 +29,17 @@ module Siba::Encryption
29
29
  command = command_without_password.gsub "****", passphare_for_command
30
30
  siba_file.run_shell command, "failed to encrypt: #{command_without_password}"
31
31
  unless siba_file.file_file? path_to_encrypted_backup
32
- raise siba::error, "failed to find encrypted backup file: #{command_without_password}"
32
+ raise siba::error, "failed to find encrypted backup file: #{command_without_password}"
33
33
  end
34
34
  end
35
- path_to_encrypted_backup
35
+ path_to_encrypted_backup
36
36
  end
37
37
 
38
38
  def decrypt(path_to_encrypted_file, path_to_decrypted_file=nil)
39
39
  path_to_decrypted_file = path_to_encrypted_file.gsub /\.gpg$/, "" if path_to_decrypted_file.nil?
40
40
  siba_file.run_this("decrypt") do
41
41
  if siba_file.file_file? path_to_decrypted_file
42
- raise Siba::Error, "Decrypted file #{path_to_decrypted_file} already exists"
42
+ raise Siba::Error, "Decrypted file #{path_to_decrypted_file} already exists"
43
43
  end
44
44
  passphare_for_command = passphrase.gsub('"','\\"')
45
45
  gpg_homedir = Siba::TestFiles.mkdir_in_tmp_dir "gpg-homedir"
@@ -47,7 +47,7 @@ module Siba::Encryption
47
47
  command = command_without_password.gsub "****", passphare_for_command
48
48
  siba_file.run_shell command, "failed to decrypt: #{command_without_password}"
49
49
  unless siba_file.file_file? path_to_decrypted_file
50
- raise siba::error, "failed to find decrypted backup file: #{command_without_password}"
50
+ raise siba::error, "failed to find decrypted backup file: #{command_without_password}"
51
51
  end
52
52
  end
53
53
  path_to_decrypted_file
@@ -99,14 +99,14 @@ module Siba::Encryption
99
99
  else
100
100
  cipher.upcase!
101
101
  end
102
-
102
+
103
103
  raise Siba::CheckError, "'#{cipher}' cipher is not supported.
104
104
  #{supported_ciphers_msg}" unless supported_ciphers.include?(cipher)
105
105
  end
106
106
  cipher
107
107
  end
108
108
 
109
- def get_cipher_names
109
+ def get_cipher_names
110
110
  output = siba_file.run_shell "gpg --version"
111
111
  cipher_names = parse_cipher_names output
112
112
  raise Siba::Error, "Failed to get the list of supported ciphers" if cipher_names.empty?
@@ -117,7 +117,7 @@ module Siba::Encryption
117
117
  scan = version.scan /Cipher:(.*?)\n\w+:/m
118
118
  scan = version.scan /Cipher:(.*)/m if scan.size == 0
119
119
  if scan.size == 0 || !scan[0].is_a?(Array) || scan[0].size == 0 || !scan[0][0].is_a?(String)
120
- raise "Failed to parse gpg version information"
120
+ raise "Failed to parse gpg version information"
121
121
  end
122
122
  scan = scan[0][0]
123
123
  scan.gsub!(/ |\n/, "")
@@ -14,7 +14,7 @@ module Siba::Encryption
14
14
  passphrase = Siba::SibaCheck.options_string(options, "passphrase")
15
15
  cipher = Siba::SibaCheck.options_string(options, "cipher", true)
16
16
  @encryption = Siba::Encryption::Gpg::Encryption.new passphrase, cipher
17
- end
17
+ end
18
18
 
19
19
  # Encrypt backup archive file (path_to_archive) and put it to dest_dir.
20
20
  # Return the name of encrypted file. It must begin with archive name
@@ -9,10 +9,10 @@ module Siba
9
9
 
10
10
  def installed?(category, type)
11
11
  types = all_installed[category]
12
- return false if types.nil?
12
+ return false if types.nil?
13
13
  types.include? type
14
14
  end
15
-
15
+
16
16
  def all_installed
17
17
  @installed ||= find_installed
18
18
  end
@@ -25,7 +25,7 @@ module Siba
25
25
  path = type_dir category, type
26
26
  unless siba_file.file_directory? path
27
27
  path = Siba::GemHelper.gem_path gem_name(category, type)
28
- path = File.join path, "lib", gem_name(category, type)
28
+ path = File.join path, "lib", gem_name(category, type)
29
29
  end
30
30
  unless siba_file.file_directory? path
31
31
  raise Siba::Error, "Failed to get path to plugin #{plugin_category_and_type(category, type)}"
@@ -43,18 +43,22 @@ module Siba
43
43
  end
44
44
 
45
45
  def gem_name(category, type)
46
- "#{GEM_PREFIX}#{category}-#{type}"
46
+ "#{GEM_PREFIX}#{category}-#{type}"
47
47
  end
48
48
 
49
49
  def plugin_category_and_type(category, type)
50
50
  "#{category}#{type.nil? ? "" : '-' + type}"
51
51
  end
52
52
 
53
+ def install_gem_message(category, type)
54
+ "'#{type}' plugin is not installed.\nRun 'gem install #{gem_name(category, type)}' to install it and try again."
55
+ end
56
+
53
57
  private
54
58
 
55
59
  def find_installed
56
60
  installed = {}
57
- Siba::GemHelper.all_local_gems.map{|a| a.name}.each do |item|
61
+ Siba::GemHelper.all_local_gems.map{|a| a.name}.each do |item|
58
62
  Siba::Plugins::CATEGORIES.each do |category|
59
63
  installed[category] ||= []
60
64
  gem_prefix_full = /^#{GEM_PREFIX}#{category}-/
@@ -68,7 +72,7 @@ module Siba
68
72
  }.select{|dir| File.file?(File.join(dir,"init.rb")) }
69
73
  .map{|directory| File.basename(directory)}
70
74
  end
71
-
75
+
72
76
  installed
73
77
  end
74
78
 
@@ -8,7 +8,7 @@ module Siba
8
8
  InitClassName = "Init"
9
9
 
10
10
  def self.loader
11
- @loader ||= PluginLoader.new
11
+ @loader ||= PluginLoader.new
12
12
  end
13
13
 
14
14
  def load(category, type, options)
@@ -22,7 +22,7 @@ module Siba
22
22
  @type=type
23
23
  @options = options
24
24
  logger.debug "Loading #{plugin_category_and_type} plugin"
25
-
25
+
26
26
  require_plugin
27
27
  plugin_module = get_plugin_module
28
28
  plugin_type_module = get_plugin_type_module plugin_module
@@ -40,9 +40,10 @@ module Siba
40
40
  else
41
41
  gem_name = Siba::InstalledPlugins.gem_name category, type
42
42
  begin
43
- Gem::Specification.find_by_name(gem_name)
43
+ Gem::Specification.find_by_name(gem_name)
44
44
  rescue Gem::LoadError
45
- raise PluginLoadError, "Unknown type '#{type}' for '#{category}' plugin. #{available_types_msg}"
45
+ error_msg = Siba::InstalledPlugins.install_gem_message(category, type)
46
+ raise PluginLoadError, error_msg
46
47
  end
47
48
  require gem_name
48
49
  end
@@ -52,7 +53,7 @@ module Siba
52
53
  plugin_module_name = "#{category.capitalize}"
53
54
  Siba.const_get(plugin_module_name)
54
55
  rescue Exception
55
- raise PluginLoadError, "Failed to load #{plugin_category_and_type} plugin: module 'Siba::#{plugin_module_name}' is undefined."
56
+ raise PluginLoadError, "Failed to load #{plugin_category_and_type} plugin: module 'Siba::#{plugin_module_name}' is undefined."
56
57
  end
57
58
 
58
59
  def get_plugin_type_module(plugin_module)
@@ -20,7 +20,7 @@ module Siba::Source
20
20
  file = files_to_include[i]
21
21
  file = siba_file.file_expand_path file
22
22
  next if ignored? file
23
-
23
+
24
24
  is_file = siba_file.file_file? file
25
25
  unless is_file || siba_file.file_directory?(file)
26
26
  logger.error "Source file or directory does not exist: #{file}"
@@ -28,7 +28,7 @@ module Siba::Source
28
28
  end
29
29
 
30
30
  path_to_subdir = Files.sub_dir_name i+1, size_digits, is_file, file, dest_dir
31
- siba_file.file_utils_mkpath path_to_subdir
31
+ siba_file.file_utils_mkpath path_to_subdir
32
32
 
33
33
  logger.debug file
34
34
  if is_file
@@ -79,7 +79,7 @@ module Siba::Source
79
79
 
80
80
  def restore_file(path_to_backup_dir, entry_name_to_restore, path_to_source)
81
81
  backup_dir_entries = Siba::FileHelper.entries path_to_backup_dir
82
- if backup_dir_entries.size != 1
82
+ if backup_dir_entries.size != 1
83
83
  logger.error "Failed to restore file: #{entry_name_to_restore}"
84
84
  return
85
85
  end
@@ -105,7 +105,7 @@ module Siba::Source
105
105
  def copy_file(file, dest_dir)
106
106
  siba_file.run_this "copy file" do
107
107
  return if ignored? file
108
- siba_file.file_utils_cp(file, dest_dir)
108
+ siba_file.file_utils_cp(file, dest_dir)
109
109
  end
110
110
  end
111
111
 
@@ -121,13 +121,13 @@ module Siba::Source
121
121
  Siba::FileHelper.entries(dir).each do |entry|
122
122
  entry = File.join dir, entry
123
123
  if siba_file.file_file? entry
124
- copy_file entry, dest_dir
124
+ copy_file entry, dest_dir
125
125
  elsif siba_file.file_directory? entry
126
126
  copy_dir entry, dest_dir, true if include_subdirs
127
127
  else
128
128
  logger.error "Failed to backup: #{entry}."
129
129
  end
130
- end
130
+ end
131
131
  end
132
132
  end
133
133
 
@@ -147,7 +147,7 @@ module Siba::Source
147
147
  file.strip!
148
148
  pattern.strip!
149
149
  basename = File.basename(file)
150
-
150
+
151
151
  return File.fnmatch(pattern, basename, File::FNM_CASEFOLD) || # match basename against pattern
152
152
  File.fnmatch(pattern, file, File::FNM_CASEFOLD) # match whole path against pattern
153
153
  end
@@ -4,7 +4,7 @@ require 'siba/plugins/source/files/files'
4
4
 
5
5
  module Siba::Source
6
6
  module Files
7
- class Init
7
+ class Init
8
8
  include Siba::LoggerPlug
9
9
  attr_accessor :files
10
10
 
@@ -22,7 +22,7 @@ module Siba::Source
22
22
  @files.backup dest_dir
23
23
  end
24
24
 
25
- # Restore source files and dirs from_dir
25
+ # Restore source files and dirs from_dir
26
26
  # No return value is expected
27
27
  def restore(from_dir)
28
28
  logger.info "Restoring files"
@@ -23,9 +23,9 @@ private
23
23
  Siba.current_dir = File.dirname path_to_options_yml
24
24
  Siba.settings = options["settings"] || {}
25
25
  Siba.backup_name = File.basename path_to_options_yml, ".yml"
26
- TmpDir.test_access
26
+ TmpDir.test_access
27
27
  tasks = SibaTasks.new options, path_to_options_yml, !current_source
28
- file_name = get_backup_choice tasks
28
+ file_name = get_backup_choice tasks
29
29
  unless file_name.nil?
30
30
  if user_wants_to_proceed?
31
31
  tasks.restore file_name
@@ -35,7 +35,7 @@ private
35
35
  end
36
36
  end
37
37
  Siba.cleanup_tmp_dir
38
- rescue Exception => e
38
+ rescue Exception => e
39
39
  logger.fatal e
40
40
  logger.log_exception e, true
41
41
  end
@@ -81,7 +81,7 @@ private
81
81
 
82
82
  if (i+rows) <= list.size
83
83
  num2 = "#{(i+rows).to_s.rjust(2)}."
84
- str2 = list[i+rows-1][2]
84
+ str2 = list[i+rows-1][2]
85
85
  column2 = "#{num2} #{str2}"
86
86
  end
87
87
  siba_kernel.puts " #{column1}#{column2}"
@@ -114,7 +114,7 @@ Type 'yes' if you want to proceed:
114
114
  return list[number-1][0]
115
115
  else
116
116
  siba_kernel.printf msg
117
- end
117
+ end
118
118
  end
119
119
  end
120
120
 
@@ -7,7 +7,7 @@ module Siba
7
7
  attr_accessor :category, :name, :name_camelized
8
8
  CATEGORY_REPLACE_TEXT = "c6y"
9
9
  NAME_REPLACE_TEXT = "demo"
10
-
10
+
11
11
  def initialize(category, name)
12
12
  @category = category
13
13
  unless Siba::Plugins.valid_category? category
@@ -34,13 +34,13 @@ module Siba
34
34
  logger.debug "Scaffolding started"
35
35
  dest_dir = File.join dest_dir, name
36
36
  if siba_file.file_directory?(dest_dir) || siba_file.file_file?(dest_dir)
37
- raise Siba::Error, "Directory already exists #{dest_dir}."
37
+ raise Siba::Error, "Directory already exists #{dest_dir}."
38
38
  end
39
39
 
40
40
  logger.debug "Checking if GIT is installed"
41
41
  raise Siba::Error, "Please install GIT first" unless siba_file.shell_ok? "git help"
42
42
  scaffolds_dir = siba_file.file_expand_path "../../../scaffolds", __FILE__
43
-
43
+
44
44
  logger.debug "Creating a tmp dir"
45
45
  dest_tmp_dir = Siba::TestFiles.mkdir_in_tmp_dir "scaffold"
46
46
 
@@ -50,18 +50,18 @@ module Siba
50
50
  raise Siba::Error, "Scaffold project dir does not exist '#{project_dir}'"
51
51
  end
52
52
  siba_file.file_utils_cp_r File.join(project_dir,"."), dest_tmp_dir
53
-
53
+
54
54
  logger.debug "Copying init file"
55
55
  init_file = File.join scaffolds_dir, "#{category}.rb"
56
56
  unless siba_file.file_file? init_file
57
57
  raise Siba::Error, "Scaffold init file does not exist '#{init_file}'"
58
58
  end
59
- init_dir = File.join dest_tmp_dir, "lib", "siba-#{CATEGORY_REPLACE_TEXT}-demo"
59
+ init_dir = File.join dest_tmp_dir, "lib", "siba-#{CATEGORY_REPLACE_TEXT}-demo"
60
60
  unless siba_file.file_directory? init_dir
61
61
  raise Siba::Error, "Source dir does not exist '#{init_dir}'"
62
62
  end
63
63
  init_file_dest = File.join init_dir,"init.rb"
64
- siba_file.file_utils_cp init_file, init_file_dest
64
+ siba_file.file_utils_cp init_file, init_file_dest
65
65
  unless siba_file.file_file? init_file_dest
66
66
  raise Siba::Error, "Filed to create init file '#{init_file_dest}'"
67
67
  end
@@ -73,20 +73,20 @@ module Siba
73
73
  replace_siba_version dest_tmp_dir
74
74
 
75
75
  logger.debug "Setting gem category and name in file names and contents"
76
- replace_category_and_name dest_tmp_dir
76
+ replace_category_and_name dest_tmp_dir
77
77
 
78
78
  gitify dest_tmp_dir
79
-
79
+
80
80
  logger.debug "Copying the project to destination"
81
81
  siba_file.file_utils_mkpath dest_dir
82
82
  siba_file.file_utils_cp_r File.join(dest_tmp_dir,"."), dest_dir
83
83
 
84
-
84
+
85
85
  logger.info "Project created in #{dest_dir}"
86
86
  logger.info "There is a README file with instructions there"
87
87
  logger.show_finish_message = false
88
88
  end
89
- rescue Exception => e
89
+ rescue Exception => e
90
90
  logger.fatal e
91
91
  logger.log_exception e, true
92
92
  end
@@ -95,7 +95,7 @@ module Siba
95
95
  Siba::FileHelper.entries(dir).each do |entry|
96
96
  entry_path = replace_path dir, entry
97
97
  if siba_file.file_directory? entry_path
98
- replace_category_and_name entry_path
98
+ replace_category_and_name entry_path
99
99
  else
100
100
  replace_file_contents entry_path
101
101
  end
@@ -104,8 +104,8 @@ module Siba
104
104
 
105
105
  def replace_path(dir, entry)
106
106
  entry_path = File.join dir, entry
107
- entry_after = entry.gsub CATEGORY_REPLACE_TEXT, category
108
- entry_after = entry_after.gsub NAME_REPLACE_TEXT, name
107
+ entry_after = entry.gsub CATEGORY_REPLACE_TEXT, category
108
+ entry_after = entry_after.gsub NAME_REPLACE_TEXT, name
109
109
  if entry_after != entry
110
110
  entry_path_after = File.join(dir, entry_after)
111
111
  siba_file.file_utils_mv entry_path, entry_path_after
@@ -117,10 +117,10 @@ module Siba
117
117
  def replace_file_contents(path_to_file)
118
118
  return unless siba_file.file_file? path_to_file
119
119
  Siba::FileHelper.change_file(path_to_file) do |file_text|
120
- file_text.gsub! CATEGORY_REPLACE_TEXT, category
120
+ file_text.gsub! CATEGORY_REPLACE_TEXT, category
121
121
  file_text.gsub! CATEGORY_REPLACE_TEXT.capitalize, category.capitalize
122
- file_text.gsub! NAME_REPLACE_TEXT, name
123
- file_text.gsub! NAME_REPLACE_TEXT.capitalize, name_camelized
122
+ file_text.gsub! NAME_REPLACE_TEXT, name
123
+ file_text.gsub! NAME_REPLACE_TEXT.capitalize, name_camelized
124
124
  file_text
125
125
  end
126
126
  end
@@ -138,7 +138,7 @@ module Siba
138
138
  raise Siba::Error, "Can not find gemspec file #{path_to_gemspec}" unless siba_file.file_file? path_to_gemspec
139
139
  Siba::FileHelper.change_file(path_to_gemspec) do |file_text|
140
140
  version = Siba::VERSION.split('.')[0..-2].join('.')
141
- file_text.gsub "siba_version", version
141
+ file_text.gsub "siba_version", version
142
142
  end
143
143
  end
144
144