Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
winton committed Jun 15, 2009
0 parents commit 648ace0
Show file tree
Hide file tree
Showing 27 changed files with 233 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .gitignore
@@ -0,0 +1,7 @@
.DS_Store
*.gem
coverage
log
pkg
tmp
vendor
18 changes: 18 additions & 0 deletions MIT-LICENSE
@@ -0,0 +1,18 @@
Copyright (c) 2009 Winton Welsh

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18 changes: 18 additions & 0 deletions README.markdown
@@ -0,0 +1,18 @@
GemTemplate
===========

A gem template for new projects.

Setup
-----

<pre>
git clone git://github.com/winton/sum.git my_project
cd my_project
rake setup
git remote add origin git@github.com:winton/my_project.git
</pre>

A project wide find-replace occurs on file names and contents.

Edit <code>gemspec.rb</code> and <code>MIT-LICENSE</code>, and your project is ready for its first commit.
64 changes: 64 additions & 0 deletions Rakefile
@@ -0,0 +1,64 @@
require 'rubygems'
require 'rake'
require 'rake/gempackagetask'
require 'spec/rake/spectask'
require 'gemspec'

begin
require 'vendor/active_wrapper/lib/active_wrapper/tasks'

ActiveWrapper::Tasks.new(
:base => File.dirname(__FILE__),
:env => ENV['ENV']
)
rescue Exception
end

desc "Generate gemspec"
task :gemspec do
File.open("#{Dir.pwd}/#{GEM_NAME}.gemspec", 'w') do |f|
f.write(GEM_SPEC.to_ruby)
end
end

desc "Install gem"
task :install do
Rake::Task['gem'].invoke
`sudo gem uninstall #{GEM_NAME} -x`
`sudo gem install pkg/#{GEM_NAME}*.gem`
`rm -Rf pkg`
end

desc "Package gem"
Rake::GemPackageTask.new(GEM_SPEC) do |pkg|
pkg.gem_spec = GEM_SPEC
end

desc "Setup project"
task :setup do
name = File.basename(Dir.pwd)
`rm -Rf .git`
begin
dir = Dir['**/gem_template*']
from = dir.pop
if from
rb = from.include?('.rb')
to = File.dirname(from) + "/#{name}#{'.rb' if rb}"
FileUtils.mv(from, to)
end
end while dir.length > 0
Dir["**/*"].each do |path|
next if path.include?('Rakefile')
if File.file?(path)
`sed -i "" 's/gem_template/#{name}/g' #{path}`
end
end
`git init`
end

desc "Run specs"
Spec::Rake::SpecTask.new do |t|
t.rcov = true
t.spec_opts = ["--format", "specdoc", "--colour"]
t.spec_files = FileList["spec/**/*_spec.rb"]
end
3 changes: 3 additions & 0 deletions app.ru
@@ -0,0 +1,3 @@
require "#{File.dirname(__FILE__)}/lib/sum"

run Application
10 changes: 10 additions & 0 deletions bin/sum
@@ -0,0 +1,10 @@
#!/usr/bin/env ruby

$:.push File.expand_path("#{File.dirname(__FILE__)}/../lib")
require 'sum'

Application.class_eval do
set :environment, ENV['RACK_ENV'] || :production
end

Application.run!
10 changes: 10 additions & 0 deletions config/database.yml
@@ -0,0 +1,10 @@
development: &dev
adapter: mysql
database: sum
username: root
password:
host: localhost
production:
<<: *dev
test:
<<: *dev
6 changes: 6 additions & 0 deletions config/externals.yml
@@ -0,0 +1,6 @@
active_wrapper:
repo: git@github.com:winton/active_wrapper.git
path: vendor
sinatra:
repo: git://github.com/sinatra/sinatra.git
path: vendor
Empty file added db/migrate/.gitignore
Empty file.
18 changes: 18 additions & 0 deletions db/migrate/001_users.rb
@@ -0,0 +1,18 @@
class Users < ActiveRecord::Migration
def self.up
create_table :users do |t|
t.column :recent_transactions, :string, :size => 1024
t.column :savings_goal, :decimal, :precision => 10, :scale => 2
t.column :spending_goal, :decimal, :precision => 10, :scale => 2
t.column :spent_this_month, :decimal, :precision => 10, :scale => 2
t.column :temporary_spending_reduction, :decimal, :precision => 10, :scale => 2
t.column :send_at, :datetime
t.column :reset_at, :datetime
t.timestamps
end
end

def self.down
drop_table :users
end
end
19 changes: 19 additions & 0 deletions gemspec.rb
@@ -0,0 +1,19 @@
GEM_NAME = 'sum'
GEM_FILES = FileList['**/*'] - FileList['coverage', 'coverage/**/*', 'pkg', 'pkg/**/*']
GEM_SPEC = Gem::Specification.new do |s|
# == CONFIGURE ==
s.author = "Winton Welsh"
s.email = "mail@wintoni.us"
s.homepage = "http://github.com/winton/#{GEM_NAME}"
s.summary = "Sinatra app that powers SumApp.com, a super simple budgeting system"
# == CONFIGURE ==
s.executables << GEM_NAME
s.extensions << "install"
s.extra_rdoc_files = [ "README.markdown" ]
s.files = GEM_FILES.to_a
s.has_rdoc = false
s.name = GEM_NAME
s.platform = Gem::Platform::RUBY
s.require_path = "lib"
s.version = "0.1.0"
end
4 changes: 4 additions & 0 deletions install
@@ -0,0 +1,4 @@
#!/usr/bin/env ruby

$:.push File.expand_path("#{File.dirname(__FILE__)}/lib")
require 'sum'
11 changes: 11 additions & 0 deletions lib/sum.rb
@@ -0,0 +1,11 @@
Dir["#{File.dirname(__FILE__)}/../vendor/*/lib"].each do |path|
$:.unshift path
end

require 'active_wrapper'
require 'sinatra/base'

class Application < Sinatra::Base
end

require "#{File.dirname(__FILE__)}/sum/boot"
21 changes: 21 additions & 0 deletions lib/sum/boot.rb
@@ -0,0 +1,21 @@
Application.class_eval do

set :root, File.expand_path("#{File.dirname(__FILE__)}/../../")
set :public, "#{root}/public"
set :logging, true
set :static, true
set :views, "#{root}/lib/views"

# Set up database and logging
$db, $log = ActiveWrapper.setup(
:base => root,
:env => environment,
:stdout => true
)
$db.establish_connection

# Require controllers and models
Dir["#{root}/lib/sum/**/*.rb"].each do |path|
require path unless path == __FILE__
end
end
5 changes: 5 additions & 0 deletions lib/sum/controller/front.rb
@@ -0,0 +1,5 @@
Application.class_eval do
get '/' do
"#{self.class.environment}"
end
end
2 changes: 2 additions & 0 deletions lib/sum/model/user.rb
@@ -0,0 +1,2 @@
class User < ActiveRecord::Base
end
Binary file added public/images/1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/3.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/bg.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/field_off.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/field_on.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/github_ribbon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/submit.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/top.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions spec/spec.opts
@@ -0,0 +1 @@
--color
16 changes: 16 additions & 0 deletions spec/spec_helper.rb
@@ -0,0 +1,16 @@
$TESTING=true
SPEC = File.dirname(__FILE__)
$:.unshift File.expand_path("#{SPEC}/../lib")

require 'sum'
require 'pp'

Spec::Runner.configure do |config|
end

# For use with rspec textmate bundle
def debug(object)
puts "<pre>"
puts object.pretty_inspect.gsub('<', '&lt;').gsub('>', '&gt;')
puts "</pre>"
end

0 comments on commit 648ace0

Please sign in to comment.