<commit_before>module Calatrava

  class MobileWebApp
    include Rake::DSL

    def initialize(path, manifest)
      @path, @manifest = path, manifest
      @apache = Apache.new
    end

    def build_dir ; "#{@path}/web/public" ; end
    def scripts_build_dir ; "#{build_dir}/scripts" ; end
    def styles_build_dir ; "#{build_dir}/styles" ; end

    def coffee_files
      Dir.chdir @path do
        core_coffee = ['bridge', 'init'].collect { |l| "web/app/source/#{l}.coffee" }
        core_coffee += @manifest.coffee_files.select { |cf| cf =~ /calatrava.coffee$/ }
        web_coffee = Dir['web/app/source/*.coffee'] - core_coffee
        mf_coffee = @manifest.coffee_files.reject { |cf| cf =~ /calatrava.coffee$/ }
        core_coffee + web_coffee + [Calatrava::Project.current.config.path('env.coffee')] + mf_coffee
      end
    end

    def haml_files
      Dir.chdir(@path) { @manifest.haml_files }
    end

    def scripts
      coffee_files.collect { |cf| "scripts/#{File.basename(cf, '.coffee')}.js" }
    end

    def install_tasks
      directory build_dir
      directory scripts_build_dir
      directory styles_build_dir

      app_files = coffee_files.collect do |cf|
        file "#{scripts_build_dir}/#{File.basename(cf, '.coffee')}.js" => [scripts_build_dir, cf] do
          coffee cf, scripts_build_dir
        end
      end

      app_files << file("#{build_dir}/index.html" => [@manifest.src_file, "web/app/views/index.haml"] + haml_files) do
        HamlSupport::compile "web/app/views/index.haml", build_dir
      end

      app_files += @manifest.css_tasks(styles_build_dir)

      task :shared do
        cp_ne "assets/images/*", File.join(build_dir, 'images')
        cp_ne "assets/lib/*.js", scripts_build_dir
      end        

      desc "Build the web app"
      task :build => app_files + [:shared]

      desc "Publishes the built web app as an artifact"
      task :publish => :build do
        artifact_dir(build_dir, 'web/public')
      end
      
      desc "Clean web app"
      task :clean => 'apache:clean' do
        rm_rf build_dir
      end

      namespace :apache do
        @apache.install_tasks
      end

    end
  end

end
<commit_msg>Create the web/public/images directory before trying to copy things to it<commit_after>module Calatrava

  class MobileWebApp
    include Rake::DSL

    def initialize(path, manifest)
      @path, @manifest = path, manifest
      @apache = Apache.new
    end

    def build_dir ; "#{@path}/web/public" ; end
    def scripts_build_dir ; "#{build_dir}/scripts" ; end
    def styles_build_dir ; "#{build_dir}/styles" ; end
    def images_build_dir ; "#{build_dir}/images" ; end

    def coffee_files
      Dir.chdir @path do
        core_coffee = ['bridge', 'init'].collect { |l| "web/app/source/#{l}.coffee" }
        core_coffee += @manifest.coffee_files.select { |cf| cf =~ /calatrava.coffee$/ }
        web_coffee = Dir['web/app/source/*.coffee'] - core_coffee
        mf_coffee = @manifest.coffee_files.reject { |cf| cf =~ /calatrava.coffee$/ }
        core_coffee + web_coffee + [Calatrava::Project.current.config.path('env.coffee')] + mf_coffee
      end
    end

    def haml_files
      Dir.chdir(@path) { @manifest.haml_files }
    end

    def scripts
      coffee_files.collect { |cf| "scripts/#{File.basename(cf, '.coffee')}.js" }
    end

    def install_tasks
      directory build_dir
      directory scripts_build_dir
      directory styles_build_dir
      directory images_build_dir

      app_files = coffee_files.collect do |cf|
        file "#{scripts_build_dir}/#{File.basename(cf, '.coffee')}.js" => [scripts_build_dir, cf] do
          coffee cf, scripts_build_dir
        end
      end

      app_files << file("#{build_dir}/index.html" => [@manifest.src_file, "web/app/views/index.haml"] + haml_files) do
        HamlSupport::compile "web/app/views/index.haml", build_dir
      end

      app_files += @manifest.css_tasks(styles_build_dir)

      task :shared => [images_build_dir, scripts_build_dir] do
        cp_ne "assets/images/*", File.join(build_dir, 'images')
        cp_ne "assets/lib/*.js", scripts_build_dir
      end        

      desc "Build the web app"
      task :build => app_files + [:shared]

      desc "Publishes the built web app as an artifact"
      task :publish => :build do
        artifact_dir(build_dir, 'web/public')
      end
      
      desc "Clean web app"
      task :clean => 'apache:clean' do
        rm_rf build_dir
      end

      namespace :apache do
        @apache.install_tasks
      end

    end
  end

end

{'fraction_non_alphanumeric': 0.1203155818540434, 'fraction_numerical': 0.0, 'mean_word_length': 2.579607843137255, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5693644', 'n_tokens_mistral': 1574, 'n_tokens_neox': 1501, 'n_words': 336}