Class: MagicStylez::Generators::UpdateGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/generators/magic_stylez/update_generator.rb

Instance Method Summary collapse

Instance Method Details

#end_descObject



51
52
53
54
55
56
57
58
# File 'lib/generators/magic_stylez/update_generator.rb', line 51

def end_desc
  puts("========================================================================================================")
  puts("-    -    -    -    -    -    -    -    M  A G I C  S T Y L E Z     -    -    -    -    -    -    -    -")
  puts("--------------------------------------------------------------------------------------------------------")
  puts("  .   .   .                               Version #{::MagicStylez::VERSION.to_s.ljust(10)}                                .   .   .   ")
  puts("  .   .   .                    http://berlinmagic.github.io/magic_stylez/                   .   .   .   ")
  puts("========================================================================================================")
end

#initial_descObject



13
14
15
16
17
# File 'lib/generators/magic_stylez/update_generator.rb', line 13

def initial_desc
  puts(' *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   * ')
  puts(' -   -   -   -   -   -   -   -   -   -  M  A G I C  S T Y L E Z  -   -   -   -   -   -   -   -   -   - ')
  puts(' *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   * ')
end

#update_corporatesObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/generators/magic_stylez/update_generator.rb', line 19

def update_corporates
  puts("...")
  puts("... Updating Corporate-folder to version #{::MagicStylez::VERSION}")
  puts("...")
  if File.directory?("#{::Rails.root}/app/assets/stylesheets/corporate")
    Dir.glob("#{::MagicStylez::Rails::Engine.root}/vendor/assets/stylesheets/corporate/**/*").each do |fl|
      file_name = File.basename( fl )
      if file_name.match(/^_([a-z]*).scss$/)
        destination = "#{::Rails.root}/app/assets/stylesheets/corporate/#{file_name}"
        short_name = file_name.match(/^_([a-z]*).scss$/)[0]
        puts("check:  corporate/#{short_name}")
        if File.exists?( destination )
          diffrents = compare_style_file( file_name )
          if diffrents.present?
            append_to_file destination, diffrents
            puts("> add new variables")
            puts("...")
          end
        else
          copy_file file_name, file_name
          puts("copied new file:  corporate/#{short_name}")
        end
      end
    end
  else
    puts("E R R O R !!!")
    puts("corporate folder doesn't exist!")
    puts("please run the install generator first.")
  end
  puts("...")
end