gm 0.1.6 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. data/lib/gm/rubygems_plugin.rb +131 -0
  2. data/lib/rubygems_plugin.rb +1 -0
  3. metadata +17 -186
  4. data/LICENSE.txt +0 -22
  5. data/README.textile +0 -13
  6. data/bin/gem-make +0 -6
  7. data/bin/gm +0 -6
  8. data/gm_behaviors/author_behavior.rb +0 -29
  9. data/gm_behaviors/bin_files_behavior.rb +0 -10
  10. data/gm_behaviors/dependencies_behavior.rb +0 -22
  11. data/gm_behaviors/executables_behavior.rb +0 -13
  12. data/gm_behaviors/general_behavior.rb +0 -41
  13. data/gm_behaviors/github_behavior.rb +0 -14
  14. data/gm_behaviors/gm_files_behavior.rb +0 -13
  15. data/gm_behaviors/lib_files_behavior.rb +0 -10
  16. data/gm_behaviors/rails_behavior.rb +0 -11
  17. data/gm_behaviors/rdoc_behavior.rb +0 -34
  18. data/gm_behaviors/rspec_behavior.rb +0 -10
  19. data/gm_behaviors/rubigen_behavior.rb +0 -13
  20. data/gm_behaviors/rubyforge_behavior.rb +0 -12
  21. data/gm_behaviors/test_behavior.rb +0 -10
  22. data/gm_behaviors/text_files_behavior.rb +0 -10
  23. data/gm_commands/build_command.rb +0 -25
  24. data/gm_commands/build_gemspec_command.rb +0 -34
  25. data/gm_commands/clean_command.rb +0 -14
  26. data/gm_commands/config_command.rb +0 -42
  27. data/gm_commands/create_command.rb +0 -10
  28. data/gm_commands/gen_command.rb +0 -31
  29. data/gm_commands/help_command.rb +0 -246
  30. data/gm_commands/install_command.rb +0 -17
  31. data/gm_commands/publish_command.rb +0 -34
  32. data/gm_commands/spec_command.rb +0 -14
  33. data/gm_generators/bin/bin_generator.rb +0 -22
  34. data/gm_generators/bin/templates/bin/bin.rb +0 -3
  35. data/gm_generators/gem/gem_generator.rb +0 -38
  36. data/gm_generators/gem/templates/Gmfile +0 -4
  37. data/gm_generators/gem/templates/README.textile +0 -0
  38. data/gm_generators/gem/templates/lib/module.rb +0 -4
  39. data/gm_generators/mit_license/mit_license_generator.rb +0 -17
  40. data/gm_generators/mit_license/templates/LICENSE.txt +0 -22
  41. data/gm_generators/rails/rails_generator.rb +0 -18
  42. data/gm_generators/rails/templates/rails/init.rb +0 -1
  43. data/gm_generators/test/templates/test_case.rb.erb +0 -5
  44. data/gm_generators/test/templates/test_helper.rb.erb +0 -7
  45. data/gm_generators/test/test_generator.rb +0 -26
  46. data/gm_networks/github_network.rb +0 -72
  47. data/gm_networks/rubyforge_network.rb +0 -90
  48. data/lib/autotest/discover.rb +0 -3
  49. data/lib/autotest/gm.rb +0 -37
  50. data/lib/extentions/gem.rb +0 -27
  51. data/lib/gm.rb +0 -30
  52. data/lib/gm/app.rb +0 -111
  53. data/lib/gm/behavior.rb +0 -25
  54. data/lib/gm/command.rb +0 -66
  55. data/lib/gm/configuration.rb +0 -20
  56. data/lib/gm/documentation.rb +0 -38
  57. data/lib/gm/helpers.rb +0 -24
  58. data/lib/gm/loader.rb +0 -84
  59. data/lib/gm/network.rb +0 -29
  60. data/lib/gm/system.rb +0 -16
  61. data/test/command_test.rb +0 -106
  62. data/test/gem_extentions_test.rb +0 -31
  63. data/test/system_test.rb +0 -17
  64. data/test/test_helper.rb +0 -12
@@ -1,27 +0,0 @@
1
-
2
- module Gem # :nodoc:
3
-
4
- def self.find_recent_files(path)
5
- specs = searcher.find_all path
6
-
7
- specs = specs.inject({}) do |s, spec|
8
- if s[spec.name].nil? or (spec <=> s[spec.name]) == 1
9
- s[spec.name] = spec
10
- end
11
- s
12
- end
13
-
14
- specs = specs.collect do |name, spec|
15
- searcher.matching_files spec, path
16
- end
17
-
18
- specs.flatten.compact
19
- end
20
-
21
- def self.find_recent_resources(path)
22
- find_recent_files(File.join('..',path)).map do |gem_path|
23
- File.expand_path(gem_path)
24
- end
25
- end
26
-
27
- end
data/lib/gm.rb DELETED
@@ -1,30 +0,0 @@
1
-
2
- begin
3
- require 'ec'
4
- require 'erb'
5
- require 'clip'
6
- require 'singleton'
7
- require 'rubigen'
8
- require 'rubigen/scripts/generate'
9
- rescue LoadError
10
- retry if require 'rubygems'
11
- end
12
-
13
- module GM
14
-
15
- def self.app
16
- GM::App.instance
17
- end
18
-
19
- end
20
-
21
- require File.dirname(__FILE__)+'/extentions/gem'
22
- require File.dirname(__FILE__)+'/gm/loader'
23
- require File.dirname(__FILE__)+'/gm/system'
24
- require File.dirname(__FILE__)+'/gm/helpers'
25
- require File.dirname(__FILE__)+'/gm/documentation'
26
- require File.dirname(__FILE__)+'/gm/configuration'
27
- require File.dirname(__FILE__)+'/gm/app'
28
- require File.dirname(__FILE__)+'/gm/command'
29
- require File.dirname(__FILE__)+'/gm/behavior'
30
- require File.dirname(__FILE__)+'/gm/network'
@@ -1,111 +0,0 @@
1
-
2
- module GM
3
-
4
- class App
5
- include Singleton
6
-
7
- def initialize # :nodoc:
8
- reset!
9
- end
10
-
11
- # reset the app
12
- def reset!
13
- EC.store.reset!(true)
14
- GM::Behavior.behaviors.clear
15
- GM::Command.commands.clear
16
- GM::Network.networks.clear
17
-
18
- EC.store.specify do |root|
19
- root.conf(:log_level) do |c|
20
- c.should_be_a String
21
- c.should_not_be_empty
22
- end
23
- end
24
- end
25
-
26
- # run the app
27
- def run
28
- load_behaviors
29
- load_commands
30
- load_networks
31
-
32
- if ARGV.include? '-v'
33
- EC.store.config[:log_level] = 'verbose'
34
- ARGV.delete '-v'
35
- elsif ARGV.include? '-d'
36
- EC.store.config[:log_level] = 'debug'
37
- ARGV.delete '-d'
38
- else
39
- EC.store.config[:log_level] = 'normal'
40
- end
41
-
42
- load_configuration('~/.gmrc')
43
- load_configuration('Gmfile')
44
- EC.store.validate
45
-
46
- Command.run
47
- end
48
-
49
- def load_configuration(path)
50
- path = File.expand_path(path)
51
- if File.exist? path
52
- EC.store.configure_with_yaml(path)
53
- else
54
- log "Missing configuration file: #{path}"
55
- end
56
- end
57
-
58
- def reset_spec!
59
- @spec = nil
60
- end
61
-
62
- def spec
63
- @spec ||= Gem::Specification.new
64
- end
65
-
66
- def log(msg)
67
- puts msg if %w( debug verbose normal ).include? EC.store.config[:log_level]
68
- end
69
-
70
- def info(msg)
71
- puts msg if %w( debug verbose ).include? EC.store.config[:log_level]
72
- end
73
-
74
- def debug(msg)
75
- puts msg if %w( debug ).include? EC.store.config[:log_level]
76
- end
77
-
78
- private
79
-
80
- # load all behaviors
81
- def load_behaviors
82
- find_paths('gm_behaviors/*_behavior.rb').each do |path|
83
- GM::Behavior.load_behavior path
84
- end
85
- end
86
-
87
- # load all networks
88
- def load_networks
89
- find_paths('gm_networks/*_network.rb').each do |path|
90
- GM::Network.load_network path
91
- end
92
- end
93
-
94
- # load all commands
95
- def load_commands
96
- find_paths('gm_commands/*_command.rb').each do |path|
97
- GM::Command.load_command path
98
- end
99
- end
100
-
101
- def find_paths(pattern)
102
- if File.exist? 'gm.gemspec'
103
- Dir.glob(pattern).uniq
104
- else
105
- Gem.find_recent_resources(pattern).uniq
106
- end
107
- end
108
-
109
- end
110
-
111
- end
@@ -1,25 +0,0 @@
1
-
2
- module GM
3
-
4
- class Behavior
5
-
6
- include GM::Documentation
7
- include GM::Configuration
8
- include GM::Helpers
9
- include GM::System
10
- include GM::Loader
11
-
12
- desc ""
13
- doc ""
14
-
15
- loads :behaviors
16
-
17
- attr_accessor :command
18
-
19
- def run
20
-
21
- end
22
-
23
- end
24
-
25
- end
@@ -1,66 +0,0 @@
1
-
2
- module GM
3
-
4
- class Command
5
-
6
- attr_accessor :argv
7
- attr_accessor :options
8
-
9
- include GM::Documentation
10
- include GM::Configuration
11
- include GM::Helpers
12
- include GM::System
13
- include GM::Loader
14
-
15
- desc ""
16
- doc ""
17
- banner ""
18
- loads :commands
19
-
20
- # build a command
21
- def self.run(cmd_name=nil, argv=ARGV)
22
- if Array === cmd_name
23
- argv = cmd_name
24
- cmd_name = nil
25
- end
26
- cmd = self.build(cmd_name, argv)
27
- clip = Clip(argv) do |p|
28
- p.banner = cmd.banner_text
29
- cmd.add_options(p)
30
- end
31
- cmd.options = clip
32
- argv.clear
33
- argv.concat(clip.remainder)
34
- cmd.argv = argv
35
- cmd.run
36
- argv
37
- end
38
-
39
- # build a command
40
- def self.build(cmd_name=nil, argv=ARGV)
41
- if Array === cmd_name
42
- argv = cmd_name
43
- cmd_name = nil
44
- end
45
- if cmd_name.nil?
46
- cmd_name = (argv.detect {|i| i !~ /^--?/ } || 'help')
47
- argv.delete(cmd_name)
48
- end
49
- app = GM.app
50
- cmd_name = cmd_name.to_s.underscore.to_sym
51
- cmd_class = GM::Command.commands[cmd_name]
52
- cmd_class ||= GM::Command.commands[:help]
53
- cmd_class.new
54
- end
55
-
56
- # A command can overwrite this method in order to add extra command line options.
57
- def add_options(options)
58
- end
59
-
60
- # A command must overwrite this method.
61
- def run
62
- end
63
-
64
- end
65
-
66
- end
@@ -1,20 +0,0 @@
1
-
2
- module GM
3
-
4
- module Configuration
5
-
6
- def self.included(base)
7
- base.extend GM::Configuration::ClassMethods
8
- end
9
-
10
- module ClassMethods
11
-
12
- def specify_conf(&block)
13
- EC.store.specify(&block)
14
- end
15
-
16
- end
17
-
18
- end
19
-
20
- end
@@ -1,38 +0,0 @@
1
-
2
- module GM
3
-
4
- module Documentation
5
-
6
- def self.included(base)
7
- base.extend GM::Documentation::ClassMethods
8
- end
9
-
10
- module ClassMethods
11
- def desc(text)
12
- module_eval %{
13
- def self.description
14
- ERB.new(#{text.inspect}).result(binding)
15
- end
16
- }
17
- end
18
- def doc(text)
19
- module_eval %{
20
- def self.documentation
21
- ERB.new(#{text.inspect}).result(binding)
22
- end
23
- }
24
- end
25
- def banner(text)
26
- text = "#{File.basename($0)} #{text}" unless text.blank?
27
- module_eval %{
28
- def self.banner_text
29
- #{text.inspect}
30
- end
31
- def banner_text; self.class.banner_text ; end
32
- }
33
- end
34
- end
35
-
36
- end
37
-
38
- end
@@ -1,24 +0,0 @@
1
-
2
- module GM
3
-
4
- module Helpers
5
-
6
- def app
7
- GM.app
8
- end
9
-
10
- def config
11
- EC.store.config
12
- end
13
-
14
- def spec
15
- GM.app.spec
16
- end
17
-
18
- def gem_file_name
19
- "#{spec.name}-#{spec.version}.gem"
20
- end
21
-
22
- end
23
-
24
- end
@@ -1,84 +0,0 @@
1
-
2
- module GM
3
-
4
- module Loader
5
-
6
- def self.included(base)
7
- base.extend GM::Loader::Macros
8
- end
9
-
10
- module Macros
11
-
12
- def loads(name, options={})
13
- options.reverse_merge!(
14
- :name => name.to_s.singularize.underscore,
15
- :includes => [],
16
- :extends => [],
17
- :extention => ".rb",
18
- :collection => name.to_s.pluralize.underscore,
19
- :only_eval => false
20
- )
21
- options[:extends] = [options[:extends]].flatten
22
- options[:includes] = [options[:includes]].flatten
23
- unless options[:only_eval]
24
- module_eval %{
25
- extend GM::Loader::ClassMethods
26
- def self.load_#{options[:name]}(path)
27
- klass = load(path, #{options.inspect})
28
- #{options[:collection]}[klass.name] = klass
29
- klass
30
- end
31
- def self.name
32
- return @name unless @name.nil?
33
- regexp = /^(?:[#][<]Module[:]0x[0-9a-f]+[>][:]{2})?(.+)#{options[:name].camelize}$/
34
- @name = self.to_s
35
- @name.gsub!(regexp, '\\1')
36
- @name = @name.underscore.to_sym
37
- end
38
- def self.#{options[:collection]}
39
- @#{options[:collection]} ||= {}
40
- end
41
- }
42
- else
43
- module_eval %{
44
- extend GM::Loader::ClassMethods
45
- def self.load_#{options[:name]}(path)
46
- load(path, #{options.inspect})
47
- true
48
- end
49
- }
50
- end
51
- end
52
-
53
- end
54
-
55
- module ClassMethods
56
-
57
- def load(path, options={})
58
- raise LoadError, "file missing at path: #{path}" unless File.exist?(path)
59
- cmd_name = File.basename(path, '.rb')
60
- cmd_name = cmd_name.camelize
61
-
62
- mod = Module.new
63
- options[:includes].each do |mod|
64
- mod.send :include, mod
65
- end
66
- options[:extends].each do |mod|
67
- mod.send :extend, mod
68
- end
69
- mod.module_eval(IO.read(path), path)
70
-
71
- unless options[:only_eval]
72
- cmd_class = (mod.module_eval(cmd_name) rescue nil)
73
-
74
- raise LoadError, "Expected file to define #{cmd_name} (#{path})" if cmd_class.nil?
75
-
76
- cmd_class
77
- end
78
- end
79
-
80
- end
81
-
82
- end
83
-
84
- end
@@ -1,29 +0,0 @@
1
-
2
- module GM
3
-
4
- class Network
5
-
6
- include GM::Documentation
7
- include GM::Configuration
8
- include GM::Helpers
9
- include GM::System
10
- include GM::Loader
11
-
12
- desc ""
13
- doc ""
14
-
15
- loads :networks
16
-
17
- def publish
18
- end
19
-
20
- def published_versions
21
- end
22
-
23
- def has_version?(version)
24
- published_versions.include? version
25
- end
26
-
27
- end
28
-
29
- end