forked from exercism/exercism
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cleanup the README and add the standard scripts folder
- Loading branch information
Showing
5 changed files
with
92 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |