Browse files

Add the basic foundation for an Adhearsion app generator

  • Loading branch information...
1 parent 0e7ac22 commit 90dcf9de9a020a1d6bfd8da2737feacc0f3fe355 @benlangfeld committed Apr 9, 2011
View
2 .gitignore
@@ -1,3 +1,5 @@
pkg/*
*.gem
.bundle
+tmp
+Gemfile.lock
View
10 Rakefile
@@ -1,2 +1,12 @@
require 'bundler'
Bundler::GemHelper.install_tasks
+
+require 'rake'
+require 'cucumber'
+require 'cucumber/rake/task'
+
+Cucumber::Rake::Task.new(:features) do |t|
+ t.cucumber_opts = "features --format progress"
+end
+
+task :default => :features
View
10 ahn-rails.gemspec
@@ -18,4 +18,14 @@ Gem::Specification.new do |s|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]
+
+ s.add_dependency 'adhearsion', '~> 1.0.1'
+
+ s.add_development_dependency 'rspec-rails', '~> 2.5.0'
+ s.add_development_dependency 'cucumber', '~> 0.10.2'
+ s.add_development_dependency 'aruba', '~> 0.3.5'
+ s.add_development_dependency 'rails', '~> 3.0.6'
+ s.add_development_dependency 'mocha', '~> 0.9.12'
+ s.add_development_dependency 'bcrypt-ruby', '~> 2.1.2'
+ s.add_development_dependency 'sqlite3-ruby', '~> 1.3.1'
end
View
10 features/app_generator.feature
@@ -0,0 +1,10 @@
+Feature: Adhearsion App Generator
+ In order to integrate Adhearsion and Rails
+ As a rails developer
+ I want to generate an Adhearsion app inside my Rails app
+
+ @announce
+ Scenario: Generate railsified application layout
+ Given a new Rails app
+ When I cd to "rails_app"
+ And I run `rails g ahn:app -f`
View
4 features/step_definitions/rails_setup_steps.rb
@@ -0,0 +1,4 @@
+Given /^a new Rails app$/ do
+ Given "I run `rails new rails_app`"
+ And "I run `ln -s ../../lib/generators rails_app/lib/generators`"
+end
View
7 features/support/env.rb
@@ -0,0 +1,7 @@
+require 'cucumber'
+require 'rspec'
+require 'aruba/cucumber'
+
+Before do
+ @aruba_timeout_seconds = 5
+end
View
28 lib/generators/ahn.rb
@@ -0,0 +1,28 @@
+require 'rails/generators/base'
+
+module Ahn
+ module Generators
+ class Base < Rails::Generators::Base #:nodoc:
+ def self.source_root
+ @_ahn_source_root ||= File.expand_path File.join(File.dirname(__FILE__), 'ahn', generator_name, 'templates')
+ end
+
+ def self.banner
+ "rails generate ahn:#{generator_name} #{self.arguments.map{ |a| a.usage }.join(' ')} [options]"
+ end
+
+ private
+
+ def add_gem(name, options = {})
+ gemfile_content = File.read destination_path("Gemfile")
+ File.open(destination_path("Gemfile"), 'a') { |f| f.write("\n") } unless gemfile_content =~ /\n\Z/
+ gem name, options unless gemfile_content.include? name
+ end
+
+ def print_usage
+ self.class.help Thor::Base.shell.new
+ exit
+ end
+ end
+ end
+end
View
5 lib/generators/ahn/app/USAGE
@@ -0,0 +1,5 @@
+Description:
+ The ahn:app generator creates an Adhearsion app that is coupled with your Rails app.
+
+Examples:
+ rails generate ahn:app
View
24 lib/generators/ahn/app/app_generator.rb
@@ -0,0 +1,24 @@
+require 'generators/ahn'
+
+module Ahn
+ module Generators
+ class AppGenerator < Base
+ argument :config_name, :type => :string, :default => 'app', :banner => 'config_name'
+
+ def generate_app
+ # template "load_config.rb", "config/initializers/load_#{file_name}_config.rb"
+ # copy_file "config.yml", "config/#{file_name}_config.yml"
+ end
+
+ private
+
+ def file_name
+ config_name.underscore
+ end
+
+ def constant_name
+ config_name.underscore.upcase
+ end
+ end
+ end
+end

0 comments on commit 90dcf9d

Please sign in to comment.