flynn 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,7 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ .DS_Store
6
+ coverage.data
7
+ coverage
data/.rvmrc ADDED
@@ -0,0 +1,2 @@
1
+ rvm_gemset_create_on_use_flag=1
2
+ rvm use 1.9.2@flynn
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in flynn.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,18 @@
1
+ Copyright (c) 2011 Luke Chadwick
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to
5
+ deal in the Software without restriction, including without limitation the
6
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7
+ sell copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16
+ THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # Flynn
2
+
3
+ Flynn is an open source command line tool for easily bootstrapping new projects. It is a lightweight framework designed to meet the following goals: One command to start new projects, easily pluggable (allowing users to write their own *recipes*), simple configuration, and readable and maintainable code.
4
+
5
+ The tool currently hooks into RVM heavily for the creation of ruby projects. There should be very few other dependencies. *Recipes* are responsible for installing anything (read: gems) they need.
6
+
7
+ ## Installation & Your first project
8
+
9
+ * Install Ruby 1.9 (via RVM or natively)
10
+
11
+ $> gem install rvm
12
+ $> rvm install <your favorite ruby>
13
+ $> rvm use --default <your favorite ruby>
14
+
15
+ * Install Flynn:
16
+
17
+ $> gem install flynn
18
+
19
+ * Create a new rails3 project:
20
+
21
+ $> flynn rails3 awesomeproject -J -O -m ../templates/heroku_template.rb
22
+
23
+ ## Writing your own recipe: MySinatra
24
+
25
+ $> mate ~/.flynn/recipes/my_sinatra.rb
26
+ class Flynn::Recipes::MySinatra
27
+ def create(app_name, options=[])
28
+ # Do whatever tasks you want
29
+ end
30
+ end
31
+
32
+ Flynn will automatically load any ruby files within this directory.
33
+
34
+ ##Contributing
35
+
36
+ Fork on GitHub, create a test & send a pull request.
37
+
38
+ ##Bugs
39
+
40
+ Use the [Issue Tracker](http://github.com/vertis/flynn/issues)
41
+
42
+ ## License & Acknowledgments
43
+
44
+ Flynn is distributed under the MIT license, for full details please see the LICENSE file.
45
+
data/Rakefile ADDED
@@ -0,0 +1,41 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ begin
5
+ require 'cover_me'
6
+
7
+ desc "Produce the coverage report"
8
+ task :coverage do
9
+ CoverMe.complete!
10
+ end
11
+ rescue LoadError
12
+ $stderr.puts "cover_me gem is not installed"
13
+ end
14
+
15
+ def load_rvm
16
+ return true if defined?(RVM)
17
+ puts "Loading RVM"
18
+ # load in RVM environment
19
+ if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm')
20
+ begin
21
+ rvm_path = File.dirname(File.dirname(ENV['MY_RUBY_HOME']))
22
+ rvm_lib_path = File.join(rvm_path, 'lib')
23
+ $LOAD_PATH.unshift rvm_lib_path
24
+
25
+ require 'rvm'
26
+ @ruby_version = ENV['RUBY_VERSION']
27
+ rescue LoadError
28
+ # RVM is unavailable at this point.
29
+ raise "RVM ruby lib is currently unavailable."
30
+ end
31
+ else
32
+ raise "RVM ruby lib is currently unavailable."
33
+ end
34
+ end
35
+
36
+ desc "Install in the global gemset"
37
+ task :install_global => [:build] do
38
+ load_rvm
39
+ RVM.gemset_use! 'global'
40
+ system("gem install pkg/flynn-#{Flynn::VERSION}.gem")
41
+ end
data/bin/flynn ADDED
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
3
+
4
+ require "rubygems" # ruby1.9 doesn't "require" it though
5
+ require 'flynn'
6
+ require 'active_support/inflector'
7
+
8
+ def print_usage
9
+ puts "Usage: flynn <recipe> <app_name> [options]"
10
+ available_recipes = Flynn::Recipes.available_recipes.map {|recipe| recipe.to_s.underscore }
11
+ puts ""
12
+ puts "Available recipes:"
13
+ available_recipes.each do |recipe|
14
+ puts " #{recipe}"
15
+ end
16
+ end
17
+
18
+
19
+ recipe = ARGV.shift
20
+ if recipe == 'help'
21
+ print_usage
22
+ exit 0
23
+ end
24
+ app_name = ARGV.shift
25
+ if Flynn::Recipes.const_defined?(recipe.camelize)
26
+ Flynn::Recipes.const_get(recipe.camelize).new.create(app_name, ARGV)
27
+ else
28
+ $stderr.puts "Flynn doesn't know how to create: #{recipe}"
29
+ puts ""
30
+ print_usage
31
+ end
data/flynn.gemspec ADDED
@@ -0,0 +1,28 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "flynn/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "flynn"
7
+ s.version = Flynn::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Luke Chadwick"]
10
+ s.email = ["luke.a.chadwick@gmail.com"]
11
+ s.homepage = ""
12
+ s.summary = %q{Flynn helps create ruby projects of different types}
13
+ s.description = %q{Whenever I start a new ruby project, I usually find myself repeating the same setup steps.
14
+ Flynn is a tool to help create common project types with sane defaults. }
15
+
16
+ s.rubyforge_project = "flynn"
17
+
18
+ s.files = `git ls-files`.split("\n")
19
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
+ s.require_paths = ["lib"]
22
+
23
+ s.add_dependency('activesupport')
24
+ s.add_dependency('i18n')
25
+
26
+ s.add_development_dependency('rspec')
27
+ s.add_development_dependency('cover_me')
28
+ end
data/lib/flynn.rb ADDED
@@ -0,0 +1,15 @@
1
+ require 'flynn/helpers'
2
+ require 'flynn/config'
3
+ require 'flynn/recipes'
4
+
5
+ module Flynn
6
+ def self.config
7
+ return @config unless @config.nil?
8
+ @config = Flynn::Config.new
9
+ @config.build
10
+ end
11
+
12
+ def self.root
13
+ @root ="#{File.expand_path('../..',__FILE__)}"
14
+ end
15
+ end
@@ -0,0 +1,23 @@
1
+ require 'pathname'
2
+
3
+ module Flynn
4
+ class Config
5
+ def build
6
+ recipes_directory.mkpath # will make the .flynn directory as well
7
+ config_file.open('w').close # is there an easier way
8
+ self
9
+ end
10
+
11
+ def flynn_directory
12
+ @flynn_directory ||= Pathname.new("#{ENV["HOME"]}/.flynn")
13
+ end
14
+
15
+ def config_file
16
+ @config_file ||= flynn_directory + 'config.yml'
17
+ end
18
+
19
+ def recipes_directory
20
+ @recipes_directory ||= flynn_directory + 'recipes'
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,29 @@
1
+ module Flynn
2
+ module Helpers
3
+ def inside(dir)
4
+ current_dir = Dir.pwd
5
+ Dir.chdir(dir)
6
+ yield
7
+ Dir.chdir(current_dir)
8
+ end
9
+
10
+ def run(cmd)
11
+ puts "Running: #{cmd}"
12
+ system(cmd)
13
+ end
14
+
15
+ def create_file(name, content)
16
+ throw Exception.new("File exists: #{name}") if File.exists?(name)
17
+ File.open(name, 'w') { |f| f.write content }
18
+ return true
19
+ end
20
+
21
+ def executable_path(cmd)
22
+ ENV['PATH'].split(':').each do |folder|
23
+ path = folder+'/'+cmd
24
+ return path if File.exists?(path)
25
+ end
26
+ nil
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,22 @@
1
+ require 'flynn/recipes/rvm_base'
2
+ require 'flynn/recipes/basic'
3
+ require 'flynn/recipes/gem'
4
+ require 'flynn/recipes/node_web'
5
+ require 'flynn/recipes/rails2'
6
+ require 'flynn/recipes/rails3'
7
+ require 'flynn/recipes/rails_edge'
8
+ require 'flynn/recipes/sinatra'
9
+
10
+ module Flynn
11
+ module Recipes
12
+ def self.load_user_recipes
13
+ Flynn.config.recipes_directory.children.each do |child|
14
+ require child.expand_path if child.extname=='.rb'
15
+ end
16
+ end
17
+
18
+ def self.available_recipes
19
+ Flynn::Recipes.constants - [:RvmBase]
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,15 @@
1
+ module Flynn
2
+ module Recipes
3
+ class Basic < RvmBase
4
+ def create(app_name, options={})
5
+ require 'fileutils'
6
+ puts "Creating #{app_name}"
7
+ FileUtils.mkdir(app_name)
8
+ inside app_name do
9
+ run("bundle init")
10
+ end
11
+ create_project_rvmrc(app_name)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,12 @@
1
+ module Flynn
2
+ module Recipes
3
+ class Gem < RvmBase
4
+ def create(app_name, *options)
5
+ puts "Creating new project in: #{app_name}"
6
+ run("bundle gem #{app_name}")
7
+
8
+ create_project_rvmrc(app_name)
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,52 @@
1
+ require 'fileutils'
2
+ require 'erb'
3
+
4
+ module Flynn
5
+ module Recipes
6
+ class NodeWeb
7
+ include Flynn::Helpers
8
+
9
+ def create(app_name, options=[])
10
+ namespace = lambda do
11
+ @app_name = app_name
12
+ @app_description = ""
13
+
14
+ #TODO: make this pull from your git details if they exist
15
+ @app_author = "You"
16
+ @app_author_email = "you@yourdomain.com"
17
+ end.call
18
+
19
+ check_for_node
20
+ check_for_npm
21
+
22
+ run("git clone https://github.com/vertis/flynn-node-template.git #{app_name}")
23
+ inside app_name do
24
+ template = ERB.new(File.read('package.json.erb'), nil)
25
+ create_file('package.json', template.result(namespace.send(:binding)))
26
+ run('rm package.json.erb')
27
+ run('git remote rm origin 2>/dev/null >/dev/null') # Borrowed from https://github.com/mwotton/instigator
28
+ run("npm install")
29
+ end
30
+ end
31
+
32
+ private
33
+ # Warn and exit if node.js isn't installed
34
+ def check_for_node
35
+ unless executable_path('node')
36
+ $stderr.puts "node.js is not installed"
37
+ throw Exception.new('node.js is not installed')
38
+ end
39
+ end
40
+
41
+ def check_for_npm
42
+ unless executable_path('npm')
43
+ install_npm
44
+ end
45
+ end
46
+
47
+ def install_npm
48
+ run("curl http://npmjs.org/install.sh | sh")
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,16 @@
1
+ require 'fileutils'
2
+
3
+ module Flynn
4
+ module Recipes
5
+ class Rails2 < RvmBase
6
+ def create(app_name, options=[])
7
+ RVM.gemset_create app_name
8
+ RVM.gemset_use! app_name
9
+ run("gem install rails -v '~> 2.3' --no-rdoc --no-ri")
10
+ puts "Creating #{app_name}"
11
+ run("rvm gemset use #{app_name} && rails #{app_name} #{options.join(" ")}")
12
+ create_project_rvmrc(app_name)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,17 @@
1
+ require 'fileutils'
2
+
3
+ module Flynn
4
+ module Recipes
5
+ class Rails3 < RvmBase
6
+ def create(app_name, options=[])
7
+ RVM.gemset_create app_name
8
+ RVM.gemset_use! app_name
9
+ #install_gem 'install', 'rails', '-v', '~> 2.3'
10
+ run("gem install rails -v '~> 3.0' --no-rdoc --no-ri")
11
+ puts "Creating #{app_name}"
12
+ run("rvm gemset use #{app_name} && rails new #{app_name} #{options.join(" ")}")
13
+ create_project_rvmrc(app_name)
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,46 @@
1
+ require 'fileutils'
2
+
3
+ module Flynn
4
+ module Recipes
5
+ class RailsEdge < RvmBase
6
+ def create(app_name, options=[])
7
+ #disable_rvmrc
8
+ rails_base = "#{ENV['HOME']}/.flynn/rails_edge"
9
+ rails_src = "#{ENV['HOME']}/.flynn/rails_src"
10
+ RVM.gemset_create app_name
11
+ RVM.gemset_use! app_name
12
+
13
+ FileUtils.mkdir_p rails_base
14
+ File.open("#{ENV['HOME']}/.flynn/rails_edge/Gemfile", 'w') {|f| f.puts gemfile }
15
+ if File.directory?(rails_src)
16
+ inside rails_src do
17
+ run("git pull")
18
+ end
19
+ else
20
+ run("git clone git://github.com/rails/rails.git #{rails_src}")
21
+ end
22
+ bundle_cmd = "bundle install --gemfile #{rails_base}/Gemfile --binstubs"
23
+ puts "Creating '#{app_name}' running edge rails (this could take a while)"
24
+ run("rvm gemset use #{app_name} && #{bundle_cmd}")
25
+ run("rvm gemset use #{app_name} && #{rails_base}/bin/rails new #{app_name} --dev #{options.join(" ")}")
26
+ create_project_rvmrc(app_name)
27
+ # TODO: There must be a better way than having to call this a second time
28
+ inside app_name do
29
+ run "bundle install"
30
+ end
31
+ #restore_rvmrc
32
+ end
33
+
34
+ private
35
+ def gemfile
36
+ @gemfile ||= <<-EOS
37
+ # A sinatra gemfile
38
+ source "http://rubygems.org"
39
+
40
+ gem 'rake', '>= 0.9.0'
41
+ gem 'rails', :git => "#{ENV['HOME']}/.flynn/rails_src"
42
+ EOS
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,47 @@
1
+ module Flynn
2
+ module Recipes
3
+ class RvmBase
4
+ include Flynn::Helpers
5
+
6
+ def initialize
7
+ load_rvm
8
+ end
9
+
10
+ protected
11
+
12
+ def create_project_rvmrc(app_name)
13
+ rvmrc = <<-RVMRC
14
+ rvm_gemset_create_on_use_flag=1
15
+ rvm use #{@ruby_version}@#{app_name}
16
+ RVMRC
17
+ File.open("#{app_name}/.rvmrc", 'w') {|f| f.write(rvmrc) }
18
+ inside app_name do
19
+ run("rvm rvmrc trust")
20
+ end
21
+ end
22
+
23
+ private
24
+
25
+ def load_rvm
26
+ return true if defined?(RVM)
27
+ puts "Loading RVM"
28
+ # load in RVM environment
29
+ if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm')
30
+ begin
31
+ rvm_path = File.dirname(File.dirname(ENV['MY_RUBY_HOME']))
32
+ rvm_lib_path = File.join(rvm_path, 'lib')
33
+ $LOAD_PATH.unshift rvm_lib_path
34
+
35
+ require 'rvm'
36
+ @ruby_version = ENV['RUBY_VERSION']
37
+ rescue LoadError
38
+ # RVM is unavailable at this point.
39
+ raise "RVM ruby lib is currently unavailable."
40
+ end
41
+ else
42
+ raise "RVM ruby lib is currently unavailable."
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,81 @@
1
+ require 'fileutils'
2
+
3
+ module Flynn
4
+ module Recipes
5
+ class Sinatra < RvmBase
6
+ def create(app_name, options=[])
7
+ @app_name = app_name
8
+ RVM.gemset_create app_name
9
+ RVM.gemset_use! app_name
10
+ puts "Creating #{app_name}"
11
+ FileUtils.mkdir(app_name)
12
+ create_gemfile
13
+ create_config_ru
14
+ create_app_rb
15
+ create_standard_directories
16
+ create_project_rvmrc(app_name)
17
+
18
+ inside(@app_name) do
19
+ run("bundle install")
20
+ end
21
+ end
22
+
23
+ private
24
+ def create_gemfile
25
+ inside(@app_name) do
26
+ File.open("Gemfile", 'w') {|f| f.write(gemfile) }
27
+ end
28
+ end
29
+
30
+ def create_config_ru
31
+ inside(@app_name) do
32
+ File.open("config.ru", 'w') {|f| f.write(config_ru) }
33
+ end
34
+ end
35
+
36
+ def create_app_rb
37
+ inside(@app_name) do
38
+ File.open("app.rb", 'w') {|f| f.write(app_rb) }
39
+ end
40
+ end
41
+
42
+ def create_standard_directories
43
+ inside(@app_name) do
44
+ FileUtils.mkdir_p('views')
45
+ FileUtils.mkdir_p('public')
46
+ end
47
+ end
48
+
49
+ def config_ru
50
+ @config_ru ||= <<-EOS
51
+ require "./app" # ruby1.9 compatible
52
+
53
+ run Sinatra::Application
54
+ EOS
55
+ end
56
+
57
+ def app_rb
58
+ @app_rb ||= <<-EOS
59
+ require 'rubygems'
60
+ require 'bundler/setup'
61
+ require 'sinatra'
62
+
63
+ get '/' do
64
+ "Generated by Flynn"
65
+ end
66
+ EOS
67
+ end
68
+
69
+ def gemfile
70
+ @gemfile ||= <<-EOS
71
+ # A sinatra gemfile
72
+ source "http://rubygems.org"
73
+
74
+ gem 'sinatra'
75
+ gem 'haml'
76
+ gem 'sass'
77
+ EOS
78
+ end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,3 @@
1
+ module Flynn
2
+ VERSION = "0.0.8"
3
+ end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+ require 'pathname'
3
+
4
+ describe Flynn::Config do
5
+ context "#build" do
6
+ before :all do
7
+ @flynn_directory = Pathname.new("#{ENV["HOME"]}/.flynn")
8
+ @recipes_directory = @flynn_directory + 'recipes'
9
+ @config_file = @flynn_directory + 'config.yml'
10
+ end
11
+
12
+ it "should create the .flynn directory if it doesn't exist" do
13
+ Flynn::Config.new.build
14
+ @flynn_directory.exist?.should == true
15
+ end
16
+
17
+ it "should create the .flynn/recipes directory if it doesn't exist" do
18
+ Flynn::Config.new.build
19
+ @recipes_directory.exist?.should == true
20
+ end
21
+
22
+ it "should create the .flynn/config.yml file if it doesn't exist" do
23
+ Flynn::Config.new.build
24
+ @config_file.exist?.should == true
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+
3
+ describe Flynn::Helpers do
4
+ before(:all) do
5
+ class Subject
6
+ include Flynn::Helpers
7
+ end
8
+ end
9
+ subject { Subject.new }
10
+
11
+ context "#inside" do
12
+ it "I should be inside the directory specified while within the block" do
13
+ subject.inside 'tmp' do
14
+ Dir.pwd.should =~ /tmp$/
15
+ end
16
+ end
17
+ end
18
+
19
+ context "#executable_path" do
20
+ it "should return the path to the executable if it exists within $PATH" do
21
+ subject.executable_path('bash').should =~ /bash$/
22
+ end
23
+
24
+ it "should return nil if the executable doesn't exist within $PATH" do
25
+ subject.executable_path('fake').should be_nil
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+ require 'fileutils'
3
+
4
+ describe Flynn::Recipes::Basic do
5
+ it "should have a create method" do
6
+ subject.should respond_to(:create)
7
+ end
8
+
9
+ it "should create a new basic project with the correct name" do
10
+ Dir.chdir('tmp')
11
+ subject.create('my_directory')
12
+ File.exists?('my_directory').should be_true
13
+ FileUtils.rm_r('my_directory')
14
+ Dir.chdir('..')
15
+ end
16
+ end
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+ require 'fileutils'
3
+
4
+ describe Flynn::Recipes::Gem do
5
+ it "should have a create method" do
6
+ subject.should respond_to(:create)
7
+ end
8
+
9
+ context "creating a gem project" do
10
+ before(:all) do
11
+ Dir.chdir('tmp')
12
+ subject.create('my_gem')
13
+ end
14
+
15
+ after(:all) do
16
+ FileUtils.rm_r('my_gem')
17
+ Dir.chdir('..')
18
+ end
19
+
20
+ it "should create a new gem project with the correct name" do
21
+ File.exists?('my_gem').should be_true
22
+ end
23
+
24
+ it "should create an .rvmrc for the new application" do
25
+ File.exists?('my_gem/.rvmrc').should be_true
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ describe Flynn::Recipes::NodeWeb do
4
+ it "should have a create method" do
5
+ subject.should respond_to(:create)
6
+ end
7
+
8
+ context "creating a node web project" do
9
+ before(:all) do
10
+ Dir.chdir('tmp')
11
+ subject.create('my_node')
12
+ end
13
+
14
+ after(:all) do
15
+ FileUtils.rm_r('my_node')
16
+ Dir.chdir('..')
17
+ end
18
+
19
+ it "should create a new node project with the correct name" do
20
+ File.exists?('my_node').should be_true
21
+ end
22
+
23
+ it "should create an package.json for the new application" do
24
+ File.exists?('my_node/package.json').should be_true
25
+ end
26
+
27
+ it "should create an app.js file for the new application" do
28
+ File.exists?('my_node/app.js').should be_true
29
+ end
30
+
31
+ it "should have the standard directories" do
32
+ File.directory?('my_node/public').should be_true
33
+ File.directory?('my_node/views').should be_true
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+ require 'fileutils'
3
+
4
+ describe Flynn::Recipes::Rails2 do
5
+ it "should have a create method" do
6
+ subject.should respond_to(:create)
7
+ end
8
+
9
+ context "creating a rails2 project" do
10
+ before(:all) do
11
+ Dir.chdir('tmp')
12
+ subject.create('my_rails2')
13
+ end
14
+
15
+ after(:all) do
16
+ FileUtils.rm_r('my_rails2')
17
+ Dir.chdir('..')
18
+ end
19
+
20
+ it "should create a new rails2 project with the correct name" do
21
+ File.exists?('my_rails2').should be_true
22
+ end
23
+
24
+ it "should create an .rvmrc for the new application" do
25
+ File.exists?('my_rails2/.rvmrc').should be_true
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+ require 'fileutils'
3
+
4
+ describe Flynn::Recipes::Rails3 do
5
+ it "should have a create method" do
6
+ subject.should respond_to(:create)
7
+ end
8
+
9
+ context "creating a rails3 project" do
10
+ before(:all) do
11
+ Dir.chdir('tmp')
12
+ subject.create('my_rails3')
13
+ end
14
+
15
+ after(:all) do
16
+ FileUtils.rm_r('my_rails3')
17
+ Dir.chdir('..')
18
+ end
19
+
20
+ it "should create a new rails3 project with the correct name" do
21
+ File.exists?('my_rails3').should be_true
22
+ end
23
+
24
+ it "should create an .rvmrc for the new application" do
25
+ File.exists?('my_rails3/.rvmrc').should be_true
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+ require 'fileutils'
3
+
4
+ describe Flynn::Recipes::RailsEdge do
5
+ it "should have a create method" do
6
+ subject.should respond_to(:create)
7
+ end
8
+
9
+ context "creating a rails edge project" do
10
+ before(:all) do
11
+ Dir.chdir('tmp')
12
+ subject.create('my_edge')
13
+ end
14
+
15
+ after(:all) do
16
+ FileUtils.rm_r('my_edge')
17
+ Dir.chdir('..')
18
+ end
19
+
20
+ it "should put down a gemfile to use with bundling" do
21
+ File.exists?("#{ENV['HOME']}/.flynn/rails_edge/gemfile").should be_true
22
+ end
23
+
24
+ it "should create a new rails edge project with the correct name" do
25
+ File.exists?('my_edge').should be_true
26
+ end
27
+
28
+ it "should create an .rvmrc for the new application" do
29
+ File.exists?('my_edge/.rvmrc').should be_true
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,45 @@
1
+ require 'spec_helper'
2
+ require 'fileutils'
3
+
4
+ describe Flynn::Recipes::Sinatra do
5
+ it "should have a create method" do
6
+ subject.should respond_to(:create)
7
+ end
8
+
9
+ context "creating a sinatra project" do
10
+ before(:all) do
11
+ Dir.chdir('tmp')
12
+ subject.create('my_sinatra')
13
+ end
14
+
15
+ after(:all) do
16
+ FileUtils.rm_r('my_sinatra')
17
+ Dir.chdir('..')
18
+ end
19
+
20
+ it "should create a new sinatra project with the correct name" do
21
+ File.exists?('my_sinatra').should be_true
22
+ end
23
+
24
+ it "should create an .rvmrc for the new application" do
25
+ File.exists?('my_sinatra/.rvmrc').should be_true
26
+ end
27
+
28
+ it "should create an Gemfile for the new application" do
29
+ File.exists?('my_sinatra/Gemfile').should be_true
30
+ end
31
+
32
+ it "should create a config.ru for the new application" do
33
+ File.exists?('my_sinatra/config.ru').should be_true
34
+ end
35
+
36
+ it "should create an app.rb file for the new application" do
37
+ File.exists?('my_sinatra/app.rb').should be_true
38
+ end
39
+
40
+ it "should have the standard directories" do
41
+ File.directory?('my_sinatra/public').should be_true
42
+ File.directory?('my_sinatra/views').should be_true
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ describe Flynn::Recipes do
4
+ before :all do
5
+ recipe = """
6
+ class Flynn::Recipes::Test
7
+ def create
8
+ end
9
+ end
10
+ """
11
+ @test_recipe = Flynn.config.recipes_directory + 'test.rb'
12
+ File.open(@test_recipe, 'w') {|f| f.puts recipe}
13
+ end
14
+
15
+ it "should load all the recipes in the user recipe paths" do
16
+ Flynn::Recipes.load_user_recipes
17
+ lambda { Flynn::Recipes::Test.new }.should_not raise_error
18
+ end
19
+
20
+ it "should return a list of all defined recipes" do
21
+ Flynn::Recipes.available_recipes.should == [:Gem, :Basic, :Rails2, :Rails3, :RailsEdge, :Sinatra, :Test]
22
+ end
23
+ end
@@ -0,0 +1,10 @@
1
+ require 'spec_helper'
2
+
3
+ describe Flynn do
4
+ [:Basic, :Gem, :Rails2, :Rails3].each do |recipe|
5
+ it "should instantiate the #{recipe} recipe with no arguments" do
6
+ lambda { Flynn::Recipes.const_get(recipe).new }.should_not raise_error
7
+ lambda { Flynn::Recipes.const_get(recipe).new( "hiss" ) }.should raise_error
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+ require 'cover_me'
3
+ require "flynn"
4
+
5
+ RSpec.configure do |config|
6
+ # config.after(:suite) do
7
+ # CoverMe.complete!
8
+ # end
9
+ end
metadata ADDED
@@ -0,0 +1,142 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: flynn
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.8
6
+ platform: ruby
7
+ authors:
8
+ - Luke Chadwick
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-06-04 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: activesupport
17
+ prerelease: false
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ type: :runtime
25
+ version_requirements: *id001
26
+ - !ruby/object:Gem::Dependency
27
+ name: i18n
28
+ prerelease: false
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: "0"
35
+ type: :runtime
36
+ version_requirements: *id002
37
+ - !ruby/object:Gem::Dependency
38
+ name: rspec
39
+ prerelease: false
40
+ requirement: &id003 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: "0"
46
+ type: :development
47
+ version_requirements: *id003
48
+ - !ruby/object:Gem::Dependency
49
+ name: cover_me
50
+ prerelease: false
51
+ requirement: &id004 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: "0"
57
+ type: :development
58
+ version_requirements: *id004
59
+ description: "Whenever I start a new ruby project, I usually find myself repeating the same setup steps.\n\
60
+ Flynn is a tool to help create common project types with sane defaults. "
61
+ email:
62
+ - luke.a.chadwick@gmail.com
63
+ executables:
64
+ - flynn
65
+ extensions: []
66
+
67
+ extra_rdoc_files: []
68
+
69
+ files:
70
+ - .gitignore
71
+ - .rvmrc
72
+ - Gemfile
73
+ - LICENSE
74
+ - README.md
75
+ - Rakefile
76
+ - bin/flynn
77
+ - flynn.gemspec
78
+ - lib/flynn.rb
79
+ - lib/flynn/config.rb
80
+ - lib/flynn/helpers.rb
81
+ - lib/flynn/recipes.rb
82
+ - lib/flynn/recipes/basic.rb
83
+ - lib/flynn/recipes/gem.rb
84
+ - lib/flynn/recipes/node_web.rb
85
+ - lib/flynn/recipes/rails2.rb
86
+ - lib/flynn/recipes/rails3.rb
87
+ - lib/flynn/recipes/rails_edge.rb
88
+ - lib/flynn/recipes/rvm_base.rb
89
+ - lib/flynn/recipes/sinatra.rb
90
+ - lib/flynn/version.rb
91
+ - spec/flynn/config_spec.rb
92
+ - spec/flynn/helpers_spec.rb
93
+ - spec/flynn/recipes/basic_spec.rb
94
+ - spec/flynn/recipes/gem_spec.rb
95
+ - spec/flynn/recipes/node_web_spec.rb
96
+ - spec/flynn/recipes/rails2_spec.rb
97
+ - spec/flynn/recipes/rails3_spec.rb
98
+ - spec/flynn/recipes/rails_edge_spec.rb
99
+ - spec/flynn/recipes/sinatra_spec.rb
100
+ - spec/flynn/recipes_spec.rb
101
+ - spec/flynn_spec.rb
102
+ - spec/spec_helper.rb
103
+ homepage: ""
104
+ licenses: []
105
+
106
+ post_install_message:
107
+ rdoc_options: []
108
+
109
+ require_paths:
110
+ - lib
111
+ required_ruby_version: !ruby/object:Gem::Requirement
112
+ none: false
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: "0"
117
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
+ none: false
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: "0"
123
+ requirements: []
124
+
125
+ rubyforge_project: flynn
126
+ rubygems_version: 1.7.2
127
+ signing_key:
128
+ specification_version: 3
129
+ summary: Flynn helps create ruby projects of different types
130
+ test_files:
131
+ - spec/flynn/config_spec.rb
132
+ - spec/flynn/helpers_spec.rb
133
+ - spec/flynn/recipes/basic_spec.rb
134
+ - spec/flynn/recipes/gem_spec.rb
135
+ - spec/flynn/recipes/node_web_spec.rb
136
+ - spec/flynn/recipes/rails2_spec.rb
137
+ - spec/flynn/recipes/rails3_spec.rb
138
+ - spec/flynn/recipes/rails_edge_spec.rb
139
+ - spec/flynn/recipes/sinatra_spec.rb
140
+ - spec/flynn/recipes_spec.rb
141
+ - spec/flynn_spec.rb
142
+ - spec/spec_helper.rb