merb-slices 0.9.5 → 0.9.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +4 -4
- data/TODO +2 -0
- data/lib/generators/base.rb +6 -5
- data/lib/generators/templates/common/lib/%base_name%/merbtasks.rb +3 -6
- data/lib/merb-slices/merbtasks.rb +44 -0
- data/lib/merb-slices/module.rb +8 -2
- data/lib/merb-slices/router_ext.rb +1 -1
- data/spec/full_slice_generator_spec.rb +0 -2
- data/spec/slice_generator_spec.rb +3 -14
- data/spec/thin_slice_generator_spec.rb +0 -2
- data/spec/very_thin_slice_generator_spec.rb +0 -2
- metadata +3 -3
data/Rakefile
CHANGED
@@ -17,7 +17,7 @@ GEM_EMAIL = "info@fabien.be"
|
|
17
17
|
|
18
18
|
GEM_NAME = "merb-slices"
|
19
19
|
PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
|
20
|
-
GEM_VERSION = (Merb::MORE_VERSION rescue "0.9.
|
20
|
+
GEM_VERSION = (Merb::MORE_VERSION rescue "0.9.6") + PKG_BUILD
|
21
21
|
|
22
22
|
RELEASE_NAME = "REL #{GEM_VERSION}"
|
23
23
|
|
@@ -35,7 +35,7 @@ spec = Gem::Specification.new do |s|
|
|
35
35
|
s.author = GEM_AUTHOR
|
36
36
|
s.email = GEM_EMAIL
|
37
37
|
s.homepage = PROJECT_URL
|
38
|
-
s.add_dependency('merb-core', '>= 0.9.
|
38
|
+
s.add_dependency('merb-core', '>= 0.9.6')
|
39
39
|
s.require_path = 'lib'
|
40
40
|
s.files = %w(LICENSE README Rakefile Generators TODO) + Dir.glob("{lib,spec}/**/*")
|
41
41
|
end
|
@@ -46,14 +46,14 @@ end
|
|
46
46
|
|
47
47
|
desc "Install the gem"
|
48
48
|
task :install => [:package] do
|
49
|
-
sh
|
49
|
+
sh install_command(GEM_NAME, GEM_VERSION)
|
50
50
|
end
|
51
51
|
|
52
52
|
namespace :jruby do
|
53
53
|
|
54
54
|
desc "Run :package and install the resulting .gem with jruby"
|
55
55
|
task :install => :package do
|
56
|
-
sh
|
56
|
+
sh jinstall_command(GEM_NAME, GEM_VERSION)
|
57
57
|
end
|
58
58
|
|
59
59
|
end
|
data/TODO
CHANGED
data/lib/generators/base.rb
CHANGED
@@ -19,10 +19,11 @@ module Merb::Generators
|
|
19
19
|
|
20
20
|
class BaseSliceGenerator < NamedGenerator
|
21
21
|
|
22
|
-
def self.common_template(name,
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
def self.common_template(name, template_source)
|
23
|
+
common_base_dir = File.expand_path(File.dirname(__FILE__))
|
24
|
+
template name do |t|
|
25
|
+
t.source = File.join(common_base_dir, 'templates', 'common', template_source)
|
26
|
+
t.destination = template_source
|
26
27
|
end
|
27
28
|
end
|
28
29
|
|
@@ -30,4 +31,4 @@ module Merb::Generators
|
|
30
31
|
|
31
32
|
add :slice, SliceGenerator
|
32
33
|
|
33
|
-
end
|
34
|
+
end
|
@@ -52,13 +52,10 @@ namespace :slices do
|
|
52
52
|
|
53
53
|
namespace :freeze do
|
54
54
|
|
55
|
-
desc "Freezes <%= module_name %> by installing the gem into application/gems
|
55
|
+
desc "Freezes <%= module_name %> by installing the gem into application/gems"
|
56
56
|
task :gem do
|
57
|
-
|
58
|
-
|
59
|
-
rescue NameError
|
60
|
-
puts "! dependency 'merb-freezer' missing"
|
61
|
-
end
|
57
|
+
ENV["GEM"] ||= "<%= base_name %>"
|
58
|
+
Rake::Task['slices:install_as_gem'].invoke
|
62
59
|
end
|
63
60
|
|
64
61
|
desc "Freezes <%= module_name %> by copying all files from <%= base_name %>/app to your application"
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require "rubygems/dependency_installer"
|
2
|
+
|
1
3
|
desc "Show information on application slices"
|
2
4
|
task :slices => [ "slices:list" ]
|
3
5
|
|
@@ -16,4 +18,46 @@ namespace :slices do
|
|
16
18
|
end
|
17
19
|
end
|
18
20
|
|
21
|
+
desc "Install a slice into the local gems dir (GEM=your-slice)"
|
22
|
+
task :install_as_gem do
|
23
|
+
if ENV['GEM']
|
24
|
+
ENV['GEM_DIR'] ||= File.join(Merb.root, 'gems')
|
25
|
+
puts "Installing #{ENV["GEM"]} as a local gem"
|
26
|
+
install_gem(ENV['GEM_DIR'], ENV['GEM'], ENV['VERSION'])
|
27
|
+
else
|
28
|
+
puts "No slice GEM specified"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# Install a gem - looks remotely and locally; won't process rdoc or ri options.
|
33
|
+
def install_gem(install_dir, gem, version = nil)
|
34
|
+
Gem.configuration.update_sources = false
|
35
|
+
Gem.clear_paths # default to plain rubygems path
|
36
|
+
installer = Gem::DependencyInstaller.new(:install_dir => install_dir)
|
37
|
+
exception = nil
|
38
|
+
begin
|
39
|
+
installer.install gem, version
|
40
|
+
rescue Gem::InstallError => e
|
41
|
+
exception = e
|
42
|
+
rescue Gem::GemNotFoundException => e
|
43
|
+
puts "Locating #{gem} in local gem path cache..."
|
44
|
+
spec = if version
|
45
|
+
Gem.source_index.find_name(gem, "= #{version}").first
|
46
|
+
else
|
47
|
+
Gem.source_index.find_name(gem).sort_by { |g| g.version }.last
|
48
|
+
end
|
49
|
+
if spec && File.exists?(gem_file =
|
50
|
+
File.join(spec.installation_path, 'cache', "#{spec.full_name}.gem"))
|
51
|
+
installer.install gem_file
|
52
|
+
end
|
53
|
+
exception = e
|
54
|
+
end
|
55
|
+
if installer.installed_gems.empty? && e
|
56
|
+
puts "Failed to install gem '#{gem}' (#{e.message})"
|
57
|
+
end
|
58
|
+
installer.installed_gems.each do |spec|
|
59
|
+
puts "Successfully installed #{spec.full_name}"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
19
63
|
end
|
data/lib/merb-slices/module.rb
CHANGED
@@ -188,7 +188,12 @@ module Merb
|
|
188
188
|
def config
|
189
189
|
@config ||= begin
|
190
190
|
empty_hash = Hash.new { |h,k| h[k] = {} }
|
191
|
-
File.exists?(Merb.root / "config" / "slices.yml")
|
191
|
+
if File.exists?(Merb.root / "config" / "slices.yml")
|
192
|
+
require "yaml"
|
193
|
+
YAML.load(File.read(Merb.root / "config" / "slices.yml")) || empty_hash
|
194
|
+
else
|
195
|
+
empty_hash
|
196
|
+
end
|
192
197
|
end
|
193
198
|
end
|
194
199
|
|
@@ -212,7 +217,8 @@ module Merb
|
|
212
217
|
#
|
213
218
|
# @param <#to_s> The slice module to check for.
|
214
219
|
def exists?(module_name)
|
215
|
-
|
220
|
+
const_name = module_name.to_s.camel_case
|
221
|
+
slice_names.include?(const_name) && Object.const_defined?(const_name)
|
216
222
|
end
|
217
223
|
|
218
224
|
# A lookup for finding a Slice module's path
|
@@ -40,7 +40,7 @@ module Merb
|
|
40
40
|
def add_slice(slice_module, options = {}, &block)
|
41
41
|
if Merb::Slices.exists?(slice_module)
|
42
42
|
options = { :path => options } if options.is_a?(String)
|
43
|
-
slice_module = Object.full_const_get(slice_module.to_s) if slice_module.class.in?(String, Symbol)
|
43
|
+
slice_module = Object.full_const_get(slice_module.to_s.camel_case) if slice_module.class.in?(String, Symbol)
|
44
44
|
namespace = options[:namespace] || slice_module.to_s.snake_case
|
45
45
|
options[:path] ||= slice_module[:path_prefix] || options[:namespace] || slice_module.identifier
|
46
46
|
options[:default_routes] = true unless options.key?(:default_routes)
|
@@ -2,21 +2,10 @@ require File.dirname(__FILE__) + '/spec_helper'
|
|
2
2
|
|
3
3
|
describe Merb::Generators::SliceGenerator do
|
4
4
|
|
5
|
-
|
5
|
+
it "should invoke the full generator by default"
|
6
6
|
|
7
|
-
it "should invoke the
|
8
|
-
@generator = Merb::Generators::SliceGenerator.new('/tmp', {}, 'testing')
|
9
|
-
@generator.should invoke(Merb::Generators::FullSliceGenerator).with('testing')
|
10
|
-
end
|
7
|
+
it "should invoke the flat generator if flat is true"
|
11
8
|
|
12
|
-
it "should invoke the flat generator if flat is true"
|
13
|
-
@generator = Merb::Generators::SliceGenerator.new('/tmp', { :thin => true }, 'testing')
|
14
|
-
@generator.should invoke(Merb::Generators::ThinSliceGenerator).with('testing')
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should invoke the very flat generator if very flat is true" do
|
18
|
-
@generator = Merb::Generators::SliceGenerator.new('/tmp', { :very_thin => true }, 'testing')
|
19
|
-
@generator.should invoke(Merb::Generators::VeryThinSliceGenerator).with('testing')
|
20
|
-
end
|
9
|
+
it "should invoke the very flat generator if very flat is true"
|
21
10
|
|
22
11
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: merb-slices
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fabien Franzen
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-09-09 00:00:00 +03:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 0.9.
|
23
|
+
version: 0.9.6
|
24
24
|
version:
|
25
25
|
description: Merb-Slices is a Merb plugin for using and creating application 'slices' which help you modularize your application.
|
26
26
|
email: info@fabien.be
|