sanji 1.0.0.pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README.md +3 -0
- data/bin/sanji +14 -0
- data/lib/sanji/app_builder.rb +59 -0
- data/lib/sanji/app_generator.rb +39 -0
- data/lib/sanji/assistant.rb +96 -0
- data/lib/sanji/recipe.rb +36 -0
- data/lib/sanji/recipes/annotate.rb +11 -0
- data/lib/sanji/recipes/cleanup.rb +19 -0
- data/lib/sanji/recipes/controllers.rb +80 -0
- data/lib/sanji/recipes/devise.rb +15 -0
- data/lib/sanji/recipes/draper.rb +14 -0
- data/lib/sanji/recipes/figaro.rb +22 -0
- data/lib/sanji/recipes/frontend.rb +47 -0
- data/lib/sanji/recipes/haml.rb +11 -0
- data/lib/sanji/recipes/paloma.rb +9 -0
- data/lib/sanji/recipes/postgresql.rb +23 -0
- data/lib/sanji/recipes/reform.rb +12 -0
- data/lib/sanji/recipes/seedbank.rb +12 -0
- data/lib/sanji/recipes/setup.rb +25 -0
- data/lib/sanji/recipes/simple_gems.rb +11 -0
- data/lib/sanji/utilities/text.rb +37 -0
- data/lib/sanji.rb +25 -0
- metadata +66 -0
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            SHA1:
         | 
| 3 | 
            +
              metadata.gz: db57a4e0739187f622d2dfd0e997135ac62bb85d
         | 
| 4 | 
            +
              data.tar.gz: fa9dc9a29f35da36a0cd46150927a579bfda400e
         | 
| 5 | 
            +
            SHA512:
         | 
| 6 | 
            +
              metadata.gz: 399f7e0e08d027a55c717a2bdcd0522adb6433e9b79d3f369a0ee14f5d8c3ddc583f584daaba233bfc9ec25f707bcbfe7cc2a57f0d247ce5c07bbf10d7c05e61
         | 
| 7 | 
            +
              data.tar.gz: 18aed75ec1c1fe017eb316bf603c206ed6e6ac705c1630aec79232743ede32923a7200eb40c1412ec8cd8ff159d69c5660f1e5952b4f94f25547f2ffc0b378c9
         | 
    
        data/README.md
    ADDED
    
    
    
        data/bin/sanji
    ADDED
    
    | @@ -0,0 +1,14 @@ | |
| 1 | 
            +
            #!/usr/bin/env ruby
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require 'sanji'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            templates_root =
         | 
| 6 | 
            +
              File.expand_path(File.join('..', 'templates'), File.dirname(__FILE__))
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            Sanji::AppGenerator.source_root templates_root
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            Sanji::AppGenerator.source_paths <<
         | 
| 11 | 
            +
              Rails::Generators::AppGenerator.source_root <<
         | 
| 12 | 
            +
              templates_root
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            Sanji::AppGenerator.start
         | 
| @@ -0,0 +1,59 @@ | |
| 1 | 
            +
            module Sanji
         | 
| 2 | 
            +
              class AppBuilder < Rails::AppBuilder
         | 
| 3 | 
            +
             | 
| 4 | 
            +
                RECIPES = [
         | 
| 5 | 
            +
                  :Setup,
         | 
| 6 | 
            +
                  :Annotate,
         | 
| 7 | 
            +
                  :Draper,
         | 
| 8 | 
            +
                  :Figaro,
         | 
| 9 | 
            +
                  :Haml,
         | 
| 10 | 
            +
                  :Paloma,
         | 
| 11 | 
            +
                  :Postgresql,
         | 
| 12 | 
            +
                  :Reform,
         | 
| 13 | 
            +
                  :Seedbank,
         | 
| 14 | 
            +
                  :Frontend,
         | 
| 15 | 
            +
                  :SimpleGems,
         | 
| 16 | 
            +
                  :Controllers,
         | 
| 17 | 
            +
                  :Devise,
         | 
| 18 | 
            +
                  :Cleanup
         | 
| 19 | 
            +
                ]
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                def after_create_tasks
         | 
| 22 | 
            +
                  RECIPES.each do |name|
         | 
| 23 | 
            +
                    self.get_recipe_instance(name).run_after_create
         | 
| 24 | 
            +
                  end
         | 
| 25 | 
            +
                end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                def after_bundle_tasks
         | 
| 28 | 
            +
                  RECIPES.each do |name|
         | 
| 29 | 
            +
                    self.get_recipe_instance(name).run_after_bundle
         | 
| 30 | 
            +
                  end
         | 
| 31 | 
            +
                end
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                def after_everything_tasks
         | 
| 34 | 
            +
                  RECIPES.each do |name|
         | 
| 35 | 
            +
                    self.get_recipe_instance(name).run_after_everything
         | 
| 36 | 
            +
                  end
         | 
| 37 | 
            +
                end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
             | 
| 40 | 
            +
             | 
| 41 | 
            +
                protected
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                def get_recipe_instance name
         | 
| 44 | 
            +
                  recipe = self.recipe_instances[name]
         | 
| 45 | 
            +
                  return recipe if recipe
         | 
| 46 | 
            +
             | 
| 47 | 
            +
                  recipe_class = ::Sanji::Recipes.const_get name
         | 
| 48 | 
            +
                  recipe = recipe_class.new self
         | 
| 49 | 
            +
             | 
| 50 | 
            +
                  self.recipe_instances[name] = recipe
         | 
| 51 | 
            +
                  recipe
         | 
| 52 | 
            +
                end
         | 
| 53 | 
            +
             | 
| 54 | 
            +
                def recipe_instances
         | 
| 55 | 
            +
                  @recipe_instances ||= {}
         | 
| 56 | 
            +
                end
         | 
| 57 | 
            +
             | 
| 58 | 
            +
              end
         | 
| 59 | 
            +
            end
         | 
| @@ -0,0 +1,39 @@ | |
| 1 | 
            +
            require 'rails/generators'
         | 
| 2 | 
            +
            require 'rails/generators/rails/app/app_generator'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            module Sanji
         | 
| 5 | 
            +
              class AppGenerator < Rails::Generators::AppGenerator
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                def finish_template
         | 
| 8 | 
            +
                  invoke :sanji_after_create_tasks
         | 
| 9 | 
            +
                  super
         | 
| 10 | 
            +
                end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                def run_after_bundle_callbacks
         | 
| 13 | 
            +
                  invoke :sanji_after_bundle_tasks
         | 
| 14 | 
            +
                  super
         | 
| 15 | 
            +
                  invoke :sanji_after_everything_tasks
         | 
| 16 | 
            +
                end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                def sanji_after_create_tasks
         | 
| 19 | 
            +
                  build :after_create_tasks
         | 
| 20 | 
            +
                end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                def sanji_after_bundle_tasks
         | 
| 23 | 
            +
                  build :after_bundle_tasks
         | 
| 24 | 
            +
                end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                def sanji_after_everything_tasks
         | 
| 27 | 
            +
                  build :after_everything_tasks
         | 
| 28 | 
            +
                end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
             | 
| 31 | 
            +
             | 
| 32 | 
            +
                protected
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                def get_builder_class
         | 
| 35 | 
            +
                  Sanji::AppBuilder
         | 
| 36 | 
            +
                end
         | 
| 37 | 
            +
             | 
| 38 | 
            +
              end
         | 
| 39 | 
            +
            end
         | 
| @@ -0,0 +1,96 @@ | |
| 1 | 
            +
            class Sanji::Assistant
         | 
| 2 | 
            +
             | 
| 3 | 
            +
              attr_reader :builder
         | 
| 4 | 
            +
             | 
| 5 | 
            +
              def initialize recipe, builder
         | 
| 6 | 
            +
                @recipe = recipe
         | 
| 7 | 
            +
                @builder = builder
         | 
| 8 | 
            +
              end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
              def method_missing name, *args, &block
         | 
| 11 | 
            +
                self.builder.send name, *args, &block
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
             | 
| 15 | 
            +
             | 
| 16 | 
            +
              def text &block
         | 
| 17 | 
            +
                Sanji::Utilities::Text.create &block
         | 
| 18 | 
            +
              end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
              def generator name, value
         | 
| 21 | 
            +
                self.builder.insert_into_file 'config/application.rb',
         | 
| 22 | 
            +
                  self.text { |t| t.indent(3).puts "g.#{name} #{value}" },
         | 
| 23 | 
            +
                  :after => "# sanji-generators\n"
         | 
| 24 | 
            +
              end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
             | 
| 27 | 
            +
              # `block` will have an Sanji::Utilities::Text instance as an argument.
         | 
| 28 | 
            +
              def application_config &block
         | 
| 29 | 
            +
                config = self.text &block
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                self.builder.insert_into_file 'config/application.rb', config,
         | 
| 32 | 
            +
                  :after => "class Application < Rails::Application\n"
         | 
| 33 | 
            +
              end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
              def bundle_exec command = ''
         | 
| 36 | 
            +
                self.builder.run "bundle exec #{command}"
         | 
| 37 | 
            +
              end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
              def add_gem name, version_or_options = nil, extra = nil
         | 
| 40 | 
            +
                first_arg =
         | 
| 41 | 
            +
                  if version_or_options.is_a? String
         | 
| 42 | 
            +
                    "'#{version_or_options}'"
         | 
| 43 | 
            +
                  else
         | 
| 44 | 
            +
                    version_or_options.to_s.gsub /\{|\}/, ''
         | 
| 45 | 
            +
                  end
         | 
| 46 | 
            +
             | 
| 47 | 
            +
                second_arg = extra.to_s.gsub(/\{|\}/, '') if extra
         | 
| 48 | 
            +
             | 
| 49 | 
            +
                values = ["'#{name}'", first_arg, second_arg].reject &:blank?
         | 
| 50 | 
            +
                entry = values.join ', '
         | 
| 51 | 
            +
             | 
| 52 | 
            +
                self.builder.insert_into_file 'Gemfile', :after => "# sanji-gems\n" do
         | 
| 53 | 
            +
                  "gem #{entry}\n"
         | 
| 54 | 
            +
                end
         | 
| 55 | 
            +
              end
         | 
| 56 | 
            +
             | 
| 57 | 
            +
              def remove_gem name
         | 
| 58 | 
            +
                self.builder.gsub_file 'Gemfile',
         | 
| 59 | 
            +
                  Regexp.new("^\\s*gem ('|\")#{name}('|\").*\\n"), ''
         | 
| 60 | 
            +
              end
         | 
| 61 | 
            +
             | 
| 62 | 
            +
              def delete_file filename
         | 
| 63 | 
            +
                self.builder.run "rm #{filename}"
         | 
| 64 | 
            +
              end
         | 
| 65 | 
            +
             | 
| 66 | 
            +
              def log_start method_name
         | 
| 67 | 
            +
                self.say "start ##{method_name}"
         | 
| 68 | 
            +
              end
         | 
| 69 | 
            +
             | 
| 70 | 
            +
              def log_end method_name
         | 
| 71 | 
            +
                self.say "end ##{method_name}"
         | 
| 72 | 
            +
              end
         | 
| 73 | 
            +
             | 
| 74 | 
            +
              def say text
         | 
| 75 | 
            +
                self.builder.say recipe_message(text), Thor::Shell::Color::YELLOW
         | 
| 76 | 
            +
              end
         | 
| 77 | 
            +
             | 
| 78 | 
            +
              def ask question
         | 
| 79 | 
            +
                self.builder.ask recipe_message(question)
         | 
| 80 | 
            +
              end
         | 
| 81 | 
            +
             | 
| 82 | 
            +
              def yes? question
         | 
| 83 | 
            +
                self.builder.yes? recipe_message("#{question} (y/n)")
         | 
| 84 | 
            +
              end
         | 
| 85 | 
            +
             | 
| 86 | 
            +
              def no? question
         | 
| 87 | 
            +
                self.builder.no? recipe_message("#{question} (y/n)")
         | 
| 88 | 
            +
              end
         | 
| 89 | 
            +
             | 
| 90 | 
            +
              private
         | 
| 91 | 
            +
             | 
| 92 | 
            +
              def recipe_message message = ''
         | 
| 93 | 
            +
                "#{@recipe.class.name} -> #{message}"
         | 
| 94 | 
            +
              end
         | 
| 95 | 
            +
             | 
| 96 | 
            +
            end
         | 
    
        data/lib/sanji/recipe.rb
    ADDED
    
    | @@ -0,0 +1,36 @@ | |
| 1 | 
            +
            class Sanji::Recipe
         | 
| 2 | 
            +
             | 
| 3 | 
            +
              attr_reader :a
         | 
| 4 | 
            +
             | 
| 5 | 
            +
              def initialize builder
         | 
| 6 | 
            +
                @a = Sanji::Assistant.new self, builder
         | 
| 7 | 
            +
              end
         | 
| 8 | 
            +
             | 
| 9 | 
            +
              def run_after_create
         | 
| 10 | 
            +
                a.log_start :after_create
         | 
| 11 | 
            +
                self.after_create
         | 
| 12 | 
            +
                a.log_end :after_create
         | 
| 13 | 
            +
              end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
              def run_after_bundle
         | 
| 16 | 
            +
                a.log_start :after_bundle
         | 
| 17 | 
            +
                self.after_bundle
         | 
| 18 | 
            +
                a.log_end :after_bundle
         | 
| 19 | 
            +
              end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
              def run_after_everything
         | 
| 22 | 
            +
                a.log_start :after_everything
         | 
| 23 | 
            +
                self.after_everything
         | 
| 24 | 
            +
                a.log_end :after_everything
         | 
| 25 | 
            +
              end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
              def after_create
         | 
| 28 | 
            +
              end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
              def after_bundle
         | 
| 31 | 
            +
              end
         | 
| 32 | 
            +
             | 
| 33 | 
            +
              def after_everything
         | 
| 34 | 
            +
              end
         | 
| 35 | 
            +
             | 
| 36 | 
            +
            end
         | 
| @@ -0,0 +1,19 @@ | |
| 1 | 
            +
            class Sanji::Recipes::Cleanup < Sanji::Recipe
         | 
| 2 | 
            +
             | 
| 3 | 
            +
              def after_everything
         | 
| 4 | 
            +
                # remove all helper comments from Setup recipe.
         | 
| 5 | 
            +
                [
         | 
| 6 | 
            +
                  'config/application.rb',
         | 
| 7 | 
            +
                  'Gemfile'
         | 
| 8 | 
            +
                ].each { |file| a.gsub_file file, /^\s*# sanji.*\n/, '' }
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                self.remove_gemfile_comments
         | 
| 11 | 
            +
              end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
              protected
         | 
| 14 | 
            +
             | 
| 15 | 
            +
              def remove_gemfile_comments
         | 
| 16 | 
            +
                a.gsub_file 'Gemfile', /^\s*#.*\n/, ''
         | 
| 17 | 
            +
              end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            end
         | 
| @@ -0,0 +1,80 @@ | |
| 1 | 
            +
            class Sanji::Recipes::Controllers < Sanji::Recipe
         | 
| 2 | 
            +
             | 
| 3 | 
            +
              def after_bundle
         | 
| 4 | 
            +
                self.setup_public
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                self.setup_admin if self.has_admin?
         | 
| 7 | 
            +
                self.setup_private if self.has_private?
         | 
| 8 | 
            +
              end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
              protected
         | 
| 11 | 
            +
             | 
| 12 | 
            +
              def has_admin?
         | 
| 13 | 
            +
                a.yes? 'Create admin namespace?'
         | 
| 14 | 
            +
              end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
              def has_private?
         | 
| 17 | 
            +
                a.yes? 'Create private module for logged-in non-admin users?'
         | 
| 18 | 
            +
              end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
              def has_homepage?
         | 
| 21 | 
            +
                a.yes? 'Create controller for public home page?'
         | 
| 22 | 
            +
              end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
              def setup_admin
         | 
| 25 | 
            +
                a.generate 'controller', 'admin/base'
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                a.inside 'app/views/admin' do
         | 
| 28 | 
            +
                  a.run 'rm -R base'
         | 
| 29 | 
            +
                end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                route =
         | 
| 32 | 
            +
                  a.text do |t|
         | 
| 33 | 
            +
                    t.indent.puts 'namespace :admin do'
         | 
| 34 | 
            +
                    t.indent.puts 'end'
         | 
| 35 | 
            +
                  end
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                a.route route
         | 
| 38 | 
            +
              end
         | 
| 39 | 
            +
             | 
| 40 | 
            +
              def setup_private
         | 
| 41 | 
            +
                a.generate 'controller', 'private/base'
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                a.inside 'app/views/private' do
         | 
| 44 | 
            +
                  a.run 'rm -R base'
         | 
| 45 | 
            +
                end
         | 
| 46 | 
            +
             | 
| 47 | 
            +
                route =
         | 
| 48 | 
            +
                  a.text do |t|
         | 
| 49 | 
            +
                    t.indent.puts 'scope :module => :private do'
         | 
| 50 | 
            +
                    t.indent.puts 'end'
         | 
| 51 | 
            +
                  end
         | 
| 52 | 
            +
             | 
| 53 | 
            +
                a.route route
         | 
| 54 | 
            +
              end
         | 
| 55 | 
            +
             | 
| 56 | 
            +
              def setup_public
         | 
| 57 | 
            +
                a.generate 'controller', 'public/base'
         | 
| 58 | 
            +
             | 
| 59 | 
            +
                a.inside 'app/views/public' do
         | 
| 60 | 
            +
                  a.run 'rm -R base'
         | 
| 61 | 
            +
                end
         | 
| 62 | 
            +
             | 
| 63 | 
            +
                if self.has_homepage?
         | 
| 64 | 
            +
                  a.copy_file 'public_home_controller.rb',
         | 
| 65 | 
            +
                    'app/controller/public/home_controller.rb'
         | 
| 66 | 
            +
             | 
| 67 | 
            +
                  a.template 'public_home_index.haml.erb', 'app/views/public/home/index.haml'
         | 
| 68 | 
            +
             | 
| 69 | 
            +
                  a.route "root :to => 'public/home#index'"
         | 
| 70 | 
            +
             | 
| 71 | 
            +
                  # Change public namespace to module only.
         | 
| 72 | 
            +
                  a.gsub_file 'config/routes.rb',
         | 
| 73 | 
            +
                    /namespace :public/,
         | 
| 74 | 
            +
                    'scope :module => :public'
         | 
| 75 | 
            +
                else
         | 
| 76 | 
            +
                  a.route "scope :module => :public do\n  end"
         | 
| 77 | 
            +
                end
         | 
| 78 | 
            +
              end
         | 
| 79 | 
            +
             | 
| 80 | 
            +
            end
         | 
| @@ -0,0 +1,15 @@ | |
| 1 | 
            +
            class Sanji::Recipes::Devise < Sanji::Recipe
         | 
| 2 | 
            +
             | 
| 3 | 
            +
              def after_create
         | 
| 4 | 
            +
                a.add_gem 'devise', '~> 3.0.0'
         | 
| 5 | 
            +
              end
         | 
| 6 | 
            +
             | 
| 7 | 
            +
              def after_bundle
         | 
| 8 | 
            +
                a.generate 'devise:install'
         | 
| 9 | 
            +
                a.generate 'devise:views'
         | 
| 10 | 
            +
                a.generate 'devise User'
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                a.rake 'db:migrate'
         | 
| 13 | 
            +
              end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            end
         | 
| @@ -0,0 +1,14 @@ | |
| 1 | 
            +
            class Sanji::Recipes::Draper < Sanji::Recipe
         | 
| 2 | 
            +
             | 
| 3 | 
            +
              def after_create
         | 
| 4 | 
            +
                a.add_gem 'draper'
         | 
| 5 | 
            +
                a.generator :decorator, false
         | 
| 6 | 
            +
              end
         | 
| 7 | 
            +
             | 
| 8 | 
            +
              def after_bundle
         | 
| 9 | 
            +
                a.create_file 'app/decorators/application_decorator.rb' do
         | 
| 10 | 
            +
                  "class ApplicationDecorator < Draper::Decorator\nend"
         | 
| 11 | 
            +
                end
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            end
         | 
| @@ -0,0 +1,22 @@ | |
| 1 | 
            +
            class Sanji::Recipes::Figaro < Sanji::Recipe
         | 
| 2 | 
            +
             | 
| 3 | 
            +
              def after_create
         | 
| 4 | 
            +
                a.add_gem 'figaro'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                self.create_application_yml_sample
         | 
| 7 | 
            +
              end
         | 
| 8 | 
            +
             | 
| 9 | 
            +
              def after_bundle
         | 
| 10 | 
            +
                a.bundle_exec 'figaro install'
         | 
| 11 | 
            +
              end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
              protected
         | 
| 14 | 
            +
             | 
| 15 | 
            +
              def create_application_yml_sample
         | 
| 16 | 
            +
                a.create_file 'config/application.sample.yml' do
         | 
| 17 | 
            +
                  "# This will be the template for application.yml\n" \
         | 
| 18 | 
            +
                  "# Put all valid keys here and their sample values."
         | 
| 19 | 
            +
                end
         | 
| 20 | 
            +
              end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
            end
         | 
| @@ -0,0 +1,47 @@ | |
| 1 | 
            +
            class Sanji::Recipes::Frontend < Sanji::Recipe
         | 
| 2 | 
            +
             | 
| 3 | 
            +
              def after_create
         | 
| 4 | 
            +
                self.application_css_to_scss
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                if self.use_bootstrap?
         | 
| 7 | 
            +
                  self.setup_bootstrap
         | 
| 8 | 
            +
                else
         | 
| 9 | 
            +
                  self.setup_normalize
         | 
| 10 | 
            +
                end
         | 
| 11 | 
            +
              end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
              protected
         | 
| 14 | 
            +
             | 
| 15 | 
            +
              def application_css_to_scss
         | 
| 16 | 
            +
                a.inside 'app/assets/stylesheets' do
         | 
| 17 | 
            +
                  a.run 'mv application.css application.scss'
         | 
| 18 | 
            +
                end
         | 
| 19 | 
            +
              end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
              def use_bootstrap?
         | 
| 22 | 
            +
                a.yes? 'Use twitter bootstrap css and javascripts?'
         | 
| 23 | 
            +
              end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
              def setup_bootstrap
         | 
| 26 | 
            +
                a.add_gem 'bootstrap-sass'
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                a.insert_into_file 'app/assets/stylesheets/application.scss',
         | 
| 29 | 
            +
                  :after => "*/\n" do
         | 
| 30 | 
            +
                    "@import 'bootstrap-sprockets';\n" \
         | 
| 31 | 
            +
                    "@import 'bootstrap';\n"
         | 
| 32 | 
            +
                  end
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                a.insert_into_file 'app/assets/javascripts/application.js',
         | 
| 35 | 
            +
                  "//= require bootstrap-sprockets\n",
         | 
| 36 | 
            +
                  :after => "//= require jquery\n"
         | 
| 37 | 
            +
              end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
              def setup_normalize
         | 
| 40 | 
            +
                a.add_gem 'normalize-rails'
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                a.insert_into_file 'app/assets/stylesheets/application.scss',
         | 
| 43 | 
            +
                  "@import 'normalize-rails';\n",
         | 
| 44 | 
            +
                  :after => "*/\n"
         | 
| 45 | 
            +
              end
         | 
| 46 | 
            +
             | 
| 47 | 
            +
            end
         | 
| @@ -0,0 +1,23 @@ | |
| 1 | 
            +
            class Sanji::Recipes::Postgresql < Sanji::Recipe
         | 
| 2 | 
            +
             | 
| 3 | 
            +
              def after_create
         | 
| 4 | 
            +
                a.remove_gem 'sqlite3'
         | 
| 5 | 
            +
                a.add_gem 'pg'
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                self.create_database_yml
         | 
| 8 | 
            +
              end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
             | 
| 11 | 
            +
              protected
         | 
| 12 | 
            +
             | 
| 13 | 
            +
              def create_database_yml
         | 
| 14 | 
            +
                username = a.ask 'Development database username?'
         | 
| 15 | 
            +
                password = a.ask 'Development database password?'
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                a.delete_file 'config/database.yml'
         | 
| 18 | 
            +
                a.template 'database.yml.erb', 'config/database.yml',
         | 
| 19 | 
            +
                  :username => username,
         | 
| 20 | 
            +
                  :password => password
         | 
| 21 | 
            +
              end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            end
         | 
| @@ -0,0 +1,25 @@ | |
| 1 | 
            +
            class Sanji::Recipes::Setup < Sanji::Recipe
         | 
| 2 | 
            +
             | 
| 3 | 
            +
              def after_create
         | 
| 4 | 
            +
                self.add_generators_block
         | 
| 5 | 
            +
                self.add_gemfile_marker
         | 
| 6 | 
            +
              end
         | 
| 7 | 
            +
             | 
| 8 | 
            +
             | 
| 9 | 
            +
              protected
         | 
| 10 | 
            +
             | 
| 11 | 
            +
              def add_generators_block
         | 
| 12 | 
            +
                a.application_config do |t|
         | 
| 13 | 
            +
                  t.indent(2).puts 'config.generators do |g|'
         | 
| 14 | 
            +
                  t.indent(3).puts '# sanji-generators'
         | 
| 15 | 
            +
                  t.indent(2).puts 'end'
         | 
| 16 | 
            +
                end
         | 
| 17 | 
            +
              end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
              def add_gemfile_marker
         | 
| 20 | 
            +
                a.append_to_file 'Gemfile' do
         | 
| 21 | 
            +
                  "# sanji-gems\n"
         | 
| 22 | 
            +
                end
         | 
| 23 | 
            +
              end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            end
         | 
| @@ -0,0 +1,37 @@ | |
| 1 | 
            +
            class Sanji::Utilities::Text
         | 
| 2 | 
            +
             | 
| 3 | 
            +
              attr_reader :value
         | 
| 4 | 
            +
             | 
| 5 | 
            +
             | 
| 6 | 
            +
              def self.create &block
         | 
| 7 | 
            +
                instance = self.new
         | 
| 8 | 
            +
                block.call instance
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                instance.value
         | 
| 11 | 
            +
              end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
             | 
| 14 | 
            +
              def initialize
         | 
| 15 | 
            +
                @value = ''
         | 
| 16 | 
            +
              end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
              def puts text = ''
         | 
| 19 | 
            +
                self.value << "#{text}\n"
         | 
| 20 | 
            +
                self
         | 
| 21 | 
            +
              end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
              def print text = ''
         | 
| 24 | 
            +
                self.value << "#{text}"
         | 
| 25 | 
            +
                self
         | 
| 26 | 
            +
              end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
              def indent quantity = 1
         | 
| 29 | 
            +
                self.value << ('  ' * quantity)
         | 
| 30 | 
            +
                self
         | 
| 31 | 
            +
              end
         | 
| 32 | 
            +
             | 
| 33 | 
            +
              def empty_line
         | 
| 34 | 
            +
                self.puts
         | 
| 35 | 
            +
              end
         | 
| 36 | 
            +
             | 
| 37 | 
            +
            end
         | 
    
        data/lib/sanji.rb
    ADDED
    
    | @@ -0,0 +1,25 @@ | |
| 1 | 
            +
            module Sanji
         | 
| 2 | 
            +
              module Recipes
         | 
| 3 | 
            +
              end
         | 
| 4 | 
            +
             | 
| 5 | 
            +
              module Utilities
         | 
| 6 | 
            +
              end
         | 
| 7 | 
            +
            end
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            # Require all utilities
         | 
| 10 | 
            +
            Dir["#{File.dirname(__FILE__)}/sanji/utilities/*.rb"].each do |filename|
         | 
| 11 | 
            +
              require filename.sub('.rb', '')
         | 
| 12 | 
            +
            end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
             | 
| 15 | 
            +
            require 'sanji/assistant'
         | 
| 16 | 
            +
            require 'sanji/recipe'
         | 
| 17 | 
            +
             | 
| 18 | 
            +
            # Require all recipes
         | 
| 19 | 
            +
            Dir["#{File.dirname(__FILE__)}/sanji/recipes/*.rb"].each do |filename|
         | 
| 20 | 
            +
              require filename.sub('.rb', '')
         | 
| 21 | 
            +
            end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            require 'sanji/app_generator'
         | 
| 24 | 
            +
            require 'sanji/app_builder'
         | 
| 25 | 
            +
             | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,66 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: sanji
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 1.0.0.pre
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - Karl Paragua
         | 
| 8 | 
            +
            autorequire: 
         | 
| 9 | 
            +
            bindir: bin
         | 
| 10 | 
            +
            cert_chain: []
         | 
| 11 | 
            +
            date: 2015-12-09 00:00:00.000000000 Z
         | 
| 12 | 
            +
            dependencies: []
         | 
| 13 | 
            +
            description: rails application generator
         | 
| 14 | 
            +
            email: kb.paragua@gmail.com
         | 
| 15 | 
            +
            executables:
         | 
| 16 | 
            +
            - sanji
         | 
| 17 | 
            +
            extensions: []
         | 
| 18 | 
            +
            extra_rdoc_files: []
         | 
| 19 | 
            +
            files:
         | 
| 20 | 
            +
            - README.md
         | 
| 21 | 
            +
            - bin/sanji
         | 
| 22 | 
            +
            - lib/sanji.rb
         | 
| 23 | 
            +
            - lib/sanji/app_builder.rb
         | 
| 24 | 
            +
            - lib/sanji/app_generator.rb
         | 
| 25 | 
            +
            - lib/sanji/assistant.rb
         | 
| 26 | 
            +
            - lib/sanji/recipe.rb
         | 
| 27 | 
            +
            - lib/sanji/recipes/annotate.rb
         | 
| 28 | 
            +
            - lib/sanji/recipes/cleanup.rb
         | 
| 29 | 
            +
            - lib/sanji/recipes/controllers.rb
         | 
| 30 | 
            +
            - lib/sanji/recipes/devise.rb
         | 
| 31 | 
            +
            - lib/sanji/recipes/draper.rb
         | 
| 32 | 
            +
            - lib/sanji/recipes/figaro.rb
         | 
| 33 | 
            +
            - lib/sanji/recipes/frontend.rb
         | 
| 34 | 
            +
            - lib/sanji/recipes/haml.rb
         | 
| 35 | 
            +
            - lib/sanji/recipes/paloma.rb
         | 
| 36 | 
            +
            - lib/sanji/recipes/postgresql.rb
         | 
| 37 | 
            +
            - lib/sanji/recipes/reform.rb
         | 
| 38 | 
            +
            - lib/sanji/recipes/seedbank.rb
         | 
| 39 | 
            +
            - lib/sanji/recipes/setup.rb
         | 
| 40 | 
            +
            - lib/sanji/recipes/simple_gems.rb
         | 
| 41 | 
            +
            - lib/sanji/utilities/text.rb
         | 
| 42 | 
            +
            homepage: https://www.github.com/kbparagua/sanji
         | 
| 43 | 
            +
            licenses:
         | 
| 44 | 
            +
            - MIT
         | 
| 45 | 
            +
            metadata: {}
         | 
| 46 | 
            +
            post_install_message: 
         | 
| 47 | 
            +
            rdoc_options: []
         | 
| 48 | 
            +
            require_paths:
         | 
| 49 | 
            +
            - lib
         | 
| 50 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 51 | 
            +
              requirements:
         | 
| 52 | 
            +
              - - ">="
         | 
| 53 | 
            +
                - !ruby/object:Gem::Version
         | 
| 54 | 
            +
                  version: '0'
         | 
| 55 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 56 | 
            +
              requirements:
         | 
| 57 | 
            +
              - - ">"
         | 
| 58 | 
            +
                - !ruby/object:Gem::Version
         | 
| 59 | 
            +
                  version: 1.3.1
         | 
| 60 | 
            +
            requirements: []
         | 
| 61 | 
            +
            rubyforge_project: 
         | 
| 62 | 
            +
            rubygems_version: 2.4.5.1
         | 
| 63 | 
            +
            signing_key: 
         | 
| 64 | 
            +
            specification_version: 4
         | 
| 65 | 
            +
            summary: rails application generator
         | 
| 66 | 
            +
            test_files: []
         |