gm 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. data/LICENSE.txt +22 -0
  2. data/README.textile +13 -0
  3. data/bin/gem-make +6 -0
  4. data/bin/gm +6 -0
  5. data/gm_behaviors/author_behavior.rb +29 -0
  6. data/gm_behaviors/bin_files_behavior.rb +10 -0
  7. data/gm_behaviors/dependencies_behavior.rb +22 -0
  8. data/gm_behaviors/executables_behavior.rb +13 -0
  9. data/gm_behaviors/general_behavior.rb +41 -0
  10. data/gm_behaviors/github_behavior.rb +11 -0
  11. data/gm_behaviors/gm_files_behavior.rb +13 -0
  12. data/gm_behaviors/lib_files_behavior.rb +10 -0
  13. data/gm_behaviors/rails_behavior.rb +11 -0
  14. data/gm_behaviors/rdoc_behavior.rb +34 -0
  15. data/gm_behaviors/rspec_behavior.rb +10 -0
  16. data/gm_behaviors/rubigen_behavior.rb +13 -0
  17. data/gm_behaviors/rubyforge_behavior.rb +12 -0
  18. data/gm_behaviors/test_behavior.rb +10 -0
  19. data/gm_behaviors/text_files_behavior.rb +10 -0
  20. data/gm_commands/build_command.rb +25 -0
  21. data/gm_commands/build_gemspec_command.rb +35 -0
  22. data/gm_commands/clean_command.rb +14 -0
  23. data/gm_commands/config_command.rb +42 -0
  24. data/gm_commands/create_command.rb +10 -0
  25. data/gm_commands/gen_command.rb +31 -0
  26. data/gm_commands/help_command.rb +246 -0
  27. data/gm_commands/install_command.rb +17 -0
  28. data/gm_commands/publish_command.rb +33 -0
  29. data/gm_commands/spec_command.rb +14 -0
  30. data/gm_generators/bin/bin_generator.rb +22 -0
  31. data/gm_generators/bin/templates/bin/bin.rb +3 -0
  32. data/gm_generators/gem/gem_generator.rb +38 -0
  33. data/gm_generators/gem/templates/Gmfile +4 -0
  34. data/gm_generators/gem/templates/README.textile +0 -0
  35. data/gm_generators/gem/templates/lib/module.rb +4 -0
  36. data/gm_generators/mit_license/mit_license_generator.rb +17 -0
  37. data/gm_generators/mit_license/templates/LICENSE.txt +22 -0
  38. data/gm_generators/rails/rails_generator.rb +18 -0
  39. data/gm_generators/rails/templates/rails/init.rb +1 -0
  40. data/gm_generators/test/templates/test_case.rb.erb +5 -0
  41. data/gm_generators/test/templates/test_helper.rb.erb +7 -0
  42. data/gm_generators/test/test_generator.rb +26 -0
  43. data/gm_networks/github_network.rb +72 -0
  44. data/gm_networks/rubyforge_network.rb +90 -0
  45. data/lib/autotest/discover.rb +3 -0
  46. data/lib/autotest/gm.rb +37 -0
  47. data/lib/extentions/gem.rb +27 -0
  48. data/lib/gm.rb +30 -0
  49. data/lib/gm/app.rb +108 -0
  50. data/lib/gm/behavior.rb +23 -0
  51. data/lib/gm/command.rb +70 -0
  52. data/lib/gm/configuration.rb +20 -0
  53. data/lib/gm/documentation.rb +38 -0
  54. data/lib/gm/helpers.rb +20 -0
  55. data/lib/gm/loader.rb +84 -0
  56. data/lib/gm/network.rb +29 -0
  57. data/lib/gm/system.rb +16 -0
  58. data/test/command_test.rb +106 -0
  59. data/test/gem_extentions_test.rb +31 -0
  60. data/test/system_test.rb +17 -0
  61. data/test/test_helper.rb +12 -0
  62. metadata +159 -0
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2009 Simon Menke
2
+
3
+ Permission is hereby granted, free of charge, to any person
4
+ obtaining a copy of this software and associated documentation
5
+ files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use,
7
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the
9
+ Software is furnished to do so, subject to the following
10
+ conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,13 @@
1
+ h1. GM (GemMake)
2
+
3
+ GM is a gem and gemspec builder for use with github.
4
+
5
+ For the documentation go to "http://simonmenke.github.com/gm":http://simonmenke.github.com/gm
6
+
7
+ For bug reports and feature requests go to "http://menke.lighthouseapp.com/projects/23688-gm":http://menke.lighthouseapp.com/projects/23688-gm
8
+
9
+ h2. Todo
10
+
11
+ * Document extendability
12
+ * Document architecture
13
+ * Implement CDN interfaces (rubyforge, github, your site, ...)
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.dirname(__FILE__)+'/../lib/gm'
4
+
5
+ APP_ROOT = File.expand_path('.')
6
+ GM::App.instance.run
data/bin/gm ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.dirname(__FILE__)+'/../lib/gm'
4
+
5
+ APP_ROOT = File.expand_path('.')
6
+ GM::App.instance.run
@@ -0,0 +1,29 @@
1
+
2
+ class AuthorBehavior < GM::Behavior
3
+
4
+ specify_conf do |root|
5
+
6
+ root.map :author do |author|
7
+ author.should_be_present
8
+
9
+ author.conf(:name) do |name|
10
+ name.should_be_present
11
+ name.should_be_a String
12
+ name.should_not_be_empty
13
+ end
14
+
15
+ author.conf(:email) do |email|
16
+ email.should_be_present
17
+ email.should_be_a String
18
+ email.should_not_be_empty
19
+ end
20
+ end
21
+
22
+ end
23
+
24
+ def run
25
+ spec.author = config[:author][:name]
26
+ spec.email = config[:author][:email]
27
+ end
28
+
29
+ end
@@ -0,0 +1,10 @@
1
+
2
+ class BinFilesBehavior < GM::Behavior
3
+
4
+ desc "Collect bin files"
5
+
6
+ def run
7
+ spec.files += Dir.glob('bin/*')
8
+ end
9
+
10
+ end
@@ -0,0 +1,22 @@
1
+
2
+ class DependenciesBehavior < GM::Behavior
3
+
4
+ specify_conf do |root|
5
+
6
+ # root.list :dependencies do |dependency|
7
+ # dependency.conf do |c|
8
+ # c.should_be_a String
9
+ # c.should_not_be_empty
10
+ # end
11
+ # end
12
+
13
+ end
14
+
15
+ def run
16
+ (config[:dependencies] || []).each do |dependency|
17
+ gem, requirement = dependency.strip.split(/\s+/, 2)
18
+ spec.add_dependency gem.strip, requirement.strip
19
+ end
20
+ end
21
+
22
+ end
@@ -0,0 +1,13 @@
1
+
2
+ class ExecutablesBehavior < GM::Behavior
3
+
4
+ desc "Discover exceutables in bin/"
5
+
6
+ def run
7
+ paths = Dir.glob('bin/*')
8
+ spec.executables = paths.collect do |path|
9
+ File.basename(path)
10
+ end
11
+ end
12
+
13
+ end
@@ -0,0 +1,41 @@
1
+
2
+ class GeneralBehavior < GM::Behavior
3
+
4
+ specify_conf do |root|
5
+
6
+ root.map :general do |general|
7
+ general.should_be_present
8
+
9
+ general.conf(:name) do |s|
10
+ s.should_be_present
11
+ s.should_be_a String
12
+ s.should_not_be_empty
13
+ end
14
+
15
+ general.conf(:version) do |s|
16
+ s.should_be_present
17
+ s.should_be_a String
18
+ s.should_not_be_empty
19
+ end
20
+
21
+ general.conf(:summary) do |s|
22
+ s.should_be_a String
23
+ s.should_not_be_empty
24
+ end
25
+
26
+ general.conf(:homepage) do |s|
27
+ s.should_be_a String
28
+ s.should_not_be_empty
29
+ end
30
+ end
31
+
32
+ end
33
+
34
+ def run
35
+ spec.name ||= config[:general][:name]
36
+ spec.version = config[:general][:version]
37
+ spec.summary = config[:general][:summary]
38
+ spec.homepage = config[:general][:homepage]
39
+ end
40
+
41
+ end
@@ -0,0 +1,11 @@
1
+
2
+ class GithubBehavior < GM::Behavior
3
+
4
+ def run
5
+ if GM::App.emulate? and config[:github][:emulate]
6
+ name = config[:github][:project] || config[:general][:name]
7
+ spec.name = "#{config[:github][:username]}-#{name}"
8
+ end
9
+ end
10
+
11
+ end
@@ -0,0 +1,13 @@
1
+
2
+ class GmFilesBehavior < GM::Behavior
3
+
4
+ desc "Collect all GM related files (generators, commands, networks, behaviors)"
5
+
6
+ def run
7
+ spec.files += Dir.glob('gm_commands/*_command.rb')
8
+ spec.files += Dir.glob('gm_behaviors/*_behavior.rb')
9
+ spec.files += Dir.glob('gm_networks/*_network.rb')
10
+ spec.files += Dir.glob('gm_generators/**/*')
11
+ end
12
+
13
+ end
@@ -0,0 +1,10 @@
1
+
2
+ class LibFilesBehavior < GM::Behavior
3
+
4
+ desc "Collect lib files"
5
+
6
+ def run
7
+ spec.files += Dir.glob('lib/**/*.rb')
8
+ end
9
+
10
+ end
@@ -0,0 +1,11 @@
1
+
2
+ class RailsBehavior < GM::Behavior
3
+
4
+ desc "Collect all Rails related files (rails/init.rb, tasks/*.rake)"
5
+
6
+ def run
7
+ spec.files += Dir.glob('rails/init.rb')
8
+ spec.files += Dir.glob('tasks/*.rake')
9
+ end
10
+
11
+ end
@@ -0,0 +1,34 @@
1
+
2
+ class RdocBehavior < GM::Behavior
3
+
4
+ specify_conf do |root|
5
+
6
+ root.map :rdoc do |rdoc|
7
+
8
+ rdoc.conf(:enabled) do |s|
9
+ s.should_be_present
10
+ end
11
+
12
+ rdoc.conf(:extra_files) do |s|
13
+ end
14
+
15
+ rdoc.conf(:options) do |s|
16
+ s.should_be_a String
17
+ s.should_not_be_empty
18
+ end
19
+
20
+ end
21
+
22
+ end
23
+
24
+ def run
25
+ if config[:rdoc] and config[:rdoc][:enabled]
26
+ spec.has_rdoc = true
27
+ spec.extra_rdoc_files = config[:rdoc][:extra_files]
28
+ spec.rdoc_options = config[:rdoc][:options]
29
+ else
30
+ spec.has_rdoc = false
31
+ end
32
+ end
33
+
34
+ end
@@ -0,0 +1,10 @@
1
+
2
+ class RspecBehavior < GM::Behavior
3
+
4
+ desc "Collect rspec files"
5
+
6
+ def run
7
+ spec.test_files += Dir.glob('spec/**/*.rb')
8
+ end
9
+
10
+ end
@@ -0,0 +1,13 @@
1
+
2
+ class RubigenBehavior < GM::Behavior
3
+
4
+ desc "Collect rubigen files"
5
+
6
+ def run
7
+ paths = Dir.glob('*generators/**/*')
8
+ paths.reject! { |path| File.directory? path }
9
+ paths.reject! { |path| File.basename(path)[0,1] == "." }
10
+ spec.files += paths
11
+ end
12
+
13
+ end
@@ -0,0 +1,12 @@
1
+
2
+ class RubyforgeBehavior < GM::Behavior
3
+
4
+ def run
5
+ if config[:rubyforge]
6
+ spec.rubyforge_project = config[:rubyforge][:project]
7
+ else
8
+ spec.rubyforge_project = config[:general][:name]
9
+ end
10
+ end
11
+
12
+ end
@@ -0,0 +1,10 @@
1
+
2
+ class TestBehavior < GM::Behavior
3
+
4
+ desc "Collect Test::Unit files"
5
+
6
+ def run
7
+ spec.test_files += Dir.glob('test/**/*.rb')
8
+ end
9
+
10
+ end
@@ -0,0 +1,10 @@
1
+
2
+ class TextFilesBehavior < GM::Behavior
3
+
4
+ desc "Collect text files"
5
+
6
+ def run
7
+ spec.files += Dir.glob('*.{txt,rdoc,textile}')
8
+ end
9
+
10
+ end
@@ -0,0 +1,25 @@
1
+
2
+ class BuildCommand < GM::Command
3
+
4
+ desc "Build the gem"
5
+ banner "build"
6
+ doc <<-DOC
7
+ build a gem and put the result in pkg/
8
+ DOC
9
+
10
+ def extra_options(p)
11
+ p.flag 'E', 'no-emulation', :desc => 'Don\'t emulate any network'
12
+ end
13
+
14
+ def run
15
+ GM::Command.run(:build_gemspec, [(options.no_emulation? ? '-E' : nil)].compact)
16
+
17
+ app.info "Building your gem..."
18
+ builder = Gem::Builder.new app.gemspec
19
+ app.gem_file_name = builder.build
20
+ sh("rm -f pkg/#{app.gem_file_name}",
21
+ "mkdir -p pkg",
22
+ "mv #{app.gem_file_name} pkg/")
23
+ end
24
+
25
+ end
@@ -0,0 +1,35 @@
1
+
2
+ class BuildGemspecCommand < GM::Command
3
+
4
+ def extra_options(p)
5
+ p.flag 'E', 'no-emulation', :desc => 'Don\'t emulate any network'
6
+ end
7
+
8
+ def run
9
+ app.info "Generating your gemspec..."
10
+ app.emulate = !options.no_emulation?
11
+ app.gemspec = Gem::Specification.new
12
+
13
+ GM::Behavior.behaviors.each do |name,klass|
14
+ behavior = klass.new
15
+ behavior.run
16
+ end
17
+
18
+ clean_file_list
19
+ spec.validate
20
+ end
21
+
22
+ private
23
+
24
+ def clean_file_list
25
+ spec.files.reject! { |path| File.directory? path }
26
+ spec.files.reject! { |path| File.basename(path) == '.DS_Store' }
27
+ spec.files.reject! { |path| File.basename(path) == '.gitignore' }
28
+ spec.files.reject! { |path| path.include? '/.svn' }
29
+ spec.files.reject! { |path| path.include? '/.git' }
30
+ spec.files.uniq!
31
+ spec.files.compact!
32
+ spec.files.sort!
33
+ end
34
+
35
+ end
@@ -0,0 +1,14 @@
1
+
2
+ class CleanCommand < GM::Command
3
+
4
+ desc "Remove the build files."
5
+ banner "clean"
6
+ doc <<-DOC
7
+ This command will remove the pkg/ directory.
8
+ DOC
9
+
10
+ def run
11
+ sh("rm -rf pkg")
12
+ end
13
+
14
+ end
@@ -0,0 +1,42 @@
1
+
2
+ class ConfigCommand < GM::Command
3
+
4
+ desc "Manage your GM configurations."
5
+ banner "config [show edit]"
6
+ doc <<-DOC
7
+ With the edit argument the config command allows you to edit your glabal GM configurations.
8
+ With the show argument the config command will display all the configurations made in your environment.
9
+
10
+ The edit option is the default.
11
+ DOC
12
+
13
+ EMPTY_CONFIG = <<-EOC
14
+ author:
15
+ name:
16
+ email:
17
+ github:
18
+ username:
19
+ EOC
20
+
21
+ def run
22
+ case argv.first
23
+ when 'edit' then run_edit
24
+ when 'show' then run_show
25
+ else run_edit
26
+ end
27
+ end
28
+
29
+ def run_edit
30
+ path = File.expand_path('~/.gmrc')
31
+ unless File.exist? path
32
+ File.open(path, 'w+') { |f| f.write EMPTY_CONFIG }
33
+ end
34
+ sh("$EDITOR '#{path}'")
35
+ end
36
+
37
+ def run_show
38
+ GM::Command.run(:build_gemspec)
39
+ puts config.to_yaml
40
+ end
41
+
42
+ end