<commit_before>require 'generators/ember/generator_helpers'
require 'net/http'
require 'uri'
require 'fileutils'

module Ember
  module Generators
    class InstallGenerator < ::Rails::Generators::Base
      desc "Install Ember.js into your vendor folder"
      class_option :head, :type => :boolean, :default => false, :desc => "Download latest Ember.js from GitHub and fetch it into your project"

      def fetch_ember
        if options.head?
          fetch 'http://builds.emberjs.com/ember-latest.js', 'vendor/assets/ember/development/ember.js'
          fetch 'http://builds.emberjs.com/ember-latest.min.js', 'vendor/assets/ember/production/ember.js'
        end
      end

      def fetch_ember_data
        if options.head?
          fetch 'http://builds.emberjs.com/ember-data-latest.js', 'vendor/assets/ember/development/ember-data.js'
          fetch 'http://builds.emberjs.com/ember-data-latest.min.js', 'vendor/assets/ember/production/ember-data.js'
        end
      end

    private

      def fetch(from, to)
        message = "#{from} -> #{to}"
        say_status("downloading:", message , :green)

        uri = URI(from)

        FileUtils.mkdir_p File.dirname(to)

        open(to, 'w+') do |output|
          output.puts Net::HTTP.get(uri).force_encoding("UTF-8")<commit_msg>prepend source URI and fetched date when using install generator.<commit_after>require 'generators/ember/generator_helpers'
require 'net/http'
require 'uri'
require 'fileutils'

module Ember
  module Generators
    class InstallGenerator < ::Rails::Generators::Base
      desc "Install Ember.js into your vendor folder"
      class_option :head, :type => :boolean, :default => false, :desc => "Download latest Ember.js from GitHub and fetch it into your project"

      def fetch_ember
        if options.head?
          fetch 'http://builds.emberjs.com/ember-latest.js', 'vendor/assets/ember/development/ember.js'
          fetch 'http://builds.emberjs.com/ember-latest.min.js', 'vendor/assets/ember/production/ember.js'
        end
      end

      def fetch_ember_data
        if options.head?
          fetch 'http://builds.emberjs.com/ember-data-latest.js', 'vendor/assets/ember/development/ember-data.js'
          fetch 'http://builds.emberjs.com/ember-data-latest.min.js', 'vendor/assets/ember/production/ember-data.js'
        end
      end

    private

      def fetch(from, to)
        message = "#{from} -> #{to}"
        say_status("downloading:", message , :green)

        uri = URI(from)

        FileUtils.mkdir_p File.dirname(to)

        open(to, 'w+') do |output|
          output.puts "// Fetched from: " + uri.to_s
          output.puts "// Fetched on: " + Time.now.utc.iso8601.to_s
          output.puts Net::HTTP.get(uri).force_encoding("UTF-8")
{'fraction_non_alphanumeric': 0.1315504156125768, 'fraction_numerical': 0.0021684134441633538, 'mean_word_length': 2.7506775067750677, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4029876', 'n_tokens_mistral': 871, 'n_tokens_neox': 848, 'n_words': 184}