Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

updated with standard extension files

  • Loading branch information...
commit 3e9541100d583461e0de9cb0f4367ab6f64ff3c0 1 parent 4e6effa
@saturnflyer saturnflyer authored
View
31 Rakefile
@@ -1,9 +1,3 @@
-# I think this is the one that should be moved to the extension Rakefile template
-
-# 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"
@@ -24,7 +18,8 @@ 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 'spec/translator'
+require 'cucumber'
+require 'cucumber/rake/task'
# Cleanup the RADIANT_ROOT constant so specs will load the environment
Object.send(:remove_const, :RADIANT_ROOT)
@@ -40,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|
@@ -63,13 +60,13 @@ namespace :spec do
end
end
- # Hopefully no one has written their extensions in pre-0.9 style
- # desc "Translate specs from pre-0.9 to 0.9 style"
- # task :translate do
- # translator = ::Spec::Translator.new
- # dir = RAILS_ROOT + '/spec'
- # translator.translate(dir, dir)
- # 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
@@ -99,17 +96,17 @@ namespace :spec do
end
end
-desc 'Generate documentation for the <%= file_name %> extension.'
+desc 'Generate documentation for the archive extension.'
Rake::RDocTask.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
- rdoc.title = '<%= class_name %>'
+ rdoc.title = 'ArchiveExtension'
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 <%= file_name %> extension.'
+desc 'Test the archive extension.'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.pattern = 'test/**/*_test.rb'
View
12 archive_extension.rb
@@ -1,10 +1,10 @@
# Uncomment this if you reference any of your controllers in activate
-# require_dependency 'application'
-
+# require_dependency 'application_controller'
+require 'radiant-archive-extension/version'
class ArchiveExtension < Radiant::Extension
- version "1.0"
+ version RadiantArchiveExtension::VERSION
description "Provides page types for news or blog archives."
- url "http://dev.radiantcms.org/"
+ url "http://radiantcms.org/"
def activate
# allow bootstrap
@@ -17,8 +17,4 @@ def allowed_children_with_archive
end
end
end
-
- def deactivate
- end
-
end
View
3  config/initializers/radiant_config.rb
@@ -0,0 +1,3 @@
+Radiant.config do |config|
+ # config.define "setting.name", :default => 'value', :select_from => ['foo', 'bar']
+end
View
3  config/locales/en.yml
@@ -0,0 +1,3 @@
+---
+en:
+ archive: Archive
View
5 config/routes.rb
@@ -0,0 +1,5 @@
+ActionController::Routing::Routes.draw do |map|
+ # map.namespace :admin, :member => { :remove => :get } do |admin|
+ # admin.resources :archive
+ # end
+end
View
1  cucumber.yml
@@ -0,0 +1 @@
+default: --format progress features --tags ~@proposed,~@in_progress
View
16 features/support/env.rb
@@ -0,0 +1,16 @@
+# 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}
+
+Cucumber::Rails::World.class_eval do
+ include Dataset
+ datasets_directory "#{RADIANT_ROOT}/spec/datasets"
+ Dataset::Resolver.default = Dataset::DirectoryResolver.new("#{RADIANT_ROOT}/spec/datasets", File.dirname(__FILE__) + '/../../spec/datasets', File.dirname(__FILE__) + '/../datasets')
+ self.datasets_database_dump_path = "#{Rails.root}/tmp/dataset"
+
+ # dataset :archive
+end
View
14 features/support/paths.rb
@@ -0,0 +1,14 @@
+def path_to(page_name)
+ case page_name
+
+ when /the homepage/i
+ root_path
+
+ when /login/i
+ login_path
+ # Add more page name => path mappings here
+
+ else
+ raise "Can't find mapping from \"#{page_name}\" to a path."
+ end
+end
View
2  lib/radiant-archive-extension.rb
@@ -0,0 +1,2 @@
+module RadiantArchiveExtension
+end
View
3  lib/radiant-archive-extension/version.rb
@@ -0,0 +1,3 @@
+module RadiantArchiveExtension
+ VERSION = '1.0.0'
+end
View
33 lib/tasks/archive_extension_tasks.rake
@@ -7,22 +7,49 @@ namespace :radiant do
require 'radiant/extension_migrator'
if ENV["VERSION"]
ArchiveExtension.migrator.migrate(ENV["VERSION"].to_i)
+ Rake::Task['db:schema:dump'].invoke
else
ArchiveExtension.migrator.migrate
+ Rake::Task['db:schema:dump'].invoke
end
end
desc "Copies public assets of the Archive to the instance public/ directory."
task :update => :environment do
is_svn_or_dir = proc {|path| path =~ /\.svn/ || File.directory?(path) }
+ puts "Copying assets from ArchiveExtension"
Dir[ArchiveExtension.root + "/public/**/*"].reject(&is_svn_or_dir).each do |file|
path = file.sub(ArchiveExtension.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
+ unless ArchiveExtension.root.starts_with? RAILS_ROOT # don't need to copy vendored tasks
+ puts "Copying rake tasks from ArchiveExtension"
+ local_tasks_path = File.join(RAILS_ROOT, %w(lib tasks))
+ mkdir_p local_tasks_path, :verbose => false
+ Dir[File.join ArchiveExtension.root, %w(lib tasks *.rake)].each do |file|
+ cp file, local_tasks_path, :verbose => false
+ end
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 = ArchiveExtension.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
Please sign in to comment.
Something went wrong with that request. Please try again.