strap 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -56,6 +56,9 @@ module Strap
56
56
  config.db_port,
57
57
  config.db_host)
58
58
 
59
+ config.run_rename_files
60
+ config.run_change_permissions
61
+
59
62
  core.commit_to_repo(config.destination_repo)
60
63
 
61
64
  config.run_after_bootstrap
@@ -1,11 +1,16 @@
1
+ require 'debugger'
2
+
1
3
  module Strap
2
4
 
3
5
  class Config
4
6
 
5
7
  attr_accessor :db_name, :db_user, :db_password, :db_socket, :db_host, :db_port,
6
- :sql, :source_repo, :destination_repo, :after
8
+ :sql, :source_repo, :destination_repo, :after, :files_to_rename,
9
+ :files_to_change_permissions_on
7
10
 
8
11
  def initialize(file)
12
+ self.files_to_rename = []
13
+ self.files_to_change_permissions_on = []
9
14
  instance_eval File.read(file)
10
15
  end
11
16
 
@@ -22,11 +27,25 @@ module Strap
22
27
  end
23
28
 
24
29
  def rename_file(old_name, new_name)
25
- File.rename(old_name, new_name)
30
+ self.files_to_rename << [old_name, new_name]
31
+ end
32
+
33
+ def run_rename_files
34
+ return false unless files_to_rename.length > 0
35
+ files_to_rename.each do |file|
36
+ File.rename(file[0], file[1])
37
+ end
26
38
  end
27
39
 
28
40
  def change_permissions(permission, file)
29
- File.chmod permission, file
41
+ self.files_to_change_permissions_on << [permission, file]
42
+ end
43
+
44
+ def run_change_permissions
45
+ return false unless files_to_change_permissions_on.length > 0
46
+ files_to_change_permissions_on.each do |file|
47
+ File.chmod file[0], file[1]
48
+ end
30
49
  end
31
50
 
32
51
  end
@@ -1,3 +1,3 @@
1
1
  module Strap
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -7,6 +7,7 @@ describe Strap::Config do
7
7
  before do
8
8
  @path = "test_path"
9
9
  File.new("old_name", "w")
10
+ File.new("old_name_2", "w")
10
11
  File.new("change_permissions", "w")
11
12
  @core = Strap::Core.new
12
13
  @core.create_project_directory(@path)
@@ -15,7 +16,9 @@ describe Strap::Config do
15
16
 
16
17
  after do
17
18
  FileUtils.remove_file("old_name") if File.file?("old_name")
19
+ FileUtils.remove_file("old_name_2") if File.file?("old_name_2")
18
20
  FileUtils.remove_file("new_name") if File.file?("new_name")
21
+ FileUtils.remove_file("new_name_2") if File.file?("new_name_2")
19
22
  FileUtils.remove_file("change_permissions") if File.file?("change_permissions")
20
23
  FileUtils.remove_dir(@path) if File.directory?(@path)
21
24
  end
@@ -41,11 +44,20 @@ describe Strap::Config do
41
44
  it "should rename a file" do
42
45
  File.file?("old_name").must_equal true
43
46
  @config = Strap::Config.new("test/lib/templates/#{Strap::CONFIG_FILENAME}")
47
+ @config.run_rename_files
44
48
  File.file?("new_name").must_equal true
45
49
  end
46
50
 
51
+ it "should rename multiple files" do
52
+ File.file?("old_name_2").must_equal true
53
+ @config = Strap::Config.new("test/lib/templates/#{Strap::CONFIG_FILENAME}")
54
+ @config.run_rename_files
55
+ File.file?("new_name_2").must_equal true
56
+ end
57
+
47
58
  it "should change file permissions" do
48
59
  @config = Strap::Config.new("test/lib/templates/#{Strap::CONFIG_FILENAME}")
60
+ @config.run_change_permissions
49
61
  File.stat("change_permissions").mode.must_equal 33279
50
62
  end
51
63
 
@@ -8,6 +8,7 @@ set :source_repo, Strap::Test::SOURCE_REPO
8
8
  set :destination_repo, Strap::Test::DESTINATION_REPO
9
9
 
10
10
  rename_file "old_name", "new_name"
11
+ rename_file "old_name_2", "new_name_2"
11
12
 
12
13
  change_permissions 0777, "change_permissions"
13
14
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: strap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: