class JsonVoorhees::SetupAppGenerator

Public Instance Methods

sprint() click to toggle source
# File lib/generators/json_voorhees/setup_app/setup_app_generator.rb, line 8
def sprint
    create_file_structure
  clone_arcadex
  all_gems
    run_bundle
    rspec
    api_controller
  include_middleware
  make_admin
  make_user
  run "rake railties:install:migrations"
  run_db_migrations
    routes
    make_controllers
  custom_active_admin
  seed_database
  initializers
  run "wheneverize"
    run_git
end

Private Instance Methods

all_gems() click to toggle source
# File lib/generators/json_voorhees/setup_app/setup_app_generator.rb, line 119
def all_gems
  # Dev gems
  gem_group :development, :test do
    #gem 'sqlite3', '~> 1.3.9'    # dev & test database
    gem 'figaro', '~> 0.7.0'     # env variables
    gem 'annotate', ">=2.6.0"
    gem 'rspec-rails', '~> 3.0.0'
    gem 'byebug', '~> 3.2.0'
    gem 'factory_girl_rails', '~> 4.0'
    gem 'database_cleaner', '~> 1.3.0'
  end
  gem_group :development do
    gem 'better_errors', '~> 1.1.0'
    gem 'binding_of_caller', '~> 0.7.1' # needed by better_errors or variable inspection
  end
  # Other gems
  # This ties in nicely with Ember, 0.8.0 is the stable version
  gem 'active_model_serializers', '~> 0.8.0'
  # This is the api of choice now
  gem 'rails-api'
  gem 'kaminari'
  gem 'bcrypt', '~> 3.1.7'
  gem 'type_cartographer'
  gem 'devise', "~> 3.2.4" 
  gem 'arcadex', :path => "engines/arcadex"
  gem 'autoprefixer-rails'
  gem 'bootstrap-sass', '~> 3.2.0'
  gem 'activeadmin', :git => 'https://github.com/activeadmin/activeadmin.git', :branch => "master"
  #gem 'defcon', '~> 1.2.3'
  gem 'authorization', :path => "gems/authorization"
  gem 'whenever', :require => false
  gem 'rack-cors', :require => 'rack/cors'
  gem 'httparty'
  gem 'paperclip', '~> 4.2'
  gem 'aws-sdk', '~> 1.5.7'
  gem 'rails_config', '~> 0.4.2'
  #gem 'websocket-rails'
end
api_controller() click to toggle source
# File lib/generators/json_voorhees/setup_app/setup_app_generator.rb, line 100
def api_controller
    template "api_controller_with_arcadex.rb", "app/controllers/api/v1/api_controller.rb"
end
clone_arcadex() click to toggle source
# File lib/generators/json_voorhees/setup_app/setup_app_generator.rb, line 31
def clone_arcadex
  run "git clone https://www.github.com/cleor41/arcadex"
  run "rm -rf arcadex/.git"
  run "mv arcadex engines/arcadex"
end
create_file_structure() click to toggle source
# File lib/generators/json_voorhees/setup_app/setup_app_generator.rb, line 158
def create_file_structure
    run "rm -rf test"
                    run "rm -f README.rdoc"
                    run "echo '# Describe your application here' > README.md"
                    run "mkdir engines && touch engines/.gitkeep"
                    run "mkdir gems && touch gems/.gitkeep"
                    run "mkdir notes && touch notes/.gitkeep"
                    run "rails plugin new gems/authorization"
end
custom_active_admin() click to toggle source
# File lib/generators/json_voorhees/setup_app/setup_app_generator.rb, line 52
def custom_active_admin
  template "active_admin_token_register.rb.erb", "app/admin/arcadex_token.rb"
end
include_middleware() click to toggle source
# File lib/generators/json_voorhees/setup_app/setup_app_generator.rb, line 73
    def include_middleware
      inject_into_file 'config/application.rb', after: "class Application < Rails::Application\n" do <<-'RUBY'

    #So Rails-Api doesn't remove all of the middleware
    config.api_only = false

      RUBY
      end
    end
initializers() click to toggle source
# File lib/generators/json_voorhees/setup_app/setup_app_generator.rb, line 37
def initializers
  run "rails g json_voorhees:app_environment"
end
make_admin() click to toggle source
# File lib/generators/json_voorhees/setup_app/setup_app_generator.rb, line 56
def make_admin
  if options.fbonly?
    run "rails g json_voorhees:app_make_admin --fbonly"
  else
    run "rails g json_voorhees:app_make_admin"
  end
end
make_controllers() click to toggle source
# File lib/generators/json_voorhees/setup_app/setup_app_generator.rb, line 91
def make_controllers
    generate "controller", "app_index app"
  run "rm -f app/controllers/app_index_controller.rb"
  copy_file "app_index_controller.rb", "app/controllers/app_index_controller.rb"
  #Copy the views over
  copy_file "views/app", "app/views/app_index/app.html.erb"
  copy_file "views/app_index", "app/views/layouts/app_index.html.erb"
end
make_user() click to toggle source
# File lib/generators/json_voorhees/setup_app/setup_app_generator.rb, line 64
def make_user
  if options.fbonly?
    run "rails g json_voorhees:app_make_user --fbonly"
  else
    run "rails g json_voorhees:app_make_user"
  end
  run_bundle
end
routes() click to toggle source
# File lib/generators/json_voorhees/setup_app/setup_app_generator.rb, line 83
def routes
  route "mount Defcon::Engine, at: \'/\'"
    route "root to: \"app_index#app\""
  if !options.active_admin? && options.admin?
              route "get \'admin\' => \'main#admin\', as: \"admin\" #admin_path"
  end
end
rspec() click to toggle source
# File lib/generators/json_voorhees/setup_app/setup_app_generator.rb, line 104
    def rspec
                        generate "rspec:install"
                        run "rm -f .rspec"
                        copy_file "hidden_rspec.rb", ".rspec"
                        copy_file "rspec_factory_girl.rb", "spec/support/factory_girl.rb"
                        inject_into_file 'spec/rails_helper.rb', after: "RSpec.configure do |config|\n" do <<-'RUBY'

        config.include ::Requests::JsonHelpers, :type => :request
        config.include ::Requests::JsonHelpers, :type => :controller

                        RUBY
                        end
                        copy_file "json_helpers.rb", "spec/support/request_helpers.rb"
    end
run_bundle() click to toggle source
# File lib/generators/json_voorhees/setup_app/setup_app_generator.rb, line 168
def run_bundle
  Bundler.with_clean_env do
    run "bundle install"
  end
end
run_db_migrations() click to toggle source
# File lib/generators/json_voorhees/setup_app/setup_app_generator.rb, line 174
def run_db_migrations
  run "rake db:migrate RAILS_ENV=development"
  run "rake db:migrate RAILS_ENV=test"
  run "rake db:migrate RAILS_ENV=production"
end
run_git() click to toggle source
# File lib/generators/json_voorhees/setup_app/setup_app_generator.rb, line 180
def run_git
  git :init
  git add: "."
  run "git commit -m \"Initial commit\""
end
seed_database() click to toggle source
# File lib/generators/json_voorhees/setup_app/setup_app_generator.rb, line 41
    def seed_database
      #db/seeds.rb
      inject_into_file "db/seeds.rb", after: "#   Mayor.create(name: 'Emanuel', city: cities.first)\n" do <<-'RUBY'

::Defcon::AdminUser.create({username: "admin", password: "password", password_confirmation: "password"})
      
      RUBY
      end
      run "rake db:seed"
    end