generic_app 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +8 -0
- data/gem_test.sh +27 -17
- data/lib/generic_app/version.rb +1 -1
- data/lib/generic_app.rb +47 -14
- data/spec/lib/1_new_app_spec.rb +24 -11
- data/spec/lib/2_legacy_app_spec.rb +20 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7fd06aa9d58922cf9688ac51c18a3ff980f1537
|
4
|
+
data.tar.gz: 0b0edbb493e11eb6a79626b29364820dc5ccd65e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2ac976717b13c130e9f71e44b8c935b22faf809c45d0ebc38b2270759b4141db1621c87dc21a8a7defc7396775ffe700b5972e70b5a119167d2eb89f8ad99d1
|
7
|
+
data.tar.gz: beb6a7580d359f3bdb7e599af04b18975905b30ac04390965699956d8cd68a694032583454c3542c4343aae823dccd97880bbf5ac44f516b793fb362104f5c0d
|
data/.codeclimate.yml
ADDED
data/gem_test.sh
CHANGED
@@ -14,30 +14,40 @@ echo "BEGIN TESTING generic_app"
|
|
14
14
|
rake 2>&1 | tee $DIR_GENERIC_APP/log/generic_app.txt
|
15
15
|
echo "FINISHED TESTING generic_app"
|
16
16
|
echo "****************************"
|
17
|
-
|
18
|
-
echo '
|
19
|
-
echo 'BEGIN TEST
|
17
|
+
echo ''
|
18
|
+
echo '*************'
|
19
|
+
echo 'BEGIN TEST 1A'
|
20
20
|
echo 'Creating new Rails app'
|
21
|
-
|
22
|
-
|
23
|
-
echo 'FINISHED TEST 1'
|
21
|
+
cd $DIR_PARENT/tmp1 && sh test_app.sh 2>&1 | tee $DIR_GENERIC_APP/log/tmp1A.txt
|
22
|
+
echo 'FINISHED TEST1A'
|
24
23
|
echo '***************'
|
25
|
-
|
26
|
-
echo '
|
27
|
-
echo 'BEGIN TEST
|
24
|
+
echo ''
|
25
|
+
echo '*************'
|
26
|
+
echo 'BEGIN TEST 1B'
|
27
|
+
echo 'Creating new Rails app'
|
28
|
+
cd $DIR_PARENT/tmp1 && sh test_code.sh 2>&1 | tee $DIR_GENERIC_APP/log/tmp1B.txt
|
29
|
+
echo 'FINISHED TEST 1B'
|
30
|
+
echo '****************'
|
31
|
+
echo ''
|
32
|
+
echo '*************'
|
33
|
+
echo 'BEGIN TEST 2A'
|
28
34
|
echo 'Adding Generic App features to legacy Rails app'
|
29
|
-
|
30
|
-
|
31
|
-
echo '
|
32
|
-
echo '
|
33
|
-
|
34
|
-
|
35
|
+
cd $DIR_PARENT/tmp2 && sh test_app.sh 2>&1 | tee $DIR_GENERIC_APP/log/tmp2A.txt
|
36
|
+
echo 'FINISHED TEST 2A'
|
37
|
+
echo '****************'
|
38
|
+
echo ''
|
39
|
+
echo '*************'
|
40
|
+
echo 'BEGIN TEST 2B'
|
41
|
+
cd $DIR_PARENT/tmp2 && sh test_code.sh 2>&1 | tee $DIR_GENERIC_APP/log/tmp2B.txt
|
42
|
+
echo 'FINISHED TEST 2B'
|
43
|
+
echo '****************'
|
35
44
|
|
36
45
|
echo
|
37
46
|
echo '***********************************'
|
38
47
|
echo 'The locations of the test logs are:'
|
39
|
-
echo "TEST
|
40
|
-
echo "TEST
|
48
|
+
echo "GEM TEST: $DIR_GENERIC_APP/log/generic_app.txt"
|
49
|
+
echo "TEST 1 (new app): $DIR_GENERIC_APP/log/tmp1.txt"
|
50
|
+
echo "TEST 2 (legacy app): $DIR_GENERIC_APP/log/tmp2.txt"
|
41
51
|
echo
|
42
52
|
echo "If all went well, the results at the end of each test show 0 or 31m0 failures and 0 errors."
|
43
53
|
echo
|
data/lib/generic_app/version.rb
CHANGED
data/lib/generic_app.rb
CHANGED
@@ -45,23 +45,56 @@ module GenericApp
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def self.add (subdir_name)
|
48
|
-
self.
|
49
|
-
self.
|
48
|
+
self.add_to_file_if("#{subdir_name}/.gitignore", 'tmp*')
|
49
|
+
self.add_to_file_if("#{subdir_name}/.gitignore", '.DS_Store')
|
50
|
+
self.add_to_file_if("#{subdir_name}/.gitignore", 'notes/*.dot')
|
51
|
+
self.add_to_file_if("#{subdir_name}/.gitignore", 'notes/*.svg')
|
52
|
+
self.add_to_file_if("#{subdir_name}/.gitignore", 'gemsurance_report.html')
|
53
|
+
path_gemfile = "#{subdir_name}/Gemfile"
|
54
|
+
self.add_to_file_always(path_gemfile, '# Gems added by generic_app')
|
55
|
+
self.add_to_file_always(path_gemfile, 'group :development, :test do')
|
56
|
+
|
57
|
+
self.add_to_file_if(path_gemfile, "gem 'sandi_meter'")
|
58
|
+
StringInFile.replace("gem 'sandi_meter'", " gem 'sandi_meter'", path_gemfile)
|
59
|
+
self.add_to_file_if(path_gemfile, "gem 'brakeman'")
|
60
|
+
StringInFile.replace("gem 'brakeman'", " gem 'brakeman'", path_gemfile)
|
61
|
+
self.add_to_file_if(path_gemfile, "gem 'bundler-audit'")
|
62
|
+
StringInFile.replace("gem 'bundler-audit'", " gem 'bundler-audit'", path_gemfile)
|
63
|
+
self.add_to_file_if(path_gemfile, "gem 'rails-erd'")
|
64
|
+
StringInFile.replace("gem 'rails-erd'", " gem 'rails-erd'", path_gemfile)
|
65
|
+
self.add_to_file_if(path_gemfile, "gem 'railroady'")
|
66
|
+
StringInFile.replace("gem 'railroady'", " gem 'railroady'", path_gemfile)
|
67
|
+
self.add_to_file_if(path_gemfile, "gem 'annotate'")
|
68
|
+
StringInFile.replace("gem 'annotate'", " gem 'annotate'", path_gemfile)
|
69
|
+
self.add_to_file_if(path_gemfile, "gem 'gemsurance'")
|
70
|
+
StringInFile.replace("gem 'gemsurance'", " gem 'gemsurance'", path_gemfile)
|
71
|
+
|
72
|
+
self.add_to_file_always(path_gemfile, 'end')
|
73
|
+
|
50
74
|
self.copy_scripts (subdir_name)
|
75
|
+
LineContaining.delete('***', "#{subdir_name}/test_code.sh")
|
76
|
+
LineContaining.delete('rubocop', "#{subdir_name}/test_code.sh")
|
77
|
+
LineContaining.delete('rails_best_practices', "#{subdir_name}/test_code.sh")
|
78
|
+
LineContaining.delete('metric_fu', "#{subdir_name}/test_code.sh")
|
79
|
+
end
|
80
|
+
|
81
|
+
def self.add_to_file_always (filename, str)
|
82
|
+
puts '------------------------------------'
|
83
|
+
puts "Updating #{filename} (adding #{str})"
|
84
|
+
text_from_file = File.read(filename)
|
85
|
+
last_char = text_from_file[-1]
|
86
|
+
open(filename, 'a') { |f|
|
87
|
+
if last_char != "\n"
|
88
|
+
f.puts "\n"
|
89
|
+
end
|
90
|
+
f.puts "\n#{str}"
|
91
|
+
}
|
51
92
|
end
|
52
93
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
text_from_file = File.read("#{subdir_name}/.gitignore")
|
58
|
-
last_char = text_from_file[-1]
|
59
|
-
open("#{subdir_name}/.gitignore", 'a') { |f|
|
60
|
-
if last_char != "\n"
|
61
|
-
f.puts "\n"
|
62
|
-
end
|
63
|
-
f.puts "\n#{str}"
|
64
|
-
}
|
94
|
+
# Add to file if not already present
|
95
|
+
def self.add_to_file_if (filename, str)
|
96
|
+
if StringInFile.present(str, filename) == false
|
97
|
+
self.add_to_file_always(filename, str)
|
65
98
|
end
|
66
99
|
end
|
67
100
|
|
data/spec/lib/1_new_app_spec.rb
CHANGED
@@ -42,19 +42,32 @@ describe GenericApp do
|
|
42
42
|
expect(StringInFile.present("tmp", "#{dir_app_1}/.gitignore")).to eq(true)
|
43
43
|
expect(StringInFile.present("tmp*", "#{dir_app_1}/.gitignore")).to eq(true)
|
44
44
|
expect(StringInFile.present(".DS_Store", "#{dir_app_1}/.gitignore")).to eq(true)
|
45
|
+
expect(StringInFile.present("notes/*.dot", "#{dir_app_1}/.gitignore")).to eq(true)
|
46
|
+
expect(StringInFile.present("notes/*.svg", "#{dir_app_1}/.gitignore")).to eq(true)
|
47
|
+
expect(StringInFile.present("gemsurance_report.html", "#{dir_app_1}/.gitignore")).to eq(true)
|
45
48
|
end
|
46
|
-
|
47
|
-
it "The notes/1-file_list.txt file should be in place" do
|
48
|
-
expect(StringInFile.present("
|
49
|
-
expect(StringInFile.present("
|
50
|
-
expect(StringInFile.present("
|
49
|
+
|
50
|
+
it "The notes/1-file_list-controllers.txt file should be in place" do
|
51
|
+
expect(StringInFile.present("users_controller_test.rb", "#{dir_app_1}/notes/1-file_list-controllers.txt")).to eq(true)
|
52
|
+
expect(StringInFile.present("users_controller.rb", "#{dir_app_1}/notes/1-file_list-controllers.txt")).to eq(true)
|
53
|
+
expect(StringInFile.present("confirmations_controller.rb", "#{dir_app_1}/notes/1-file_list-controllers.txt")).to eq(true)
|
54
|
+
expect(StringInFile.present("omniauth_callbacks_controller.rb", "#{dir_app_1}/notes/1-file_list-controllers.txt")).to eq(true)
|
55
|
+
expect(StringInFile.present("passwords_controller.rb", "#{dir_app_1}/notes/1-file_list-controllers.txt")).to eq(true)
|
56
|
+
expect(StringInFile.present("registrations_controller.rb", "#{dir_app_1}/notes/1-file_list-controllers.txt")).to eq(true)
|
57
|
+
expect(StringInFile.present("sessions_controller.rb", "#{dir_app_1}/notes/1-file_list-controllers.txt")).to eq(true)
|
58
|
+
expect(StringInFile.present("unlocks_controller.rb", "#{dir_app_1}/notes/1-file_list-controllers.txt")).to eq(true)
|
59
|
+
end
|
60
|
+
|
61
|
+
it "The notes/1-file_list-misc.txt file should be in place" do
|
62
|
+
expect(StringInFile.present("application_helper.rb", "#{dir_app_1}/notes/1-file_list-misc.txt")).to eq(true)
|
63
|
+
expect(StringInFile.present("users_helper.rb", "#{dir_app_1}/notes/1-file_list-misc.txt")).to eq(true)
|
51
64
|
end
|
52
65
|
|
53
|
-
it "The notes/
|
54
|
-
expect(StringInFile.present("
|
55
|
-
expect(StringInFile.present("
|
56
|
-
expect(StringInFile.present("
|
57
|
-
expect(StringInFile.present("
|
58
|
-
expect(StringInFile.present("def show", "#{dir_app_1}/notes/mvc-users.txt")).to eq(true)
|
66
|
+
it "The notes/1-file_list-models.txt file should be in place" do
|
67
|
+
expect(StringInFile.present("admin_test.rb", "#{dir_app_1}/notes/1-file_list-models.txt")).to eq(true)
|
68
|
+
expect(StringInFile.present("user_test.rb", "#{dir_app_1}/notes/1-file_list-models.txt")).to eq(true)
|
69
|
+
expect(StringInFile.present("admin.rb", "#{dir_app_1}/notes/1-file_list-models.txt")).to eq(true)
|
70
|
+
expect(StringInFile.present("user.rb", "#{dir_app_1}/notes/1-file_list-models.txt")).to eq(true)
|
59
71
|
end
|
72
|
+
|
60
73
|
end
|
@@ -42,5 +42,25 @@ describe GenericApp do
|
|
42
42
|
expect(StringInFile.present("tmp", "#{dir_app_2}/.gitignore")).to eq(true)
|
43
43
|
expect(StringInFile.present("tmp*", "#{dir_app_2}/.gitignore")).to eq(true)
|
44
44
|
expect(StringInFile.present(".DS_Store", "#{dir_app_2}/.gitignore")).to eq(true)
|
45
|
+
expect(StringInFile.present("notes/*.dot", "#{dir_app_2}/.gitignore")).to eq(true)
|
46
|
+
expect(StringInFile.present("notes/*.svg", "#{dir_app_2}/.gitignore")).to eq(true)
|
47
|
+
expect(StringInFile.present("gemsurance_report.html", "#{dir_app_2}/.gitignore")).to eq(true)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "The Gemfile includes code checking gems" do
|
51
|
+
expect(StringInFile.present("gem 'sandi_meter'", "#{dir_app_2}/Gemfile")).to eq(true)
|
52
|
+
expect(StringInFile.present("gem 'brakeman'", "#{dir_app_2}/Gemfile")).to eq(true)
|
53
|
+
expect(StringInFile.present("gem 'bundler-audit'", "#{dir_app_2}/Gemfile")).to eq(true)
|
54
|
+
expect(StringInFile.present("gem 'rails-erd'", "#{dir_app_2}/Gemfile")).to eq(true)
|
55
|
+
expect(StringInFile.present("gem 'railroady'", "#{dir_app_2}/Gemfile")).to eq(true)
|
56
|
+
expect(StringInFile.present("gem 'annotate'", "#{dir_app_2}/Gemfile")).to eq(true)
|
57
|
+
expect(StringInFile.present("gem 'gemsurance'", "#{dir_app_2}/Gemfile")).to eq(true)
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'The test_code.sh script excludes certain parts of the original' do
|
61
|
+
expect(StringInFile.present('***', "#{dir_app_2}/test_code.sh")).to eq(false)
|
62
|
+
expect(StringInFile.present('rubocop', "#{dir_app_2}/test_code.sh")).to eq(false)
|
63
|
+
expect(StringInFile.present('rails_best_practices', "#{dir_app_2}/test_code.sh")).to eq(false)
|
64
|
+
expect(StringInFile.present('metric_fu', "#{dir_app_2}/test_code.sh")).to eq(false)
|
45
65
|
end
|
46
66
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: generic_app
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Hsu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -77,6 +77,7 @@ executables:
|
|
77
77
|
extensions: []
|
78
78
|
extra_rdoc_files: []
|
79
79
|
files:
|
80
|
+
- ".codeclimate.yml"
|
80
81
|
- ".gitignore"
|
81
82
|
- ".travis.yml"
|
82
83
|
- Gemfile
|