gnarus_exercise 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,23 @@
1
+ GnarusExercise
2
+ ==============
3
+
4
+ This project rocks and uses MIT-LICENSE.
5
+
6
+ Configuring a new project without user ownership
7
+ ================================================
8
+
9
+ ```
10
+ rails new my_exercise -m https://raw.github.com/caelum/gnarus-exercise/master/template.rb
11
+ ```
12
+
13
+ You will be prompted about add <code>devise</code> into your application, then is up
14
+ to you accept or not. The template will handle all the configurations for you.
15
+
16
+
17
+ TODO
18
+ ====
19
+
20
+ - update method UPDATE from exercise to be safe
21
+ - exercisecontroller entire code should work with/without devise
22
+ - no need to override gnarusexercises:exercise would be lovely
23
+ - eval solution?
@@ -7,26 +7,12 @@ module GnarusExercise
7
7
  @exercises = Exercise.all.select{|e| e.author.id == current_user.id}
8
8
  end
9
9
 
10
- # GET /exercises/1
11
- # GET /exercises/1.json
12
10
  def show
13
11
  @exercise = Exercise.find(params[:id])
14
-
15
- respond_to do |format|
16
- format.html # show.html.erb
17
- format.json { render json: @exercise }
18
- end
19
12
  end
20
13
 
21
- # GET /exercises/new
22
- # GET /exercises/new.json
23
14
  def new
24
15
  @exercise = Exercise.new
25
-
26
- respond_to do |format|
27
- format.html # new.html.erb
28
- format.json { render json: @exercise }
29
- end
30
16
  end
31
17
 
32
18
  # GET /exercises/1/edit
@@ -34,26 +20,21 @@ module GnarusExercise
34
20
  @exercise = Exercise.find(params[:id])
35
21
  end
36
22
 
37
- # POST /exercises
38
- # POST /exercises.json
39
23
  def create
40
24
  @exercise = Exercise.new(params[:exercise])
41
25
  @exercise.author = current_user if defined?(Devise)
42
26
 
43
- respond_to do |format|
44
27
  if @exercise.save
45
- format.html { redirect_to @exercise, notice: 'Exercise was successfully created.' }
46
- format.json { render json: @exercise, status: :created, location: @exercise }
28
+ redirect_to @exercise, notice: 'Exercise was successfully created.'
47
29
  else
48
- format.html { render action: "new" }
49
- format.json { render json: @exercise.errors, status: :unprocessable_entity }
30
+ render action: "new"
50
31
  end
51
- end
52
32
  end
53
33
 
54
34
  def update
55
35
  @exercise = Exercise.find(params[:id])
56
36
  if defined?(Devise) && @exercise.author == current_user
37
+ params[:exercise].delete :author_id
57
38
  @exercise.update_attributes(params[:exercise])
58
39
  end
59
40
 
@@ -2,6 +2,6 @@ module GnarusExercise
2
2
  class Exercise < ActiveRecord::Base
3
3
  attr_accessible :author_id, :content
4
4
  has_many :attempts
5
- belongs_to :author, :class_name => User
5
+ belongs_to :author, :class_name => User if defined?(User)
6
6
  end
7
7
  end
@@ -15,6 +15,7 @@
15
15
  <%= f.label :content %><br />
16
16
  <%= f.text_area :content %>
17
17
  </div>
18
+ <%= render :partial => "my_fields", :locals => { :f => f} %>
18
19
  <div class="actions">
19
20
  <%= f.submit %>
20
21
  </div>
@@ -1,3 +1,3 @@
1
1
  module GnarusExercise
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
metadata CHANGED
@@ -1,55 +1,63 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: gnarus_exercise
3
- version: !ruby/object:Gem::Version
4
- version: 1.0.0
5
- prerelease:
3
+ version: !ruby/object:Gem::Version
4
+ hash: 21
5
+ prerelease: false
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 1
10
+ version: 1.0.1
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Guilherme Silveira
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2012-04-05 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
17
+
18
+ date: 2012-04-06 00:00:00 -03:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
15
22
  name: rails
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ~>
20
- - !ruby/object:Gem::Version
21
- version: 3.2.2
22
- type: :runtime
23
23
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
25
  none: false
26
- requirements:
26
+ requirements:
27
27
  - - ~>
28
- - !ruby/object:Gem::Version
28
+ - !ruby/object:Gem::Version
29
+ hash: 11
30
+ segments:
31
+ - 3
32
+ - 2
33
+ - 2
29
34
  version: 3.2.2
30
- - !ruby/object:Gem::Dependency
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
31
38
  name: sqlite3
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
37
- version: '0'
38
- type: :development
39
39
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
41
  none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '0'
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 3
46
+ segments:
47
+ - 0
48
+ version: "0"
49
+ type: :development
50
+ version_requirements: *id002
46
51
  description: Create external exercises by mounting this plugin.
47
- email:
52
+ email:
48
53
  - guilherme.silveira@caelum.com.br
49
54
  executables: []
55
+
50
56
  extensions: []
57
+
51
58
  extra_rdoc_files: []
52
- files:
59
+
60
+ files:
53
61
  - app/assets/javascripts/gnarus_exercise/application.js
54
62
  - app/assets/stylesheets/gnarus_exercise/application.css
55
63
  - app/controllers/gnarus_exercise/application_controller.rb
@@ -58,15 +66,12 @@ files:
58
66
  - app/helpers/gnarus_exercise/application_helper.rb
59
67
  - app/models/gnarus_exercise/attempt.rb
60
68
  - app/models/gnarus_exercise/exercise.rb
61
- - app/models/gnarus_exercise/user.rb
62
69
  - app/views/gnarus_exercise/exercises/_form.html.erb
63
70
  - app/views/gnarus_exercise/exercises/edit.html.erb
64
71
  - app/views/gnarus_exercise/exercises/index.html.erb
65
72
  - app/views/gnarus_exercise/exercises/new.html.erb
66
73
  - app/views/gnarus_exercise/exercises/show.html.erb
67
74
  - app/views/layouts/gnarus_exercise/application.html.erb
68
- - config/initializers/devise.rb
69
- - config/locales/devise.en.yml
70
75
  - config/routes.rb
71
76
  - db/migrate/20120405185453_create_gnarus_exercise_exercises.rb
72
77
  - db/migrate/20120405185533_create_gnarus_exercise_attempts.rb
@@ -76,7 +81,7 @@ files:
76
81
  - lib/tasks/gnarus_exercise_tasks.rake
77
82
  - MIT-LICENSE
78
83
  - Rakefile
79
- - README.rdoc
84
+ - README.md
80
85
  - test/dummy/app/assets/javascripts/application.js
81
86
  - test/dummy/app/assets/stylesheets/application.css
82
87
  - test/dummy/app/controllers/application_controller.rb
@@ -114,31 +119,41 @@ files:
114
119
  - test/unit/gnarus_exercise/attempt_test.rb
115
120
  - test/unit/gnarus_exercise/exercise_test.rb
116
121
  - test/unit/gnarus_exercise/user_test.rb
122
+ has_rdoc: true
117
123
  homepage: http://online.caelum.com.br
118
124
  licenses: []
125
+
119
126
  post_install_message:
120
127
  rdoc_options: []
121
- require_paths:
128
+
129
+ require_paths:
122
130
  - lib
123
- required_ruby_version: !ruby/object:Gem::Requirement
131
+ required_ruby_version: !ruby/object:Gem::Requirement
124
132
  none: false
125
- requirements:
126
- - - ! '>='
127
- - !ruby/object:Gem::Version
128
- version: '0'
129
- required_rubygems_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ hash: 3
137
+ segments:
138
+ - 0
139
+ version: "0"
140
+ required_rubygems_version: !ruby/object:Gem::Requirement
130
141
  none: false
131
- requirements:
132
- - - ! '>='
133
- - !ruby/object:Gem::Version
134
- version: '0'
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ hash: 3
146
+ segments:
147
+ - 0
148
+ version: "0"
135
149
  requirements: []
150
+
136
151
  rubyforge_project:
137
- rubygems_version: 1.8.19
152
+ rubygems_version: 1.3.7
138
153
  signing_key:
139
154
  specification_version: 3
140
155
  summary: A plugin structure for external exercises.
141
- test_files:
156
+ test_files:
142
157
  - test/dummy/app/assets/javascripts/application.js
143
158
  - test/dummy/app/assets/stylesheets/application.css
144
159
  - test/dummy/app/controllers/application_controller.rb
@@ -1,10 +0,0 @@
1
- = GnarusExercise
2
-
3
- This project rocks and uses MIT-LICENSE.
4
-
5
- echo "gem gnarus_exercise" > Gemfile
6
- echo "gem devise" > Gemfile
7
- bundle install
8
- rails g devise:install
9
- rails g devise User
10
- rake gnarus_exercise:install:migrations
@@ -1,5 +0,0 @@
1
- module GnarusExercise
2
- class User < ActiveRecord::Base
3
- # attr_accessible :title, :body
4
- end
5
- end
@@ -1,223 +0,0 @@
1
- # Use this hook to configure devise mailer, warden hooks and so forth.
2
- # Many of these configuration options can be set straight in your model.
3
- Devise.setup do |config|
4
- # ==> Mailer Configuration
5
- # Configure the e-mail address which will be shown in Devise::Mailer,
6
- # note that it will be overwritten if you use your own mailer class with default "from" parameter.
7
- config.mailer_sender = "please-change-me-at-config-initializers-devise@example.com"
8
-
9
- # Configure the class responsible to send e-mails.
10
- # config.mailer = "Devise::Mailer"
11
-
12
- # Automatically apply schema changes in tableless databases
13
- config.apply_schema = false
14
-
15
- # ==> ORM configuration
16
- # Load and configure the ORM. Supports :active_record (default) and
17
- # :mongoid (bson_ext recommended) by default. Other ORMs may be
18
- # available as additional gems.
19
- require 'devise/orm/active_record'
20
-
21
- # ==> Configuration for any authentication mechanism
22
- # Configure which keys are used when authenticating a user. The default is
23
- # just :email. You can configure it to use [:username, :subdomain], so for
24
- # authenticating a user, both parameters are required. Remember that those
25
- # parameters are used only when authenticating and not when retrieving from
26
- # session. If you need permissions, you should implement that in a before filter.
27
- # You can also supply a hash where the value is a boolean determining whether
28
- # or not authentication should be aborted when the value is not present.
29
- # config.authentication_keys = [ :email ]
30
-
31
- # Configure parameters from the request object used for authentication. Each entry
32
- # given should be a request method and it will automatically be passed to the
33
- # find_for_authentication method and considered in your model lookup. For instance,
34
- # if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
35
- # The same considerations mentioned for authentication_keys also apply to request_keys.
36
- # config.request_keys = []
37
-
38
- # Configure which authentication keys should be case-insensitive.
39
- # These keys will be downcased upon creating or modifying a user and when used
40
- # to authenticate or find a user. Default is :email.
41
- config.case_insensitive_keys = [ :email ]
42
-
43
- # Configure which authentication keys should have whitespace stripped.
44
- # These keys will have whitespace before and after removed upon creating or
45
- # modifying a user and when used to authenticate or find a user. Default is :email.
46
- config.strip_whitespace_keys = [ :email ]
47
-
48
- # Tell if authentication through request.params is enabled. True by default.
49
- # It can be set to an array that will enable params authentication only for the
50
- # given strategies, for example, `config.params_authenticatable = [:database]` will
51
- # enable it only for database (email + password) authentication.
52
- # config.params_authenticatable = true
53
-
54
- # Tell if authentication through HTTP Basic Auth is enabled. False by default.
55
- # It can be set to an array that will enable http authentication only for the
56
- # given strategies, for example, `config.http_authenticatable = [:token]` will
57
- # enable it only for token authentication.
58
- # config.http_authenticatable = false
59
-
60
- # If http headers should be returned for AJAX requests. True by default.
61
- # config.http_authenticatable_on_xhr = true
62
-
63
- # The realm used in Http Basic Authentication. "Application" by default.
64
- # config.http_authentication_realm = "Application"
65
-
66
- # It will change confirmation, password recovery and other workflows
67
- # to behave the same regardless if the e-mail provided was right or wrong.
68
- # Does not affect registerable.
69
- # config.paranoid = true
70
-
71
- # By default Devise will store the user in session. You can skip storage for
72
- # :http_auth and :token_auth by adding those symbols to the array below.
73
- # Notice that if you are skipping storage for all authentication paths, you
74
- # may want to disable generating routes to Devise's sessions controller by
75
- # passing :skip => :sessions to `devise_for` in your config/routes.rb
76
- config.skip_session_storage = [:http_auth]
77
-
78
- # ==> Configuration for :database_authenticatable
79
- # For bcrypt, this is the cost for hashing the password and defaults to 10. If
80
- # using other encryptors, it sets how many times you want the password re-encrypted.
81
- #
82
- # Limiting the stretches to just one in testing will increase the performance of
83
- # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
84
- # a value less than 10 in other environments.
85
- config.stretches = Rails.env.test? ? 1 : 10
86
-
87
- # Setup a pepper to generate the encrypted password.
88
- # config.pepper = "c15dde3b38b00250c612bae710383894fc4670bf4013bb36fedacacb906ddbfe819179662ae9368cafb82d82741e4b16a72ce55747a0ca518e8bbd953cae10c7"
89
-
90
- # ==> Configuration for :confirmable
91
- # A period that the user is allowed to access the website even without
92
- # confirming his account. For instance, if set to 2.days, the user will be
93
- # able to access the website for two days without confirming his account,
94
- # access will be blocked just in the third day. Default is 0.days, meaning
95
- # the user cannot access the website without confirming his account.
96
- # config.allow_unconfirmed_access_for = 2.days
97
-
98
- # If true, requires any email changes to be confirmed (exctly the same way as
99
- # initial account confirmation) to be applied. Requires additional unconfirmed_email
100
- # db field (see migrations). Until confirmed new email is stored in
101
- # unconfirmed email column, and copied to email column on successful confirmation.
102
- config.reconfirmable = true
103
-
104
- # Defines which key will be used when confirming an account
105
- # config.confirmation_keys = [ :email ]
106
-
107
- # ==> Configuration for :rememberable
108
- # The time the user will be remembered without asking for credentials again.
109
- # config.remember_for = 2.weeks
110
-
111
- # If true, extends the user's remember period when remembered via cookie.
112
- # config.extend_remember_period = false
113
-
114
- # If true, uses the password salt as remember token. This should be turned
115
- # to false if you are not using database authenticatable.
116
- config.use_salt_as_remember_token = true
117
-
118
- # Options to be passed to the created cookie. For instance, you can set
119
- # :secure => true in order to force SSL only cookies.
120
- # config.cookie_options = {}
121
-
122
- # ==> Configuration for :validatable
123
- # Range for password length. Default is 6..128.
124
- # config.password_length = 6..128
125
-
126
- # Email regex used to validate email formats. It simply asserts that
127
- # an one (and only one) @ exists in the given string. This is mainly
128
- # to give user feedback and not to assert the e-mail validity.
129
- # config.email_regexp = /\A[^@]+@[^@]+\z/
130
-
131
- # ==> Configuration for :timeoutable
132
- # The time you want to timeout the user session without activity. After this
133
- # time the user will be asked for credentials again. Default is 30 minutes.
134
- # config.timeout_in = 30.minutes
135
-
136
- # ==> Configuration for :lockable
137
- # Defines which strategy will be used to lock an account.
138
- # :failed_attempts = Locks an account after a number of failed attempts to sign in.
139
- # :none = No lock strategy. You should handle locking by yourself.
140
- # config.lock_strategy = :failed_attempts
141
-
142
- # Defines which key will be used when locking and unlocking an account
143
- # config.unlock_keys = [ :email ]
144
-
145
- # Defines which strategy will be used to unlock an account.
146
- # :email = Sends an unlock link to the user email
147
- # :time = Re-enables login after a certain amount of time (see :unlock_in below)
148
- # :both = Enables both strategies
149
- # :none = No unlock strategy. You should handle unlocking by yourself.
150
- # config.unlock_strategy = :both
151
-
152
- # Number of authentication tries before locking an account if lock_strategy
153
- # is failed attempts.
154
- # config.maximum_attempts = 20
155
-
156
- # Time interval to unlock the account if :time is enabled as unlock_strategy.
157
- # config.unlock_in = 1.hour
158
-
159
- # ==> Configuration for :recoverable
160
- #
161
- # Defines which key will be used when recovering the password for an account
162
- # config.reset_password_keys = [ :email ]
163
-
164
- # Time interval you can reset your password with a reset password key.
165
- # Don't put a too small interval or your users won't have the time to
166
- # change their passwords.
167
- config.reset_password_within = 6.hours
168
-
169
- # ==> Configuration for :encryptable
170
- # Allow you to use another encryption algorithm besides bcrypt (default). You can use
171
- # :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1,
172
- # :authlogic_sha512 (then you should set stretches above to 20 for default behavior)
173
- # and :restful_authentication_sha1 (then you should set stretches to 10, and copy
174
- # REST_AUTH_SITE_KEY to pepper)
175
- # config.encryptor = :sha512
176
-
177
- # ==> Configuration for :token_authenticatable
178
- # Defines name of the authentication token params key
179
- # config.token_authentication_key = :auth_token
180
-
181
- # ==> Scopes configuration
182
- # Turn scoped views on. Before rendering "sessions/new", it will first check for
183
- # "users/sessions/new". It's turned off by default because it's slower if you
184
- # are using only default views.
185
- # config.scoped_views = false
186
-
187
- # Configure the default scope given to Warden. By default it's the first
188
- # devise role declared in your routes (usually :user).
189
- # config.default_scope = :user
190
-
191
- # Configure sign_out behavior.
192
- # Sign_out action can be scoped (i.e. /users/sign_out affects only :user scope).
193
- # The default is true, which means any logout action will sign out all active scopes.
194
- # config.sign_out_all_scopes = true
195
-
196
- # ==> Navigation configuration
197
- # Lists the formats that should be treated as navigational. Formats like
198
- # :html, should redirect to the sign in page when the user does not have
199
- # access, but formats like :xml or :json, should return 401.
200
- #
201
- # If you have any extra navigational formats, like :iphone or :mobile, you
202
- # should add them to the navigational formats lists.
203
- #
204
- # The "*/*" below is required to match Internet Explorer requests.
205
- # config.navigational_formats = ["*/*", :html]
206
-
207
- # The default HTTP method used to sign out a resource. Default is :delete.
208
- config.sign_out_via = :delete
209
-
210
- # ==> OmniAuth
211
- # Add a new OmniAuth provider. Check the wiki for more information on setting
212
- # up on your models and hooks.
213
- # config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo'
214
-
215
- # ==> Warden configuration
216
- # If you want to use other strategies, that are not supported by Devise, or
217
- # change the failure app, you can configure them inside the config.warden block.
218
- #
219
- # config.warden do |manager|
220
- # manager.intercept_401 = false
221
- # manager.default_strategies(:scope => :user).unshift :some_external_strategy
222
- # end
223
- end
@@ -1,57 +0,0 @@
1
- # Additional translations at https://github.com/plataformatec/devise/wiki/I18n
2
-
3
- en:
4
- errors:
5
- messages:
6
- expired: "has expired, please request a new one"
7
- not_found: "not found"
8
- already_confirmed: "was already confirmed, please try signing in"
9
- not_locked: "was not locked"
10
- not_saved:
11
- one: "1 error prohibited this %{resource} from being saved:"
12
- other: "%{count} errors prohibited this %{resource} from being saved:"
13
-
14
- devise:
15
- failure:
16
- already_authenticated: 'You are already signed in.'
17
- unauthenticated: 'You need to sign in or sign up before continuing.'
18
- unconfirmed: 'You have to confirm your account before continuing.'
19
- locked: 'Your account is locked.'
20
- invalid: 'Invalid email or password.'
21
- invalid_token: 'Invalid authentication token.'
22
- timeout: 'Your session expired, please sign in again to continue.'
23
- inactive: 'Your account was not activated yet.'
24
- sessions:
25
- signed_in: 'Signed in successfully.'
26
- signed_out: 'Signed out successfully.'
27
- passwords:
28
- send_instructions: 'You will receive an email with instructions about how to reset your password in a few minutes.'
29
- updated: 'Your password was changed successfully. You are now signed in.'
30
- updated_not_active: 'Your password was changed successfully.'
31
- send_paranoid_instructions: "If your e-mail exists on our database, you will receive a password recovery link on your e-mail"
32
- confirmations:
33
- send_instructions: 'You will receive an email with instructions about how to confirm your account in a few minutes.'
34
- send_paranoid_instructions: 'If your e-mail exists on our database, you will receive an email with instructions about how to confirm your account in a few minutes.'
35
- confirmed: 'Your account was successfully confirmed. You are now signed in.'
36
- registrations:
37
- signed_up: 'Welcome! You have signed up successfully.'
38
- signed_up_but_unconfirmed: 'A message with a confirmation link has been sent to your email address. Please open the link to activate your account.'
39
- signed_up_but_inactive: 'You have signed up successfully. However, we could not sign you in because your account is not yet activated.'
40
- signed_up_but_locked: 'You have signed up successfully. However, we could not sign you in because your account is locked.'
41
- updated: 'You updated your account successfully.'
42
- update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and click on the confirm link to finalize confirming your new email address."
43
- destroyed: 'Bye! Your account was successfully cancelled. We hope to see you again soon.'
44
- unlocks:
45
- send_instructions: 'You will receive an email with instructions about how to unlock your account in a few minutes.'
46
- unlocked: 'Your account has been unlocked successfully. Please sign in to continue.'
47
- send_paranoid_instructions: 'If your account exists, you will receive an email with instructions about how to unlock it in a few minutes.'
48
- omniauth_callbacks:
49
- success: 'Successfully authorized from %{kind} account.'
50
- failure: 'Could not authorize you from %{kind} because "%{reason}".'
51
- mailer:
52
- confirmation_instructions:
53
- subject: 'Confirmation instructions'
54
- reset_password_instructions:
55
- subject: 'Reset password instructions'
56
- unlock_instructions:
57
- subject: 'Unlock Instructions'