Class: Gem::Compiler
- Inherits:
-
Object
- Object
- Gem::Compiler
- Includes:
- UserInteraction
- Defined in:
- lib/rubygems-compile/compiler.rb
Class Method Summary collapse
Instance Method Summary collapse
- #compile(gem) ⇒ Object
- #compile_file_message(file) ⇒ Object
- #gem_compilation_message ⇒ Object
- #gem_files ⇒ Object
-
#initialize ⇒ Compiler
constructor
A new instance of Compiler.
- #really_verbose ⇒ Object
-
#safe?(file) ⇒ Boolean
Uses the GemAnalyzer class to determine if a given file might have any potential issues when compiled.
- #trying_to_compile_self? ⇒ Boolean
- #verbose ⇒ Object
Constructor Details
#initialize ⇒ Compiler
Returns a new instance of Compiler.
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/rubygems-compile/compiler.rb', line 12 def initialize require 'rbconfig' unless MacRuby.const_defined?(:Compiler) load File.join(RbConfig::CONFIG['bindir'], 'macrubyc') end require 'rubygems-compile/analyzer' @current_directory = [] @config = Gem.configuration end |
Class Method Details
Instance Method Details
#compile(gem) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/rubygems-compile/compiler.rb', line 23 def compile gem @spec = gem.is_a?(Gem::Specification) ? gem : gem.spec return if say if verbose gem_files.each do |file| = (file) full_path = File.join(@spec.full_gem_path, file) if safe? full_path MacRuby::Compiler.compile_file full_path else << "\t\t\tSKIPPED: #{@analyzer.warnings.uniq.join(', ')}" end say if really_verbose end end |
#compile_file_message(file) ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/rubygems-compile/compiler.rb', line 80 def file name = File.basename(file) dirs = file.chomp(name).split(File::SEPARATOR) tabs = "\t" * dirs.count dirs.each_with_index do |dir, index| unless @current_directory[index] == dir @current_directory[index] = dir say( "\t" * (index + 1) + dir + File::SEPARATOR) if really_verbose end end "#{tabs}#{name} => #{name}o" end |
#gem_compilation_message ⇒ Object
51 52 53 54 |
# File 'lib/rubygems-compile/compiler.rb', line 51 def slash = really_verbose ? '/' : '' "Compiling #{@spec.full_name}#{slash}" end |
#gem_files ⇒ Object
69 70 71 |
# File 'lib/rubygems-compile/compiler.rb', line 69 def gem_files @spec.lib_files.select { |file| File.extname(file) == '.rb' } end |
#really_verbose ⇒ Object
99 100 101 |
# File 'lib/rubygems-compile/compiler.rb', line 99 def really_verbose @config.really_verbose end |
#safe?(file) ⇒ Boolean
Uses the GemAnalyzer class to determine if a given file might have any potential issues when compiled.
45 46 47 48 49 |
# File 'lib/rubygems-compile/compiler.rb', line 45 def safe? file @analyzer = Gem::Analyzer.new File.read(file) @analyzer.parse @analyzer.warnings.empty? end |
#trying_to_compile_self? ⇒ Boolean
103 104 105 106 107 108 |
# File 'lib/rubygems-compile/compiler.rb', line 103 def if @spec.name == 'rubygems-compile' alert 'You cannot compile rubygems-compile' if really_verbose true end end |
#verbose ⇒ Object
95 96 97 |
# File 'lib/rubygems-compile/compiler.rb', line 95 def verbose @config.verbose end |