simonmenke-gm 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,131 @@
1
+ require 'rubygems/command_manager'
2
+
3
+ class Gem::Commands::SpecifyCommand < Gem::Command
4
+
5
+ def initialize
6
+ super 'specify', 'Generate a spec file'
7
+ end
8
+
9
+ def execute
10
+ code = IO.read('Gmfile')
11
+ eval(code, binding, 'Gmfile')
12
+ complete_configuration
13
+ if spec.validate
14
+ File.open("#{spec.name}.gemspec", 'w+') { |f| f.write spec.to_ruby }
15
+ end
16
+ end
17
+
18
+ private
19
+
20
+ def specify(&block)
21
+ @spec ||= begin
22
+ spec = Gem::Specification.new
23
+ @proxy = Proxy.new(spec)
24
+ block.call(@proxy)
25
+ spec
26
+ end
27
+ end
28
+
29
+ def spec
30
+ @spec
31
+ end
32
+
33
+ def clean_files
34
+ @spec.test_files = clean_files_in(@spec.test_files)
35
+ @spec.files = clean_files_in(@spec.files)
36
+ end
37
+
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)
47
+ end
48
+ array = array.reject { |path| File.symlink?(path) }
49
+ array
50
+ end
51
+
52
+ def complete_configuration
53
+ find_files
54
+ if spec.summary and !spec.description
55
+ spec.description = spec.summary
56
+ end
57
+ if spec.description and !spec.summary
58
+ spec.summary = spec.description
59
+ end
60
+ clean_files
61
+ end
62
+
63
+ def find_files
64
+ if spec.files.empty?
65
+ spec.files = Dir.glob('{app,config,db,lib,rails,spec,tasks,test,vendor}/**/*.{rb,erb,rake,meta,builder}')
66
+ spec.files += Dir.glob('public/**/*.*')
67
+ end
68
+ if spec.test_files.empty?
69
+ spec.test_files = Dir.glob('{test,spec}/**/*.{rb}')
70
+ end
71
+ spec.files += @proxy.files
72
+ spec.test_files += @proxy.test_files
73
+ end
74
+
75
+ class Proxy
76
+ attr_reader :ignored_files, :files, :test_files
77
+ def initialize(target)
78
+ @target = target
79
+ @ignored_files = []
80
+ @files = []
81
+ @test_files = []
82
+ end
83
+ def ignore_files(pattern=nil, &proc)
84
+ @ignored_files.push(pattern || proc)
85
+ end
86
+ def include_files(*pattern, &proc)
87
+ pattern.push(proc)
88
+ pattern = pattern.flatten.compact.uniq
89
+ pattern = pattern.first if pattern.size == 1
90
+ include_pattern(pattern) { |files| @files.concat(files) }
91
+ end
92
+ def include_test_files(*pattern, &proc)
93
+ pattern.push(proc)
94
+ pattern = pattern.flatten.compact.uniq
95
+ pattern = pattern.first if pattern.size == 1
96
+ include_pattern(pattern) { |files| @test_files.concat(files) }
97
+ end
98
+ def include_pattern(pattern, &inject)
99
+ case pattern
100
+ when Proc then include_pattern(pattern.call, &inject)
101
+ when Array then pattern.each { |p| include_pattern(p, &inject) }
102
+ when String then inject.call(Dir.glob(pattern).compact.uniq)
103
+ when NilClass then # nothing
104
+ end
105
+ end
106
+ def method_missing(m,*args,&block)
107
+ m = m.to_s
108
+ if args.size == 1 && m[-1,1] != '=' && @target.respond_to?("#{m}=")
109
+ m = "#{m}="
110
+ end
111
+ @target.send(m,*args,&block)
112
+ end
113
+ end
114
+ end
115
+
116
+ class Gem::Commands::MakeCommand < Gem::Command
117
+
118
+ def initialize
119
+ super 'make', 'Generate a spec file and build the gem'
120
+ end
121
+
122
+
123
+ def execute
124
+ Gem::CommandManager.instance.run('specify')
125
+ Gem::CommandManager.instance.run("build #{Dir.glob("*.gemspec")}")
126
+ end
127
+
128
+ end
129
+
130
+ Gem::CommandManager.instance.register_command :specify
131
+ Gem::CommandManager.instance.register_command :make
@@ -1,130 +1 @@
1
- require 'rubygems/command_manager'
2
-
3
- class Gem::Commands::SpecifyCommand < Gem::Command
4
-
5
- def initialize
6
- super 'specify', 'Generate a spec file'
7
- end
8
-
9
- def execute
10
- code = IO.read('Gmfile')
11
- eval(code, binding, 'Gmfile')
12
- complete_configuration
13
- if spec.validate
14
- File.open("#{spec.name}.gemspec", 'w+') { |f| f.write spec.to_ruby }
15
- end
16
- end
17
-
18
- private
19
-
20
- def specify(&block)
21
- @spec ||= begin
22
- spec = Gem::Specification.new
23
- @proxy = Proxy.new(spec)
24
- block.call(@proxy)
25
- spec
26
- end
27
- end
28
-
29
- def spec
30
- @spec
31
- end
32
-
33
- def clean_files
34
- @spec.test_files = clean_files_in(@spec.test_files)
35
- @spec.files = clean_files_in(@spec.files)
36
- end
37
-
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)
47
- end
48
- array
49
- end
50
-
51
- def complete_configuration
52
- find_files
53
- if spec.summary and !spec.description
54
- spec.description = spec.summary
55
- end
56
- if spec.description and !spec.summary
57
- spec.summary = spec.description
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
72
- end
73
-
74
- class Proxy
75
- attr_reader :ignored_files, :files, :test_files
76
- def initialize(target)
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
104
- end
105
- def method_missing(m,*args,&block)
106
- m = m.to_s
107
- if args.size == 1 && m[-1,1] != '=' && @target.respond_to?("#{m}=")
108
- m = "#{m}="
109
- end
110
- @target.send(m,*args,&block)
111
- end
112
- end
113
- end
114
-
115
- class Gem::Commands::MakeCommand < Gem::Command
116
-
117
- def initialize
118
- super 'make', 'Generate a spec file and build the gem'
119
- end
120
-
121
-
122
- def execute
123
- Gem::CommandManager.instance.run('specify')
124
- Gem::CommandManager.instance.run("build #{Dir.glob("*.gemspec")}")
125
- end
126
-
127
- end
128
-
129
- Gem::CommandManager.instance.register_command :specify
130
- Gem::CommandManager.instance.register_command :make
1
+ require 'gm/rubygems_plugin'
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.2
4
+ version: 1.0.3
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-26 00:00:00 -07:00
12
+ date: 2009-08-14 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -22,9 +22,11 @@ extensions: []
22
22
  extra_rdoc_files: []
23
23
 
24
24
  files:
25
+ - lib/gm/rubygems_plugin.rb
25
26
  - lib/rubygems_plugin.rb
26
27
  has_rdoc: false
27
28
  homepage: http://github.com/simonmenke/gm
29
+ licenses:
28
30
  post_install_message:
29
31
  rdoc_options: []
30
32
 
@@ -45,7 +47,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
45
47
  requirements: []
46
48
 
47
49
  rubyforge_project: gem-make
48
- rubygems_version: 1.2.0
50
+ rubygems_version: 1.3.5
49
51
  signing_key:
50
52
  specification_version: 3
51
53
  summary: Building gems the clean way.