This repository has been archived by the owner on Dec 12, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
several new scripts to improve workflow
- Loading branch information
Showing
12 changed files
with
220 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/sh | ||
|
||
# Generate a new Rails app for RailsCasts | ||
|
||
rails new $* -m "$(dirname $0)/../templates/rails_template.rb" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,43 @@ | ||
#!/usr/bin/env ruby | ||
|
||
# Creates a new project directory given an episode name. | ||
# rcnew '123 Some Episode' | ||
# rcnew 123 'Some Episode' | ||
|
||
require "fileutils" | ||
require "erb" | ||
|
||
name = $*.join(" ") | ||
path = name.downcase.gsub(/[^0-9a-z]+/, ' ').strip.gsub(' ', '-') | ||
FileUtils.mkdir(path) | ||
FileUtils.mkdir("#{path}/edit") | ||
FileUtils.mkdir("#{path}/compressed") | ||
class EpisodeGenerator | ||
attr_reader :number, :name | ||
|
||
def initialize(number, name) | ||
@number = number.to_i | ||
@name = name | ||
end | ||
|
||
def run | ||
FileUtils.cp_r(template_path, path) | ||
Dir["#{path}/**/*.erb"].each do |erb| | ||
result = ERB.new(File.read(erb)).result(binding) | ||
File.write(erb.sub(/\.erb$/, ""), result) | ||
FileUtils.rm(erb) | ||
end | ||
end | ||
|
||
def dirname | ||
[number, *@name.downcase.gsub(/[^0-9a-z]+/, " ").split].join("-") | ||
end | ||
|
||
def path | ||
File.join(ENV["RAILSCASTS"], dirname) | ||
end | ||
|
||
def template_path | ||
File.join(ENV["RAILSCASTS"], "template-#{pro? ? 'pro' : 'free'}") | ||
end | ||
|
||
def pro? | ||
dirname =~ /revised$/ || @number % 2 > 0 | ||
end | ||
end | ||
|
||
EpisodeGenerator.new(*$*).run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env ruby | ||
|
||
# Push code to railscasts repository | ||
# rcpush | ||
|
||
require "rubygems" | ||
require "rest_client" # gem install rest-client | ||
|
||
class EpisodePusher | ||
attr_reader :name | ||
|
||
def initialize | ||
@name = `pwd`[/\/([0-9]+-.+)\//, 1] | ||
end | ||
|
||
def run | ||
create_repo | ||
push | ||
end | ||
|
||
def create_repo | ||
options = {login: ENV["GITHUB_USER"], token: ENV["GITHUB_TOKEN"], :name => "railscasts/#{name}", public: 1} | ||
RestClient.post("https://github.com/api/v2/json/repos/create", options) | ||
end | ||
|
||
def push | ||
system <<-COMMANDS | ||
git init | ||
git add . | ||
git commit -m 'initial commit' | ||
git remote add origin git@github.com:railscasts/#{name}.git | ||
git push -u origin master | ||
COMMANDS | ||
end | ||
end | ||
|
||
EpisodePusher.new.run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export RAILSCASTS="$HOME/Projects/RailsCasts/Episodes" | ||
|
||
rc() { cd $RAILSCASTS/$1; } | ||
_rc() { _files -W $RAILSCASTS -/; } | ||
compdef _rc rc | ||
|
||
# add plugin's bin directory to path | ||
export PATH="$(dirname $0)/bin:$PATH" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# RailsCasts Example Application | ||
|
||
Run these commands to try it out. | ||
|
||
``` | ||
bundle | ||
rake db:setup | ||
rails s | ||
``` | ||
|
||
Requires Ruby 1.9.2 or later to run. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Example</title> | ||
<%= stylesheet_link_tag "application", media: "all" %> | ||
<%= javascript_include_tag "application" %> | ||
<%= csrf_meta_tag %> | ||
</head> | ||
<body> | ||
<div id="container"> | ||
<% flash.each do |name, msg| %> | ||
<%= content_tag :div, msg, id: "flash_#{name}" %> | ||
<% end %> | ||
<%= yield %> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
html, body { | ||
background-color: #4B7399; | ||
font-family: Verdana, Helvetica, Arial; | ||
font-size: 14px; | ||
} | ||
|
||
a img { | ||
border: none; | ||
} | ||
|
||
a { | ||
color: #0000FF; | ||
} | ||
|
||
.clear { | ||
clear: both; | ||
height: 0; | ||
overflow: hidden; | ||
} | ||
|
||
#container { | ||
width: 80%; | ||
margin: 0 auto; | ||
background-color: #FFF; | ||
padding: 20px 40px; | ||
border: solid 1px black; | ||
margin-top: 20px; | ||
} | ||
|
||
#flash_notice, #flash_error, #flash_alert { | ||
padding: 5px 8px; | ||
margin: 10px 0; | ||
} | ||
|
||
#flash_notice { | ||
background-color: #CFC; | ||
border: solid 1px #6C6; | ||
} | ||
|
||
#flash_error, #flash_alert { | ||
background-color: #FCC; | ||
border: solid 1px #C66; | ||
} | ||
|
||
.field_with_errors { | ||
display: inline; | ||
} | ||
|
||
.error_messages { | ||
width: 400px; | ||
border: 2px solid #CF0000; | ||
padding: 0px; | ||
padding-bottom: 12px; | ||
margin-bottom: 20px; | ||
background-color: #f0f0f0; | ||
font-size: 12px; | ||
} | ||
|
||
.error_messages h2 { | ||
text-align: left; | ||
font-weight: bold; | ||
padding: 5px 10px; | ||
font-size: 12px; | ||
margin: 0; | ||
background-color: #c00; | ||
color: #fff; | ||
} | ||
|
||
.error_messages p { | ||
margin: 8px 10px; | ||
} | ||
|
||
.error_messages ul { | ||
margin-bottom: 0; | ||
} | ||
|
||
form .field, form .actions { | ||
margin: 12px 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
def template(from, to = nil) | ||
to ||= from | ||
remove_file to | ||
file to, File.read(File.expand_path("../#{from}", __FILE__)) | ||
end | ||
|
||
remove_file "app/assets/images/rails.png" | ||
remove_file "public/index.html" | ||
remove_file "README.rdoc" | ||
template "README.md" | ||
template "layout.css.scss", "app/assets/stylesheets/layout.css.scss" | ||
template "application.html.erb", "app/views/layouts/application.html.erb" |