rubygems-compile 1.0.0-universal-macruby → 1.1.2-universal-macruby

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,82 @@
1
+ # rubygems-compile
2
+
3
+ A set of rubygems commands for `macgem` that interface with the
4
+ MacRuby compiler. This gem requires MacRuby 0.11 or newer.
5
+
6
+ All you need to do is:
7
+
8
+ ```bash
9
+ sudo macgem install rubygems-compile
10
+ ```
11
+
12
+ And then you're off to the races!
13
+
14
+ ## Commands
15
+
16
+ `compile`
17
+
18
+ Can be used to compile, or re-compile, any gems that are already
19
+ installed.
20
+
21
+ ```bash
22
+ sudo macgem compile nokogiri # Compile gems based on names you provide
23
+ sudo macgem compile minitest --version 2.0.2 # Compile a specific version of a gem
24
+ sudo macgem compile --all # Compile all installed gems
25
+ sudo macgem compile rspec --no-ignore-dependencies # Also compile dependencies
26
+ ```
27
+
28
+ `uncompile`
29
+
30
+ Can be used to remove the compiled `.rbo` files if a gem does not
31
+ work well when compiled. If you find a gem that does not work when
32
+ compiled, it would be greatly appreciated if you reported it here or
33
+ to the MacRuby project itself so that someone can look into the
34
+ problem.
35
+
36
+ ```bash
37
+ sudo macgem uncompile nokogiri # Uncompile gems based on names you provide
38
+ sudo macgem uncompile minitest --version 2.0.2 # Compile a specific version of a gem
39
+ sudo macgem uncompile --all # Uncompile all installed gems
40
+ sudo macgem uncompile rspec --no-ignore-dependencies # Also uncompile dependencies
41
+ ```
42
+
43
+ `auto_compile`
44
+
45
+ If you don't like the idea of calling `compile` each time you
46
+ install a gem, then you can use `auto_compile` to enable a
47
+ post-install hook that will automatically compile gems when they are
48
+ installed. You can call `auto_compile` a second time to turn off the
49
+ feature.
50
+
51
+ ```bash
52
+ sudo macgem auto_compile # gems will compiled when you install them
53
+ sudo macgem auto_compile # gems will not be compiled when you install them
54
+ ```
55
+
56
+ ## Caveats
57
+
58
+ * Large gems will take a long time to compile, but these are the gems
59
+ that will benefit the most from being compiled so please be patient
60
+ * This has only been tested on a few gems, but should not break
61
+ existing gems since we leave the original files around
62
+ * At the moment, compiled gems will not provide usable backtraces
63
+ + If you suspect a bug in the way MacRuby compiled a file, try running with pre-compiled files disabled like so: `VM_DISABLE_RBO=1 macruby my_code.rb`
64
+ * `.rbo` files take up more disk space than their `.rb` equivalents
65
+
66
+ ## Known Issues
67
+
68
+ * Source files using a non-standard suffix (e.g. `mime-types` has a `.rb.data` file) will not get compiled
69
+ + This might be addressable in a later release, but is not a big deal
70
+ * Gems that explicitly require a file with the file suffix (e.g. `require 'nokogiri.rb'`) will never load the compiled version of the file
71
+ + This issue may be addressed in MacRuby itself in the near future
72
+ + Alternatively, those gems should be updated so that compiled code can be loaded
73
+
74
+ ## TODO
75
+
76
+ * Parallel compilation to speed up compilation of large gems
77
+ + This might require changes in the MacRuby compiler
78
+
79
+ ## Copyright
80
+
81
+ Copyright (c) 2011-2012 Mark Rada. See LICENSE.txt for further details.
82
+
data/Rakefile CHANGED
@@ -1,24 +1,21 @@
1
- require 'rake/testtask'
2
- require 'rake/gempackagetask'
3
- require 'rubygems/dependency_installer'
4
-
5
1
  task :default => :gem
6
2
 
7
- Rake::TestTask.new(:test) do |test|
8
- test.libs << 'lib' << 'test'
3
+ require 'rake/testtask'
4
+ Rake::TestTask.new do |test|
5
+ test.libs << 'test'
9
6
  test.pattern = 'test/**/test_*.rb'
10
7
  test.verbose = true
11
8
  test.ruby_opts = ['-rhelper']
12
9
  end
13
10
 
14
- eval IO.read('rubygems-compile.gemspec')
11
+ require 'rubygems'
12
+ spec = Gem::Specification.load('rubygems-compile.gemspec')
15
13
 
16
- Rake::GemPackageTask.new(GEM_SPEC) do |pkg|
17
- pkg.need_zip = false
18
- pkg.need_tar = true
19
- end
14
+ require 'rake/gempackagetask'
15
+ Rake::GemPackageTask.new(spec) { }
20
16
 
17
+ require 'rubygems/dependency_installer'
21
18
  desc 'Build the gem and install it'
22
19
  task :install => :gem do
23
- Gem::Installer.new("pkg/#{GEM_SPEC.file_name}").install
20
+ Gem::Installer.new("pkg/#{spec.file_name}").install
24
21
  end
@@ -0,0 +1,26 @@
1
+ require 'ripper'
2
+
3
+ ##
4
+ # Uses the ripper parser to analyze ruby code contained in gems
5
+ # and raises warnings if the code has potential issues.
6
+
7
+ class Gem::Analyzer < Ripper::SexpBuilder
8
+
9
+ ##
10
+ # Cache of issues found for the current session.
11
+
12
+ attr_reader :warnings
13
+
14
+ def parse
15
+ @warnings = []
16
+ super
17
+ end
18
+
19
+ def on_kw token
20
+ # Related to MacRuby ticket #721
21
+ if token == '__FILE__'
22
+ @warnings << '__FILE__ keyword is used (MacRuby ticket #721)'
23
+ end
24
+ end
25
+
26
+ end
@@ -1,4 +1,7 @@
1
1
  require 'rubygems/dependency_list'
2
+ require 'rubygems/version_option'
3
+ require 'rubygems-compile/compile_methods'
4
+
2
5
 
3
6
  ##
4
7
  # Use the MacRuby compiler to compile installed gems.
@@ -38,14 +41,12 @@ class Gem::Commands::CompileCommand < Gem::Command
38
41
 
39
42
  def execute
40
43
  gems = execution_list
41
- gems.delete_if { |spec| spec.name == 'rubygems-compile' }
42
-
43
44
  if gems.count >= 10
44
- alert 'This could take a while; you might want to take a coffee break'
45
+ alert 'This could take a while...'
45
46
  end
46
47
 
47
- compiler = Gem::Compiler.new
48
- gems.each { |gem| compiler.compile(gem) }
48
+ require 'rubygems-compile/compiler'
49
+ gems.each { |gem| Gem::Compiler.compile gem }
49
50
  end
50
51
 
51
52
  end
@@ -1,3 +1,6 @@
1
+ require 'rubygems/version_option'
2
+ require 'rubygems-compile/compile_methods'
3
+
1
4
  class Gem::Commands::UncompileCommand < Gem::Command
2
5
  include Gem::VersionOption
3
6
  include Gem::CompileMethods
@@ -32,8 +35,8 @@ class Gem::Commands::UncompileCommand < Gem::Command
32
35
  # an uncompiler object for each of them.
33
36
 
34
37
  def execute
35
- uncompiler = Gem::Uncompiler.new
36
- execution_list.each { |gem| uncompiler.uncompile(gem) }
38
+ require 'rubygems-compile/uncompiler'
39
+ execution_list.each { |gem| Gem::Uncompiler.uncompile(gem) }
37
40
  end
38
41
 
39
42
  end
@@ -0,0 +1,74 @@
1
+ module Gem::CompileMethods
2
+ if Gem::VERSION.to_f < 1.8
3
+
4
+ def execution_list
5
+ return all_gemspecs if options[:all]
6
+
7
+ specs = get_all_gem_names.map do |gem|
8
+ candidates = Gem.source_index.find_name(gem, options[:version])
9
+
10
+ if candidates.empty?
11
+ alert_error "#{gem} is not installed. Skipping."
12
+ next
13
+ end
14
+
15
+ candidates << dependencies_for(candidates) unless options[:ignore]
16
+ candidates
17
+ end
18
+ specs.flatten!
19
+ specs.uniq!
20
+ specs.delete_if { |spec| spec.name == 'rubygems-compile' }
21
+ specs
22
+ end
23
+
24
+
25
+ private
26
+
27
+ def all_gemspecs
28
+ specs = Gem.source_index.all_gems.map(&:last)
29
+ specs.select { |spec| spec.name != 'rubygems-compile' }
30
+ end
31
+
32
+ def dependencies_for specs
33
+ specs.map { |spec|
34
+ spec.runtime_dependencies.map { |dep|
35
+ deps = Gem.source_index.find_name(dep.name, dep.requirement)
36
+ deps + dependencies_for(deps)
37
+ }
38
+ }
39
+ end
40
+
41
+ else
42
+
43
+ def execution_list
44
+ return all_gemspecs if options[:all]
45
+
46
+ specs = get_all_gem_names.map { |gem|
47
+ gems = Gem::Specification.find_all_by_name(gem, options[:version])
48
+ gems << dependencies_for(gems) unless options[:ignore]
49
+ gems
50
+ }
51
+ specs.flatten!
52
+ specs.uniq!
53
+ specs.delete_if { |spec| spec.name == 'rubygems_compile' }
54
+ specs
55
+ end
56
+
57
+
58
+ private
59
+
60
+ def all_gemspecs
61
+ Gem::Specification.select { |spec| spec.name != 'rubygems-compile' }
62
+ end
63
+
64
+ def dependencies_for specs
65
+ specs.map { |spec|
66
+ spec.runtime_dependencies.map { |dep|
67
+ deps = Gem::Specification.find_all_by_name(dep.name, dep.requirement)
68
+ deps + dependencies_for(deps)
69
+ }
70
+ }
71
+ end
72
+
73
+ end
74
+ end
@@ -1,36 +1,55 @@
1
1
  class Gem::Compiler
2
2
  include Gem::UserInteraction
3
3
 
4
+ class << self
5
+ def compile gem
6
+ @instance ||= Gem::Compiler.new
7
+ @instance.compile gem
8
+ end
9
+ alias_method :call, :compile
10
+ end
11
+
4
12
  def initialize
13
+ require 'rbconfig'
14
+ unless MacRuby.const_defined?(:Compiler)
15
+ load File.join(RbConfig::CONFIG['bindir'], 'macrubyc')
16
+ end
17
+ require 'rubygems-compile/analyzer'
18
+
5
19
  @current_directory = []
6
20
  @config = Gem.configuration
7
21
  end
8
22
 
9
- def call gem
23
+ def compile gem
10
24
  @spec = gem.is_a?(Gem::Specification) ? gem : gem.spec
11
25
 
12
- if @spec.name == 'rubygems-compile'
13
- alert_info 'You cannot compile rubygems-compile' if @config.really_verbose
14
- return
15
- end
16
-
17
- say compilation_message if @config.verbose
26
+ return if trying_to_compile_self?
27
+ say gem_compilation_message if verbose
18
28
 
19
29
  gem_files.each do |file|
20
- say compile_file_msg(file) if @config.really_verbose
21
- absolute_file_path = File.join(@spec.full_gem_path, file)
22
- MacRuby::Compiler.new(
23
- bundle: true,
24
- output: "#{absolute_file_path}o",
25
- files: [absolute_file_path]
26
- ).run
30
+ message = compile_file_message(file)
31
+ full_path = File.join(@spec.full_gem_path, file)
32
+ if safe? full_path
33
+ MacRuby::Compiler.compile_file full_path
34
+ else
35
+ message << "\t\t\tSKIPPED: #{@analyzer.warnings.uniq.join(', ')}"
36
+ end
37
+ say message if really_verbose
27
38
  end
28
39
  end
29
40
 
30
- alias_method :compile, :call
41
+ ##
42
+ # Uses the GemAnalyzer class to determine if a given file might have
43
+ # any potential issues when compiled.
44
+
45
+ def safe? file
46
+ @analyzer = Gem::Analyzer.new File.read(file)
47
+ @analyzer.parse
48
+ @analyzer.warnings.empty?
49
+ end
31
50
 
32
- def compilation_message
33
- slash = @config.really_verbose ? '/' : ''
51
+ def gem_compilation_message
52
+ slash = really_verbose ? '/' : ''
34
53
  "Compiling #{@spec.full_name}#{slash}"
35
54
  end
36
55
 
@@ -46,13 +65,19 @@ class Gem::Compiler
46
65
  # level or test directory.
47
66
  #
48
67
 
49
- def gem_files
50
- files = @spec.files - @spec.test_files - @spec.extra_rdoc_files
51
- files.reject { |file| file.match /^(?:test|spec)/ }
52
- .select { |file| file.match /\.rb$/ }
68
+ if Gem::VERSION.to_f < 1.8
69
+ def gem_files
70
+ @spec.lib_files.select { |file| File.extname(file) == '.rb' }
71
+ end
72
+ else
73
+ def gem_files
74
+ Dir.glob("#{@spec.lib_dirs_glob}/**/*.rb").map { |file|
75
+ file.sub(Regexp.new(Regexp.escape(@spec.full_gem_path)), '')
76
+ }
77
+ end
53
78
  end
54
79
 
55
- def compile_file_msg file
80
+ def compile_file_message file
56
81
  name = File.basename(file)
57
82
  dirs = file.chomp(name).split(File::SEPARATOR)
58
83
  tabs = "\t" * dirs.count
@@ -60,11 +85,26 @@ class Gem::Compiler
60
85
  dirs.each_with_index do |dir, index|
61
86
  unless @current_directory[index] == dir
62
87
  @current_directory[index] = dir
63
- say( "\t" * (index + 1) + dir + File::SEPARATOR)
88
+ say( "\t" * (index + 1) + dir + File::SEPARATOR) if really_verbose
64
89
  end
65
90
  end
66
91
 
67
92
  "#{tabs}#{name} => #{name}o"
68
93
  end
69
94
 
95
+ def verbose
96
+ @config.verbose
97
+ end
98
+
99
+ def really_verbose
100
+ @config.really_verbose
101
+ end
102
+
103
+ def trying_to_compile_self?
104
+ if @spec.name == 'rubygems-compile'
105
+ alert 'You cannot compile rubygems-compile' if really_verbose
106
+ true
107
+ end
108
+ end
109
+
70
110
  end
@@ -3,7 +3,8 @@
3
3
  # command.
4
4
 
5
5
  if Gem.configuration[:compile]
6
+ require 'rubygems-compile/compiler'
6
7
  module Gem
7
- @post_install_hooks << ::Gem::Compiler.new
8
+ @post_install_hooks << ::Gem::Compiler
8
9
  end
9
10
  end
@@ -1,7 +1,13 @@
1
1
  class Gem::Uncompiler
2
2
  include Gem::UserInteraction
3
3
 
4
+ def self.uncompile gem
5
+ @instance ||= Gem::Uncompiler.new
6
+ @instance.uncompile gem
7
+ end
8
+
4
9
  def initialize
10
+ require 'fileutils'
5
11
  @config = Gem.configuration
6
12
  end
7
13
 
@@ -11,9 +17,9 @@ class Gem::Uncompiler
11
17
  say uncompilation_message if @config.verbose
12
18
 
13
19
  gem_files.each do |file|
14
- say "\tAsploded #{file}" if @config.really_verbose
15
20
  absolute_file_path = File.join(@spec.full_gem_path, file)
16
21
  FileUtils.rm absolute_file_path
22
+ say "\tAsploded #{file}" if @config.really_verbose
17
23
  end
18
24
  end
19
25
 
@@ -1,4 +1,4 @@
1
- if RUBY_VERSION.to_f < 0.11
1
+ unless MACRUBY_REVISION.match /^git commit/
2
2
 
3
3
  ui = Gem::UserInteraction.new
4
4
  ui.alert_warning 'rubygems-compile requires MacRuby 0.11 or newer'
@@ -6,18 +6,13 @@ if RUBY_VERSION.to_f < 0.11
6
6
 
7
7
  else
8
8
 
9
- require 'rbconfig'
10
- require 'fileutils'
11
- require 'rubygems/version_option'
12
-
13
- unless MacRuby.const_defined?(:Compiler)
14
- load File.join(RbConfig::CONFIG['bindir'], 'macrubyc')
15
- end
16
-
17
- require 'rubygems-compile/common_methods'
18
- require 'rubygems-compile/compiler'
19
- require 'rubygems-compile/uncompiler'
20
- require 'rubygems-compile/commands'
21
9
  require 'rubygems-compile/post_install_hook'
10
+ require 'rubygems-compile/commands/compile_command'
11
+ require 'rubygems-compile/commands/uncompile_command'
12
+ require 'rubygems-compile/commands/autocompile_command'
13
+
14
+ Gem::CommandManager.instance.register_command :compile
15
+ Gem::CommandManager.instance.register_command :uncompile
16
+ Gem::CommandManager.instance.register_command :auto_compile
22
17
 
23
18
  end
@@ -2,6 +2,6 @@ require 'rubygems'
2
2
  require 'rubygems/command_manager'
3
3
  require 'rubygems_plugin'
4
4
 
5
- gem 'minitest-macruby-pride', '>= 2.2.0'
5
+ gem 'minitest', '>= 2.6.1'
6
6
  require 'minitest/autorun'
7
7
  require 'minitest/pride'
@@ -0,0 +1,13 @@
1
+ class TestGemAnalyzer < MiniTest::Unit::TestCase
2
+
3
+ def test_finds_usage_of___FILE__
4
+ assert_raises Gem::Analyzer::Warning do
5
+ Gem::Analyzer.new("__FILE__").parse
6
+ end
7
+
8
+ assert_block do
9
+ Gem::Analyzer.new("puts '__FILE__'").parse
10
+ end
11
+ end
12
+
13
+ end
@@ -4,19 +4,19 @@ class TestAutoCompile < MiniTest::Unit::TestCase
4
4
  @command = Gem::Commands::AutoCompileCommand.new
5
5
  end
6
6
 
7
- def test_turn_on
8
- end
7
+ # def test_turn_on
8
+ # end
9
9
 
10
- def test_turn_on_when_already_on
11
- end
10
+ # def test_turn_on_when_already_on
11
+ # end
12
12
 
13
- def test_turn_off
14
- end
13
+ # def test_turn_off
14
+ # end
15
15
 
16
- def test_turn_off_when_already_off
17
- end
16
+ # def test_turn_off_when_already_off
17
+ # end
18
18
 
19
- def test_calls_compile_on_each_gem_after_installation
20
- end
19
+ # def test_calls_compile_on_each_gem_after_installation
20
+ # end
21
21
 
22
22
  end
@@ -0,0 +1,39 @@
1
+ # class CommonMethodsTester
2
+ # include Gem::CompileMethods
3
+
4
+ # class Gem
5
+ # class << self
6
+ # def source_index
7
+ # GemList.new
8
+ # end
9
+ # end
10
+ # end
11
+
12
+ # end
13
+
14
+ # class GemList
15
+ # def all_gems
16
+ # ['the', 'answer', 'to', 'life', 'the', 'universe', 'and', 'everything']
17
+ # end
18
+ # end
19
+
20
+ # class TestCommonMethods < MiniTest::Unit::TestCase
21
+
22
+ # def modul
23
+ # @@modul ||= CommonMethodsTester.new
24
+ # end
25
+
26
+ # def test_execution_list
27
+ # end
28
+
29
+ # def test_gems_list
30
+ # def modul.options
31
+ # { all: true }
32
+ # end
33
+ # assert_equal GemList.new.all_gems, modul.gems_list
34
+ # end
35
+
36
+ # def test_dependencies_for
37
+ # end
38
+
39
+ # end
@@ -1,36 +1,32 @@
1
1
  class TestCompileCommand < MiniTest::Unit::TestCase
2
+
2
3
  def setup
3
4
  @command = Gem::Commands::CompileCommand.new
4
5
  end
5
- end
6
6
 
7
- class Test < TestCompileCommand
8
- def test_finds_all_files
9
- # gets into all require dirs
10
- # does not compile test files
11
- end
12
- def test_recompiles_rbos_if_they_already_exist
13
- # to support use on nightly builds
14
- end
15
- end
7
+ # def test_finds_all_files
8
+ # # gets into all require dirs
9
+ # # does not compile test files
10
+ # end
11
+ # def test_recompiles_rbos_if_they_already_exist
12
+ # # to support use on nightly builds
13
+ # end
16
14
 
17
- class TestCompileInterface < TestCompileCommand
18
- def test_has_an_option_to_compile_all_installed_gems
19
- # by extension, this is also needed to support nightly build users
20
- end
21
- end
15
+ # def test_has_an_option_to_compile_all_installed_gems
16
+ # # by extension, this is also needed to support nightly build users
17
+ # end
22
18
 
23
- class TestCompileSpecialCases < TestCompileCommand
24
- def test_refuses_to_compile_itself
25
- # obvious
26
- end
19
+ # def test_refuses_to_compile_itself
20
+ # # obvious
21
+ # end
27
22
 
28
- def test_loads_rubyc_without_warning
29
- # this might not be doable without upstream load guarding; minor issue
30
- end
23
+ # def test_loads_rubyc_without_warning
24
+ # # this might not be doable without upstream load guarding; minor issue
25
+ # end
26
+
27
+ # # important to test so we don't break rubygems
28
+ # def test_skips_loading_on_older_macruby_versions
29
+ # # and prints a message
30
+ # end
31
31
 
32
- # important to test so we don't break rubygems
33
- def test_skips_loading_on_older_macruby_versions
34
- # and prints a message
35
- end
36
32
  end
@@ -4,13 +4,13 @@ class TestUncompileCommand < MiniTest::Unit::TestCase
4
4
  @command = Gem::Commands::UncompileCommand.new
5
5
  end
6
6
 
7
- def test_removes_rbo_files
8
- end
7
+ # def test_removes_rbo_files
8
+ # end
9
9
 
10
- def test_leaves_rb_files
11
- end
10
+ # def test_leaves_rb_files
11
+ # end
12
12
 
13
- def test_can_uncompile_multiple_gems_at_once
14
- end
13
+ # def test_can_uncompile_multiple_gems_at_once
14
+ # end
15
15
 
16
16
  end
metadata CHANGED
@@ -2,33 +2,32 @@
2
2
  name: rubygems-compile
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.0
5
+ version: 1.1.2
6
6
  platform: universal-macruby
7
7
  authors:
8
8
  - Mark Rada
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-06-02 00:00:00 -04:00
13
- default_executable:
12
+ date: 2012-03-04 00:00:00 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
- name: minitest-macruby-pride
15
+ name: minitest
17
16
  prerelease: false
18
17
  requirement: !ruby/object:Gem::Requirement
19
18
  none: false
20
19
  requirements:
21
- - - '>='
20
+ - - ~>
22
21
  - !ruby/object:Gem::Version
23
- version: 2.2.0
22
+ version: "2.11"
24
23
  type: :development
25
24
  version_requirements: !ruby/object:Gem::Requirement
26
25
  none: false
27
26
  requirements:
28
- - - '>='
27
+ - - ~>
29
28
  - !ruby/object:Gem::Version
30
- version: 2.2.0
31
- description: 'A set of rubygems commands that interface with the MacRuby compiler.
29
+ version: "2.11"
30
+ description: 'A trio of rubygems commands that interface with the MacRuby compiler.
32
31
 
33
32
  '
34
33
  email: mrada@marketcircle.com
@@ -36,27 +35,27 @@ executables: []
36
35
  extensions: []
37
36
  extra_rdoc_files:
38
37
  - LICENSE.txt
39
- - README.rdoc
38
+ - README.markdown
40
39
  files:
41
- - lib/rubygems-compile/analysis.rb
40
+ - lib/rubygems-compile/analyzer.rb
42
41
  - lib/rubygems-compile/commands/autocompile_command.rb
43
42
  - lib/rubygems-compile/commands/compile_command.rb
44
43
  - lib/rubygems-compile/commands/uncompile_command.rb
45
- - lib/rubygems-compile/commands.rb
46
- - lib/rubygems-compile/common_methods.rb
44
+ - lib/rubygems-compile/compile_methods.rb
47
45
  - lib/rubygems-compile/compiler.rb
48
46
  - lib/rubygems-compile/post_install_hook.rb
49
47
  - lib/rubygems-compile/uncompiler.rb
50
48
  - lib/rubygems_plugin.rb
51
49
  - test/helper.rb
50
+ - test/test_analyzer.rb
52
51
  - test/test_autocompile_command.rb
52
+ - test/test_common_methods.rb
53
53
  - test/test_compile_command.rb
54
54
  - test/test_uncompile_command.rb
55
55
  - Rakefile
56
56
  - .gemtest
57
57
  - LICENSE.txt
58
- - README.rdoc
59
- has_rdoc: true
58
+ - README.markdown
60
59
  homepage: http://github.com/ferrous26/rubygems-compile
61
60
  licenses:
62
61
  - MIT
@@ -82,13 +81,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
81
  version: "0"
83
82
  requirements: []
84
83
  rubyforge_project:
85
- rubygems_version: 1.4.2
84
+ rubygems_version: 1.8.17
86
85
  signing_key:
87
86
  specification_version: 3
88
- summary: A set of rubygems commands that interface with the MacRuby compiler
87
+ summary: A trio of rubygems commands that interface with the MacRuby compiler
89
88
  test_files:
90
89
  - test/helper.rb
90
+ - test/test_analyzer.rb
91
91
  - test/test_autocompile_command.rb
92
+ - test/test_common_methods.rb
92
93
  - test/test_compile_command.rb
93
94
  - test/test_uncompile_command.rb
94
95
  - Rakefile
@@ -1,58 +0,0 @@
1
- = rubygems-compile
2
-
3
- A set of rubygems commands for <tt>macgem</tt> that interface with the
4
- MacRuby compiler. This gem requires MacRuby 0.11 or newer.
5
-
6
- All you need to do is:
7
-
8
- sudo macgem install rubygems-compile --pre
9
-
10
- And then you're off to the races!
11
-
12
- == Commands
13
-
14
- [+compile+] Can be used to compile, or re-compile, any gems that are already installed.
15
-
16
- sudo macgem compile nokogiri # Compile gems based on names you provide
17
- sudo macgem compile minitest --version 2.0.2 # Compile a specific version of a gem
18
- sudo macgem compile --all # Compile all installed gems
19
- sudo macgem compile rspec --no-ignore-dependencies # Also compile dependencies
20
-
21
- [+uncompile+] Can be used to remove the compiled <tt>.rbo</tt> files if a gem does not work well when compiled.
22
-
23
- sudo macgem uncompile nokogiri # Uncompile gems based on names you provide
24
- sudo macgem uncompile minitest --version 2.0.2 # Compile a specific version of a gem
25
- sudo macgem uncompile --all # Uncompile all installed gems
26
- sudo macgem uncompile rspec --no-ignore-dependencies # Also uncompile dependencies
27
-
28
- [+auto_compile+] Can be used to enable a post-install hook that will automatically compile gems when you install them. Call it once to turn on, call it a second time to disable it.
29
-
30
- sudo macgem auto_compile # gems will compiled when you install them
31
- sudo macgem auto_compile # gems will not be compiled when you install them
32
-
33
- == Caveats
34
-
35
- * Large gems will take a long time to compile, but these are the gems
36
- that will benefit the most from being compiled so please be patient
37
- * This has only been tested on a few gems, but should not break
38
- existing gems since we leave the original files around
39
- * At the moment, compiled gems will not provide usable backtraces
40
- * <tt>.rbo</tt> files take up more disk space than their <tt>.rb</tt> equivalents
41
-
42
- == Known Issues
43
-
44
- * Source files using a non-standard suffix (e.g. <tt>mime-types</tt> has a <tt>.rb.data</tt> file) will not get compiled
45
- * This might be addressable in a later release, but is not a big deal
46
- * Gems that explicitly require a file with the file suffix (e.g. <tt>require 'nokogiri.rb'</tt>) will never load the compiled version of the file
47
- * Those gems should be updated so that compiled code can be loaded
48
-
49
- == TODO
50
-
51
- * Code parsing to WARN about gems that will have issues when compiled
52
- * Parallel compilation to speed up compilation of large gems
53
- * This might require changes in the MacRuby compiler
54
-
55
- == Copyright
56
-
57
- Copyright (c) 2011 Mark Rada. See LICENSE.txt for further details.
58
-
@@ -1,11 +0,0 @@
1
- require 'ripper'
2
-
3
- class GemAnalyzer < Ripper::SexpBuilder
4
-
5
- def on_command command, args
6
- puts args.class
7
- puts command.class
8
- super.tap { |x| puts x.inspect }
9
- end
10
-
11
- end
@@ -1,8 +0,0 @@
1
- require 'rubygems-compile/commands/compile_command'
2
- Gem::CommandManager.instance.register_command :compile
3
-
4
- require 'rubygems-compile/commands/uncompile_command'
5
- Gem::CommandManager.instance.register_command :uncompile
6
-
7
- require 'rubygems-compile/commands/autocompile_command'
8
- Gem::CommandManager.instance.register_command :auto_compile
@@ -1,39 +0,0 @@
1
- module Gem
2
-
3
- module CompileMethods
4
-
5
- def execution_list
6
- gems_list.map do |gem|
7
- candidates = Gem.source_index.find_name(gem, options[:version])
8
-
9
- if candidates.empty?
10
- alert_error "#{gem} is not installed. Skipping."
11
- next
12
- end
13
-
14
- candidates << dependencies_for(*candidates) unless options[:ignore]
15
- candidates
16
- end.flatten.uniq
17
- end
18
-
19
- def gems_list
20
- installed_gems = Gem.source_index.all_gems
21
- if options[:all] then
22
- installed_gems.map { |_, spec| spec.name }
23
- else
24
- get_all_gem_names
25
- end
26
- end
27
-
28
- def dependencies_for *specs
29
- specs.map { |spec|
30
- spec.runtime_dependencies.map { |dep|
31
- deps = Gem.source_index.find_name(dep.name,dep.requirement)
32
- deps + dependencies_for(*deps)
33
- }
34
- }
35
- end
36
-
37
- end
38
-
39
- end