Initial files
authorNeil Smith <neil.git@njae.me.uk>
Tue, 29 Dec 2015 17:41:41 +0000 (17:41 +0000)
committerNeil Smith <neil.git@njae.me.uk>
Tue, 29 Dec 2015 17:41:41 +0000 (17:41 +0000)
.gitignore [new file with mode: 0644]
Gemfile [new file with mode: 0644]
app.rb [new file with mode: 0644]
helpers.rb [new file with mode: 0644]
rakefile [new file with mode: 0644]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..a28186a
--- /dev/null
@@ -0,0 +1,31 @@
+*.gem
+*.rbc
+/.config
+/coverage/
+/InstalledFiles
+/pkg/
+/spec/reports/
+/spec/examples.txt
+/test/tmp/
+/test/version_tmp/
+/tmp/
+
+## Documentation cache and generated files:
+/.yardoc/
+/_yardoc/
+/doc/
+/rdoc/
+
+## Environment normalization:
+/.bundle/
+/vendor/bundle
+/lib/bundler/man/
+
+# for a library or gem, you might want to ignore these files since the code is
+# intended to run in multiple environments; otherwise, check them in:
+Gemfile.lock
+.ruby-version
+.ruby-gemset
+
+# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
+.rvmrc
diff --git a/Gemfile b/Gemfile
new file mode 100644 (file)
index 0000000..92c908e
--- /dev/null
+++ b/Gemfile
@@ -0,0 +1,13 @@
+# A sample Gemfile
+source "https://rubygems.org"
+
+gem 'sinatra'
+gem 'rake'
+
+group :test, :development do
+  gem 'rspec'
+end
+
+group :test do
+  gem 'rack-test'
+end
\ No newline at end of file
diff --git a/app.rb b/app.rb
new file mode 100644 (file)
index 0000000..9485a28
--- /dev/null
+++ b/app.rb
@@ -0,0 +1,22 @@
+# app.rb
+ENV['RACK_ENV'] ||= 'development'
+
+require 'bundler'
+Bundler.require :default, ENV['RACK_ENV'].to_sym
+
+require_relative 'helpers'
+# require_relative 'routes/secrets'
+# require_relative 'routes/sessions'
+
+class SimpleApp < Sinatra::Base
+  
+  set :root, File.dirname(__FILE__)
+
+  enable :sessions
+
+  helpers Sinatra::SampleApp::Helpers
+
+  # register Sinatra::SampleApp::Routing::Sessions
+  # register Sinatra::SampleApp::Routing::Secrets
+
+end
diff --git a/helpers.rb b/helpers.rb
new file mode 100644 (file)
index 0000000..a0de50d
--- /dev/null
@@ -0,0 +1,15 @@
+module Sinatra
+  module SampleApp
+    module Helpers
+
+      def require_logged_in
+        redirect('/sessions/new') unless is_authenticated?
+      end
+
+      def is_authenticated?
+        return !!session[:user_id]
+      end
+
+    end
+  end
+end
diff --git a/rakefile b/rakefile
new file mode 100644 (file)
index 0000000..89a8265
--- /dev/null
+++ b/rakefile
@@ -0,0 +1,8 @@
+# rakefile
+require 'rspec/core/rake_task'
+
+RSpec::Core::RakeTask.new :specs do |task|
+  task.pattern = Dir['spec/**/*_spec.rb']
+end
+
+task :default => ['specs']