hydra-tutorial 0.1.3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/README.md +92 -22
- data/bin/hydra-tutorial +4 -2
- data/development_notes.txt +476 -0
- data/hydra-tutorial.gemspec +9 -11
- data/{templates → old_tutorial/templates}/application/dataset_hydra_mods_om.rb +0 -0
- data/{templates → old_tutorial/templates}/application/dataset_hydra_om.rb +0 -0
- data/{templates → old_tutorial/templates}/application/datasets_controller.rb +0 -0
- data/{or_templates/adding_our_models → old_tutorial/templates/application}/mods_desc_metadata.rb +0 -0
- data/{templates → old_tutorial/templates}/building_a_basic_rails_app/dataset_af_om.rb +0 -0
- data/{templates → old_tutorial/templates}/building_a_basic_rails_app/dataset_simple_om.rb +0 -0
- data/{or_templates → old_tutorial/templates}/building_a_basic_rails_app/fedora.yml +0 -0
- data/{templates → old_tutorial/templates}/building_a_basic_rails_app/om_record.rb +0 -0
- data/{or_templates → old_tutorial/templates}/building_a_basic_rails_app/solr.yml +0 -0
- data/old_tutorial/tutorial.thor +493 -0
- data/{or_templates/sprinkle_some_styling → templates}/_add_assets_links.html.erb +0 -0
- data/{or_templates/add_file_upload/_form.html.erb → templates/_form.add_file_upload.html.erb} +0 -0
- data/{or_templates/wiring_it_into_rails/_form.html.erb → templates/_form.wiring_it_into_rails.html.erb} +0 -0
- data/{or_templates/adding_our_models → templates}/basic_af_model.rb +0 -0
- data/{or_templates/adding_our_models → templates}/basic_mods_model.rb +0 -0
- data/{or_templates/adding_our_models → templates}/basic_om_model.rb +0 -0
- data/{or_templates/add_tests → templates}/ci.rake +0 -0
- data/{or_templates/add_tests → templates}/ci_with_coverage.rake +0 -0
- data/templates/{building_a_basic_rails_app/fedora.yml → fedora.yml} +0 -0
- data/{or_templates/add_tests → templates}/integration_spec.rb +0 -0
- data/templates/{application/mods_desc_metadata.rb → mods_desc_metadata.rb} +0 -0
- data/{or_templates → templates}/records_controller.rb +0 -0
- data/{or_templates/add_tests → templates}/records_controller_spec.rb +0 -0
- data/{or_templates/wiring_it_into_rails → templates}/show.html.erb +0 -0
- data/templates/{building_a_basic_rails_app/solr.yml → solr.yml} +0 -0
- data/tutorial.thor +806 -341
- metadata +32 -30
- data/open-repositories-tutorial.thor +0 -888
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -2,34 +2,104 @@
|
|
2
2
|
|
3
3
|
The tutorial will:
|
4
4
|
|
5
|
-
*
|
6
|
-
*
|
7
|
-
*
|
8
|
-
*
|
9
|
-
*
|
10
|
-
*
|
11
|
-
*
|
12
|
-
*
|
13
|
-
*
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
5
|
+
* Install all Hydra / Rails application prerequisites.
|
6
|
+
* Generate a new rails application.
|
7
|
+
* Walk through building a Hydra model:
|
8
|
+
* First, as an ActiveFedora::Base object with an XML datastream.
|
9
|
+
* Then, with a simple OM terminology for a basic, contrived schema
|
10
|
+
* Finally, with a simple MODS-based terminology.
|
11
|
+
* Wire the model into Rails using standard Rails scaffolding.
|
12
|
+
* Add blacklight and hydra-head gems for object discovery.
|
13
|
+
* Add some basic Rspec and Capybara tests.
|
14
|
+
|
15
|
+
At the end of the tutorial, you will have a working Hydra Head for adding
|
16
|
+
MODS-based metadata records.
|
17
|
+
|
18
|
+
Throughout the process, there are several prompts to poke around the Rails
|
19
|
+
console and/or in a browser. In addition, Git is used to help you track changes
|
20
|
+
in the code from one step of the tutorial to the next.
|
21
|
+
|
22
|
+
In subsequent releases of the tutorial, we will try to wire in file uploads,
|
23
|
+
collections, more complete test example, etc.
|
19
24
|
|
20
25
|
## Pre-requisites
|
21
|
-
* ruby v 1.8.7 or higher
|
22
|
-
* java 1.5 or higher (in order to run solr under a java servlet container)
|
23
|
-
* [[RVM|https://rvm.beginrescueend.com/rvm/install/]] (recommended)
|
24
26
|
|
25
|
-
|
27
|
+
This tutorial depends on the following:
|
28
|
+
|
29
|
+
* A Unix-like operating system.
|
30
|
+
* Ruby 1.8.7 or higher (but 1.9 is recommended).
|
31
|
+
* Java 1.5 or higher (to run Solr under a Java servlet container).
|
32
|
+
* [RVM](https://rvm.beginrescueend.com/rvm/install/) (recommended).
|
33
|
+
* Git (recommended).
|
34
|
+
|
35
|
+
ActiveFedora, Hydra, and Rails require some gems that compile binaries and
|
36
|
+
rely on installed system libraries like libxml, libxslt, and sqlite. If
|
37
|
+
these aren't installed, the tutorial *will not function properly*. If
|
38
|
+
something seems wrong, try running `bundle install` directly inside the
|
39
|
+
tutorial directory, and watch the output carefully.
|
40
|
+
|
41
|
+
## Setup
|
42
|
+
|
43
|
+
Install rvm to get Ruby:
|
44
|
+
|
26
45
|
```bash
|
27
|
-
<INSTALL RUBY, e.g.:
|
28
46
|
$ curl -L https://get.rvm.io | bash -s stable --ruby
|
29
|
-
$ rvm install 1.9.3
|
30
|
-
|
31
|
-
|
47
|
+
$ rvm install 1.9.3 # (See https://rvm.io/rvm/install/ )
|
48
|
+
```
|
49
|
+
|
50
|
+
Consider using a hydra-specific gemset.
|
51
|
+
|
52
|
+
```bash
|
53
|
+
$ rvm use 1.9.3@hydra-tutorial --create
|
54
|
+
```
|
55
|
+
|
56
|
+
Install the hydra-tutorial gem:
|
57
|
+
|
58
|
+
```bash
|
32
59
|
$ gem install hydra-tutorial
|
60
|
+
```
|
61
|
+
|
62
|
+
## Running the tutorial
|
63
|
+
|
64
|
+
Run the tutorial one step at a time -- specifically, run the next step
|
65
|
+
in the tutorial:
|
66
|
+
|
67
|
+
```bash
|
33
68
|
$ hydra-tutorial
|
34
69
|
```
|
35
70
|
|
71
|
+
Run all remaining steps in the tutorial:
|
72
|
+
|
73
|
+
```bash
|
74
|
+
$ hydra-tutorial --run-all
|
75
|
+
```
|
76
|
+
|
77
|
+
Reset the tutorial back to the beginning:
|
78
|
+
|
79
|
+
```bash
|
80
|
+
$ hydra-tutorial --reset
|
81
|
+
$ rm -rf hydra_tutorial_app # Or rename the directory.
|
82
|
+
```
|
83
|
+
|
84
|
+
Other options relevant to users:
|
85
|
+
|
86
|
+
--no-git # Do not create Git commits for each tutorial step.
|
87
|
+
--diff # Run git diff: previous vs. current code.
|
88
|
+
--app FOO # Set the name of the Rails application subdirectory.
|
89
|
+
# The default is hydra_tutorial_app.
|
90
|
+
|
91
|
+
## Known issues
|
92
|
+
|
93
|
+
If the tutorial bombs with the `execJs: 'Could not find a JavaScript runtime'`
|
94
|
+
error, you may need to install a Javascript runtime such as
|
95
|
+
[node.js](https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager).
|
96
|
+
|
97
|
+
|
98
|
+
## Developer notes
|
99
|
+
|
100
|
+
You can run the entire tutorial non-interactively from the root of the Git
|
101
|
+
project checkout:
|
102
|
+
|
103
|
+
```bash
|
104
|
+
$ bin/hydra-tutorial --run-all --quick
|
105
|
+
```
|
data/bin/hydra-tutorial
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
#! /usr/bin/env ruby
|
2
2
|
|
3
|
-
|
3
|
+
# Invokes the tutorial's main() task.
|
4
4
|
|
5
|
+
tutorial = File.join(File.dirname(__FILE__), '..', 'tutorial.thor')
|
6
|
+
exec(tutorial, 'main', *ARGV)
|
@@ -0,0 +1,476 @@
|
|
1
|
+
TODO:
|
2
|
+
- Incorporate enhancements from notes.txt info tutorial.
|
3
|
+
|
4
|
+
- Improve README.
|
5
|
+
- Remove monkey-patch to hydra-head.
|
6
|
+
- Write method to extract long messages from the tutorial code.
|
7
|
+
- Support the --pop option.
|
8
|
+
- Implement a --help option.
|
9
|
+
- Support control over verbosity, and tie it to :capture declarations.
|
10
|
+
- Improve tutorial unit tests.
|
11
|
+
- Improve the views in the tutorial.
|
12
|
+
- Write unit tests for the tutorial script itself.
|
13
|
+
- Write an integration test for the entire tutorial.
|
14
|
+
|
15
|
+
|
16
|
+
====================================================================
|
17
|
+
|
18
|
+
# Install a version of Ruby.
|
19
|
+
|
20
|
+
# Install RVM.
|
21
|
+
|
22
|
+
# Install Ruby 1.9.
|
23
|
+
|
24
|
+
# Create a gemset
|
25
|
+
rvm use --rvmrc --create 1.9.3@hydra_walkthrough
|
26
|
+
|
27
|
+
# See current gems.
|
28
|
+
gem list
|
29
|
+
|
30
|
+
# Install bundler and Rails.
|
31
|
+
gem install bundler rails
|
32
|
+
|
33
|
+
# See the effect.
|
34
|
+
gem list
|
35
|
+
|
36
|
+
# Initialize a new Rails application.
|
37
|
+
rails new hydra_walkthrough
|
38
|
+
|
39
|
+
# Put the .rvmrc file in our project directory.
|
40
|
+
mv .rvmrc hydra_walkthrough
|
41
|
+
|
42
|
+
# Get a copy of the resources directory.
|
43
|
+
...
|
44
|
+
|
45
|
+
# Get a copy the hydra-jetty project.
|
46
|
+
git clone git://github.com/projecthydra/hydra-jetty.git
|
47
|
+
|
48
|
+
# Put a copy of it into our Rails project.
|
49
|
+
cp -r hydra-jetty hydra_walkthrough/jetty
|
50
|
+
|
51
|
+
# Check out the initial Rails app.
|
52
|
+
cd hydra_walkthrough
|
53
|
+
|
54
|
+
# Add to .gitignore
|
55
|
+
jetty
|
56
|
+
.rvmrc
|
57
|
+
Gemfile.lock
|
58
|
+
|
59
|
+
# Git.
|
60
|
+
git init
|
61
|
+
git add .
|
62
|
+
git commit -m 'Initial commit'
|
63
|
+
|
64
|
+
# Run the Rails server in a second terminal window.
|
65
|
+
rails server
|
66
|
+
open http://localhost:3000
|
67
|
+
|
68
|
+
# Check before we add some gems.
|
69
|
+
rake -T
|
70
|
+
|
71
|
+
# Add some lines to Gemfile.
|
72
|
+
# In the :assets block.
|
73
|
+
gem 'execjs'
|
74
|
+
gem 'therubyracer', :platforms => :ruby
|
75
|
+
|
76
|
+
# In the :development block.
|
77
|
+
gem 'jettywrapper'
|
78
|
+
gem 'debugger'
|
79
|
+
|
80
|
+
# Git.
|
81
|
+
git add .
|
82
|
+
git commit -m 'Added some gems: execjs, therubyracer, jettywrapper, debugger'
|
83
|
+
|
84
|
+
# Set up SOLR and Fedora config files.
|
85
|
+
cp ../resources/solr.yml config
|
86
|
+
cp ../resources/fedora.yml config
|
87
|
+
|
88
|
+
# Git.
|
89
|
+
git add -A
|
90
|
+
git commit -m 'Created SOLR and Fedora config files'
|
91
|
+
|
92
|
+
# Bundle.
|
93
|
+
bundle install
|
94
|
+
|
95
|
+
# Check after: note the jetty tasks.
|
96
|
+
rake -T
|
97
|
+
|
98
|
+
# Start the Jetty server that will run Fedora and SOLR.
|
99
|
+
rake jetty:start
|
100
|
+
|
101
|
+
# Check them out.
|
102
|
+
open http://localhost:8983/fedora/
|
103
|
+
open http://localhost:8983/solr/development/admin/
|
104
|
+
|
105
|
+
# More Gemile.
|
106
|
+
gem 'active-fedora'
|
107
|
+
gem 'om'
|
108
|
+
|
109
|
+
# Bundle.
|
110
|
+
bundle install
|
111
|
+
|
112
|
+
# Git.
|
113
|
+
git add .
|
114
|
+
git commit -m 'Added active-fedora and OM gems'
|
115
|
+
|
116
|
+
# Create a basic model.
|
117
|
+
cp ../resources/basic_af_model.rb app/models/record.rb
|
118
|
+
|
119
|
+
# Git.
|
120
|
+
git add -A
|
121
|
+
git commit -m 'Created a basic Record model with a descMetadata datastream'
|
122
|
+
|
123
|
+
# Check it out.
|
124
|
+
rails console
|
125
|
+
|
126
|
+
## CREATE
|
127
|
+
> obj = Record.new
|
128
|
+
> xml = '<xyz><foo>ABC</foo><foo>DEF</foo><bar>123</bar></xyz>'
|
129
|
+
> obj.descMetadata.content = xml
|
130
|
+
> obj.save
|
131
|
+
|
132
|
+
> pid = obj.pid
|
133
|
+
|
134
|
+
## RETRIEVE
|
135
|
+
> obj = Record.find(pid)
|
136
|
+
> ds = obj.descMetadata
|
137
|
+
> puts ds.content
|
138
|
+
|
139
|
+
## UPDATE
|
140
|
+
> doc = ds.ng_xml
|
141
|
+
> elements = doc.xpath '//foo'
|
142
|
+
> elements.each { |e| puts e }
|
143
|
+
> exit
|
144
|
+
|
145
|
+
# Check it out in the browser.
|
146
|
+
open http://localhost:8983/fedora/objects/
|
147
|
+
-> click search
|
148
|
+
-> click the hyperlink of the object's PID (eg, 'changeme:1')
|
149
|
+
-> click hyperlink to view the object's datastreams list
|
150
|
+
-> click hyperlink to view the content of the descMetadata datastream
|
151
|
+
|
152
|
+
# Back in the Rails console:
|
153
|
+
|
154
|
+
rails console
|
155
|
+
|
156
|
+
## DELETE
|
157
|
+
> obj = Record.find('changeme:1')
|
158
|
+
> obj.delete
|
159
|
+
> exit
|
160
|
+
|
161
|
+
# Check it out in the browser.
|
162
|
+
# And click search button.
|
163
|
+
open http://localhost:8983/fedora/objects/
|
164
|
+
|
165
|
+
# Enhance our datastream.
|
166
|
+
cp ../resources/basic_om_model.rb app/models/record.rb
|
167
|
+
|
168
|
+
# Git.
|
169
|
+
git commit -am 'Added an OM terminology'
|
170
|
+
|
171
|
+
# Check it out.
|
172
|
+
rails console
|
173
|
+
|
174
|
+
> obj = Record.new
|
175
|
+
> obj.descMetadata.title = "My object title"
|
176
|
+
> obj.save
|
177
|
+
> puts obj.descMetadata.content
|
178
|
+
> obj.delete
|
179
|
+
> exit
|
180
|
+
|
181
|
+
# Modify record.rb
|
182
|
+
# Add this after the has_metadata call.
|
183
|
+
|
184
|
+
delegate :title, :to => 'descMetadata'
|
185
|
+
|
186
|
+
# Git.
|
187
|
+
git commit -am 'Added delegate() to the model'
|
188
|
+
|
189
|
+
# Check it out.
|
190
|
+
rails console
|
191
|
+
|
192
|
+
> obj = Record.new
|
193
|
+
> obj.title = "My object title"
|
194
|
+
> obj.save
|
195
|
+
> puts obj.descMetadata.content
|
196
|
+
> puts obj.title.inspect
|
197
|
+
> obj.delete
|
198
|
+
> exit
|
199
|
+
|
200
|
+
# Use delegate_to().
|
201
|
+
# Replace the delete() line.
|
202
|
+
|
203
|
+
delegate_to 'descMetadata', [:title, :author, :url, :description], :unique => true
|
204
|
+
|
205
|
+
# Git.
|
206
|
+
git commit -am 'Switched to delegate_to()'
|
207
|
+
|
208
|
+
# Check it out.
|
209
|
+
rails console
|
210
|
+
|
211
|
+
> obj = Record.new
|
212
|
+
> obj.title = "Some title"
|
213
|
+
> obj.title
|
214
|
+
> obj.author = 'Some author'
|
215
|
+
> obj.save
|
216
|
+
> puts obj.descMetadata.contnet
|
217
|
+
> puts obj.descMetadata.content
|
218
|
+
> obj.delete
|
219
|
+
> exit
|
220
|
+
|
221
|
+
# Enhance our model.
|
222
|
+
# This example is too complicated.
|
223
|
+
# Also, it undoes the delegate_to().
|
224
|
+
cp ../resources/basic_mods_model.rb app/models/record.rb
|
225
|
+
cp ../resources/mods_desc_metadata.rb app/models/mods_desc_metadata.rb
|
226
|
+
|
227
|
+
# Git.
|
228
|
+
git add -A
|
229
|
+
git commit -m 'Added a more extensive OM example'
|
230
|
+
|
231
|
+
# Check it out.
|
232
|
+
rails console
|
233
|
+
|
234
|
+
> obj = Record.new
|
235
|
+
> obj.title = "My object title"
|
236
|
+
> obj.save
|
237
|
+
> puts obj.descMetadata.content
|
238
|
+
> obj.delete
|
239
|
+
> exit
|
240
|
+
|
241
|
+
# Initialize a controller and views for our Record model.
|
242
|
+
rails generate scaffold_controller Record --no-helper --skip-test-framework
|
243
|
+
|
244
|
+
# Git.
|
245
|
+
git add -A
|
246
|
+
git commit -m 'Added a basic controller and views for the Record model'
|
247
|
+
|
248
|
+
# Check files that were created.
|
249
|
+
app/controlers/records_controller.rb
|
250
|
+
app/views/records/
|
251
|
+
|
252
|
+
# Modify config/routes.rb
|
253
|
+
resources :records
|
254
|
+
|
255
|
+
# Git.
|
256
|
+
git commit -am 'Set up resourceful routing for the Record model'
|
257
|
+
|
258
|
+
# Put some files in place.
|
259
|
+
cp ../resources/_form.html.erb app/views/records/_form.html.erb
|
260
|
+
cp ../resources/show.html.erb app/views/records/show.html.erb
|
261
|
+
|
262
|
+
# Git.
|
263
|
+
git commit -am 'Fleshed out the edit form and show page'
|
264
|
+
|
265
|
+
# Try it out.
|
266
|
+
# Delete links are not working.
|
267
|
+
# Keywords are not being saved.
|
268
|
+
# The view has multiple problems and is not in synce with the model.
|
269
|
+
open http://localhost:3000/records/new
|
270
|
+
|
271
|
+
# More Gemile.
|
272
|
+
gem 'blacklight'
|
273
|
+
gem 'hydra-head'
|
274
|
+
gem 'devise'
|
275
|
+
|
276
|
+
# Git.
|
277
|
+
git commit -am 'Added blacklight, hydra-head, and devise'
|
278
|
+
|
279
|
+
# Bundle.
|
280
|
+
bundle install
|
281
|
+
|
282
|
+
# Remove some files.
|
283
|
+
rm public/index.html
|
284
|
+
rm config/solr.yml
|
285
|
+
|
286
|
+
# Set up devise.
|
287
|
+
rails generate blacklight --devise
|
288
|
+
|
289
|
+
# Git.
|
290
|
+
git add -A
|
291
|
+
git commit -m 'Set up devise'
|
292
|
+
|
293
|
+
# Remove some files.
|
294
|
+
rm config/solr.yml
|
295
|
+
rm app/controllers/catalog_controller.rb
|
296
|
+
|
297
|
+
# Set up a User model for hydra-head.
|
298
|
+
rails generate hydra:head User
|
299
|
+
|
300
|
+
# Do some stuff.
|
301
|
+
rake db:migrate
|
302
|
+
rake db:test:prepare
|
303
|
+
rake jetty:stop
|
304
|
+
rake hydra:jetty:config
|
305
|
+
rake jetty:start
|
306
|
+
|
307
|
+
# Git.
|
308
|
+
git add -A
|
309
|
+
git commit -m 'Set up User model under hydra-head'
|
310
|
+
|
311
|
+
# Various edits:
|
312
|
+
|
313
|
+
# app/controllers/records_controller.rb
|
314
|
+
include Hydra::AssetsControllerHelper
|
315
|
+
include Hydra::AccessControlsEnforcement
|
316
|
+
before_filter :enforce_access_controls
|
317
|
+
|
318
|
+
# app/controllers/records_controller.rb
|
319
|
+
# In create(), after @record is set.
|
320
|
+
apply_depositor_metadata(@record)
|
321
|
+
|
322
|
+
# app/models/record.rb
|
323
|
+
include Hydra::ModelMixins::CommonMetadata
|
324
|
+
include Hydra::ModelMethods
|
325
|
+
|
326
|
+
# app/models/solr_document.rb
|
327
|
+
# After other includes.
|
328
|
+
include Hydra::Solr::Document
|
329
|
+
|
330
|
+
# app/assets/javascripts/application.js
|
331
|
+
# At end of file.
|
332
|
+
Blacklight.do_search_context_behavior = function() { }
|
333
|
+
|
334
|
+
# Git.
|
335
|
+
git commit -am 'Included hydra-head into our model, controller, etc.'
|
336
|
+
|
337
|
+
# Check it out.
|
338
|
+
# Needed to edit hydra-head: _user_util_links.html.erb
|
339
|
+
open http://localhost:3000/records/new
|
340
|
+
-> Click sign up.
|
341
|
+
-> Enter any email and password.
|
342
|
+
|
343
|
+
# Add some gems for testing.
|
344
|
+
# In the :test group (and :development group?)
|
345
|
+
gem 'rspec'
|
346
|
+
gem 'rspec-rails'
|
347
|
+
|
348
|
+
# Git.
|
349
|
+
git commit -am 'Added rspec gem'
|
350
|
+
|
351
|
+
# Bundle
|
352
|
+
bundle install
|
353
|
+
|
354
|
+
# Set up rspec.
|
355
|
+
rails generate rspec:install
|
356
|
+
|
357
|
+
# Git.
|
358
|
+
git add -A
|
359
|
+
git commit -m 'Initialized rspec directory'
|
360
|
+
|
361
|
+
# Create a test.
|
362
|
+
# This test should do something real.
|
363
|
+
mkdir spec/controllers
|
364
|
+
cp ../resources/records_controller_spec.rb spec/controllers/records_controller_spec.rb
|
365
|
+
|
366
|
+
# Git.
|
367
|
+
git add -A
|
368
|
+
git commit -m 'Create a placeholder test'
|
369
|
+
|
370
|
+
# Run the test
|
371
|
+
rspec
|
372
|
+
|
373
|
+
# Add some gems for testing.
|
374
|
+
# In the :test group (and :development group?)
|
375
|
+
gem 'capybara'
|
376
|
+
|
377
|
+
# Bundle
|
378
|
+
bundle install
|
379
|
+
|
380
|
+
# Git.
|
381
|
+
git commit -am 'Added capybara gem'
|
382
|
+
|
383
|
+
# Create a test.
|
384
|
+
mkdir spec/integration
|
385
|
+
cp ../resources/integration_spec.rb spec/integration/integration_spec.rb
|
386
|
+
|
387
|
+
# Git.
|
388
|
+
git add -A
|
389
|
+
git commit -m 'Created a few integration tests'
|
390
|
+
|
391
|
+
# Run the tests
|
392
|
+
rspec
|
393
|
+
|
394
|
+
# Create a ci rake task.
|
395
|
+
cp ../resources/ci.rake lib/tasks/ci.rake
|
396
|
+
|
397
|
+
# Git.
|
398
|
+
git add -A
|
399
|
+
git commit -m 'Created a ci rake task'
|
400
|
+
|
401
|
+
# Run it.
|
402
|
+
rake jetty:stop
|
403
|
+
rake ci
|
404
|
+
rake jetty:start
|
405
|
+
|
406
|
+
# Add a gem for test coverage.
|
407
|
+
# In the :test group (and :development group?)
|
408
|
+
gem 'simplecov'
|
409
|
+
|
410
|
+
# Bundle
|
411
|
+
bundle install
|
412
|
+
|
413
|
+
# Git.
|
414
|
+
git commit -am 'Added simplecov gem'
|
415
|
+
|
416
|
+
# ci.rake
|
417
|
+
# After Rails.env is set.
|
418
|
+
ENV['COVERAGE'] ||= 'true'
|
419
|
+
|
420
|
+
# spec/spec_helper.rb
|
421
|
+
# After ENV['RAILS_ENV'] is set.
|
422
|
+
if ENV['COVERAGE'] == "true"
|
423
|
+
require 'simplecov'
|
424
|
+
SimpleCov.start do
|
425
|
+
add_filter "config/"
|
426
|
+
add_filter "spec/"
|
427
|
+
end
|
428
|
+
end
|
429
|
+
|
430
|
+
# Add to .gitignore
|
431
|
+
coverage
|
432
|
+
|
433
|
+
# Git
|
434
|
+
git commit -am 'Set up test coverage'
|
435
|
+
|
436
|
+
# Run it.
|
437
|
+
rake jetty:stop
|
438
|
+
rake ci
|
439
|
+
rake jetty:start
|
440
|
+
|
441
|
+
# Check test coverage
|
442
|
+
open coverage/index.html
|
443
|
+
|
444
|
+
# app/models/record.rb
|
445
|
+
# After has_metadata
|
446
|
+
has_file_datastream :name => 'content', :type => ActiveFedora::Datastream
|
447
|
+
|
448
|
+
# app/controllers/records_controller.rb
|
449
|
+
include Hydra::Controller::UploadBehavior
|
450
|
+
|
451
|
+
# app/controllers/records_controller.rb
|
452
|
+
# After: apply_depositor_metadata().
|
453
|
+
@record.label = params[:record][:title] # this is a bad hack to work around an AF bug
|
454
|
+
add_posted_blob_to_asset(@record, params[:filedata]) if params.has_key?(:filedata)
|
455
|
+
|
456
|
+
# app/views/records/_form.html.erb
|
457
|
+
# Delete first line. Use this instead:
|
458
|
+
<%= form_for(@record, :html => { :multipart => true } ) do |f| -%>
|
459
|
+
<h2>File</h2>
|
460
|
+
<%= file_field_tag "filedata" %>
|
461
|
+
|
462
|
+
# Get stuff.
|
463
|
+
cp ../resources/_add_assets_links.html.erb app/views/_add_assets_links.html.erb
|
464
|
+
|
465
|
+
# Git.
|
466
|
+
git add -A
|
467
|
+
git commit -m 'Add some styling and link to new Record in the header of the layout'
|
468
|
+
|
469
|
+
# Run the app.
|
470
|
+
rake jetty:stop
|
471
|
+
rake jetty:start
|
472
|
+
rails server
|
473
|
+
|
474
|
+
# Wrap up.
|
475
|
+
Shut down rails server (CTRL-C)
|
476
|
+
rake jetty:stop
|