Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Initial Commit

  • Loading branch information...
commit c0ebe1c482ac05d257748e4c054b0e3fabefcec4 0 parents
@tomas-stefano authored
15 Readme.markdown
@@ -0,0 +1,15 @@
+tree
+ app
+ business
+ models
+ presenters
+ controllers
+ ...
+ spec
+ business
+ models
+ presenters
+ controllers
+ model_helper.rb
+ presenter_helper.rb
+ business_helper.rb
38 rails_oop_template.rb
@@ -0,0 +1,38 @@
+
+gem 'devise', :group => [:features, :models, :default] # Authentication
+gem 'simple_form', :group => :features # Awesome Form Builder
+gem 'foreigner', :group => :features # Create Fks for MySQL
+
+if yes?('Using Carrierwave?')
+ gem 'carrierwave', :group => :features # Upload Files
+end
+
+if yes?('Using mysql?')
+ gem 'mysql2', :group => :models
+end
+
+if yes?('Using RSpec?')
+ gem 'rspec', :group => :unit_testing
+ gem 'rspec-rails', :group => [:development, :test]
+ gem 'capybara', :group => [:development, :test]
+end
+
+run 'bundle install'
+generate 'devise:install'
+generate 'simple_form:install'
+generate 'rspec:install'
+generate 'devise', 'User' if yes?('Generate Devise User?')
+
+run "rm -Rf README public/index.html"
+run "rm -Rf test"
+
+run "mkdir app/business"
+run "mkdir -p spec"
+run "mkdir spec/business"
+run "mkdir -p app/presenters"
+
+run "wget --no-check-certificate 'https://github.com/tomas-stefano/rails-OOP-template/raw/master/spec/model_spec_helper.rb' -O spec/model_spec_helper.rb"
+run "wget --no-check-certificate 'https://github.com/tomas-stefano/rails-OOP-template/raw/master/spec/support/require_helper.rb' -O spec/support/require_helper.rb"
+
+puts 'The generated template run successfuly. Happy Coding! :)'
+
10 spec/model_spec_helper.rb
@@ -0,0 +1,10 @@
+$LOAD_PATH.unshift File.expand_path('../../', __FILE__)
+require 'bundler/setup'
+Bundler.require :models, :unit_tests
+require 'spec/support/require_helper'
+
+database_yml = YAML.load_file(File.expand_path('config/database.yml'))
+ActiveRecord::Base.establish_connection(database_yml['test'])
+
+I18n.load_path << Dir['config/locales/*.yml']
+I18n.locale = 'pt-BR'
78 spec/support/require_helper.rb
@@ -0,0 +1,78 @@
+module RequireHelper
+ # Require 1-n models
+ #
+ # ==== Examples
+ #
+ # require_model :country
+ # require_model :city
+ #
+ # require_models :country, :city
+ # require_models :state, :property
+ #
+ def require_model(*models)
+ models.flatten.each { |file| require "app/models/#{file.to_s}" }
+ end
+ alias :require_models :require_model
+
+ # Require 1-n validator
+ #
+ # ==== Examples
+ #
+ # require_validator :crm
+ # require_validator :city
+ #
+ # require_validators :country, :city
+ # require_validators :state, :property
+ #
+ def require_validator(*validators)
+ validators.flatten.each { |file| require "app/validators/#{file.to_s}_validator" }
+ end
+ alias :require_validators :require_validator
+
+ # Require file from app/business folder
+ #
+ # ==== Examples
+ #
+ # require_business :country
+ # require_business :city
+ #
+ def require_business(*business)
+ business.flatten.each { |file| require "app/business/#{file.to_s}"}
+ end
+
+ # Require file from app/presenters folder
+ #
+ # ==== Examples
+ #
+ # require_presenter :user_presenter
+ # require_presenters :user_presenter, :city_presenter
+ #
+ def require_presenter(*presenters)
+ presenters.flatten.each { |file| require "app/presenters/#{file.to_s}"}
+ end
+ alias :require_presenters :require_presenter
+
+ # Require file from app/enumerations folder
+ #
+ # ==== Examples
+ #
+ # require_enumeration :user_type
+ # require_enumerations :user_type, :patology_status
+ #
+ def require_enumeration(*enumerations)
+ enumerations.flatten.each { |file| require "app/enumerations/#{file.to_s}"}
+ end
+ alias :require_enumerations :require_enumeration
+
+ # Require file from spec/shared_examples folder
+ #
+ # ==== Examples
+ #
+ # require_shared_example :company
+ #
+ def require_shared_example(*shared_example)
+ shared_example.flatten.each { |file| require "spec/shared_examples/#{file.to_s}_shared_example"}
+ end
+ alias :require_shared_examples :require_shared_example
+end
+include RequireHelper
Please sign in to comment.
Something went wrong with that request. Please try again.