Class: Ember::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/ember/install_generator.rb

Instance Method Summary collapse

Instance Method Details

#copy_emberObject



9
10
11
12
13
14
15
16
17
18
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
# File 'lib/generators/ember/install_generator.rb', line 9

def copy_ember
  if options.head?

    git_root = File.expand_path "~/.ember"
    gem_file = File.join git_root, "Gemfile"

    # If it doesn't exist yet
    unless File.exist?(git_root)
      command = %{git clone git://github.com/emberjs/ember.js.git "#{git_root}"}
      say_status("downloading", command, :green)

      cmd command
    else
      Dir.chdir git_root do
        command = "git fetch origin && git reset origin/master --hard"
        say_status("updating", command, :green)

        cmd command
      end
    end

    Dir.chdir git_root do
      say_status("building", "bundle && bundle exec rake dist", :green)
      Bundler.with_clean_env do
        cmd "bundle --gemfile #{gem_file}"
        cmd %{BUNDLE_GEMFILE="#{gem_file}" bundle exec rake dist}
      end
    end

    source_paths << File.join(git_root, "dist")

    copy_file "ember.js", "vendor/assets/ember/development/ember.js"
    copy_file "ember.min.js", "vendor/assets/ember/production/ember.js"
  end
end

#copy_ember_dataObject



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/generators/ember/install_generator.rb', line 45

def copy_ember_data
  if options.head?

    git_root = File.expand_path "~/.ember-data"
    gem_file = File.join git_root, "Gemfile"

    # If it doesn't exist yet
    unless File.exist?(git_root)
      command = %{git clone git://github.com/emberjs/data.git "#{git_root}"}
      say_status("downloading", command, :green)

      cmd command
    else
      Dir.chdir git_root do
        command = "git fetch origin && git reset origin/master --hard"
        say_status("updating", command, :green)

        cmd command
      end
    end

    Dir.chdir git_root do
      say_status("building", "bundle && bundle exec rake", :green)
      Bundler.with_clean_env do
        cmd "bundle --gemfile #{gem_file}"
        cmd %{BUNDLE_GEMFILE="#{gem_file}" bundle exec rake}
      end
    end

    source_paths << File.join(git_root, "dist")

    copy_file "ember-data.js", "vendor/assets/ember/development/ember-data.js"
    copy_file "ember-data.min.js", "vendor/assets/ember/production/ember-data.js"
  end
end