simonmenke-gm 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. data/gm_behaviors/author_behavior.rb +29 -0
  2. data/gm_behaviors/bin_files_behavior.rb +10 -0
  3. data/gm_behaviors/dependencies_behavior.rb +22 -0
  4. data/gm_behaviors/executables_behavior.rb +13 -0
  5. data/gm_behaviors/general_behavior.rb +41 -0
  6. data/gm_behaviors/github_behavior.rb +11 -0
  7. data/gm_behaviors/gm_files_behavior.rb +13 -0
  8. data/gm_behaviors/lib_files_behavior.rb +10 -0
  9. data/gm_behaviors/rails_behavior.rb +11 -0
  10. data/gm_behaviors/rdoc_behavior.rb +34 -0
  11. data/gm_behaviors/rspec_behavior.rb +10 -0
  12. data/gm_behaviors/rubigen_behavior.rb +13 -0
  13. data/gm_behaviors/rubyforge_behavior.rb +12 -0
  14. data/gm_behaviors/test_behavior.rb +10 -0
  15. data/gm_behaviors/text_files_behavior.rb +10 -0
  16. data/gm_commands/build_command.rb +1 -1
  17. data/gm_commands/build_gemspec_command.rb +30 -0
  18. data/gm_commands/config_command.rb +2 -2
  19. data/gm_commands/gen_command.rb +1 -1
  20. data/gm_commands/publish_command.rb +2 -2
  21. data/gm_commands/spec_command.rb +1 -1
  22. data/gm_generators/mit_license/templates/LICENSE.txt +1 -1
  23. data/gm_networks/github_network.rb +25 -3
  24. data/gm_networks/rubyforge_network.rb +18 -0
  25. data/lib/extentions/gem.rb +0 -11
  26. data/lib/gm.rb +4 -5
  27. data/lib/gm/app.rb +29 -18
  28. data/lib/gm/behavior.rb +23 -0
  29. data/lib/gm/command.rb +3 -7
  30. data/lib/gm/configuration.rb +20 -0
  31. data/lib/gm/helpers.rb +20 -0
  32. data/lib/gm/loader.rb +1 -1
  33. data/lib/gm/network.rb +2 -6
  34. data/test/gem_extentions_test.rb +0 -15
  35. metadata +45 -46
  36. data/gm_passes/clean_file_list.rb +0 -15
  37. data/gm_passes/configatron.rb +0 -92
  38. data/gm_passes/defaults.rb +0 -10
  39. data/gm_passes/executables.rb +0 -10
  40. data/gm_passes/files.rb +0 -15
  41. data/gm_passes/github.rb +0 -9
  42. data/gm_passes/gm.rb +0 -10
  43. data/gm_passes/rails.rb +0 -8
  44. data/gm_passes/rubigen.rb +0 -10
  45. data/gm_passes/specs.rb +0 -7
  46. data/gm_passes/test.rb +0 -7
  47. data/lib/extentions/configatron.rb +0 -17
  48. data/lib/gm/configuration_pass.rb +0 -58
  49. data/lib/gm/configuration_pass_queue.rb +0 -70
  50. data/lib/gm/dsl.rb +0 -45
  51. data/test/configatron_test.rb +0 -15
  52. data/test/configuration_pass_queue_test.rb +0 -56
  53. data/test/configuration_pass_test.rb +0 -24
@@ -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
@@ -9,7 +9,7 @@ class BuildCommand < GM::Command
9
9
 
10
10
  def run
11
11
  app.emulate = true
12
- app.build_gemspec
12
+ GM::Command.run(:build_gemspec)
13
13
 
14
14
  app.info "Building your gem..."
15
15
  builder = Gem::Builder.new app.gemspec
@@ -0,0 +1,30 @@
1
+
2
+ class BuildGemspecCommand < GM::Command
3
+
4
+ def run
5
+ app.info "Generating your gemspec..."
6
+ app.gemspec = Gem::Specification.new
7
+
8
+ GM::Behavior.behaviors.each do |name,klass|
9
+ behavior = klass.new
10
+ behavior.run
11
+ end
12
+
13
+ clean_file_list
14
+ spec.validate
15
+ end
16
+
17
+ private
18
+
19
+ def clean_file_list
20
+ spec.files.reject! { |path| File.directory? path }
21
+ spec.files.reject! { |path| File.basename(path) == '.DS_Store' }
22
+ spec.files.reject! { |path| File.basename(path) == '.gitignore' }
23
+ spec.files.reject! { |path| path.include? '/.svn' }
24
+ spec.files.reject! { |path| path.include? '/.git' }
25
+ spec.files.uniq!
26
+ spec.files.compact!
27
+ spec.files.sort!
28
+ end
29
+
30
+ end
@@ -35,8 +35,8 @@ EOC
35
35
  end
36
36
 
37
37
  def run_show
38
- app.build_gemspec
39
- puts configatron.to_hash2.to_yaml
38
+ GM::Command.run(:build_gemspec)
39
+ puts config.to_yaml
40
40
  end
41
41
 
42
42
  end
@@ -20,7 +20,7 @@ class GenCommand < GM::Command
20
20
  DOC
21
21
 
22
22
  def run
23
- app.build_gemspec if File.exist?('./gmfile.yml')
23
+ GM::Command.run(:build_gemspec) if File.exist?('./Gmfile')
24
24
  @gen_name = self.argv.shift
25
25
  @gen_options = self.argv
26
26
 
@@ -11,7 +11,7 @@ class PublishCommand < GM::Command
11
11
  DOC
12
12
 
13
13
  def run
14
- app.build_gemspec
14
+ GM::Command.run(:build_gemspec)
15
15
 
16
16
  networks = argv.collect do |network|
17
17
  name = network.underscore.to_sym
@@ -19,7 +19,7 @@ class PublishCommand < GM::Command
19
19
  klass.new unless klass.nil?
20
20
  end.compact
21
21
 
22
- version = configatron.general.version
22
+ version = config[:general][:version]
23
23
  networks.each do |network|
24
24
  if network.has_version? version
25
25
  GM.app.log "Skipping #{network.class.name} (version #{version} already present)"
@@ -4,7 +4,7 @@ class SpecCommand < GM::Command
4
4
  desc "Dump the gemspec file."
5
5
 
6
6
  def run
7
- app.build_gemspec
7
+ GM::Command.run(:build_gemspec)
8
8
  app.info "Writing your gemspec..."
9
9
  File.open("#{app.gemspec.name}.gemspec", 'w+') do |f|
10
10
  f.write app.gemspec.to_ruby
@@ -1,4 +1,4 @@
1
- Copyright (c) <%= DateTime.now.year %> <%= configatron.author.name %>
1
+ Copyright (c) <%= DateTime.now.year %> <%= EC.store.config[:author][:name] %>
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person
4
4
  obtaining a copy of this software and associated documentation
@@ -6,6 +6,28 @@ class GithubNetwork < GM::Network
6
6
  This will dump the .gemspec file, create a new (optonaly signed) tag and push the master branch to github.
7
7
  DOC
8
8
 
9
+ specify_conf do |root|
10
+
11
+ root.map :github do |github|
12
+
13
+ github.conf(:emulate) do |s|
14
+ end
15
+
16
+ github.conf(:project) do |s|
17
+ s.should_be_a String
18
+ s.should_not_be_empty
19
+ end
20
+
21
+ github.conf(:username) do |s|
22
+ s.should_be_present
23
+ s.should_be_a String
24
+ s.should_not_be_empty
25
+ end
26
+
27
+ end
28
+
29
+ end
30
+
9
31
  def publish
10
32
  commit_gemspec
11
33
  make_tag
@@ -26,8 +48,8 @@ class GithubNetwork < GM::Network
26
48
  private
27
49
 
28
50
  def make_tag
29
- version = configatron.general.version
30
- key = configatron.gpg.key
51
+ version = config[:general][:version]
52
+ key = config[:gpg][:key] if config[:gpg]
31
53
  signing_options = if key.nil?
32
54
  "-a"
33
55
  else
@@ -37,7 +59,7 @@ class GithubNetwork < GM::Network
37
59
  end
38
60
 
39
61
  def commit_gemspec
40
- version = configatron.general.version
62
+ version = config[:general][:version]
41
63
  GM::Command.run(:spec)
42
64
  sh %{ git ci -m "Bumped to version #{version}" -o "#{app.gemspec.name}.gemspec" -o "Gmfile" }
43
65
  end
@@ -0,0 +1,18 @@
1
+
2
+ class RubyforgeNetwork < GM::Network
3
+
4
+ specify_conf do |root|
5
+
6
+ root.map :rubyforge do |rubyforge|
7
+
8
+ rubyforge.conf(:project) do |s|
9
+ s.should_be_present
10
+ s.should_be_a String
11
+ s.should_not_be_empty
12
+ end
13
+
14
+ end
15
+
16
+ end
17
+
18
+ end