gm 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.txt +22 -0
- data/README.textile +13 -0
- data/bin/gem-make +6 -0
- data/bin/gm +6 -0
- data/gm_behaviors/author_behavior.rb +29 -0
- data/gm_behaviors/bin_files_behavior.rb +10 -0
- data/gm_behaviors/dependencies_behavior.rb +22 -0
- data/gm_behaviors/executables_behavior.rb +13 -0
- data/gm_behaviors/general_behavior.rb +41 -0
- data/gm_behaviors/github_behavior.rb +11 -0
- data/gm_behaviors/gm_files_behavior.rb +13 -0
- data/gm_behaviors/lib_files_behavior.rb +10 -0
- data/gm_behaviors/rails_behavior.rb +11 -0
- data/gm_behaviors/rdoc_behavior.rb +34 -0
- data/gm_behaviors/rspec_behavior.rb +10 -0
- data/gm_behaviors/rubigen_behavior.rb +13 -0
- data/gm_behaviors/rubyforge_behavior.rb +12 -0
- data/gm_behaviors/test_behavior.rb +10 -0
- data/gm_behaviors/text_files_behavior.rb +10 -0
- data/gm_commands/build_command.rb +25 -0
- data/gm_commands/build_gemspec_command.rb +35 -0
- data/gm_commands/clean_command.rb +14 -0
- data/gm_commands/config_command.rb +42 -0
- data/gm_commands/create_command.rb +10 -0
- data/gm_commands/gen_command.rb +31 -0
- data/gm_commands/help_command.rb +246 -0
- data/gm_commands/install_command.rb +17 -0
- data/gm_commands/publish_command.rb +33 -0
- data/gm_commands/spec_command.rb +14 -0
- data/gm_generators/bin/bin_generator.rb +22 -0
- data/gm_generators/bin/templates/bin/bin.rb +3 -0
- data/gm_generators/gem/gem_generator.rb +38 -0
- data/gm_generators/gem/templates/Gmfile +4 -0
- data/gm_generators/gem/templates/README.textile +0 -0
- data/gm_generators/gem/templates/lib/module.rb +4 -0
- data/gm_generators/mit_license/mit_license_generator.rb +17 -0
- data/gm_generators/mit_license/templates/LICENSE.txt +22 -0
- data/gm_generators/rails/rails_generator.rb +18 -0
- data/gm_generators/rails/templates/rails/init.rb +1 -0
- data/gm_generators/test/templates/test_case.rb.erb +5 -0
- data/gm_generators/test/templates/test_helper.rb.erb +7 -0
- data/gm_generators/test/test_generator.rb +26 -0
- data/gm_networks/github_network.rb +72 -0
- data/gm_networks/rubyforge_network.rb +90 -0
- data/lib/autotest/discover.rb +3 -0
- data/lib/autotest/gm.rb +37 -0
- data/lib/extentions/gem.rb +27 -0
- data/lib/gm.rb +30 -0
- data/lib/gm/app.rb +108 -0
- data/lib/gm/behavior.rb +23 -0
- data/lib/gm/command.rb +70 -0
- data/lib/gm/configuration.rb +20 -0
- data/lib/gm/documentation.rb +38 -0
- data/lib/gm/helpers.rb +20 -0
- data/lib/gm/loader.rb +84 -0
- data/lib/gm/network.rb +29 -0
- data/lib/gm/system.rb +16 -0
- data/test/command_test.rb +106 -0
- data/test/gem_extentions_test.rb +31 -0
- data/test/system_test.rb +17 -0
- data/test/test_helper.rb +12 -0
- metadata +159 -0
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) <%= DateTime.now.year %> <%= EC.store.config[:author][:name] %>
|
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,18 @@
|
|
1
|
+
|
2
|
+
class RailsGenerator < RubiGen::Base
|
3
|
+
|
4
|
+
def initialize(runtime_args, runtime_options = {})
|
5
|
+
super
|
6
|
+
@destination_root = '.'
|
7
|
+
end
|
8
|
+
|
9
|
+
def manifest
|
10
|
+
record do |m|
|
11
|
+
m.directory ''
|
12
|
+
m.directory 'rails'
|
13
|
+
|
14
|
+
m.template "rails/init.rb", "rails/init.rb"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
# initialize your rails plugin here
|
@@ -0,0 +1,26 @@
|
|
1
|
+
if defined?(RubiGen::Base)
|
2
|
+
|
3
|
+
class TestGenerator < RubiGen::Base
|
4
|
+
|
5
|
+
attr_reader :file_name, :test_case_name
|
6
|
+
|
7
|
+
def initialize(runtime_args, runtime_options = {})
|
8
|
+
super
|
9
|
+
@destination_root = '.'
|
10
|
+
@file_name = args.shift
|
11
|
+
@test_case_name = file_name.camelize unless @file_name.nil?
|
12
|
+
end
|
13
|
+
|
14
|
+
def manifest
|
15
|
+
record do |m|
|
16
|
+
m.directory ''
|
17
|
+
%w( test ).each { |path| m.directory path }
|
18
|
+
|
19
|
+
m.template "test_helper.rb.erb", "test/test_helper.rb" unless File.exist? "test/test_helper.rb"
|
20
|
+
m.template "test_case.rb.erb", "test/#{@file_name}_test.rb" unless @file_name.nil?
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end # if defined?(RubiGen::Base)
|
@@ -0,0 +1,72 @@
|
|
1
|
+
|
2
|
+
class GithubNetwork < GM::Network
|
3
|
+
|
4
|
+
desc "push new releases to GitHub"
|
5
|
+
doc <<-DOC
|
6
|
+
This will dump the .gemspec file, create a new (optonaly signed) tag and push the master branch to github.
|
7
|
+
DOC
|
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
|
+
|
31
|
+
def publish
|
32
|
+
commit_gemspec
|
33
|
+
make_tag
|
34
|
+
push_to_github
|
35
|
+
end
|
36
|
+
|
37
|
+
def published_versions
|
38
|
+
versions = %x[ git tag -l ].split(/\n/)
|
39
|
+
versions = versions.select do |version|
|
40
|
+
version =~ /v\d+\.\d+\.\d+/
|
41
|
+
end
|
42
|
+
versions.collect! do |version|
|
43
|
+
version.strip.sub(/^v/, '')
|
44
|
+
end
|
45
|
+
versions
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def make_tag
|
51
|
+
version = config[:general][:version]
|
52
|
+
key = config[:gpg][:key] if config[:gpg]
|
53
|
+
signing_options = if key.nil?
|
54
|
+
"-a"
|
55
|
+
else
|
56
|
+
"-u '#{key}'"
|
57
|
+
end
|
58
|
+
sh %{ git tag -m "Version #{version}" #{signing_options} 'v#{version}' HEAD }
|
59
|
+
end
|
60
|
+
|
61
|
+
def commit_gemspec
|
62
|
+
version = config[:general][:version]
|
63
|
+
GM::Command.run(:spec)
|
64
|
+
sh %{ git ci -m "Bumped to version #{version}" -o "#{app.gemspec.name}.gemspec" -o "Gmfile" }
|
65
|
+
end
|
66
|
+
|
67
|
+
def push_to_github
|
68
|
+
sh %{ git push origin master },
|
69
|
+
%{ git push --tags }
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
@@ -0,0 +1,90 @@
|
|
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
|
+
rubyforge.conf(:package) do |s|
|
15
|
+
s.should_be_a String
|
16
|
+
s.should_not_be_empty
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
def publish
|
24
|
+
prepare
|
25
|
+
version = config[:general][:version]
|
26
|
+
GM::Command.run(:build, ['-E'])
|
27
|
+
sh "rubyforge add_release #{group_id} #{package_id} #{version} pkg/#{app.gem_file_name}"
|
28
|
+
end
|
29
|
+
|
30
|
+
def published_versions
|
31
|
+
prepare
|
32
|
+
if rubyforge_info['release_ids'][package_name]
|
33
|
+
rubyforge_info['release_ids'][package_name].keys
|
34
|
+
else
|
35
|
+
[]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def rubyforge_info(reset=false)
|
42
|
+
@rubyforge_info = nil if reset
|
43
|
+
@rubyforge_info ||= YAML.load_file(File.expand_path('~/.rubyforge/auto-config.yml'))
|
44
|
+
end
|
45
|
+
|
46
|
+
def project_name
|
47
|
+
if config[:rubyforge]
|
48
|
+
config[:rubyforge][:project]
|
49
|
+
else
|
50
|
+
config[:general][:name]
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def package_name
|
55
|
+
if config[:rubyforge] and config[:rubyforge][:package]
|
56
|
+
config[:rubyforge][:package]
|
57
|
+
else
|
58
|
+
config[:general][:name]
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def group_id
|
63
|
+
@group_id ||= rubyforge_info['group_ids'][project_name]
|
64
|
+
end
|
65
|
+
|
66
|
+
def package_id
|
67
|
+
@package_id ||= rubyforge_info['package_ids'][package_name]
|
68
|
+
end
|
69
|
+
|
70
|
+
def prepare
|
71
|
+
unless @prepared
|
72
|
+
login
|
73
|
+
create_package
|
74
|
+
@prepared = true
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def login
|
79
|
+
sh "rubyforge login",
|
80
|
+
"rubyforge config"
|
81
|
+
end
|
82
|
+
|
83
|
+
def create_package
|
84
|
+
unless rubyforge_info['package_ids'].include? package_name
|
85
|
+
sh "rubyforge create_package #{group_id} #{package_name}"
|
86
|
+
rubyforge_info(true)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
data/lib/autotest/gm.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'autotest'
|
2
|
+
|
3
|
+
class Autotest # :nodoc:
|
4
|
+
|
5
|
+
class Gm < Autotest # :nodoc:
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
super
|
9
|
+
|
10
|
+
add_exception %r%^\./(?:doc|pkg)%
|
11
|
+
|
12
|
+
clear_mappings
|
13
|
+
|
14
|
+
self.add_mapping(/^lib\/.*\.rb$/) do |filename, _|
|
15
|
+
impl = File.basename(filename, '.rb')
|
16
|
+
files_matching %r%^test/#{impl}_test.rb$%
|
17
|
+
end
|
18
|
+
|
19
|
+
add_mapping %r%^test/.*rb$% do |filename, _|
|
20
|
+
filename
|
21
|
+
end
|
22
|
+
|
23
|
+
add_mapping %r%^test/test_helper.rb% do
|
24
|
+
files_matching %r%^test/.*_test\.rb$%
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def path_to_classname(s)
|
29
|
+
sep = File::SEPARATOR
|
30
|
+
f = s.sub(/^test#{sep}/, '').sub(/\.rb$/, '').split(sep)
|
31
|
+
f = f.map { |path| path.split(/_/).map { |seg| seg.capitalize }.join }
|
32
|
+
f = f.map { |path| path =~ /Test$/ ? path : "#{path}Test" }
|
33
|
+
f.join('::')
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
@@ -0,0 +1,27 @@
|
|
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
ADDED
@@ -0,0 +1,30 @@
|
|
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'
|
data/lib/gm/app.rb
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
|
2
|
+
module GM
|
3
|
+
|
4
|
+
class App
|
5
|
+
include Singleton
|
6
|
+
|
7
|
+
attr_accessor :configuration_passes
|
8
|
+
attr_accessor :gemspec
|
9
|
+
attr_accessor :emulate
|
10
|
+
attr_accessor :gem_file_name
|
11
|
+
attr_accessor :log_level
|
12
|
+
|
13
|
+
def initialize # :nodoc:
|
14
|
+
@log_level = :normal
|
15
|
+
reset!
|
16
|
+
end
|
17
|
+
|
18
|
+
# reset the app
|
19
|
+
def reset!
|
20
|
+
@configuration_passes = Hash.new { |h, k| h[k] = {} }
|
21
|
+
GM::Command.commands.clear
|
22
|
+
GM::Network.networks.clear
|
23
|
+
end
|
24
|
+
|
25
|
+
# exclude a pass from the configuration fase
|
26
|
+
def exclude_pass(name, fase=:normal)
|
27
|
+
@configuration_passes[fase.to_sym].delete(name.to_sym)
|
28
|
+
end
|
29
|
+
|
30
|
+
# extra options provided by the app.
|
31
|
+
def extra_options(options)
|
32
|
+
options.flag 'v', 'verbose', :desc => 'Print more information.'
|
33
|
+
options.flag 'd', 'debug', :desc => 'Print debugging information.'
|
34
|
+
end
|
35
|
+
|
36
|
+
# run the app
|
37
|
+
def run
|
38
|
+
load_behaviors
|
39
|
+
load_commands
|
40
|
+
load_networks
|
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
|
+
# should we emulate github?
|
59
|
+
def self.emulate?
|
60
|
+
instance.emulate || false
|
61
|
+
end
|
62
|
+
|
63
|
+
def log(msg)
|
64
|
+
puts msg
|
65
|
+
end
|
66
|
+
|
67
|
+
def info(msg)
|
68
|
+
puts msg if log_level == :verbose
|
69
|
+
end
|
70
|
+
|
71
|
+
def debug(msg)
|
72
|
+
puts msg if log_level == :verbose or log_level == :debug
|
73
|
+
end
|
74
|
+
|
75
|
+
private
|
76
|
+
|
77
|
+
# load all behaviors
|
78
|
+
def load_behaviors
|
79
|
+
find_paths('gm_behaviors/*_behavior.rb').each do |path|
|
80
|
+
GM::Behavior.load_behavior path
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
# load all networks
|
85
|
+
def load_networks
|
86
|
+
find_paths('gm_networks/*_network.rb').each do |path|
|
87
|
+
GM::Network.load_network path
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
# load all commands
|
92
|
+
def load_commands
|
93
|
+
find_paths('gm_commands/*_command.rb').each do |path|
|
94
|
+
GM::Command.load_command path
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def find_paths(pattern)
|
99
|
+
if File.exist? 'gm.gemspec'
|
100
|
+
Dir.glob(pattern).uniq
|
101
|
+
else
|
102
|
+
Gem.find_recent_resources(pattern).uniq
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|