generic_app 1.0.4 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 31f775611caa10bdaa430cdc406ba7b31d569353
4
- data.tar.gz: 91270cc88abfdc5d91e7e85b6fe0d6ac399d4a2b
3
+ metadata.gz: 2972e76351f3b8ab62fa84d526f3d7524f6bd5dc
4
+ data.tar.gz: 42782b747f14674f5e7ea58ee6ec5610724b8736
5
5
  SHA512:
6
- metadata.gz: 1cc5bf6c7e392379d92d8db6eaf0640ed11cd3312f9d64a6d741b5fc75a3351fd3eb75d5ce85d090a2c0d16862245a2e18b106adce94093d50418d9190ee5c05
7
- data.tar.gz: d968517570dee60145633a778827fb04301141e96e6ac8375f58547eeafbcd55789e70d5e2c0e9acfdafb983c1e1d96e7eb5af141cf1947979848edcd285ea99
6
+ metadata.gz: fd40441c4160b26e517a4af156097f104a0d757a2876b9611a1199524a18a641b6b727e280d15f9784921aadb48bcb6a9aaf68962e1a8bfac2482fc45ea2f68b
7
+ data.tar.gz: 13a42da2ba24c30517269cac00b7475b75c7c7365ae8d24b7edc39e822d3b8030f3af4188bb622a934b5e2bbad3b6ae07083b43fb2fe5bd6349502e8af9bccf6
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ Metrics/LineLength:
2
+ Exclude:
3
+ - generic_app.gemspec
4
+ - lib/generic_app.rb
5
+ - spec/lib/1_sqlite_spec.rb
6
+
7
+ Metrics/MethodLength:
8
+ Exclude:
9
+ - lib/generic_app.rb
10
+
11
+ Style/RedundantSelf:
12
+ Exclude:
13
+ - lib/generic_app.rb
data/Gemfile CHANGED
@@ -3,4 +3,4 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in generic_app.gemspec
4
4
  gemspec
5
5
 
6
- gem "codeclimate-test-reporter", group: :test, require: nil
6
+ gem 'codeclimate-test-reporter', group: :test, require: nil
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/generic_app.svg)](http://badge.fury.io/rb/generic_app)
2
- [![Dependency Status](https://gemnasium.com/jhsu802701/generic_gem.svg)](https://gemnasium.com/jhsu802701/generic_gem)
2
+ [![Dependency Status](https://gemnasium.com/jhsu802701/generic_app.svg)](https://gemnasium.com/jhsu802701/generic_app)
3
3
  [![Build Status](https://travis-ci.org/jhsu802701/generic_app.svg?branch=master)](http://travis-ci.org/jhsu802701/generic_app)
4
4
  [![Code Climate](https://codeclimate.com/github/jhsu802701/generic_app/badges/gpa.svg)](https://codeclimate.com/github/jhsu802701/generic_app)
5
5
  <a href="https://codeclimate.com/github/jhsu802701/generic_app/coverage"><img src="https://codeclimate.com/github/jhsu802701/generic_app/badges/coverage.svg" /></a>
@@ -8,12 +8,10 @@
8
8
  # GenericApp
9
9
 
10
10
  Welcome to GenericApp, the #1 Rails app generator! No other method of starting a Rails app can save you so much time and effort. Stop reinventing the wheel every time you start a new Rails project. User authentication, comprehensive tests, Guard automation, Twitter bootstrap styling, and other features that are desirable in all or most Rails apps are implemented in advance. You get post-installation scripts that consolidate routine multi-step tasks into one step, including the process of setting up your app for PostgreSQL. Outlines of the initial MVC architecture of your new app are also provided. Only GenericApp way gives you a comprehensive Rails app in just a few minutes. If you're not exactly a GenericApp user, then you're not exactly viable at Startup Weekend or 24-hour web site challenges.
11
- <br><br>
12
- GenericApp also works for legacy Rails apps. You can incorporate GenericApp's post-installation scripts into a legacy Rails app, including the PostgreSQL setup script and a script that prints out a list of all of the directories and files most relevant to the MVC architecture.
13
11
 
14
12
  ## Prerequisites
15
13
 
16
- You must have not only Ruby on Rails installed but SQLite and PostgreSQL installed as well. Everything you need to use the GenericApp gem is pre-installed in my Debian Stable Vagrant Box for Ruby On Rails ( https://github.com/jhsu802701/vagrant-debian-jessie-rvm ).
14
+ You must have not only Ruby on Rails installed but SQLite and PostgreSQL installed as well. Everything you need to use the GenericApp gem is pre-installed in my general purpose Debian Stable Docker image (rbenv-general) for Ruby On Rails. The URLs for using my Docker images are on my [Ruby on Rails cheat sheet] (https://gist.github.com/jhsu802701/8c81cbfdf3136b1c0387).
17
15
 
18
16
  ## Installation
19
17
 
@@ -29,28 +27,18 @@ Go to the directory where you keep your Rails projects and enter the command "ge
29
27
  <br><br>
30
28
  After you have provided all of the necessary parameters, your generic Rails project will not only be created for you but automatically tested as well. This takes a few minutes instead of several long and grueling hours.
31
29
 
32
- ### Adding Generic App Features To An Existing Project
33
-
34
- Go to the parent of the app's root directory. Enter the command "generic_app_add". You will be shown a list of all sub-directories within your present working directory. Pick the sub-directory corresponding to your target app. The Bash scripts and the list of directories and files within the project will be added. Please note that you may need to revise some of the scripts provided by GenericApp, which is designed around the railstutorial.org Sample App.
35
-
36
30
  ## What's the point?
37
31
 
38
- Welcome to Ruby On HIGH SPEED Rails! The GenericApp gem saves you time by automatically providing the basic
39
- elements and features that nearly all Rails apps require. Instead of spending hours reinventing the wheel, you
40
- can spend more of your time on the more advanced features and capabilities that are unique to your specific Rails
41
- app. Modifying a generic app takes far less time than creating an app completely from scratch.
32
+ Welcome to Ruby On Racetracks! The GenericApp gem saves you time by automatically providing the basic elements and features that nearly all Rails apps require. Instead of spending hours reinventing the wheel, you can spend more of your time on the more advanced features and capabilities that are unique to your specific Rails app. Modifying a generic app takes far less time than creating an app completely from scratch.
42
33
  <br><br>
43
- Creating a basic generic web site with user authentication and testing is a long and slow process that spans chapters
44
- 3 through 10 in railstutorial.org. The GenericApp Ruby gem allows you to create such a site in minutes instead of
45
- hours. This is valuable for any project and essential for events like Startup Weekend and 24-hour website
46
- challenges.
34
+ Creating a basic generic web site with user authentication and testing is a long and slow process that spans chapters 3 through 10 in railstutorial.org. The GenericApp Ruby gem allows you to create such a site in minutes instead of hours. This is valuable for any project and essential for events like Startup Weekend and 24-hour website challenges.
47
35
  <br><br>
48
- The GenericApp gem copies the GenericApp Template (https://github.com/jhsu802701/generic_app_template) for use as a template for starting a new project. Starting a Rails app completely from scratch (by using the "rails new" command) requires manually installing and configuring MiniTest, Guard, Twitter bootstrap, the user model, user sign-ups, user login/logout, user authorization, administrative users, account activations, and password resets. People are often tempted to "save time" by omitting testing. Using the GenericApp gem allows you to have all of the essential basic elements of a generic app as soon as you start it. It's a shortcut that actually complies with best practices.
36
+ The GenericApp gem copies the GenericApp Template (https://github.com/jhsu802701/generic_app_template) for use as a template for starting a new project. Starting a Rails app completely from scratch (by using the "rails new" command) requires manually installing and configuring MiniTest, Guard, Twitter bootstrap, the user model, user sign-ups, user login/logout, user authorization, administrative users, account activations, and password resets. People are often tempted to "save time" by omitting testing. Using the GenericApp gem allows you to have all of the essential basic elements of a generic app as soon as you start it. It's a shortcut that actually complies with best practices and improves quality. You can use the time you save to create a better app or to move on to other projects sooner.
49
37
 
50
38
  ## Development
51
39
 
52
40
  ### Testing GenericApp
53
- Download this GitHub repository, cd into the source code, and enter the command "sh gem_test.sh". The screen output is saved to the log files in the log directory. If all goes well, every test is completed with 0 or 31m0 failures and 0 errors.
41
+ Download this GitHub repository, cd into the source code, and enter the command "sh gem_test.sh". The screen output is saved to the log files in the log directory. If all goes well, every test is completed with 0 failures and 0 errors. Please note that bundle-audit will flag the outdated gems that result from using the old versions of the rails, pg, and nokogiri gems from the Rails Tutorial Sample App. You should update the Gemfile to the newer versions of these gems available in the rbenv-general version of the Docker image.
54
42
 
55
43
  ## Contributing
56
44
 
data/Rakefile CHANGED
@@ -1,5 +1,5 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
3
  RSpec::Core::RakeTask.new
4
- task :default => :spec
5
- task :test => :spec
4
+ task default: :spec
5
+ task test: :spec
data/bin/generic_app CHANGED
@@ -4,10 +4,10 @@ require 'generic_app'
4
4
 
5
5
  def get_input(default_value)
6
6
  value_input = gets.chomp
7
- if value_input == ""
8
- return default_value
7
+ if value_input == ''
8
+ default_value
9
9
  else
10
- return value_input
10
+ value_input
11
11
  end
12
12
  end
13
13
 
@@ -32,7 +32,7 @@ GenericApp.create_new(subdir_name, email)
32
32
 
33
33
  puts '*********************************************'
34
34
  puts "BEGIN TESTING THE #{subdir_name} RAILS APP"
35
- system("cd #{subdir_name} && sh test_app.sh")
35
+ system("cd #{subdir_name} && sh build_fast.sh")
36
36
  puts "FINISHED TESTING THE #{subdir_name} RAILS APP"
37
37
  puts '*********************************************'
38
38
 
@@ -41,4 +41,6 @@ puts 'It is currently configured to use the SQLite database in the'
41
41
  puts 'development environment.'
42
42
  puts 'To set up the PostgreSQL database, enter the'
43
43
  puts "#{ENV['PWD']}/#{subdir_name} directory and enter the command"
44
- puts 'sh setup-pg.sh .'
44
+ puts 'sh pg-setup.sh .'
45
+ puts 'Please note that the rails, pg, and nokogiri gems may be outdated.'
46
+ puts 'You should update these gem versions in the Gemfile.'
data/gem_test.sh CHANGED
@@ -5,54 +5,61 @@ DIR_GENERIC_APP=$PWD
5
5
  DIR_PARENT="${PWD%/*}"
6
6
  mkdir -p log
7
7
 
8
- echo "**************"
9
- echo "bundle install"
8
+ echo '**************'
9
+ echo 'bundle install'
10
10
  bin/setup >/dev/null
11
11
 
12
- echo "*************************"
13
- echo "BEGIN TESTING generic_app"
14
- rake 2>&1 | tee $DIR_GENERIC_APP/log/generic_app.txt
15
- echo "FINISHED TESTING generic_app"
16
- echo "****************************"
17
- echo ''
18
- echo '*************'
19
- echo 'BEGIN TEST 1A'
20
- echo 'Creating new Rails app'
12
+ echo '*************************'
13
+ echo 'BEGIN TESTING generic_app'
14
+ rake 2>&1 | tee $DIR_GENERIC_APP/log/generic_app-rake_test.txt
15
+ echo 'FINISHED TESTING generic_app'
16
+ echo '****************************'
17
+ echo
18
+ echo '****************************************'
19
+ echo 'BEGIN TESTING generic_app - code quality'
20
+ rubocop 2>&1 | tee $DIR_GENERIC_APP/log/generic_app-rubocop.txt
21
+ echo 'FINISHED TESTING generic_app - code quality'
22
+ echo '*******************************************'
23
+ echo
24
+ echo '************************************'
25
+ echo 'BEGIN TEST 1A: SQLite, build_fast.sh'
21
26
  cd $DIR_PARENT/tmp1 && spring stop
22
- cd $DIR_PARENT/tmp1 && sh test_app.sh 2>&1 | tee $DIR_GENERIC_APP/log/tmp1A.txt
27
+ cd $DIR_PARENT/tmp1 && sh build_fast.sh 2>&1 | tee $DIR_GENERIC_APP/log/tmp1A.txt
23
28
  echo 'FINISHED TEST1A'
24
29
  echo '***************'
25
30
  echo ''
26
- echo '*************'
27
- echo 'BEGIN TEST 1B'
28
- echo 'Creating new Rails app'
29
- cd $DIR_PARENT/tmp1 && sh test_code.sh 2>&1 | tee $DIR_GENERIC_APP/log/tmp1B.txt
31
+ echo '***********************************'
32
+ echo 'BEGIN TEST 1B: SQLite, test_code.sh'
33
+ printf 'y\n' | cd $DIR_PARENT/tmp1 && sh test_code.sh 2>&1 | tee $DIR_GENERIC_APP/log/tmp1B.txt
30
34
  echo 'FINISHED TEST 1B'
31
35
  echo '****************'
32
- echo ''
33
- echo '*************'
34
- echo 'BEGIN TEST 2A'
35
- echo 'Adding Generic App features to legacy Rails app'
36
- cd $DIR_PARENT/tmp2 && spring stop
37
- cd $DIR_PARENT/tmp2 && sh test_app.sh 2>&1 | tee $DIR_GENERIC_APP/log/tmp2A.txt
36
+
37
+ echo '*************************************'
38
+ echo 'BEGIN TEST 2A: PostgreSQL, pg-test.sh'
39
+ printf 'y\n' | cd $DIR_PARENT/tmp1 && sh pg-test.sh auto 2>&1 | tee $DIR_GENERIC_APP/log/tmp2A.txt
38
40
  echo 'FINISHED TEST 2A'
39
41
  echo '****************'
40
- echo ''
41
- echo '*************'
42
- echo 'BEGIN TEST 2B'
43
- cd $DIR_PARENT/tmp2 && sh test_code.sh 2>&1 | tee $DIR_GENERIC_APP/log/tmp2B.txt
42
+
43
+ echo '***************************************'
44
+ echo 'BEGIN TEST 2B: PostgreSQL, test_code.sh'
45
+ cd $DIR_PARENT/tmp1 && sh test_code.sh auto 2>&1 | tee $DIR_GENERIC_APP/log/tmp2B.txt
46
+ echo "\n"
44
47
  echo 'FINISHED TEST 2B'
45
48
  echo '****************'
46
49
 
47
50
  echo
48
51
  echo '***********************************'
49
52
  echo 'The locations of the test logs are:'
50
- echo "GEM TEST: $DIR_GENERIC_APP/log/generic_app.txt"
51
- echo "TEST 1A (new app): $DIR_GENERIC_APP/log/tmp1A.txt"
52
- echo "TEST 1B (new app): $DIR_GENERIC_APP/log/tmp1B.txt"
53
- echo "TEST 2A (legacy app): $DIR_GENERIC_APP/log/tmp2A.txt"
54
- echo "TEST 2B (legacy app): $DIR_GENERIC_APP/log/tmp2B.txt"
53
+ echo "GEM TEST: $DIR_GENERIC_APP/log/generic_app-rake_test.txt"
54
+ echo "GEM TEST - code quality: $DIR_GENERIC_APP/log/generic_app-rubocop.txt"
55
+ echo "TEST 1A (SQLite, build_fast.sh): $DIR_GENERIC_APP/log/tmp1A.txt"
56
+ echo "TEST 1B (SQLite, test_code.sh): $DIR_GENERIC_APP/log/tmp1B.txt"
57
+ echo "TEST 2A (PostgreSQL, pg-test.sh): $DIR_GENERIC_APP/log/tmp2A.txt"
58
+ echo "TEST 2B (PostgreSQL, test_code.sh): $DIR_GENERIC_APP/log/tmp2B.txt"
59
+
55
60
  echo
56
- echo "If all went well, the results at the end of tests 1A and 2A show 0 or 31m0 failures and 0 errors."
57
- echo 'Test 2B may show vulnerabilities in some gems. This is normal for the legacy app.'
61
+ echo 'If all went well, the results at the end of tests 1A and 2A show 0 failures and 0 errors.'
62
+ echo 'Please note that in tests 1B and 2B, bundle-audit will flag violations due to outdated'
63
+ echo 'rails, pg, and nokogiri gems.'
64
+ echo 'It is up to the user to update these gems upon creating a new Rails project.'
58
65
  echo
data/generic_app.gemspec CHANGED
@@ -4,23 +4,24 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'generic_app/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "generic_app"
7
+ spec.name = 'generic_app'
8
8
  spec.version = GenericApp::VERSION
9
- spec.authors = ["Jason Hsu"]
10
- spec.email = ["rubyist@jasonhsu.com"]
11
- spec.summary = %q{Save time by instantly create a generic Rails app.}
12
- spec.description = %q{Instead of creating your Rails app from scratch, start with a generic app.}
13
- spec.homepage = "https://github.com/jhsu802701/generic_app"
14
- spec.license = "MIT"
9
+ spec.authors = ['Jason Hsu']
10
+ spec.email = ['rubyist@jasonhsu.com']
11
+ spec.summary = 'Save time by instantly create a generic Rails app.'
12
+ spec.description = 'Instead of creating your Rails app from scratch, start with a generic app.'
13
+ spec.homepage = 'https://github.com/jhsu802701/generic_app'
14
+ spec.license = 'MIT'
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0")
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
19
+ spec.require_paths = ['lib']
20
20
 
21
21
  spec.add_development_dependency 'rake'
22
22
  spec.add_development_dependency 'rspec'
23
-
24
- spec.add_runtime_dependency "string_in_file"
25
- spec.add_runtime_dependency "line_containing"
23
+ spec.add_development_dependency 'rubocop'
24
+
25
+ spec.add_runtime_dependency 'string_in_file'
26
+ spec.add_runtime_dependency 'line_containing'
26
27
  end
@@ -1,3 +1,3 @@
1
1
  module GenericApp
2
- VERSION = "1.0.4"
2
+ VERSION = '1.1.0'.freeze
3
3
  end
data/lib/generic_app.rb CHANGED
@@ -1,113 +1,40 @@
1
1
  #!/usr/bin/ruby
2
2
 
3
- require "generic_app/version"
4
- require "string_in_file"
5
- require "line_containing"
3
+ require 'generic_app/version'
4
+ require 'string_in_file'
5
+ require 'line_containing'
6
6
 
7
- ENV['DIR_MAIN'] = File.expand_path("../../", __FILE__)
8
- ENV['DIR_PARENT'] = File.expand_path("../../../", __FILE__)
7
+ ENV['DIR_MAIN'] = File.expand_path('../../', __FILE__)
8
+ ENV['DIR_PARENT'] = File.expand_path('../../../', __FILE__)
9
9
 
10
+ #
10
11
  module GenericApp
11
12
  # Create app, stick with SQLite database in development
12
- def self.create_new (subdir_name, email)
13
- self.git_clone (subdir_name)
13
+ def self.create_new(subdir_name, email)
14
+ t1 = Thread.new { self.git_clone(subdir_name) }
15
+ t1.join
14
16
  self.email_update(subdir_name, email)
15
- self.git_init (subdir_name)
17
+ self.git_init(subdir_name)
16
18
  end
17
19
 
18
- def self.git_clone (subdir_name)
19
- puts "------------------------------------"
20
- puts "Downloading the Generic App Template"
21
- t1 = Thread.new {
22
- system("git clone https://github.com/jhsu802701/generic_app_template.git #{subdir_name}")
23
- }
24
- t1.join
20
+ def self.git_clone(subdir_name)
21
+ puts '------------------------------------'
22
+ puts 'Downloading the Generic App Template'
23
+ system("git clone https://github.com/jhsu802701/generic_app_template.git #{subdir_name}")
25
24
  end
26
-
27
- def self.email_update (subdir_name, email)
25
+
26
+ def self.email_update(subdir_name, email)
28
27
  email_orig = 'please-change-me-at-config-initializers-devise@example.com'
29
28
  path_of_email = "#{subdir_name}/config/initializers/devise.rb"
30
29
  StringInFile.replace(email_orig, email, path_of_email)
31
30
  end
32
31
 
33
- def self.git_init (subdir_name)
34
- puts "----------------"
35
- puts "Initializing Git"
36
- t1 = Thread.new {
37
- $stdout = File.new( '/dev/null', 'w' )
38
- system("cd #{subdir_name} && rm -rf .git")
39
- system("cd #{subdir_name} && git init")
40
- system("cd #{subdir_name} && git add .")
41
- system("cd #{subdir_name} && git commit -m 'Initial commit' >/dev/null")
42
- $stdout = STDOUT
43
- }
44
- t1.join
45
- end
46
-
47
- def self.add (subdir_name)
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_if(path_gemfile, "gem 'string_in_file'")
56
- self.add_to_file_if(path_gemfile, "gem 'line_containing'")
57
- self.add_to_file_always(path_gemfile, 'group :development, :test do')
58
-
59
- self.add_to_file_if(path_gemfile, "gem 'sandi_meter'")
60
- StringInFile.replace("gem 'sandi_meter'", " gem 'sandi_meter'", path_gemfile)
61
- self.add_to_file_if(path_gemfile, "gem 'brakeman'")
62
- StringInFile.replace("gem 'brakeman'", " gem 'brakeman'", path_gemfile)
63
- self.add_to_file_if(path_gemfile, "gem 'bundler-audit'")
64
- StringInFile.replace("gem 'bundler-audit'", " gem 'bundler-audit'", path_gemfile)
65
- self.add_to_file_if(path_gemfile, "gem 'rails-erd'")
66
- StringInFile.replace("gem 'rails-erd'", " gem 'rails-erd'", path_gemfile)
67
- self.add_to_file_if(path_gemfile, "gem 'railroady'")
68
- StringInFile.replace("gem 'railroady'", " gem 'railroady'", path_gemfile)
69
- self.add_to_file_if(path_gemfile, "gem 'annotate'")
70
- StringInFile.replace("gem 'annotate'", " gem 'annotate'", path_gemfile)
71
- self.add_to_file_if(path_gemfile, "gem 'gemsurance'")
72
- StringInFile.replace("gem 'gemsurance'", " gem 'gemsurance'", path_gemfile)
73
-
74
- self.add_to_file_always(path_gemfile, 'end')
75
-
76
- self.copy_scripts (subdir_name)
77
- LineContaining.delete('***', "#{subdir_name}/test_code.sh")
78
- LineContaining.delete('rubocop', "#{subdir_name}/test_code.sh")
79
- LineContaining.delete('rails_best_practices', "#{subdir_name}/test_code.sh")
80
- LineContaining.delete('metric_fu', "#{subdir_name}/test_code.sh")
81
- end
82
-
83
- def self.add_to_file_always (filename, str)
84
- puts '------------------------------------'
85
- puts "Updating #{filename} (adding #{str})"
86
- text_from_file = File.read(filename)
87
- last_char = text_from_file[-1]
88
- open(filename, 'a') { |f|
89
- if last_char != "\n"
90
- f.puts "\n"
91
- end
92
- f.puts "\n#{str}"
93
- }
94
- end
95
-
96
- # Add to file if not already present
97
- def self.add_to_file_if (filename, str)
98
- if StringInFile.present(str, filename) == false
99
- self.add_to_file_always(filename, str)
100
- end
101
- end
102
-
103
- def self.copy_scripts (subdir_name)
104
- puts "----------------------------------------------"
105
- puts "Adding scripts and config/database-pg.yml file"
106
- dir_template = "#{ENV['DIR_PARENT']}/high_speed_rails_clobbers_not_exactly"
107
- self.git_clone (dir_template)
108
- system("cp -r #{dir_template}/*.sh #{subdir_name}")
109
- system("cp -r #{dir_template}/*.rb #{subdir_name}")
110
- system("cp -r #{dir_template}/config/database-pg.yml #{subdir_name}/config")
111
- system("rm -rf #{dir_template}")
32
+ def self.git_init(subdir_name)
33
+ puts '----------------'
34
+ puts 'Initializing Git'
35
+ system("cd #{subdir_name} && rm -rf .git")
36
+ system("cd #{subdir_name} && git init")
37
+ system("cd #{subdir_name} && git add .")
38
+ system("cd #{subdir_name} && git commit -m 'Initial commit' >/dev/null")
112
39
  end
113
40
  end
@@ -0,0 +1,71 @@
1
+ require 'spec_helper'
2
+ require 'generic_app'
3
+ require 'string_in_file'
4
+
5
+ dir_app_1 = "#{ENV['DIR_PARENT']}/tmp1"
6
+
7
+ describe GenericApp do
8
+ it 'New Rails app' do
9
+ puts
10
+ puts '**************'
11
+ puts 'CREATING APP 1'
12
+ puts 'New Rails app'
13
+ system("rm -rf #{dir_app_1}")
14
+ Dir.chdir(ENV['DIR_PARENT']) do
15
+ GenericApp.create_new('tmp1', '007@railstutorial.org')
16
+ end
17
+ end
18
+
19
+ it 'Email address should be updated' do
20
+ expect(StringInFile.present('007@railstutorial.org', "#{dir_app_1}/config/initializers/devise.rb")).to eq(true)
21
+ end
22
+
23
+ it 'Bash scripts should be provided' do
24
+ expect(StringInFile.present('heroku run rake db:migrate', "#{dir_app_1}/heroku_upload.sh")).to eq(true)
25
+ expect(StringInFile.present('pkill', "#{dir_app_1}/kill_spring.sh")).to eq(true)
26
+ expect(StringInFile.present('tree app/controllers', "#{dir_app_1}/outline.sh")).to eq(true)
27
+ expect(StringInFile.present('rails console --sandbox', "#{dir_app_1}/sandbox.sh")).to eq(true)
28
+ expect(StringInFile.present('rake db:seed', "#{dir_app_1}/seed.sh")).to eq(true)
29
+ expect(StringInFile.present('rails server -b 0.0.0.0', "#{dir_app_1}/server.sh")).to eq(true)
30
+ expect(StringInFile.present('bundle install', "#{dir_app_1}/build_fast.sh")).to eq(true)
31
+ end
32
+
33
+ it 'New README.md file should be provided' do
34
+ expect(StringInFile.present('outline.sh', "#{dir_app_1}/README.md")).to eq(true)
35
+ end
36
+
37
+ it 'Guardfile should be set to automatically run tests upon startup' do
38
+ expect(StringInFile.present('all_on_start: true', "#{dir_app_1}/Guardfile")).to eq(true)
39
+ end
40
+
41
+ it 'The .gitignore file includes tmp, tmp*, and ,DS_Store' do
42
+ expect(StringInFile.present('tmp', "#{dir_app_1}/.gitignore")).to eq(true)
43
+ expect(StringInFile.present('tmp*', "#{dir_app_1}/.gitignore")).to eq(true)
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)
48
+ end
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-helpers.txt")).to eq(true)
63
+ end
64
+
65
+ it 'The notes/1-file_list-models.txt file should be in place' do
66
+ expect(StringInFile.present('admin_test.rb', "#{dir_app_1}/notes/1-file_list-models.txt")).to eq(true)
67
+ expect(StringInFile.present('user_test.rb', "#{dir_app_1}/notes/1-file_list-models.txt")).to eq(true)
68
+ expect(StringInFile.present('admin.rb', "#{dir_app_1}/notes/1-file_list-models.txt")).to eq(true)
69
+ expect(StringInFile.present('user.rb', "#{dir_app_1}/notes/1-file_list-models.txt")).to eq(true)
70
+ end
71
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  require 'spec_helper'
2
2
 
3
- require "codeclimate-test-reporter"
3
+ require 'codeclimate-test-reporter'
4
4
  CodeClimate::TestReporter.start
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
4
+ version: 1.1.0
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-10-05 00:00:00.000000000 Z
11
+ date: 2016-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rubocop
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: string_in_file
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -72,28 +86,26 @@ email:
72
86
  - rubyist@jasonhsu.com
73
87
  executables:
74
88
  - generic_app
75
- - generic_app_add
76
89
  - setup
77
90
  extensions: []
78
91
  extra_rdoc_files: []
79
92
  files:
80
93
  - ".codeclimate.yml"
81
94
  - ".gitignore"
95
+ - ".rubocop.yml"
82
96
  - ".travis.yml"
83
97
  - Gemfile
84
98
  - LICENSE.txt
85
99
  - README.md
86
100
  - Rakefile
87
101
  - bin/generic_app
88
- - bin/generic_app_add
89
102
  - bin/setup
90
103
  - gem_install.sh
91
104
  - gem_test.sh
92
105
  - generic_app.gemspec
93
106
  - lib/generic_app.rb
94
107
  - lib/generic_app/version.rb
95
- - spec/lib/1_new_app_spec.rb
96
- - spec/lib/2_legacy_app_spec.rb
108
+ - spec/lib/1_sqlite_spec.rb
97
109
  - spec/spec_helper.rb
98
110
  homepage: https://github.com/jhsu802701/generic_app
99
111
  licenses:
@@ -115,11 +127,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
127
  version: '0'
116
128
  requirements: []
117
129
  rubyforge_project:
118
- rubygems_version: 2.4.5.1
130
+ rubygems_version: 2.5.1
119
131
  signing_key:
120
132
  specification_version: 4
121
133
  summary: Save time by instantly create a generic Rails app.
122
134
  test_files:
123
- - spec/lib/1_new_app_spec.rb
124
- - spec/lib/2_legacy_app_spec.rb
135
+ - spec/lib/1_sqlite_spec.rb
125
136
  - spec/spec_helper.rb
data/bin/generic_app_add DELETED
@@ -1,35 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'generic_app'
4
-
5
- valid_folder = false
6
- dir_app = ''
7
-
8
- while valid_folder = false or dir_app == '' do
9
- puts '*************************************************'
10
- puts 'Adding Generic App features to a pre-existing app'
11
- puts
12
- puts "Present working directory: #{Dir.pwd}"
13
- puts
14
- system ('ls')
15
- puts
16
- puts 'Enter the name of the directory in which you wish to add the features of Generic App:'
17
- dir_app = gets.chomp
18
- begin
19
- GenericApp.add (dir_app)
20
- valid_folder = true
21
- rescue
22
- end
23
- end
24
-
25
- puts '***********************************'
26
- puts 'Please enter the following command'
27
- puts 'to enter the app:'
28
- puts "cd #{dir_app}"
29
- puts
30
- puts 'Please note that certain scripts (like test_app.sh and seed.sh)'
31
- puts 'may need to be revised for this legacy app.'
32
- puts
33
- puts 'If this legacy app uses the PostgreSQL database, run the '
34
- puts 'setup-pg.sh script to set up the database and its user.'
35
- puts
@@ -1,72 +0,0 @@
1
- require 'spec_helper'
2
- require 'generic_app'
3
- require 'string_in_file'
4
-
5
- dir_app_1 = "#{ENV['DIR_PARENT']}/tmp1"
6
-
7
- describe GenericApp do
8
- it "New Rails app" do
9
- puts
10
- puts '**************'
11
- puts 'CREATING APP 1'
12
- puts 'New Rails app'
13
- system("rm -rf #{dir_app_1}")
14
- Dir.chdir("#{ENV['DIR_PARENT']}") do
15
- GenericApp.create_new('tmp1', '007@railstutorial.org')
16
- end
17
- end
18
-
19
- it 'Email address should be updated' do
20
- expect(StringInFile.present('007@railstutorial.org', "#{dir_app_1}/config/initializers/devise.rb")).to eq(true)
21
- end
22
-
23
- it "Bash scripts should be provided" do
24
- expect(StringInFile.present("heroku run rake db:migrate", "#{dir_app_1}/heroku_upload.sh")).to eq(true)
25
- expect(StringInFile.present("pkill", "#{dir_app_1}/kill_spring.sh")).to eq(true)
26
- expect(StringInFile.present("ls -R1 -I concerns app/controllers", "#{dir_app_1}/outline.sh")).to eq(true)
27
- expect(StringInFile.present("rails console --sandbox", "#{dir_app_1}/sandbox.sh")).to eq(true)
28
- expect(StringInFile.present("rake db:seed", "#{dir_app_1}/seed.sh")).to eq(true)
29
- expect(StringInFile.present("rails server -b 0.0.0.0", "#{dir_app_1}/server.sh")).to eq(true)
30
- expect(StringInFile.present("bundle install", "#{dir_app_1}/test_app.sh")).to eq(true)
31
- end
32
-
33
- it "New README.md file should be provided" do
34
- expect(StringInFile.present("outline.sh", "#{dir_app_1}/README.md")).to eq(true)
35
- end
36
-
37
- it "Guardfile should be set to automatically run tests upon startup" do
38
- expect(StringInFile.present("all_on_start: true", "#{dir_app_1}/Guardfile")).to eq(true)
39
- end
40
-
41
- it "The .gitignore file includes tmp, tmp*, and ,DS_Store" do
42
- expect(StringInFile.present("tmp", "#{dir_app_1}/.gitignore")).to eq(true)
43
- expect(StringInFile.present("tmp*", "#{dir_app_1}/.gitignore")).to eq(true)
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)
48
- end
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
- end
64
-
65
- it "The notes/1-file_list-models.txt file should be in place" do
66
- expect(StringInFile.present("admin_test.rb", "#{dir_app_1}/notes/1-file_list-models.txt")).to eq(true)
67
- expect(StringInFile.present("user_test.rb", "#{dir_app_1}/notes/1-file_list-models.txt")).to eq(true)
68
- expect(StringInFile.present("admin.rb", "#{dir_app_1}/notes/1-file_list-models.txt")).to eq(true)
69
- expect(StringInFile.present("user.rb", "#{dir_app_1}/notes/1-file_list-models.txt")).to eq(true)
70
- end
71
-
72
- end
@@ -1,66 +0,0 @@
1
- require 'spec_helper'
2
- require 'generic_app'
3
- require 'string_in_file'
4
-
5
- dir_app_2 = "#{ENV['DIR_PARENT']}/tmp2"
6
-
7
- describe GenericApp do
8
- it 'Legacy app' do
9
- puts
10
- puts '**************'
11
- puts 'STARTING APP 2'
12
- puts 'Legacy Rails app'
13
-
14
- system("rm -rf #{dir_app_2}")
15
- Dir.chdir("#{ENV['DIR_PARENT']}") do
16
- t1 = Thread.new {
17
- puts '------------------'
18
- puts 'Getting legacy app'
19
- system('git clone https://github.com/mhartl/sample_app_3rd_edition.git tmp2')
20
- system('wait')
21
- system("cd tmp2 && git checkout remotes/origin/account-activation-password-reset")
22
- system('wait')
23
- puts 'Finished acquiring legacy app'
24
- puts '-----------------------------'
25
- }
26
- t1.join
27
- GenericApp.add ('tmp2')
28
- end
29
- end
30
-
31
- it "Bash scripts should be provided" do
32
- expect(StringInFile.present("heroku run rake db:migrate", "#{dir_app_2}/heroku_upload.sh")).to eq(true)
33
- expect(StringInFile.present("pkill", "#{dir_app_2}/kill_spring.sh")).to eq(true)
34
- expect(StringInFile.present("ls -R1 -I concerns app/controllers", "#{dir_app_2}/outline.sh")).to eq(true)
35
- expect(StringInFile.present("rails console --sandbox", "#{dir_app_2}/sandbox.sh")).to eq(true)
36
- expect(StringInFile.present("rake db:seed", "#{dir_app_2}/seed.sh")).to eq(true)
37
- expect(StringInFile.present("rails server -b 0.0.0.0", "#{dir_app_2}/server.sh")).to eq(true)
38
- expect(StringInFile.present("bundle install", "#{dir_app_2}/test_app.sh")).to eq(true)
39
- end
40
-
41
- it "The .gitignore file includes tmp, tmp*, and ,DS_Store" do
42
- expect(StringInFile.present("tmp", "#{dir_app_2}/.gitignore")).to eq(true)
43
- expect(StringInFile.present("tmp*", "#{dir_app_2}/.gitignore")).to eq(true)
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)
65
- end
66
- end