Permalink
Browse files

Initial commit.

  • Loading branch information...
0 parents commit ccddf52b3c32f99d04663fa941de4a70455e8068 @bnadlerjr committed Feb 18, 2012
Showing with 328 additions and 0 deletions.
  1. +7 −0 .gitignore
  2. +1 −0 .rvmrc
  3. +25 −0 Gemfile
  4. +66 −0 Gemfile.lock
  5. +72 −0 README.rdoc
  6. +48 −0 Rakefile
  7. +3 −0 config.ru
  8. +7 −0 lib/skillmatch.rb
  9. +13 −0 lib/skillmatch/server.rb
  10. +1 −0 lib/skillmatch/views/index.haml
  11. +8 −0 lib/skillmatch/views/layout.haml
  12. +47 −0 test/rack_test_case.rb
  13. +19 −0 test/skillmatch/server_test.rb
  14. +11 −0 test/test_helper.rb
@@ -0,0 +1,7 @@
+*.swp
+.DS_Store
+.bundle
+.sass-cache
+doc
+tags
+tmp
1 .rvmrc
@@ -0,0 +1 @@
+rvm 1.9.3
25 Gemfile
@@ -0,0 +1,25 @@
+source 'http://rubygems.org'
+
+gem "haml", "~> 3.1.3"
+gem "sinatra", "~> 1.3.1"
+
+group :development do
+ gem "rake", "~> 0.9.2"
+ gem "rdoc", "~> 3.6.1"
+ gem "sass", "~> 3.1.3"
+end
+
+group :test do
+ gem "contest", "~> 0.1.3"
+ gem "flay", "~> 1.4.3"
+ gem "flog", "~> 2.5.3"
+ gem "launchy", "~> 2.0.5"
+ gem "mocha", "~> 0.10.0", :require => false
+ gem "rack-test", "~> 0.6.1"
+ gem "reek", "~> 1.2.8"
+ gem "roodi", "~> 2.1.0"
+ gem "simplecov", "~> 0.5.4", :require => false
+end
+
+group :production do
+end
@@ -0,0 +1,66 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ addressable (2.2.6)
+ contest (0.1.3)
+ flay (1.4.3)
+ ruby_parser (~> 2.0)
+ sexp_processor (~> 3.0)
+ flog (2.5.3)
+ ruby_parser (~> 2.0)
+ sexp_processor (~> 3.0)
+ haml (3.1.4)
+ launchy (2.0.5)
+ addressable (~> 2.2.6)
+ metaclass (0.0.1)
+ mocha (0.10.3)
+ metaclass (~> 0.0.1)
+ multi_json (1.0.4)
+ rack (1.4.1)
+ rack-protection (1.2.0)
+ rack
+ rack-test (0.6.1)
+ rack (>= 1.0)
+ rake (0.9.2.2)
+ rdoc (3.6.1)
+ reek (1.2.8)
+ ruby2ruby (~> 1.2)
+ ruby_parser (~> 2.0)
+ sexp_processor (~> 3.0)
+ roodi (2.1.0)
+ ruby_parser
+ ruby2ruby (1.3.1)
+ ruby_parser (~> 2.0)
+ sexp_processor (~> 3.0)
+ ruby_parser (2.3.1)
+ sexp_processor (~> 3.0)
+ sass (3.1.14)
+ sexp_processor (3.0.10)
+ simplecov (0.5.4)
+ multi_json (~> 1.0.3)
+ simplecov-html (~> 0.5.3)
+ simplecov-html (0.5.3)
+ sinatra (1.3.2)
+ rack (~> 1.3, >= 1.3.6)
+ rack-protection (~> 1.2)
+ tilt (~> 1.3, >= 1.3.3)
+ tilt (1.3.3)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ contest (~> 0.1.3)
+ flay (~> 1.4.3)
+ flog (~> 2.5.3)
+ haml (~> 3.1.3)
+ launchy (~> 2.0.5)
+ mocha (~> 0.10.0)
+ rack-test (~> 0.6.1)
+ rake (~> 0.9.2)
+ rdoc (~> 3.6.1)
+ reek (~> 1.2.8)
+ roodi (~> 2.1.0)
+ sass (~> 3.1.3)
+ simplecov (~> 0.5.4)
+ sinatra (~> 1.3.1)
@@ -0,0 +1,72 @@
+= Skillmatch
+TODO: <Insert description here>
+
+Author:: Bob Nadler, Jr. (bnadlerjr@gmail.com)
+
+== Notes / Use
+Install dependencies using Bundler:
+ bundle install
+
+Run using rackup file, for example:
+ rackup config.ru
+
+== Contributing
+
+=== Issues / Roadmap
+
+Use GitHub issues[http://github.com/bnadlerjr/skillmatch/issues] for reporting bug and feature requests.
+
+=== Patches / Pull Requests
+* Fork the project.
+* Make your feature addition or bug fix.
+* Add tests for it. This is important so I don’t break it in a future version
+ unintentionally.
+* Commit, do not mess with rakefile, version, or history (if you want to have
+ your own version, that is fine but bump version in a commit by itself I can
+ ignore when I pull).
+* Send me a pull request. Bonus points for topic branches.
+
+=== Project Layout
+/doc::
+ Project documentation. Can be generated using rake task.
+
+/lib::
+ Main project source code.
+
+/test::
+ All test source code and data samples.
+
+config.ru::
+ Rackup file.
+
+Gemfile::
+ Dependency management with Bundler.
+
+Rakefile::
+ Rake tasks for the project. Use "rake -T" to see a list of available tasks.
+
+README.rdoc::
+ This file.
+
+== License
+(The MIT License)
+
+Copyright (c) 2012 Bob Nadler, Jr.
+
+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.
@@ -0,0 +1,48 @@
+require "rake/testtask"
+require "rdoc/task"
+require "reek/rake/task"
+require "roodi"
+require "roodi_task"
+require "flay_task"
+require "flog_task"
+
+DEFAULT_TASKS = %w[test flog flay roodi reek]
+EXTRA_RDOC_FILES = ['README.rdoc']
+LIB_FILES = Dir["lib/**/*.rb"]
+MAIN_RDOC = 'README.rdoc'
+TEST_FILES = Dir["test/**/*_test.rb"]
+TITLE = 'skillmatch'
+
+desc "Default tasks: #{DEFAULT_TASKS.join(', ')}"
+task :default => DEFAULT_TASKS
+
+Rake::TestTask.new do |t|
+ t.libs << 'test'
+ t.test_files = TEST_FILES
+end
+
+RDoc::Task.new do |t|
+ t.main = MAIN_RDOC
+ t.rdoc_dir = 'doc'
+ t.rdoc_files.include(EXTRA_RDOC_FILES, LIB_FILES)
+ t.options << '-q'
+ t.title = TITLE
+end
+
+RoodiTask.new do |t|
+ t.patterns = %w[lib/**/*.rb]
+end
+
+FlayTask.new do |t|
+ t.dirs = %w[lib]
+end
+
+FlogTask.new do |t|
+ t.dirs = %w[lib]
+end
+
+Reek::Rake::Task.new do |t|
+ t.fail_on_error = true
+ t.reek_opts = "--quiet"
+ t.verbose = false
+end
@@ -0,0 +1,3 @@
+require File.join(File.dirname(__FILE__), 'lib/skillmatch/server')
+
+run Skillmatch::Server
@@ -0,0 +1,7 @@
+require 'rubygems'
+require 'bundler'
+Bundler.setup
+
+$:.push File.dirname(__FILE__)
+
+require 'sinatra/base'
@@ -0,0 +1,13 @@
+require File.join(File.dirname(__FILE__), '../skillmatch')
+
+module Skillmatch
+ # The main application server.
+ class Server < Sinatra::Base
+ set :app_file, __FILE__
+ set :public_folder, Proc.new { File.join(root, '../public') }
+
+ get '/' do
+ haml :index
+ end
+ end
+end
@@ -0,0 +1 @@
+%p Index template
@@ -0,0 +1,8 @@
+!!! 5
+%html
+ %head
+ %title Skillmatch
+ %meta{ :name => 'author', :content => 'Bob Nadler, Jr. <bnadlerjr@gmail.com>' }
+ %link{:rel => 'stylesheet', :type => 'text/css', :href => './css/styles.css'}/
+ %body
+ = yield
@@ -0,0 +1,47 @@
+require 'rack/test'
+require 'launchy'
+
+# Base Test Case for testing Rack apps. Provides custom assertions. Relies on
+# rack-test.
+class Rack::TestCase < Test::Unit::TestCase
+ include Rack::Test::Methods
+
+ CONTENT_TYPES = {
+ :json => "application/json;charset=utf-8",
+ :html => "text/html;charset=utf-8"
+ }
+
+ # Saves the last response body as a web page.
+ def show_me_the_page
+ filename = File.join('tmp', "#{Time.now.strftime('%Y-%m-%d %T')}.html")
+ File.open(filename, 'w') { |f| f.write(last_response.body) }
+ Launchy.open(filename)
+ end
+
+ # Asserts that the last response content type matches +content_type+.
+ # +content_type+ can be either +:html+ or +:json+.
+ def assert_content_type(content_type)
+ unless CONTENT_TYPES.keys.include?(content_type)
+ raise ArgumentError, "unrecognized content_type (#{content_type})"
+ end
+
+ assert_equal CONTENT_TYPES[content_type], last_response.content_type
+ end
+
+ # Asserts that the last response code matches +status+. If it does not, and
+ # +show_page+ is true, the response body is saved to a file and opened using
+ # the default browser. +show_page+ is +true+ by default.
+ def assert_response(status, show_page=true)
+ unless last_response.send("#{status}?")
+ show_me_the_page if show_page
+ flunk "expected last_response to be #{status} but was #{last_response.status}"
+ end
+ end
+
+ # Asserts that the last response body matches the regular expression
+ # +expected+.
+ def assert_body_includes(expected)
+ assert last_response.body.match(expected),
+ "expected last_response body to include #{expected}"
+ end
+end
@@ -0,0 +1,19 @@
+require 'test_helper'
+require 'rack_test_case'
+require 'skillmatch/server'
+
+module Skillmatch
+ class ServerTest < Rack::TestCase
+ test 'get root' do
+ get '/'
+ assert_response :ok
+ assert_content_type :html
+ assert_body_includes('Index template')
+ end
+
+ private
+ def app
+ Skillmatch::Server
+ end
+ end
+end
@@ -0,0 +1,11 @@
+$:.push File.join(File.dirname(__FILE__), '..', 'lib')
+
+require 'simplecov'
+SimpleCov.start do
+ add_filter '/test/' # Don't report on test files
+ coverage_dir 'tmp/coverage' # Put results in /tmp folder
+end
+
+require 'test/unit'
+require 'contest'
+require 'mocha'

0 comments on commit ccddf52

Please sign in to comment.