merb-gen 1.0.15 → 1.1.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +59 -69
- data/bin/merb-gen +14 -2
- data/lib/generators/fcgi.rb +16 -0
- data/lib/generators/merb/merb_core.rb +14 -12
- data/lib/generators/merb/merb_flat.rb +11 -6
- data/lib/generators/merb/merb_stack.rb +14 -22
- data/lib/generators/merb/merb_very_flat.rb +32 -11
- data/lib/generators/passenger.rb +15 -0
- data/lib/generators/resource_controller.rb +1 -1
- data/lib/generators/templates/application/common/Gemfile +12 -0
- data/lib/generators/templates/application/common/Rakefile +10 -1
- data/lib/generators/templates/application/common/dotgitignore +3 -3
- data/lib/generators/templates/application/common/merb +20 -0
- data/lib/generators/templates/application/merb_core/autotest/merb_rspec.rb +9 -9
- data/lib/generators/templates/application/merb_core/config/init.rb +3 -5
- data/lib/generators/templates/application/merb_core/spec/spec.opts +1 -1
- data/lib/generators/templates/application/merb_core/spec/spec_helper.rb +9 -7
- data/lib/generators/templates/application/merb_core/test/test_helper.rb +9 -7
- data/lib/generators/templates/application/merb_flat/application.rbt +3 -0
- data/lib/generators/templates/application/merb_flat/config/init.rb +23 -19
- data/lib/generators/templates/application/merb_flat/spec/spec_helper.rb +8 -6
- data/lib/generators/templates/application/merb_flat/test/test_helper.rb +9 -7
- data/lib/generators/templates/application/merb_plugin/Rakefile +35 -4
- data/lib/generators/templates/application/merb_stack/Gemfile +48 -0
- data/lib/generators/templates/application/merb_stack/autotest/merb_rspec.rb +7 -7
- data/lib/generators/templates/application/merb_stack/config/init.rb +2 -2
- data/lib/generators/templates/application/merb_stack/config.ru +23 -0
- data/lib/generators/templates/application/merb_stack/spec/spec.opts +1 -1
- data/lib/generators/templates/application/merb_stack/spec/spec_helper.rb +9 -7
- data/lib/generators/templates/application/merb_stack/test/test_helper.rb +9 -7
- data/lib/generators/templates/application/merb_very_flat/application.rbt +1 -8
- data/lib/generators/templates/application/merb_very_flat/spec/spec_helper.rb +8 -6
- data/lib/generators/templates/application/merb_very_flat/test/test_helper.rb +9 -7
- data/lib/generators/templates/{application/common → component/fcgi}/dothtaccess +1 -2
- data/lib/generators/templates/{application/merb_stack/public → component/fcgi}/merb.fcgi +10 -4
- data/lib/generators/templates/component/model/spec/models/%file_name%_spec.rb +1 -1
- data/lib/merb-gen/app_generator.rb +58 -0
- data/lib/merb-gen/generator.rb +1 -1
- data/lib/merb-gen/version.rb +17 -0
- data/lib/merb-gen.rb +27 -25
- data/spec/controller_spec.rb +1 -1
- data/spec/fcgi_spec.rb +24 -0
- data/spec/generator_spec.rb +1 -1
- data/spec/layout_spec.rb +1 -1
- data/spec/merb_core_spec.rb +17 -5
- data/spec/merb_flat_spec.rb +10 -1
- data/spec/merb_plugin_spec.rb +3 -3
- data/spec/merb_stack_spec.rb +23 -10
- data/spec/merb_very_flat_spec.rb +13 -2
- data/spec/migration_spec.rb +1 -1
- data/spec/model_spec.rb +1 -1
- data/spec/named_generator_spec.rb +1 -1
- data/spec/namespaced_generator_spec.rb +1 -1
- data/spec/part_controller_spec.rb +1 -1
- data/spec/passenger_spec.rb +20 -0
- data/spec/resource_controller_spec.rb +1 -1
- data/spec/resource_spec.rb +1 -1
- data/spec/session_migration_spec.rb +1 -1
- data/spec/spec.opts +2 -0
- data/spec/spec_helper.rb +53 -4
- metadata +78 -45
- data/lib/generators/templates/application/common/doc.thor +0 -149
- data/lib/generators/templates/application/common/merb_thor/app_script.rb +0 -31
- data/lib/generators/templates/application/common/merb_thor/common.rb +0 -68
- data/lib/generators/templates/application/common/merb_thor/gem_ext.rb +0 -125
- data/lib/generators/templates/application/common/merb_thor/main.thor +0 -151
- data/lib/generators/templates/application/common/merb_thor/ops.rb +0 -93
- data/lib/generators/templates/application/common/merb_thor/utils.rb +0 -40
- data/lib/generators/templates/application/merb_core/public/merb.fcgi +0 -22
- data/lib/generators/templates/application/merb_stack/config/dependencies.rb +0 -34
- data/lib/generators/thor.rb +0 -33
@@ -1,149 +0,0 @@
|
|
1
|
-
$: << File.join("doc")
|
2
|
-
require 'rubygems'
|
3
|
-
require 'rdoc/rdoc'
|
4
|
-
require 'fileutils'
|
5
|
-
require 'erb'
|
6
|
-
|
7
|
-
module Merb
|
8
|
-
|
9
|
-
class GemNotFoundException < Exception
|
10
|
-
end
|
11
|
-
|
12
|
-
module DocMethods
|
13
|
-
def setup_gem_path
|
14
|
-
if File.directory?(gems_dir = File.join(File.dirname(__FILE__), 'gems'))
|
15
|
-
$BUNDLE = true; Gem.clear_paths; Gem.path.unshift(gems_dir)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def get_more
|
20
|
-
libs = []
|
21
|
-
more_library = find_library("merb-more")
|
22
|
-
File.open("#{more_library}/lib/merb-more.rb").read.each_line do |line|
|
23
|
-
if line['require']
|
24
|
-
libs << line.gsub("require '", '').gsub("'\n", '')
|
25
|
-
end
|
26
|
-
end
|
27
|
-
return libs
|
28
|
-
end
|
29
|
-
|
30
|
-
def generate_documentation(file_list, destination, arguments = [])
|
31
|
-
output_dir = File.join("/../doc", "rdoc", destination)
|
32
|
-
FileUtils.rm_rf(output_dir)
|
33
|
-
|
34
|
-
arguments += [
|
35
|
-
"--fmt", "merb",
|
36
|
-
"--op", output_dir
|
37
|
-
]
|
38
|
-
RDoc::RDoc.new.document(arguments + file_list)
|
39
|
-
AdvancedDoc.new.index
|
40
|
-
end
|
41
|
-
|
42
|
-
def find_library(directory_snippet)
|
43
|
-
gem_dir = nil
|
44
|
-
Gem.path.find do |path|
|
45
|
-
dir = Dir.glob("#{path}/gems/#{directory_snippet}*")
|
46
|
-
dir.empty? ? false : gem_dir = dir.last
|
47
|
-
end
|
48
|
-
raise GemNotFoundException if gem_dir.nil?
|
49
|
-
return gem_dir
|
50
|
-
end
|
51
|
-
|
52
|
-
def get_file_list(directory_snippet)
|
53
|
-
gem_dir = find_library(directory_snippet)
|
54
|
-
files = Dir.glob("#{gem_dir}/**/lib/**/*.rb")
|
55
|
-
files += ["#{gem_dir}/README"] if File.exists?("#{gem_dir}/README")
|
56
|
-
return files
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
class AdvancedDoc < Thor
|
61
|
-
|
62
|
-
group 'core'
|
63
|
-
include DocMethods
|
64
|
-
|
65
|
-
def initialize
|
66
|
-
super
|
67
|
-
setup_gem_path
|
68
|
-
end
|
69
|
-
|
70
|
-
desc 'index', "Regenerate the index file for your framework documentation"
|
71
|
-
def index
|
72
|
-
@directories = Dir.entries(File.join(File.dirname(__FILE__) + "/../", "doc", "rdoc"))
|
73
|
-
@directories.delete(".")
|
74
|
-
@directories.delete("..")
|
75
|
-
@directories.delete("generators")
|
76
|
-
@directories.delete("index.html")
|
77
|
-
index_template = File.read(File.join("doc", "rdoc", "generators", "template", "merb", "index.html.erb"))
|
78
|
-
|
79
|
-
File.open(File.join("doc", "rdoc", "index.html"), "w") do |file|
|
80
|
-
file.write(ERB.new(index_template).result(binding))
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
desc 'plugins', 'Generate the rdoc for each merb-plugins seperatly'
|
85
|
-
def plugins
|
86
|
-
libs = ["merb_activerecord", "merb_builder", "merb_jquery", "merb_laszlo", "merb_parts", "merb_screw_unit", "merb_sequel", "merb_stories", "merb_test_unit"]
|
87
|
-
|
88
|
-
libs.each do |lib|
|
89
|
-
options[:gem] = lib
|
90
|
-
gem
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
desc 'more', 'Generate the rdoc for each merb-more gem seperatly'
|
95
|
-
def more
|
96
|
-
libs = get_more
|
97
|
-
libs.each do |lib|
|
98
|
-
options[:gem] = lib
|
99
|
-
gem
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
desc 'core', 'Generate the rdoc for merb-core'
|
104
|
-
def core
|
105
|
-
options[:gem] = "merb-core"
|
106
|
-
gem
|
107
|
-
end
|
108
|
-
|
109
|
-
desc 'gem', 'Generate the rdoc for a specific gem'
|
110
|
-
method_options "--gem" => :required
|
111
|
-
def gem
|
112
|
-
file_list = get_file_list(options[:gem])
|
113
|
-
readme = File.join(find_library("merb-core"), "README")
|
114
|
-
generate_documentation(file_list, options[:gem], ["-m", readme])
|
115
|
-
rescue GemNotFoundException
|
116
|
-
puts "Can not find the gem in the gem path #{options[:gem]}"
|
117
|
-
end
|
118
|
-
|
119
|
-
end
|
120
|
-
|
121
|
-
class Doc < Thor
|
122
|
-
|
123
|
-
include DocMethods
|
124
|
-
|
125
|
-
def initialize
|
126
|
-
super
|
127
|
-
setup_gem_path
|
128
|
-
|
129
|
-
end
|
130
|
-
|
131
|
-
desc 'stack', 'Generate the rdoc for merb-core, merb-more merged together'
|
132
|
-
def stack
|
133
|
-
libs = ["merb"]
|
134
|
-
|
135
|
-
file_list = []
|
136
|
-
libs.each do |gem_name|
|
137
|
-
begin
|
138
|
-
file_list += get_file_list(gem_name)
|
139
|
-
rescue GemNotFoundException
|
140
|
-
puts "Could not find #{gem_name} in #{Gem.path}. Continuing with out it."
|
141
|
-
end
|
142
|
-
end
|
143
|
-
readme = File.join(find_library("merb"), "README")
|
144
|
-
generate_documentation(file_list, "stack", ["-m", readme])
|
145
|
-
end
|
146
|
-
|
147
|
-
end
|
148
|
-
|
149
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
# This was added by Merb's bundler
|
4
|
-
|
5
|
-
require "rubygems"
|
6
|
-
require File.join(File.dirname(__FILE__), "common")
|
7
|
-
|
8
|
-
gems_dir = File.join(File.dirname(__FILE__), '..', 'gems')
|
9
|
-
|
10
|
-
if File.directory?(gems_dir)
|
11
|
-
$BUNDLE = true
|
12
|
-
Gem.clear_paths
|
13
|
-
Gem.path.replace([File.expand_path(gems_dir)])
|
14
|
-
ENV["PATH"] = "#{File.dirname(__FILE__)}:#{ENV["PATH"]}"
|
15
|
-
|
16
|
-
gem_file = File.join(gems_dir, "specifications", "<%= spec.name %>-*.gemspec")
|
17
|
-
|
18
|
-
if local_gem = Dir[gem_file].last
|
19
|
-
version = File.basename(local_gem)[/-([\.\d]+)\.gemspec$/, 1]
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
version ||= "<%= Gem::Requirement.default %>"
|
24
|
-
|
25
|
-
if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
|
26
|
-
version = $1
|
27
|
-
ARGV.shift
|
28
|
-
end
|
29
|
-
|
30
|
-
gem '<%= @spec.name %>', version
|
31
|
-
load '<%= bin_file_name %>'
|
@@ -1,68 +0,0 @@
|
|
1
|
-
# This was added via Merb's bundler
|
2
|
-
|
3
|
-
require "rubygems"
|
4
|
-
require "rubygems/source_index"
|
5
|
-
|
6
|
-
module Gem
|
7
|
-
BUNDLED_SPECS = File.join(Dir.pwd, "gems", "specifications")
|
8
|
-
MAIN_INDEX = Gem::SourceIndex.from_gems_in(BUNDLED_SPECS)
|
9
|
-
FALLBACK_INDEX = Gem::SourceIndex.from_installed_gems
|
10
|
-
|
11
|
-
def self.source_index
|
12
|
-
MultiSourceIndex.new
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.searcher
|
16
|
-
MultiPathSearcher.new
|
17
|
-
end
|
18
|
-
|
19
|
-
class ArbitrarySearcher < GemPathSearcher
|
20
|
-
def initialize(source_index)
|
21
|
-
@source_index = source_index
|
22
|
-
super()
|
23
|
-
end
|
24
|
-
|
25
|
-
def init_gemspecs
|
26
|
-
@source_index.map { |_, spec| spec }.sort { |a,b|
|
27
|
-
(a.name <=> b.name).nonzero? || (b.version <=> a.version)
|
28
|
-
}
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
class MultiPathSearcher
|
33
|
-
def initialize
|
34
|
-
@main_searcher = ArbitrarySearcher.new(MAIN_INDEX)
|
35
|
-
@fallback_searcher = ArbitrarySearcher.new(FALLBACK_INDEX)
|
36
|
-
end
|
37
|
-
|
38
|
-
def find(path)
|
39
|
-
try = @main_searcher.find(path)
|
40
|
-
return try if try
|
41
|
-
@fallback_searcher.find(path)
|
42
|
-
end
|
43
|
-
|
44
|
-
def find_all(path)
|
45
|
-
try = @main_searcher.find_all(path)
|
46
|
-
return try unless try.empty?
|
47
|
-
@fallback_searcher.find_all(path)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
class MultiSourceIndex
|
52
|
-
# Used by merb.thor to confirm; not needed when MSI is in use
|
53
|
-
def load_gems_in(*args)
|
54
|
-
end
|
55
|
-
|
56
|
-
def search(*args)
|
57
|
-
try = MAIN_INDEX.search(*args)
|
58
|
-
return try unless try.empty?
|
59
|
-
FALLBACK_INDEX.search(*args)
|
60
|
-
end
|
61
|
-
|
62
|
-
def find_name(*args)
|
63
|
-
try = MAIN_INDEX.find_name(*args)
|
64
|
-
return try unless try.empty?
|
65
|
-
FALLBACK_INDEX.find_name(*args)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
@@ -1,125 +0,0 @@
|
|
1
|
-
require "erb"
|
2
|
-
|
3
|
-
Gem.pre_install_hooks.push(proc do |installer|
|
4
|
-
unless File.file?(installer.bin_dir / "common.rb")
|
5
|
-
FileUtils.mkdir_p(installer.bin_dir)
|
6
|
-
FileUtils.cp(File.dirname(__FILE__) / "common.rb", installer.bin_dir / "common.rb")
|
7
|
-
end
|
8
|
-
|
9
|
-
include ColorfulMessages
|
10
|
-
name = installer.spec.name
|
11
|
-
if $GEMS && versions = ($GEMS.assoc(name) || [])[1]
|
12
|
-
dep = Gem::Dependency.new(name, versions)
|
13
|
-
unless dep.version_requirements.satisfied_by?(installer.spec.version)
|
14
|
-
error "Cannot install #{installer.spec.full_name} " \
|
15
|
-
"for #{$INSTALLING}; " \
|
16
|
-
"you required #{dep}"
|
17
|
-
::Thor::Tasks::Merb::Gem.rollback_trans
|
18
|
-
exit!
|
19
|
-
end
|
20
|
-
end
|
21
|
-
success "Installing #{installer.spec.full_name}"
|
22
|
-
end)
|
23
|
-
|
24
|
-
class ::Gem::Uninstaller
|
25
|
-
def self._with_silent_ui
|
26
|
-
|
27
|
-
ui = Gem::DefaultUserInteraction.ui
|
28
|
-
def ui.say(str)
|
29
|
-
puts "- #{str}"
|
30
|
-
end
|
31
|
-
|
32
|
-
yield
|
33
|
-
|
34
|
-
class << Gem::DefaultUserInteraction.ui
|
35
|
-
remove_method :say
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def self._uninstall(source_index, name, op, version)
|
40
|
-
unless source_index.find_name(name, "#{op} #{version}").empty?
|
41
|
-
uninstaller = Gem::Uninstaller.new(
|
42
|
-
name,
|
43
|
-
:version => "#{op} #{version}",
|
44
|
-
:install_dir => Dir.pwd / "gems",
|
45
|
-
:all => true,
|
46
|
-
:ignore => true
|
47
|
-
)
|
48
|
-
_with_silent_ui { uninstaller.uninstall }
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def self._uninstall_others(source_index, name, version)
|
53
|
-
_uninstall(source_index, name, "<", version)
|
54
|
-
_uninstall(source_index, name, ">", version)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
Gem.post_install_hooks.push(proc do |installer|
|
59
|
-
source_index = installer.instance_variable_get("@source_index")
|
60
|
-
::Gem::Uninstaller._uninstall_others(
|
61
|
-
source_index, installer.spec.name, installer.spec.version
|
62
|
-
)
|
63
|
-
end)
|
64
|
-
|
65
|
-
class ::Gem::DependencyInstaller
|
66
|
-
alias old_fg find_gems_with_sources
|
67
|
-
|
68
|
-
def find_gems_with_sources(dep)
|
69
|
-
if @source_index.any? { |_, installed_spec|
|
70
|
-
installed_spec.satisfies_requirement?(dep)
|
71
|
-
}
|
72
|
-
return []
|
73
|
-
end
|
74
|
-
|
75
|
-
old_fg(dep)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
class ::Gem::SpecFetcher
|
80
|
-
alias old_fetch fetch
|
81
|
-
def fetch(dependency, all = false, matching_platform = true, prerelease = false)
|
82
|
-
idx = Gem::SourceIndex.from_installed_gems
|
83
|
-
|
84
|
-
reqs = dependency.version_requirements.requirements
|
85
|
-
|
86
|
-
if reqs.size == 1 && reqs[0][0] == "="
|
87
|
-
dep = idx.search(dependency).sort.last
|
88
|
-
end
|
89
|
-
|
90
|
-
if dep
|
91
|
-
file = dep.loaded_from.dup
|
92
|
-
file.gsub!(/specifications/, "cache")
|
93
|
-
file.gsub!(/gemspec$/, "gem")
|
94
|
-
spec = ::Gem::Format.from_file_by_path(file).spec
|
95
|
-
[[spec, file]]
|
96
|
-
else
|
97
|
-
old_fetch(dependency, all, matching_platform)
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
class ::Gem::Installer
|
103
|
-
def app_script_text(bin_file_name)
|
104
|
-
template = File.read(File.dirname(__FILE__) / "app_script.rb")
|
105
|
-
erb = ERB.new(template)
|
106
|
-
erb.result(binding)
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
class ::Gem::Specification
|
111
|
-
def recursive_dependencies(from, index = Gem.source_index)
|
112
|
-
specs = self.runtime_dependencies.map do |dep|
|
113
|
-
spec = index.search(dep).last
|
114
|
-
unless spec
|
115
|
-
from_name = from.is_a?(::Gem::Specification) ? from.full_name : from.to_s
|
116
|
-
wider_net = index.find_name(dep.name).last
|
117
|
-
ThorUI.error "Needed #{dep} for #{from_name}, but could not find it"
|
118
|
-
ThorUI.error "Found #{wider_net.full_name}" if wider_net
|
119
|
-
::Thor::Tasks::Merb::Gem.rollback_trans
|
120
|
-
end
|
121
|
-
spec
|
122
|
-
end
|
123
|
-
specs + specs.map {|s| s.recursive_dependencies(self, index)}.flatten.uniq
|
124
|
-
end
|
125
|
-
end
|
@@ -1,151 +0,0 @@
|
|
1
|
-
require "rubygems"
|
2
|
-
require "rubygems/source_index"
|
3
|
-
require "rubygems/dependency_installer"
|
4
|
-
require "rubygems/uninstaller"
|
5
|
-
require "fileutils"
|
6
|
-
require File.join(File.dirname(__FILE__), "utils")
|
7
|
-
require File.join(File.dirname(__FILE__), "gem_ext")
|
8
|
-
require File.join(File.dirname(__FILE__), "ops")
|
9
|
-
|
10
|
-
$INSTALLING = []
|
11
|
-
|
12
|
-
module Merb
|
13
|
-
|
14
|
-
class Gem < Thor
|
15
|
-
extend ColorfulMessages
|
16
|
-
|
17
|
-
def initialize
|
18
|
-
dirs = [Dir.pwd, File.dirname(__FILE__) / ".."]
|
19
|
-
root = dirs.find {|d| File.file?(d / "config" / "dependencies.rb")}
|
20
|
-
|
21
|
-
if root
|
22
|
-
@depsrb = root / "config" / "dependencies.rb"
|
23
|
-
else
|
24
|
-
self.class.error "dependencies.rb was not found"
|
25
|
-
exit!
|
26
|
-
end
|
27
|
-
|
28
|
-
FileUtils.mkdir_p(Dir.pwd / "gems")
|
29
|
-
|
30
|
-
@list = Collector.collect(File.read(@depsrb))
|
31
|
-
@idx = ::Gem::SourceIndex.new.load_gems_in("gems/specifications")
|
32
|
-
end
|
33
|
-
|
34
|
-
def list
|
35
|
-
require "pp"
|
36
|
-
pp @list
|
37
|
-
end
|
38
|
-
|
39
|
-
desc "redeploy", "Syncs up gems/cache with gems/gems. All gems in the cache " \
|
40
|
-
"that are not already installed will be installed from the " \
|
41
|
-
"cache. All installed gems that are not in the cache will " \
|
42
|
-
"be uninstalled."
|
43
|
-
def redeploy
|
44
|
-
gem_dir = Dir.pwd / "gems" / "gems"
|
45
|
-
cache_dir = Dir.pwd / "gems" / "cache"
|
46
|
-
|
47
|
-
gems = Dir[gem_dir / "*"].map! {|n| File.basename(n)}
|
48
|
-
cache = Dir[cache_dir / "*.gem"].map! {|n| File.basename(n, ".gem")}
|
49
|
-
new_gems = cache - gems
|
50
|
-
outdated = gems - cache
|
51
|
-
idx = ::Gem::SourceIndex.new
|
52
|
-
idx.load_gems_in(Dir.pwd / "gems" / "specifications")
|
53
|
-
|
54
|
-
new_gems.each do |g|
|
55
|
-
installer = ::Gem::Installer.new(cache_dir / "#{g}.gem",
|
56
|
-
:bin_dir => Dir.pwd / "bin",
|
57
|
-
:install_dir => Dir.pwd / "gems",
|
58
|
-
:ignore_dependencies => true,
|
59
|
-
:user_install => false,
|
60
|
-
:wrappers => true,
|
61
|
-
:source_index => idx)
|
62
|
-
|
63
|
-
installer.install
|
64
|
-
end
|
65
|
-
|
66
|
-
outdated.each do |g|
|
67
|
-
/(.*)\-(.*)/ =~ g
|
68
|
-
name, version = $1, $2
|
69
|
-
uninstaller = ::Gem::Uninstaller.new(name,
|
70
|
-
:version => version,
|
71
|
-
:bin_dir => Dir.pwd / "bin",
|
72
|
-
:install_dir => Dir.pwd / "gems",
|
73
|
-
:ignore => true,
|
74
|
-
:executables => true
|
75
|
-
)
|
76
|
-
uninstaller.uninstall
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
desc "confirm", "Confirm the current setup. merb:gem:install will " \
|
81
|
-
"automatically run this task before committing the " \
|
82
|
-
"changes it makes."
|
83
|
-
def confirm(gems = @list)
|
84
|
-
::Gem.path.replace([Dir.pwd / "gems"])
|
85
|
-
::Gem.source_index.load_gems_in(Dir.pwd / "gems" / "specifications")
|
86
|
-
|
87
|
-
self.class.info "Confirming configuration..."
|
88
|
-
|
89
|
-
::Gem.loaded_specs.clear
|
90
|
-
|
91
|
-
begin
|
92
|
-
gems.each do |name, versions|
|
93
|
-
versions ||= []
|
94
|
-
::Gem.activate name, *versions
|
95
|
-
end
|
96
|
-
rescue ::Gem::LoadError => e
|
97
|
-
self.class.error "Configuration could not be confirmed: #{e.message}"
|
98
|
-
# Don't rollback since its possibly the confirmation is just broken
|
99
|
-
# self.class.rollback_trans
|
100
|
-
end
|
101
|
-
self.class.info "Confirmed"
|
102
|
-
end
|
103
|
-
|
104
|
-
desc 'install', 'Sync up your bundled gems with the list in config/dependencies.rb'
|
105
|
-
def install(*gems)
|
106
|
-
if gems.empty?
|
107
|
-
gems = @list
|
108
|
-
else
|
109
|
-
gems = gems.map {|desc| name, *versions = desc.split(" ") }
|
110
|
-
end
|
111
|
-
|
112
|
-
$GEMS = gems
|
113
|
-
|
114
|
-
self.class.begin_trans
|
115
|
-
|
116
|
-
gems.each do |name, versions|
|
117
|
-
dep = ::Gem::Dependency.new(name, versions || [])
|
118
|
-
unless @idx.search(dep).empty?
|
119
|
-
next
|
120
|
-
end
|
121
|
-
|
122
|
-
rescue_failures do
|
123
|
-
$INSTALLING = dep
|
124
|
-
_install(dep)
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
gem_dir = Dir.pwd / "gems" / "gems"
|
129
|
-
installed_gems = Dir[gem_dir / "*"].map! {|n| File.basename(n)}
|
130
|
-
|
131
|
-
list = full_list.map {|x| x.full_name}.compact
|
132
|
-
|
133
|
-
(installed_gems - list).each do |g|
|
134
|
-
/^(.*)\-(.*)$/ =~ g
|
135
|
-
name, version = $1, $2
|
136
|
-
uninstaller = ::Gem::Uninstaller.new(name,
|
137
|
-
:version => version,
|
138
|
-
:bin_dir => (Dir.pwd / "bin").to_s,
|
139
|
-
:install_dir => (Dir.pwd / "gems").to_s,
|
140
|
-
:ignore => true,
|
141
|
-
:executables => true
|
142
|
-
)
|
143
|
-
uninstaller.uninstall
|
144
|
-
end
|
145
|
-
|
146
|
-
confirm(gems)
|
147
|
-
|
148
|
-
self.class.commit_trans
|
149
|
-
end
|
150
|
-
end
|
151
|
-
end
|
@@ -1,93 +0,0 @@
|
|
1
|
-
module Thor::Tasks
|
2
|
-
module Merb
|
3
|
-
class Collector
|
4
|
-
attr_reader :dependencies
|
5
|
-
|
6
|
-
def self.collect(str)
|
7
|
-
collector = new
|
8
|
-
collector.instance_eval(str)
|
9
|
-
collector.dependencies
|
10
|
-
end
|
11
|
-
|
12
|
-
def initialize
|
13
|
-
@dependencies = []
|
14
|
-
end
|
15
|
-
|
16
|
-
def dependency(name, *versions)
|
17
|
-
versions.pop if versions.last.is_a?(Hash)
|
18
|
-
@dependencies << [name, versions]
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
class Gem < Thor
|
23
|
-
def full_list
|
24
|
-
@idx.load_gems_in("gems/specifications")
|
25
|
-
|
26
|
-
@list.map do |name, versions|
|
27
|
-
dep = ::Gem::Dependency.new(name, versions)
|
28
|
-
spec = @idx.search(dep).last
|
29
|
-
unless spec
|
30
|
-
self.class.error "A required dependency #{dep} was not found"
|
31
|
-
self.class.rollback_trans
|
32
|
-
end
|
33
|
-
deps = spec.recursive_dependencies(dep, @idx)
|
34
|
-
[spec] + deps
|
35
|
-
end.flatten.uniq
|
36
|
-
end
|
37
|
-
|
38
|
-
def rescue_failures(error = StandardError, prc = nil)
|
39
|
-
begin
|
40
|
-
yield
|
41
|
-
rescue error => e
|
42
|
-
if prc
|
43
|
-
prc.call(e)
|
44
|
-
else
|
45
|
-
puts e.message
|
46
|
-
puts e.backtrace
|
47
|
-
end
|
48
|
-
self.class.rollback_trans
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def self.begin_trans
|
53
|
-
note "Beginning transaction"
|
54
|
-
FileUtils.cp_r(Dir.pwd / "gems", Dir.pwd / ".original_gems")
|
55
|
-
end
|
56
|
-
|
57
|
-
def self.commit_trans
|
58
|
-
note "Committing transaction"
|
59
|
-
FileUtils.rm_rf(Dir.pwd / ".original_gems")
|
60
|
-
end
|
61
|
-
|
62
|
-
def self.rollback_trans
|
63
|
-
if File.exist?(Dir.pwd / ".original_gems")
|
64
|
-
note "Rolling back transaction"
|
65
|
-
FileUtils.rm_rf(Dir.pwd / "gems")
|
66
|
-
FileUtils.mv(Dir.pwd / ".original_gems", Dir.pwd / "gems")
|
67
|
-
end
|
68
|
-
exit!
|
69
|
-
end
|
70
|
-
|
71
|
-
private
|
72
|
-
def _install(dep)
|
73
|
-
@idx.load_gems_in("gems/specifications")
|
74
|
-
return if @idx.search(dep).last
|
75
|
-
|
76
|
-
installer = ::Gem::DependencyInstaller.new(
|
77
|
-
:bin_dir => Dir.pwd / "bin",
|
78
|
-
:install_dir => Dir.pwd / "gems",
|
79
|
-
:user_install => false)
|
80
|
-
|
81
|
-
begin
|
82
|
-
installer.install dep.name, dep.version_requirements
|
83
|
-
rescue ::Gem::GemNotFoundException => e
|
84
|
-
puts "Cannot find #{dep}"
|
85
|
-
rescue ::Gem::RemoteFetcher::FetchError => e
|
86
|
-
puts e.message
|
87
|
-
puts "Retrying..."
|
88
|
-
retry
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
class String
|
2
|
-
def /(other)
|
3
|
-
(Pathname.new(self) + other).to_s
|
4
|
-
end
|
5
|
-
end
|
6
|
-
|
7
|
-
module ColorfulMessages
|
8
|
-
|
9
|
-
# red
|
10
|
-
def error(*messages)
|
11
|
-
puts messages.map { |msg| "\033[1;31m#{msg}\033[0m" }
|
12
|
-
end
|
13
|
-
|
14
|
-
# yellow
|
15
|
-
def warning(*messages)
|
16
|
-
puts messages.map { |msg| "\033[1;33m#{msg}\033[0m" }
|
17
|
-
end
|
18
|
-
|
19
|
-
# green
|
20
|
-
def success(*messages)
|
21
|
-
puts messages.map { |msg| "\033[1;32m#{msg}\033[0m" }
|
22
|
-
end
|
23
|
-
|
24
|
-
alias_method :message, :success
|
25
|
-
|
26
|
-
# magenta
|
27
|
-
def note(*messages)
|
28
|
-
puts messages.map { |msg| "\033[1;35m#{msg}\033[0m" }
|
29
|
-
end
|
30
|
-
|
31
|
-
# blue
|
32
|
-
def info(*messages)
|
33
|
-
puts messages.map { |msg| "\033[1;34m#{msg}\033[0m" }
|
34
|
-
end
|
35
|
-
|
36
|
-
end
|
37
|
-
|
38
|
-
module ThorUI
|
39
|
-
extend ColorfulMessages
|
40
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require 'merb-core'
|
5
|
-
|
6
|
-
# this is Merb.root, change this if you have some funky setup.
|
7
|
-
merb_root = File.expand_path(File.dirname(__FILE__) / '../')
|
8
|
-
|
9
|
-
# If the fcgi process runs as apache, make sure
|
10
|
-
# we have an inlinedir set for Rubyinline action-args to work
|
11
|
-
unless ENV["INLINEDIR"] || ENV["HOME"]
|
12
|
-
tmpdir = merb_root / "tmp"
|
13
|
-
unless File.directory?(tmpdir)
|
14
|
-
Dir.mkdir(tmpdir)
|
15
|
-
end
|
16
|
-
ENV["INLINEDIR"] = tmpdir
|
17
|
-
end
|
18
|
-
|
19
|
-
# start merb with the fcgi adapter, add options or change the log dir here
|
20
|
-
Merb.start(:adapter => 'fcgi',
|
21
|
-
:merb_root => merb_root,
|
22
|
-
:log_file => merb_root /'log'/'merb.log')
|