Module: Jeweler::Specification

Defined in:
lib/jeweler/specification.rb

Overview

Extend a Gem::Specification instance with this module to give it Jeweler super-cow powers.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.filelist_attribute(name) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/jeweler/specification.rb', line 8

def self.filelist_attribute(name)
  code = %{
    def #{name}
      @#{name} ||= FileList[]
    end
    def #{name}=(value)
      @#{name} = FileList[value]
    end
  }

  module_eval code, __FILE__, __LINE__ - 9
end

Instance Method Details

#ruby_code(obj) ⇒ Object

Used by Specification#to_ruby to generate a ruby-respresentation of a Gem::Specification



53
54
55
56
57
58
# File 'lib/jeweler/specification.rb', line 53

def ruby_code(obj)
  case obj
  when Rake::FileList then obj.to_a.inspect
  else super
  end
end

#set_jeweler_defaults(base_dir) ⇒ Object

Assigns the Jeweler defaults to the Gem::Specification



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/jeweler/specification.rb', line 27

def set_jeweler_defaults(base_dir)
  Dir.chdir(base_dir) do
    if blank?(files) && File.directory?(File.join(base_dir, '.git'))
      repo = Git.open(base_dir)
      self.files = repo.ls_files.keys - repo.lib.ignored_files
    end

    if blank?(test_files) && File.directory?(File.join(base_dir, '.git'))
      repo = Git.open(base_dir)
      self.test_files = FileList['{spec,test,examples}/**/*.rb'] - repo.lib.ignored_files
    end

    if blank?(executables)
      self.executables = Dir["bin/*"].map { |f| File.basename(f) }
    end

    self.has_rdoc = true
    rdoc_options << '--charset=UTF-8'

    if blank?(extra_rdoc_files)
      self.extra_rdoc_files = FileList["README*", "ChangeLog*", "LICENSE*"]
    end
  end
end