Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
dbb8b78
moved guard scroll switch on operating system to happen when the app …
allangrant Apr 30, 2012
0c454d4
Merge remote-tracking branch 'upstream/master'
allangrant Jun 24, 2012
b3c0f37
added newlines to guard scroll
allangrant Jun 24, 2012
6b74f19
more verbose git commit messages from scroll callbacks
allangrant Jun 24, 2012
6b153c6
changed generate delayed_job to generate delayed_job:active_record
allangrant Jun 24, 2012
8afc089
added haml, sass, compass, and compass_twitter_bootstrap scrolls
allangrant Jun 25, 2012
6b25d10
added exception notification scroll
allangrant Jun 25, 2012
8e2e1e1
honor -t option when interactive mode
allangrant Jun 25, 2012
d83d768
don't delete tmp file if -t option is used
allangrant Jun 25, 2012
e04eee4
null object ftw
allangrant Jun 25, 2012
f1eff6f
get config working as it might have been intended (hopefully..)
allangrant Jun 25, 2012
d8fc7a9
move spacing around
allangrant Jun 25, 2012
86e448b
merging cclow's: Added option to create and use local scrolls in ENV[…
cclow Apr 19, 2012
009f207
option to pass config file which runs before scrolls, where system de…
allangrant Jun 25, 2012
62f1316
added APPSCROLLS_CONFIG environment variable
allangrant Jun 25, 2012
0f15132
new form for config options
allangrant Jun 26, 2012
368ed32
got rid of separate config scopes per app scroll
allangrant Jun 26, 2012
5a45cf8
brought back separate scroll configs in weird way
allangrant Jun 26, 2012
7fda387
simplifying
allangrant Jun 26, 2012
5adf2a2
Revert "simplifying"
allangrant Jun 26, 2012
ed85e4c
added devise
allangrant Jun 29, 2012
f169ab5
improved devise; made scrolls in local dir load recursively and overr…
allangrant Jun 29, 2012
23ae63b
recursively include scrolls in local dir and follow symlinks
allangrant Jun 29, 2012
0e30922
heroku scroll
allangrant Jun 29, 2012
605e071
refactored some stuff
allangrant Jun 29, 2012
8c50e9c
tweaked spacing
allangrant Jun 29, 2012
fd00839
moved renamed scrolls/untested/ to untested_scrolls/
allangrant Jun 29, 2012
5497f6c
gitignore
allangrant Jun 29, 2012
944a178
improve scroll inter-compatibility
allangrant Jun 30, 2012
488e07d
multi-strategy omniauth scroll
allangrant Jun 30, 2012
3ea0943
add heroku remote even when not creating new app
allangrant Jun 30, 2012
375d26c
stub omniauth key and secret in production env, in addition to applic…
allangrant Jun 30, 2012
86ee9e9
rvm
allangrant Jun 30, 2012
fbfa6ef
mailgun scroll
allangrant Jun 30, 2012
c6bc172
fixed generated spacing in mailgun scroll
allangrant Jul 1, 2012
505f423
added to CLI: run "scrolls version" to see the current version
allangrant Jul 1, 2012
f252b15
added new method of app transformation using diff patches
allangrant Jul 1, 2012
a177881
replaces devise views with haml, using a diff patch - requires simple…
allangrant Jul 1, 2012
d7356ac
devise_haml now works with and without simple_form
allangrant Jul 1, 2012
2109dea
added new CLI alias: scroll (in addition to scrolls and appscrolls)
allangrant Jul 1, 2012
d13c7ac
bug fixes in haml generated by devise_haml
allangrant Jul 1, 2012
0ab8fa0
renamed AppScrollsScrolls to AppScrolls
allangrant Jul 1, 2012
01c00fe
added CLI command to "memorize" a scroll, instantly creating it from …
allangrant Jul 1, 2012
ed203b1
automatically set devise outgoing email address
allangrant Jul 1, 2012
6bd4e81
added asset precompiling for active admin
allangrant Jul 1, 2012
9d7748f
diff patch: active admin views for users and admin users
allangrant Jul 1, 2012
466ee48
maybe it works after all; couldn't find failing case
allangrant Jul 1, 2012
0e7f8b7
fixed self-dependency in git scroll
allangrant Jul 1, 2012
44771a5
active_admin spacing and dependencies
allangrant Jul 1, 2012
a940d77
dependency changes
allangrant Jul 1, 2012
bfcd30f
added failing test for run_before/run_after sorting; fixed with topol…
allangrant Jul 1, 2012
7839e12
removed debug message
allangrant Jul 1, 2012
b27ae15
added missing slash
allangrant Jul 2, 2012
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ dist/*
.idea
.rvmrc
.DS_Store
local_scrolls
scroll_config.rb
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,28 @@ Or print out a list of scrolls for a specific category:

scrolls list persistence

### User Scrolls

You can define an environment variable APPSCROLLS_DIR with a path to your local app scrolls:

export APPSCROLLS_DIR=~/.scrolls

### Scroll Configuration

If you wish to skip any configuration questions, you can provide the path to a configuration file with the `-c` or `--config` option:

scrolls new APP_NAME -c ~/.scrolls_config.rb

This config file is a script that can provide defaults for scrolls by setting config.SCROLL_NAME.OPTION_NAME. For example:
```
config.postgresql.pg_username = 'root'
config.postgresql.pg_password = ''
config.guard.guard_notifications = false
```

Or instead of passing a flag each time, just set the APPSCROLLS_CONFIG environment variable to include it every time:
export APPSCROLLS_CONFIG=~/.scrolls_config.rb

## Deployment Support

Web applications are boring if they aren't running proudly on the internet. The App Scrolls make this automatic for your favourite providers!
Expand Down
10 changes: 5 additions & 5 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ task :run => :clean do
require 'tempfile'
require 'appscrolls'

template = AppScrollsScrolls::Template.new(scrolls)
template = AppScrolls::Template.new(scrolls)

begin
dir = Dir.mktmpdir "rails_template"
Expand All @@ -42,22 +42,22 @@ task :print do
require 'appscrolls'

scrolls = ENV['SCROLLS'].split(',')
puts AppScrollsScrolls::Template.new(scrolls).compile
puts AppScrolls::Template.new(scrolls).compile
end

namespace :list do
desc "Display scrolls by category"
task :categories do
require 'appscrolls'
categories = AppScrollsScrolls::Scrolls.categories.sort
categories = AppScrolls::Scrolls.categories.sort
categories = (categories - ["other"]) + ["other"]
categories.each do |category|
puts "#{category}: #{AppScrollsScrolls::Scrolls.for(category).join(", ")}"
puts "#{category}: #{AppScrolls::Scrolls.for(category).join(", ")}"
end
end

# desc "Display scrolls by exclusion"
# task :exclusions do
#
# end
end
end
2 changes: 1 addition & 1 deletion appscrolls.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ require File.dirname(__FILE__) + "/version"

Gem::Specification.new do |s|
s.name = "appscrolls"
s.version = AppScrollsScrolls::VERSION
s.version = AppScrolls::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ["Michael Bleigh", "Dr Nic Williams"]
s.email = ["michael@intridea.com", "drnicwilliams@gmail.com"]
Expand Down
2 changes: 1 addition & 1 deletion bin/appscrolls
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ $:.push File.dirname(__FILE__) + '/../lib'
require 'rubygems'
require 'appscrolls/command'

AppScrollsScrolls::Command.start
AppScrolls::Command.start
7 changes: 7 additions & 0 deletions bin/scroll
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env ruby
$:.push File.dirname(__FILE__) + '/../lib'

require 'rubygems'
require 'appscrolls/command'

AppScrolls::Command.start
2 changes: 1 addition & 1 deletion bin/scrolls
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ $:.push File.dirname(__FILE__) + '/../lib'
require 'rubygems'
require 'appscrolls/command'

AppScrollsScrolls::Command.start
AppScrolls::Command.start
22 changes: 19 additions & 3 deletions lib/appscrolls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,24 @@
require 'appscrolls/config'
require 'appscrolls/template'

Dir[File.dirname(__FILE__) + '/../scrolls/*.rb'].each do |path|
def enroll_scroll_at(path)
key = File.basename(path, '.rb')
scroll = AppScrollsScrolls::Scroll.generate(key, File.open(path))
AppScrollsScrolls::Scrolls.add(scroll)
scroll_class_name = ActiveSupport::Inflector.camelize(key.gsub("-", "_"))

# default files of same keys as local scrolls are discarded
return if AppScrolls::Scrolls.const_defined?(scroll_class_name)

scroll = AppScrolls::Scroll.generate(key, File.open(path))
AppScrolls::Scrolls.add(scroll)
end

scroll_files = Dir[File.dirname(__FILE__) + '/../scrolls/*.rb']

# set up local scrolls if available
if dir = ENV['APPSCROLLS_DIR'] and dir != ""
scroll_files = Dir[dir+"/**{,/*/**}/*.rb"] + scroll_files
end

scroll_files.each do |path|
enroll_scroll_at(path)
end
47 changes: 36 additions & 11 deletions lib/appscrolls/command.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
require 'appscrolls'
require 'thor'
require File.dirname(__FILE__) + "/../../version"

module AppScrollsScrolls
module AppScrolls
class Command < Thor
include Thor::Actions

desc "version", "show version of currently installed AppScrolls gem"
def version
puts "AppScrolls version #{AppScrolls::VERSION} ready to make magic."
end

desc "new APP_NAME", "create a new Rails app"
method_option :scrolls, :type => :array, :aliases => "-s", :desc => "List scrolls, e.g. -s resque rails_basics jquery"
method_option :template, :type => :boolean, :aliases => "-t", :desc => "Only display template that would be used"
method_option :config, :type => :string, :aliases => "-c", :desc => "Path to config script to run before scrolls"
def new(name)
config_file = options[:config] || ENV['APPSCROLLS_CONFIG']
if options[:scrolls]
run_template(name, options[:scrolls], options[:template])
run_template(name, options[:scrolls], :display_only => options[:template], :config_file => config_file)
else
@scrolls = []

Expand All @@ -19,7 +28,7 @@ def new(name)
@scrolls.delete(scroll)
puts
puts "> #{yellow}Removed '#{scroll}' from template.#{clear}"
elsif AppScrollsScrolls::Scrolls.list.include?(scroll)
elsif AppScrolls::Scrolls.list.include?(scroll)
@scrolls << scroll
puts
puts "> #{green}Added '#{scroll}' to template.#{clear}"
Expand All @@ -29,22 +38,36 @@ def new(name)
end
end

run_template(name, @scrolls)
run_template(name, @scrolls, :display_only => options[:template], :config_file => config_file)
end
end

desc "list [CATEGORY]", "list available scrolls (optionally by category)"
def list(category = nil)
if category
scrolls = AppScrollsScrolls::Scrolls.for(category).map{|r| AppScrollsScrolls::Scroll.from_mongo(r) }
scrolls = AppScrolls::Scrolls.for(category).map{|r| AppScrolls::Scroll.from_mongo(r) }
else
scrolls = AppScrollsScrolls::Scrolls.list_classes
scrolls = AppScrolls::Scrolls.list_classes
end

scrolls.each do |scroll|
puts scroll.key.ljust(15) + "# #{scroll.description}"
end
end

desc "memorize NEW_SCROLL", "saves last git commit as a patch and creates scroll to apply it (alpha feature)"
def memorize(scroll_name)
scrolls_path = File.expand_path("../../../scrolls", __FILE__)
patch_file = scrolls_path + "/#{scroll_name}.diff"
scroll_file = scrolls_path + "/#{scroll_name}.rb"
@name = scroll_name
self.class.source_root File.expand_path("../../../templates", __FILE__)
self.class.attr_reader :name
template "diff_patch.tt", patch_file
template "memorized_scroll.tt", scroll_file
puts "Memorized #{scroll_name} into scroll diff patch #{scroll_name}.diff and scroll #{scroll_file}"
`open #{patch_file} #{scroll_file}`
end

no_tasks do
def cyan; "\033[36m" end
Expand All @@ -60,21 +83,23 @@ def scrolls_message
message << "#{green}#{bold}Your Scrolls:#{clear} #{@scrolls.join(", ")}"
message << "\n\n"
end
available_scrolls = AppScrollsScrolls::Scrolls.list - @scrolls
available_scrolls = AppScrolls::Scrolls.list - @scrolls
if available_scrolls.any?
message << "#{bold}#{cyan}Available Scrolls:#{clear} #{available_scrolls.join(', ')}"
message << "\n\n"
end
message
end

def run_template(name, scrolls, display_only = false)
def run_template(name, scrolls, options = {})
puts
puts
puts "#{bold}Generating and Running Template...#{clear}"
puts
file = Tempfile.new('template')
template = AppScrollsScrolls::Template.new(scrolls)
template_options = {}
template_options[:config_script] = File.read(options[:config_file]) if options[:config_file]
template = AppScrolls::Template.new(scrolls, template_options)

puts "Using the following scrolls:"
template.resolve_scrolls.map do |scroll|
Expand All @@ -85,14 +110,14 @@ def run_template(name, scrolls, display_only = false)

file.write template.compile
file.close
if display_only
if options[:display_only]
puts "Template stored to #{file.path}"
puts File.read(file.path)
else
system "rails new #{name} -m #{file.path} #{template.args.join(' ')}"
end
ensure
file.unlink
file.unlink unless options[:display_only]
end
end
end
Expand Down
9 changes: 5 additions & 4 deletions lib/appscrolls/config.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'active_support/ordered_hash'

module AppScrollsScrolls
module AppScrolls
class Config
attr_reader :questions

Expand All @@ -18,7 +18,7 @@ def initialize(schema)

def compile(values = {})
result = []
result << "config = #{values.inspect}"
result << "config.merge! #{values.inspect}" unless values.empty?
@questions.each_pair do |key, question|
result << "config['#{key}'] = #{question.compile} unless config.key?('#{key}')"
end
Expand All @@ -33,15 +33,16 @@ def initialize(details)
end

def compile
"#{question} if #{conditions}"
"#{question}#{conditions}"
end

def question
"ask_wizard(#{prompt.inspect})"
end

def conditions
[config_conditions, scroll_conditions].join(' && ')
conditions_string = [config_conditions, scroll_conditions].reject{|v| v=='true'}.join(' && ')
" if " + conditions_string unless conditions_string.empty?
end

def config_conditions
Expand Down
13 changes: 6 additions & 7 deletions lib/appscrolls/scroll.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
require 'yaml'
require 'erb'

module AppScrollsScrolls
module AppScrolls
class Scroll
extend Comparable

Expand Down Expand Up @@ -38,7 +38,7 @@ def self.generate(key, template_or_file, attributes = {})
template = template_or_file
end

scroll_class = Class.new(AppScrollsScrolls::Scroll)
scroll_class = Class.new(AppScrolls::Scroll)
scroll_class.attributes = attributes
scroll_class.template = template
scroll_class.key = key
Expand Down Expand Up @@ -72,16 +72,15 @@ def self.attributes=(hash)
end

def self.config
return nil unless attributes[:config]
AppScrollsScrolls::Config.new(attributes[:config])
AppScrolls::Config.new(attributes[:config]||[])
end

def attributes
self.class.attributes
end

def self.compile
"# >#{"[ #{name} ]".center(75,'-')}<\n\n# #{description}\nsay_scroll '#{name}'\n\n#{template}\n"
"# >#{"[ #{name} ]".center(75,'-')}<\n\n# #{description}\nsay_scroll '#{name.gsub("'", "\\'")}'\n\n#{template}\n"
end
def compile; self.class.compile end

Expand All @@ -95,8 +94,8 @@ def self.to_mongo(value)
end

def self.from_mongo(key)
return key if key.respond_to?(:superclass) && key.superclass == AppScrollsScrolls::Scroll
AppScrollsScrolls::Scrolls[key]
return key if key.respond_to?(:superclass) && key.superclass == AppScrolls::Scroll
AppScrolls::Scrolls[key]
end

def self.get_binding
Expand Down
6 changes: 4 additions & 2 deletions lib/appscrolls/scrolls.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
module AppScrollsScrolls
module AppScrolls
module Scrolls
@@categories = {}
@@list = {}

def self.add(scroll)
AppScrollsScrolls::Scrolls.const_set ActiveSupport::Inflector.camelize(scroll.key.gsub("-", "_")), scroll
sym = ActiveSupport::Inflector.camelize(scroll.key.gsub("-", "_"))
return if AppScrolls::Scrolls.const_defined?(sym)
AppScrolls::Scrolls.const_set ActiveSupport::Inflector.camelize(scroll.key.gsub("-", "_")), scroll
@@list[scroll.key] = scroll
(@@categories[scroll.category.to_s] ||= []) << scroll.key
@@categories[scroll.category.to_s].uniq!
Expand Down
Loading