Skip to content

Commit

Permalink
cleanup the README and add the standard scripts folder
Browse files Browse the repository at this point in the history
  • Loading branch information
vosechu committed Jun 15, 2013
1 parent 3da7598 commit 1a18447
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 62 deletions.
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
*.gem
*.rbc
.bundle
.config
coverage
InstalledFiles
lib/bundler/man
pkg
rdoc
spec/reports
test/tmp
test/version_tmp
tmp

# ENV vars
scripts/boot.sh

# YARD artifacts
.yardoc
_yardoc
doc/
77 changes: 16 additions & 61 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,64 +50,19 @@ The warmup exercises are collected from all over the web.
2. Install gems with: `bundle`
3. Get a client id/secret from Github at https://github.com/settings/applications/new.
* Name: whatever
* URL: http://localhost:9292
* Callback url: http://localhost:9292/github/callback
4. Start server with: `EXERCISM_GITHUB_CLIENT_ID=xxx EXERCISM_GITHUB_CLIENT_SECRET=xxx rackup`
You can also export these in your .bash_profile:
export EXERCISM_GITHUB_CLIENT_ID=xxx
export EXERCISM_GITHUB_CLIENT_SECRET=xxx
Then you can start the server with just `rackup`.
5. Login at http://localhost:9292.
6. Add yourself to the admin_users method in user.rb

## Seed

Here's a basic seed script that I've used/tweaked per whatever I need:

```ruby
$:.unshift File.expand_path("../lib", __FILE__)
require 'bundler'
Bundler.require
require 'exercism'

def reset
Mongoid.default_session.collections.each do |coll|
unless coll.name == 'system.indexes'
puts "Removing collection: #{coll.name}"
coll.drop
end
end
end

reset

alice_data = {
username: 'alice',
github_id: -1,
email: "[email protected]",
current: {'ruby' => 'nucleotide-count'},
completed: {'ruby' => %w(bob word-count anagram beer-song)}
}
alice = User.create(alice_data)

bob_data = {
username: 'bob',
github_id: -2,
email: "[email protected]",
current: {'ruby' => 'bob'},
}
bob = User.create(bob_data)

admin = User.create(username: 'kytrinyx', github_id: 276834, email: "[email protected]")

attempt = Attempt.new(alice, 'puts "hello world"', 'nucleotide_count.rb').save
attempt = Attempt.new(bob, "def bark\n \"woof\"\nend", 'bob.rb').save
Nitpick.new(attempt.submission.id, admin, 'Not enough code.').save
Nitpick.new(attempt.submission.id, admin, 'I like the method name.').save

[alice, bob, admin].each do |user|
puts
puts "Created: #{user.username}"
puts "API Key: #{user.key}"
end
```
* URL: http://localhost:4567
* Callback url: http://localhost:4567/github/callback
4. Add yourself to the admin_users method in user.rb
5. Run the seeds with `ruby scripts/seed.rb`
6. Start server with: `EXERCISM_GITHUB_CLIENT_ID=xxx EXERCISM_GITHUB_CLIENT_SECRET=xxx rackup -p 4567`
7. Login at http://localhost:4567.

#### Optional steps

Copy the export values from `scripts/boot.sh.example` into your `~/.bash_profile` or `~/.zshrc`
or
Copy bootrunner `cp scripts/boot.sh.example scripts/boot.sh`

## Testing

Run tests with: `rake test`
2 changes: 1 addition & 1 deletion lib/app/views/backdoor.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% if ENV['RACK_ENV'].to_sym == :development %>
<li><a href="/backdoor?id=276834">be admin</a></li>
<li><a href="/backdoor?id=<%= ENV.fetch('EXERCISM_ADMIN_ID') || 276834 %>">be admin</a></li>
<li><a href="/backdoor?id=-1">be alice</a></li>
<% end %>
9 changes: 9 additions & 0 deletions scripts/boot.sh.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh
# These can also be exported in your ~/.bash_profile or ~/.zshrc
export EXERCISM_GITHUB_CLIENT_ID=xxx
export EXERCISM_GITHUB_CLIENT_SECRET=xxx
# This is the github id of your admin account if you want your admin to work
# via the 'login via github' link on the homepage. If you want this you'll
# need to edit the seeds file to change Katrina's user details to your own
# export EXERCISM_ADMIN_ID=xxx
rackup -p 4567
45 changes: 45 additions & 0 deletions scripts/seed.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
$:.unshift File.expand_path("./../../lib", __FILE__)
require 'bundler'
Bundler.require
require 'exercism'

def reset
Mongoid.default_session.collections.each do |coll|
unless coll.name == 'system.indexes'
puts "Removing collection: #{coll.name}"
coll.drop
end
end
end

reset

alice_data = {
username: 'alice',
github_id: -1,
email: "[email protected]",
current: {'ruby' => 'nucleotide-count'},
completed: {'ruby' => %w(bob word-count anagram beer-song)}
}
alice = User.create(alice_data)

bob_data = {
username: 'bob',
github_id: -2,
email: "[email protected]",
current: {'ruby' => 'bob'},
}
bob = User.create(bob_data)

admin = User.create(username: 'kytrinyx', github_id: 276834, email: "[email protected]")

attempt = Attempt.new(alice, 'puts "hello world"', 'nucleotide_count.rb').save
attempt = Attempt.new(bob, "def bark\n \"woof\"\nend", 'bob.rb').save
Nitpick.new(attempt.submission.id, admin, 'Not enough code.').save
Nitpick.new(attempt.submission.id, admin, 'I like the method name.').save

[alice, bob, admin].each do |user|
puts
puts "Created: #{user.username}"
puts "API Key: #{user.key}"
end

0 comments on commit 1a18447

Please sign in to comment.