app2engine 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -41,7 +41,7 @@ module App2Engine
41
41
 
42
42
  def initializers
43
43
  define_task(:initializers, "remove initializers as they would conflict and create NameError") do
44
- move_dir('config/initializers', 'config/org_initializers')
44
+ Dir['config/initializers/*.rb'].each { |file| comment_whole_file(file) }
45
45
  end
46
46
  end
47
47
 
@@ -70,15 +70,6 @@ module App2Engine
70
70
  end
71
71
  end
72
72
 
73
- def move_dir dir, to
74
- if File.directory? to
75
- already_done dir
76
- else
77
- FileUtils.mv(dir, to)
78
- status "Move #{dir} to #{to}".green
79
- end
80
- end
81
-
82
73
  def add_file file
83
74
  contents = file_contents(file)
84
75
  file = resolve_name(file)
@@ -90,6 +81,20 @@ module App2Engine
90
81
  end
91
82
  end
92
83
 
84
+ def comment_whole_file file
85
+ file = resolve_name(file)
86
+ lines = File.readlines(file)
87
+ new_lines = lines.map { |line|
88
+ (line =~ /^(\s*|\s*#.+)$/) ? line : '# '+line
89
+ }
90
+ if new_lines == lines
91
+ already_done file
92
+ else
93
+ File.open(file, 'w') { |fh| fh.write(new_lines.join) }
94
+ status "Comment #{file}".green
95
+ end
96
+ end
97
+
93
98
  def append_to_file file, contents
94
99
  file = resolve_name(file)
95
100
  if File.read(file).include?(contents)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: app2engine
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - eregon