Skip to content

Commit

Permalink
Merge pull request #1 from codeunion/initial-files
Browse files Browse the repository at this point in the history
Initial files
  • Loading branch information
tannerwelsh committed Oct 30, 2014
2 parents 53ba041 + b986c06 commit 27a1e2b
Show file tree
Hide file tree
Showing 14 changed files with 775 additions and 0 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DATABASE_URL=sqlite:development.db
31 changes: 31 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
.DS_Store
.env
*.db

*.gem
*.rbc
/.config
/coverage/
/InstalledFiles
/pkg/
/spec/reports/
/test/tmp/
/test/version_tmp/
/tmp/

## Specific to RubyMotion:
.dat*
.repl_history
build/

## Documentation cache and generated files:
/.yardoc/
/_yardoc/
/doc/
/rdoc/

## Environment normalisation:
/.bundle/
/lib/bundler/man/

.rvmrc
19 changes: 19 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
source 'https://rubygems.org'

gem 'sinatra'
gem 'data_mapper'

gem 'rake'
gem 'faker'

group :development do
gem 'sqlite3'
gem 'dm-sqlite-adapter'
gem 'dotenv'
gem 'rerun'
end

group :production do
gem 'dm-postgres-adapter'
gem 'pg'
end
111 changes: 111 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
GEM
remote: https://rubygems.org/
specs:
addressable (2.3.6)
bcrypt (3.1.9)
bcrypt-ruby (3.1.5)
bcrypt (>= 3.1.3)
celluloid (0.16.0)
timers (~> 4.0.0)
data_mapper (1.2.0)
dm-aggregates (~> 1.2.0)
dm-constraints (~> 1.2.0)
dm-core (~> 1.2.0)
dm-migrations (~> 1.2.0)
dm-serializer (~> 1.2.0)
dm-timestamps (~> 1.2.0)
dm-transactions (~> 1.2.0)
dm-types (~> 1.2.0)
dm-validations (~> 1.2.0)
data_objects (0.10.14)
addressable (~> 2.1)
dm-aggregates (1.2.0)
dm-core (~> 1.2.0)
dm-constraints (1.2.0)
dm-core (~> 1.2.0)
dm-core (1.2.1)
addressable (~> 2.3)
dm-do-adapter (1.2.0)
data_objects (~> 0.10.6)
dm-core (~> 1.2.0)
dm-migrations (1.2.0)
dm-core (~> 1.2.0)
dm-postgres-adapter (1.2.0)
dm-do-adapter (~> 1.2.0)
do_postgres (~> 0.10.6)
dm-serializer (1.2.2)
dm-core (~> 1.2.0)
fastercsv (~> 1.5)
json (~> 1.6)
json_pure (~> 1.6)
multi_json (~> 1.0)
dm-sqlite-adapter (1.2.0)
dm-do-adapter (~> 1.2.0)
do_sqlite3 (~> 0.10.6)
dm-timestamps (1.2.0)
dm-core (~> 1.2.0)
dm-transactions (1.2.0)
dm-core (~> 1.2.0)
dm-types (1.2.2)
bcrypt-ruby (~> 3.0)
dm-core (~> 1.2.0)
fastercsv (~> 1.5)
json (~> 1.6)
multi_json (~> 1.0)
stringex (~> 1.4)
uuidtools (~> 2.1)
dm-validations (1.2.0)
dm-core (~> 1.2.0)
do_postgres (0.10.14)
data_objects (= 0.10.14)
do_sqlite3 (0.10.14)
data_objects (= 0.10.14)
dotenv (1.0.2)
faker (1.4.3)
i18n (~> 0.5)
fastercsv (1.5.5)
ffi (1.9.6)
hitimes (1.2.2)
i18n (0.6.11)
json (1.8.1)
json_pure (1.8.1)
listen (2.7.11)
celluloid (>= 0.15.2)
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9)
multi_json (1.10.1)
pg (0.17.1)
rack (1.5.2)
rack-protection (1.5.3)
rack
rake (10.3.2)
rb-fsevent (0.9.4)
rb-inotify (0.9.5)
ffi (>= 0.5.0)
rerun (0.10.0)
listen (~> 2.7, >= 2.7.3)
sinatra (1.4.5)
rack (~> 1.4)
rack-protection (~> 1.4)
tilt (~> 1.3, >= 1.3.4)
sqlite3 (1.3.9)
stringex (1.5.1)
tilt (1.4.1)
timers (4.0.1)
hitimes
uuidtools (2.1.5)

PLATFORMS
ruby

DEPENDENCIES
data_mapper
dm-postgres-adapter
dm-sqlite-adapter
dotenv
faker
pg
rake
rerun
sinatra
sqlite3
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,30 @@ Once you have SQLite3 working, you can set up your development environment with

### Files In This Repository

```sh
├── .env.example # a sample .env file for setting environment variables
├── .gitignore # list of files to be ignored by git
├── CODE_OF_CONDUCT.md # standards of relating between contributors
├── CONTRIBUTING.md # how to contribute
├── Gemfile # list of gems that this project uses
├── Gemfile.lock # a "locked" version of the Gemfile, which includes version numbers for all the gems
├── LICENSE.md # license for project material
├── README.md # you are here. ;D
├── Rakefile # a place to store one-off commands (like seeding the database)
├── config # put configuration scripts in this folder
│   └── dotenv.rb # like this one! for the dotenv gem
├── config.ru # this tells our web server how to run
├── linkedout.rb # the most important file! this is the heart of our Sinatra web app, where we define how to respond to requests from across the web
├── models.rb # where we define the data models for the app, using an ORM like DataMapper
├── public # a folder to hold "static assets" like CSS files, images, and JavaScript files
│   ├── main.css # our custom CSS
│   └── normalize.css # a commonly used CSS library to aid in cross-browser compatibility
└── views # a folder to hold the HTML templates for our pages
├── layout.erb # this is the main template for our site
└── resumes # a sub-folder, to hold specific templates related to résumés
└── show.erb # the template for the résumé show page
```

## Releases

We've inherited a project that has already been worked on. It is up to release 0.8.0, which contains the following features:
Expand Down
29 changes: 29 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
require_relative './config/dotenv'
require_relative './models'

require 'faker'

task 'db:seed' do
# Create a new user
user = User.create({ :name => Faker::Name.name,
:bio => Faker::Lorem.paragraph(2),
:email => Faker::Internet.email,
:phone => Faker::PhoneNumber.phone_number,
:website => Faker::Internet.url })

# Create 5 jobs
jobs = Array.new(5) { Job.create({ :job_title => Faker::Name.title,
:job_description => Faker::Company.bs,
:company_name => Faker::Company.name })
}

# Create a random number of skills
skills = Array.new(rand(10)) { Skill.create({ :name => Faker::Hacker.ingverb }) }

# Associate the jobs and skills with the user
jobs.each { |job| user.jobs << job }
skills.each { |skill| user.skills << skill }

# Save the user and all associations
user.save
end
3 changes: 3 additions & 0 deletions config.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
require './linkedout.rb'

run Sinatra::Application
4 changes: 4 additions & 0 deletions config/dotenv.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
if ENV['RACK_ENV'] != 'production'
require 'dotenv'
Dotenv.load('.env')
end
17 changes: 17 additions & 0 deletions linkedout.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
require 'sinatra'

require_relative 'config/dotenv'
require_relative 'models'

helpers do
def default_user
@default_user ||= User.last
end
end

get "/" do
@jobs = default_user.jobs
@skills = default_user.skills

erb :'resumes/show'
end
42 changes: 42 additions & 0 deletions models.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
require 'data_mapper'

DataMapper.setup(:default, ENV['DATABASE_URL'])

class User
include DataMapper::Resource

property :id, Serial
property :name, String, { :required => true }
property :bio, Text, { :required => true }
property :email, String, { :required => true,
:unique => true,
:format => :email_address }
property :phone, String
property :website, String, { :format => :url }

has n, :jobs, { :child_key => [:user_id] }
has n, :skills, { :child_key => [:user_id] }
end

class Job
include DataMapper::Resource

property :id, Serial
property :job_title, String, { :required => true }
property :job_description, String, { :required => true }
property :company_name, String, { :required => true }

belongs_to :user
end

class Skill
include DataMapper::Resource

property :id, Serial
property :name, String, { :required => true }

belongs_to :user
end

DataMapper.finalize
DataMapper.auto_upgrade!
9 changes: 9 additions & 0 deletions public/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
header {
min-width: 100%;
text-align: center;
}

.resume {
margin: 0 auto;
width: 720px;
}
Loading

0 comments on commit 27a1e2b

Please sign in to comment.