Class: Require::Gemspec
- Inherits:
-
Object
- Object
- Require::Gemspec
- Defined in:
- lib/require/gemspec.rb
Instance Method Summary collapse
- #clean_paths(paths, more = nil) ⇒ Object
- #executables ⇒ Object
- #extra_doc_files ⇒ Object
- #files ⇒ Object
- #instance ⇒ Object
- #name ⇒ Object
- #root ⇒ Object
Instance Method Details
#clean_paths(paths, more = nil) ⇒ Object
4 5 6 |
# File 'lib/require/gemspec.rb', line 4 def clean_paths(paths, more=nil) paths.collect { |p| p.gsub("#{root}/#{more}", '') } end |
#executables ⇒ Object
8 9 10 |
# File 'lib/require/gemspec.rb', line 8 def executables clean_paths Dir["#{root}/bin/*"], 'bin/' end |
#extra_doc_files ⇒ Object
12 13 14 |
# File 'lib/require/gemspec.rb', line 12 def extra_doc_files clean_paths Dir["#{root}/README.*"] end |
#files ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/require/gemspec.rb', line 16 def files gitignore = "#{root}/.gitignore" ignore = if File.exists?(gitignore) File.read(gitignore).split("\n").collect do |path| "#{root}/#{path.strip}" end else [] end clean_paths (Dir["#{root}/**/*"] - Dir[*ignore]) end |
#instance ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/require/gemspec.rb', line 29 def instance raise "Require must be called with a root path parameter" unless root defaults = { :executables => executables, :extra_rdoc_files => extra_doc_files, :files => files, :has_rdoc => false, :platform => Gem::Platform::RUBY, :require_path => 'lib' } ::Gem::Specification.new do |s| Require.get(:gemspec).all.each do |(option, value)| case option when :dependencies then value.all(:gem).each do |dependency| gem = Require.get(:gem, dependency.name) version = dependency.version || (gem.version rescue nil) s.add_dependency(dependency.name.to_s, version) end else if s.respond_to?("#{option}=") s.send "#{option}=", value || defaults[option] defaults[option] = nil end end end defaults.each do |option, value| s.send("#{option}=", value) if value end end end |