simonmenke-gm 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/rubygems_plugin.rb +60 -10
  2. metadata +2 -2
@@ -19,8 +19,9 @@ private
19
19
 
20
20
  def specify(&block)
21
21
  @spec ||= begin
22
- spec = Gem::Specification.new
23
- block.call(Proxy.new(spec))
22
+ spec = Gem::Specification.new
23
+ @proxy = Proxy.new(spec)
24
+ block.call(@proxy)
24
25
  spec
25
26
  end
26
27
  end
@@ -29,28 +30,77 @@ private
29
30
  @spec
30
31
  end
31
32
 
32
- def complete_configuration
33
- find_files
33
+ def clean_files
34
+ @spec.test_files = clean_files_in(@spec.test_files)
35
+ @spec.files = clean_files_in(@spec.files)
34
36
  end
35
37
 
36
- def find_files
37
- if spec.files.empty?
38
- spec.files = Dir.glob('{test,lib,spec,rails,app,vendor,db,tasks}/**/*.{rb,erb,rake}')
39
- end
40
- if spec.test_files.empty?
41
- spec.test_files = Dir.glob('{test,spec}/**/*.{rb}')
38
+ def clean_files_in(array)
39
+ array = array.dup
40
+ @proxy.ignored_files.each do |pattern|
41
+ rejector = case pattern
42
+ when Proc then lambda { |path| !!pattern.call(path) }
43
+ when Regexp then lambda { |path| !!(path =~ pattern) }
44
+ when String then lambda { |path| !!(path == pattern) }
45
+ end
46
+ array = array.reject(&rejector)
42
47
  end
48
+ array
49
+ end
50
+
51
+ def complete_configuration
52
+ find_files
43
53
  if spec.summary and !spec.description
44
54
  spec.description = spec.summary
45
55
  end
46
56
  if spec.description and !spec.summary
47
57
  spec.summary = spec.description
48
58
  end
59
+ clean_files
60
+ end
61
+
62
+ def find_files
63
+ if spec.files.empty?
64
+ spec.files = Dir.glob('{app,config,db,lib,rails,spec,tasks,test,vendor}/**/*.{rb,erb,rake}')
65
+ spec.files += Dir.glob('public/**/*.*')
66
+ end
67
+ if spec.test_files.empty?
68
+ spec.test_files = Dir.glob('{test,spec}/**/*.{rb}')
69
+ end
70
+ spec.files += @proxy.files
71
+ spec.test_files += @proxy.test_files
49
72
  end
50
73
 
51
74
  class Proxy
75
+ attr_reader :ignored_files, :files, :test_files
52
76
  def initialize(target)
53
77
  @target = target
78
+ @ignored_files = []
79
+ @files = []
80
+ @test_files = []
81
+ end
82
+ def ignore_files(pattern=nil, &proc)
83
+ @ignored_files.push(pattern || proc)
84
+ end
85
+ def include_files(*pattern, &proc)
86
+ pattern.push(proc)
87
+ pattern = pattern.flatten.compact.uniq
88
+ pattern = pattern.first if pattern.size == 1
89
+ include_pattern(pattern) { |files| @files.concat(files) }
90
+ end
91
+ def include_test_files(*pattern, &proc)
92
+ pattern.push(proc)
93
+ pattern = pattern.flatten.compact.uniq
94
+ pattern = pattern.first if pattern.size == 1
95
+ include_pattern(pattern) { |files| @test_files.concat(files) }
96
+ end
97
+ def include_pattern(pattern, &inject)
98
+ case pattern
99
+ when Proc then include_pattern(pattern.call, &inject)
100
+ when Array then pattern.each { |p| include_pattern(p, &inject) }
101
+ when String then inject.call(Dir.glob(pattern).compact.uniq)
102
+ when NilClass then # nothing
103
+ end
54
104
  end
55
105
  def method_missing(m,*args,&block)
56
106
  m = m.to_s
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simonmenke-gm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Menke
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-05-13 00:00:00 -07:00
12
+ date: 2009-05-26 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15