Skip to content

Commit

Permalink
update to latest extension defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
saturnflyer committed May 7, 2013
1 parent 49dae8f commit 92fedc6
Show file tree
Hide file tree
Showing 12 changed files with 131 additions and 40 deletions.
File renamed without changes.
38 changes: 19 additions & 19 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# In rails 1.2, plugins aren't available in the path until they're loaded.
# Check to see if the rspec plugin is installed first and require
# it if it is. If not, use the gem version.

# Determine where the RSpec plugin is by loading the boot
unless defined? RADIANT_ROOT
ENV["RAILS_ENV"] = "test"
Expand All @@ -16,19 +12,21 @@ unless defined? RADIANT_ROOT
end

require 'rake'
require 'rake/rdoctask'
require 'rdoc/task'
require 'rake/testtask'

rspec_base = File.expand_path(RADIANT_ROOT + '/vendor/plugins/rspec/lib')
$LOAD_PATH.unshift(rspec_base) if File.exist?(rspec_base)
require 'spec/rake/spectask'
require 'cucumber'
require 'cucumber/rake/task'

# Cleanup the RADIANT_ROOT constant so specs will load the environment
Object.send(:remove_const, :RADIANT_ROOT)

extension_root = File.expand_path(File.dirname(__FILE__))

task :default => :spec
task :default => [:spec, :features]
task :stats => "spec:statsetup"

desc "Run all specs in spec directory"
Expand All @@ -37,6 +35,8 @@ Spec::Rake::SpecTask.new(:spec) do |t|
t.spec_files = FileList['spec/**/*_spec.rb']
end

task :features => 'spec:integration'

namespace :spec do
desc "Run all specs in spec directory with RCov"
Spec::Rake::SpecTask.new(:rcov) do |t|
Expand All @@ -51,7 +51,7 @@ namespace :spec do
t.spec_opts = ["--format", "specdoc", "--dry-run"]
t.spec_files = FileList['spec/**/*_spec.rb']
end

[:models, :controllers, :views, :helpers].each do |sub|
desc "Run the specs under spec/#{sub}"
Spec::Rake::SpecTask.new(sub) do |t|
Expand All @@ -60,6 +60,14 @@ namespace :spec do
end
end

desc "Run the Cucumber features"
Cucumber::Rake::Task.new(:integration) do |t|
t.fork = true
t.cucumber_opts = ['--format', (ENV['CUCUMBER_FORMAT'] || 'pretty')]
# t.feature_pattern = "#{extension_root}/features/**/*.feature"
t.profile = "default"
end

# Setup specs for stats
task :statsetup do
require 'code_statistics'
Expand All @@ -73,7 +81,7 @@ namespace :spec do
::CodeStatistics::TEST_TYPES << "Helper specs"
::STATS_DIRECTORIES.delete_if {|a| a[0] =~ /test/}
end

namespace :db do
namespace :fixtures do
desc "Load fixtures (from spec/fixtures) into the current environment's database. Load specific fixtures using FIXTURES=x,y"
Expand All @@ -89,21 +97,13 @@ namespace :spec do
end

desc 'Generate documentation for the blog extension.'
Rake::RDocTask.new(:rdoc) do |rdoc|
RDoc::Task.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'BlogExtension'
rdoc.options << '--line-numbers' << '--inline-source'
rdoc.rdoc_files.include('README')
rdoc.rdoc_files.include('lib/**/*.rb')
end

# For extensions that are in transition
desc 'Test the blog extension.'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end

# Load any custom rakefiles for extension
Dir[File.dirname(__FILE__) + '/tasks/*.rake'].sort.each { |f| require f }
Dir[File.dirname(__FILE__) + '/tasks/*.rake'].sort.each { |f| require f }
21 changes: 7 additions & 14 deletions blog_extension.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
# Uncomment this if you reference any of your controllers in activate
# require_dependency 'application'
# require_dependency "application_controller"
require "radiant-blog-extension"

class BlogExtension < Radiant::Extension
version "1.0"
description "Provides features for blogging."
url "http://saturnflyer.com/"

# define_routes do |map|
# map.connect 'admin/author/:action', :controller => 'admin/author'
# end

version RadiantBlogExtension::VERSION
description RadiantBlogExtension::DESCRIPTION
url RadiantBlogExtension::URL

def activate
if Page.table_exists? #allow bootstrapping
Page.send :include, AuthorTags
Expand All @@ -30,8 +27,4 @@ def activate
end
end
end

def deactivate
end

end
end
3 changes: 3 additions & 0 deletions config/initializers/radiant_config.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Radiant.config do |config|
# config.define "setting.name", :default => 'value', :select_from => ['foo', 'bar']
end
3 changes: 3 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
en:
blog: Blog
5 changes: 5 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ActionController::Routing::Routes.draw do |map|
# map.namespace :admin, :member => { :remove => :get } do |admin|
# admin.resources :blog
# end
end
1 change: 1 addition & 0 deletions cucumber.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
default: --format progress features --tags ~@proposed,~@in_progress
11 changes: 11 additions & 0 deletions features/support/env.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Sets up the Rails environment for Cucumber
ENV["RAILS_ENV"] = "test"
# Extension root
extension_env = File.expand_path(File.dirname(__FILE__) + '/../../../../../config/environment')
require extension_env+'.rb'

Dir.glob(File.join(RADIANT_ROOT, "features", "**", "*.rb")).each {|step| require step unless step =~ /datasets_loader\.rb$/}

Cucumber::Rails::World.class_eval do
dataset :blog
end
22 changes: 22 additions & 0 deletions features/support/paths.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module NavigationHelpers

# Extend the standard PathMatchers with your own paths
# to be used in your features.
#
# The keys and values here may be used in your standard web steps
# Using:
#
# When I go to the "blog" admin page
#
# would direct the request to the path you provide in the value:
#
# admin_blog_path
#
PathMatchers = {} unless defined?(PathMatchers)
PathMatchers.merge!({
# /blog/i => 'admin_blog_path'
})

end

World(NavigationHelpers)
8 changes: 8 additions & 0 deletions lib/radiant-blog-extension.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module RadiantBlogExtension
VERSION = "1.1.0"
SUMMARY = "Provides features for blogging in Radiant CMS"
DESCRIPTION = "Provides features for blogging in Radiant CMS"
URL = "http://github.com/saturnflyer/radiant-blog-extension"
AUTHORS = ["Jim Gay"]
EMAIL = ["jim@saturnflyer.com"]
end
30 changes: 23 additions & 7 deletions lib/tasks/blog_extension_tasks.rake
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,46 @@ namespace :radiant do
namespace :extensions do
namespace :blog do

desc "Runs the migration and update tasks of the Blog extension"
task :install => [:environment, :migrate, :update]

desc "Runs the migration of the Blog extension"
task :migrate => :environment do
require 'radiant/extension_migrator'
if ENV["VERSION"]
BlogExtension.migrator.migrate(ENV["VERSION"].to_i)
Rake::Task['db:schema:dump'].invoke
else
BlogExtension.migrator.migrate
Rake::Task['db:schema:dump'].invoke
end
end

desc "Copies public assets of the Author to the instance public/ directory."
desc "Copies public assets of the Blog to the instance public/ directory."
task :update => :environment do
is_svn_or_dir = proc {|path| path =~ /\.svn/ || File.directory?(path) }
puts "Copying assets from BlogExtension"
Dir[BlogExtension.root + "/public/**/*"].reject(&is_svn_or_dir).each do |file|
path = file.sub(BlogExtension.root, '')
directory = File.dirname(path)
puts "Copying #{path}..."
mkdir_p RAILS_ROOT + directory
cp file, RAILS_ROOT + path
mkdir_p RAILS_ROOT + directory, :verbose => false
cp file, RAILS_ROOT + path, :verbose => false
end
end

desc "Syncs all available translations for this ext to the English ext master"
task :sync => :environment do
# The main translation root, basically where English is kept
language_root = BlogExtension.root + "/config/locales"
words = TranslationSupport.get_translation_keys(language_root)

Dir["#{language_root}/*.yml"].each do |filename|
next if filename.match('_available_tags')
basename = File.basename(filename, '.yml')
puts "Syncing #{basename}"
(comments, other) = TranslationSupport.read_file(filename, basename)
words.each { |k,v| other[k] ||= words[k] } # Initializing hash variable as empty if it does not exist
other.delete_if { |k,v| !words[k] } # Remove if not defined in en.yml
TranslationSupport.write_file(filename, basename, comments, other)
end
end
end
end
end
29 changes: 29 additions & 0 deletions radiant-blog-extension.gemspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "radiant-blog-extension"

Gem::Specification.new do |s|
s.name = "radiant-blog-extension"
s.version = RadiantBlogExtension::VERSION
s.platform = Gem::Platform::RUBY
s.authors = RadiantBlogExtension::AUTHORS
s.email = RadiantBlogExtension::EMAIL
s.homepage = RadiantBlogExtension::URL
s.summary = RadiantBlogExtension::SUMMARY
s.description = RadiantBlogExtension::DESCRIPTION

# Define gem dependencies here.
# Don't include a dependency on radiant itself: it causes problems when radiant is in vendor/radiant.
# s.add_dependency "something", "~> 1.0.0"
# s.add_dependency "radiant-some-extension", "~> 1.0.0"

ignores = if File.exist?('.gitignore')
File.read('.gitignore').split("\n").inject([]) {|a,p| a + Dir[p] }
else
[]
end
s.files = Dir['**/*'] - ignores
s.test_files = Dir['test/**/*','spec/**/*','features/**/*'] - ignores
# s.executables = Dir['bin/*'] - ignores
s.require_paths = ["lib"]
end

0 comments on commit 92fedc6

Please sign in to comment.