Sha256: b49cece7c10f5841b7ba0b0fe2e6ecfd74413fcc8be20cf56a87278d63d64e13

Contents?: true

Size: 1.59 KB

Versions: 34

Compression:

Stored size: 1.59 KB

Contents

require 'rails/generators'

module KepplerGaDashboard
  module Tasks
    class Install
      class << self

        def run
          copy_initializer_file
          puts "Done!"
        end

        def copy_initializer_file
          print "Agregado archivo de configuraciĆ³n...\n"
          app_path = Rails.root.join("config/initializers")
          copier.copy_file File.join(gem_path, 'lib/templates/dashboard.rb'), File.join(app_path, 'dashboard.rb')
        end

        def copy_view
          print "Vistas agregadas al proyecto...\n"
          origin = File.join(gem_path, 'app/views')
          destination = Rails.root.join('app/views')
          copy_files(['.'], origin, destination)
        end

        private

        def copy_files(directories, origin, destination)
          directories.each do |directory|
            Dir[File.join(origin, directory, 'keppler_ga_dashboard', '**/*')].each do |file|
              relative  = file.gsub(/^#{origin}\//, '')
              dest_file = File.join(destination, relative)
              dest_dir  = File.dirname(dest_file)

              if !File.exist?(dest_dir)
                FileUtils.mkdir_p(dest_dir)
              end

              copier.copy_file(file, dest_file) unless File.directory?(file)
            end
          end
        end

        def gem_path
          File.expand_path('../../..', File.dirname(__FILE__))
        end

        def copier
          unless @copier
            Rails::Generators::Base.source_root(gem_path)
            @copier = Rails::Generators::Base.new
          end
          @copier
        end
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
keppler-2.1.22 installer/core/rockets/keppler_ga_dashboard/lib/keppler_ga_dashboard/tasks/install.rb
keppler-2.1.21 installer/core/rockets/keppler_ga_dashboard/lib/keppler_ga_dashboard/tasks/install.rb
keppler-2.1.20 installer/core/rockets/keppler_ga_dashboard/lib/keppler_ga_dashboard/tasks/install.rb
keppler-2.1.19 installer/core/rockets/keppler_ga_dashboard/lib/keppler_ga_dashboard/tasks/install.rb
keppler-2.1.18 installer/core/rockets/keppler_ga_dashboard/lib/keppler_ga_dashboard/tasks/install.rb
keppler-2.1.17 installer/core/rockets/keppler_ga_dashboard/lib/keppler_ga_dashboard/tasks/install.rb
keppler-2.1.16 installer/core/rockets/keppler_ga_dashboard/lib/keppler_ga_dashboard/tasks/install.rb
keppler-2.1.15 installer/core/rockets/keppler_ga_dashboard/lib/keppler_ga_dashboard/tasks/install.rb
keppler-2.1.14 installer/core/rockets/keppler_ga_dashboard/lib/keppler_ga_dashboard/tasks/install.rb
keppler-2.1.13 installer/core/rockets/keppler_ga_dashboard/lib/keppler_ga_dashboard/tasks/install.rb
keppler-2.1.12 installer/core/rockets/keppler_ga_dashboard/lib/keppler_ga_dashboard/tasks/install.rb
keppler-2.1.11 installer/core/rockets/keppler_ga_dashboard/lib/keppler_ga_dashboard/tasks/install.rb
keppler-2.1.10 installer/core/rockets/keppler_ga_dashboard/lib/keppler_ga_dashboard/tasks/install.rb
keppler-2.1.9 installer/core/rockets/keppler_ga_dashboard/lib/keppler_ga_dashboard/tasks/install.rb
keppler-2.1.8 installer/core/rockets/keppler_ga_dashboard/lib/keppler_ga_dashboard/tasks/install.rb
keppler-2.1.7 installer/core/rockets/keppler_ga_dashboard/lib/keppler_ga_dashboard/tasks/install.rb
keppler-2.1.6 installer/core/rockets/keppler_ga_dashboard/lib/keppler_ga_dashboard/tasks/install.rb
keppler-2.1.5 installer/core/rockets/keppler_ga_dashboard/lib/keppler_ga_dashboard/tasks/install.rb
keppler-2.1.4 installer/core/rockets/keppler_ga_dashboard/lib/keppler_ga_dashboard/tasks/install.rb
keppler-2.1.3 installer/core/rockets/keppler_ga_dashboard/lib/keppler_ga_dashboard/tasks/install.rb