hydra-tutorial 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ hydra_tutorial_app
2
+ jetty
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source :rubygems
2
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,93 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ hydra-tutorial (0.0.1)
5
+ bundler
6
+ rails
7
+ thor
8
+
9
+ GEM
10
+ remote: http://rubygems.org/
11
+ specs:
12
+ actionmailer (3.2.6)
13
+ actionpack (= 3.2.6)
14
+ mail (~> 2.4.4)
15
+ actionpack (3.2.6)
16
+ activemodel (= 3.2.6)
17
+ activesupport (= 3.2.6)
18
+ builder (~> 3.0.0)
19
+ erubis (~> 2.7.0)
20
+ journey (~> 1.0.1)
21
+ rack (~> 1.4.0)
22
+ rack-cache (~> 1.2)
23
+ rack-test (~> 0.6.1)
24
+ sprockets (~> 2.1.3)
25
+ activemodel (3.2.6)
26
+ activesupport (= 3.2.6)
27
+ builder (~> 3.0.0)
28
+ activerecord (3.2.6)
29
+ activemodel (= 3.2.6)
30
+ activesupport (= 3.2.6)
31
+ arel (~> 3.0.2)
32
+ tzinfo (~> 0.3.29)
33
+ activeresource (3.2.6)
34
+ activemodel (= 3.2.6)
35
+ activesupport (= 3.2.6)
36
+ activesupport (3.2.6)
37
+ i18n (~> 0.6)
38
+ multi_json (~> 1.0)
39
+ arel (3.0.2)
40
+ builder (3.0.0)
41
+ erubis (2.7.0)
42
+ hike (1.2.1)
43
+ i18n (0.6.0)
44
+ journey (1.0.4)
45
+ json (1.7.3)
46
+ mail (2.4.4)
47
+ i18n (>= 0.4.0)
48
+ mime-types (~> 1.16)
49
+ treetop (~> 1.4.8)
50
+ mime-types (1.19)
51
+ multi_json (1.3.6)
52
+ polyglot (0.3.3)
53
+ rack (1.4.1)
54
+ rack-cache (1.2)
55
+ rack (>= 0.4)
56
+ rack-ssl (1.3.2)
57
+ rack
58
+ rack-test (0.6.1)
59
+ rack (>= 1.0)
60
+ rails (3.2.6)
61
+ actionmailer (= 3.2.6)
62
+ actionpack (= 3.2.6)
63
+ activerecord (= 3.2.6)
64
+ activeresource (= 3.2.6)
65
+ activesupport (= 3.2.6)
66
+ bundler (~> 1.0)
67
+ railties (= 3.2.6)
68
+ railties (3.2.6)
69
+ actionpack (= 3.2.6)
70
+ activesupport (= 3.2.6)
71
+ rack-ssl (~> 1.3.2)
72
+ rake (>= 0.8.7)
73
+ rdoc (~> 3.4)
74
+ thor (>= 0.14.6, < 2.0)
75
+ rake (0.9.2.2)
76
+ rdoc (3.12)
77
+ json (~> 1.4)
78
+ sprockets (2.1.3)
79
+ hike (~> 1.2)
80
+ rack (~> 1.0)
81
+ tilt (~> 1.1, != 1.3.0)
82
+ thor (0.15.4)
83
+ tilt (1.3.3)
84
+ treetop (1.4.10)
85
+ polyglot
86
+ polyglot (>= 0.3.1)
87
+ tzinfo (0.3.33)
88
+
89
+ PLATFORMS
90
+ ruby
91
+
92
+ DEPENDENCIES
93
+ hydra-tutorial!
data/README.md ADDED
@@ -0,0 +1,15 @@
1
+ # Hydra Tutorial Application
2
+
3
+ ## Pre-requisites
4
+ * ruby v 1.8.7 or higher
5
+ * java 1.5 or higher (in order to run solr under a java servlet container)
6
+ * [[RVM|https://rvm.beginrescueend.com/rvm/install/]] (recommended)
7
+
8
+ ```bash
9
+ $ gem install bundler
10
+ $ bundle install
11
+ ```
12
+
13
+ ```bash
14
+ $ ./tutorial.thor
15
+ ```
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ # encoding: UTF-8
2
+ require 'rubygems'
3
+ begin
4
+ require 'bundler/setup'
5
+ rescue LoadError
6
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
7
+ end
8
+
9
+ require 'rake'
10
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ exec File.expand_path(File.join(File.dirname(__FILE__), '..', 'open-repositories-tutorial.thor')), *ARGV
4
+
@@ -0,0 +1,16 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "hydra-tutorial"
3
+ s.version = "0.0.1"
4
+ s.platform = Gem::Platform::RUBY
5
+ s.authors = ["Chris Beer"]
6
+ s.email = ["hydra-tech@googlegroups.com"]
7
+ s.homepage = "http://projecthydra.org"
8
+ s.summary = "Hydra head tutorial walkthrough"
9
+ s.description = "Tutorial that works through setting up a hydra head"
10
+
11
+ s.add_dependency "thor"
12
+ s.add_dependency "rails"
13
+ s.add_dependency "bundler"
14
+
15
+ s.files = `git ls-files`.split("\n")
16
+ end
@@ -0,0 +1,668 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'thor'
5
+ require 'thor/group'
6
+ require 'rails/generators/actions'
7
+ require 'active_support/core_ext/array/extract_options'
8
+ require 'active_support/core_ext/string/inflections'
9
+
10
+ $base_templates_path = File.expand_path(File.join(File.dirname(__FILE__), 'or_templates'))
11
+ $application_name = ''
12
+ $application_root = ''
13
+
14
+ STATEMENT = Thor::Shell::Color::YELLOW
15
+ QUESTION = Thor::Shell::Color::GREEN
16
+ WAIT = Thor::Shell::Color::CYAN
17
+
18
+ class HydraOpenRepositoriesTutorialApp < Thor::Group
19
+ include Thor::Actions
20
+ include Rails::Generators::Actions
21
+
22
+ module TutorialActions
23
+ def continue_prompt
24
+ ask %Q{
25
+ HIT <ENTER> KEY TO CONTINUE
26
+ }, WAIT
27
+ end
28
+
29
+ def rails_console
30
+ say %Q{
31
+ We'll launch the console again. Give some of those commands a try.
32
+ }, STATEMENT
33
+
34
+ say %Q{
35
+
36
+ Hit Ctrl-D (^D) to stop the Rails console and continue this tutorial.
37
+ }, WAIT
38
+
39
+ run "rails c"
40
+ end
41
+
42
+ def rails_server url = '/'
43
+ say %Q{
44
+ We'll start the Rails server for you. It should be available in your browser at:
45
+
46
+ http://localhost:3000#{url}
47
+ }, STATEMENT
48
+
49
+ say %Q{
50
+
51
+ Hit Ctrl-C (^C) to stop the Rails server and continue this tutorial.
52
+ }, WAIT
53
+
54
+ run "rails s"
55
+ end
56
+ end
57
+
58
+ include TutorialActions
59
+ class_option :quick, :default => false
60
+
61
+ def welcome
62
+ $quick = options[:quick]
63
+ say %Q{
64
+ Welcome to this Hydra tutorial. We're going to step through building a working
65
+ Hydra application. We'll build the application gradually, starting by building
66
+ our "business logic", wiring in HTML views, and then connecting it to our
67
+ Rails application.
68
+
69
+ At several points in this tutorial, as we iteratively develop our files, you may
70
+ be prompted to review conflicts between versions of files. It is safe to blindly
71
+ accept the changes ('y'), however you may wish to view the diff ('d') to see the
72
+ things we're change.
73
+ }, STATEMENT
74
+
75
+ name = ask %Q{
76
+ What do you want to call your application?
77
+ }, QUESTION unless $quick
78
+
79
+ name = name.to_s.strip
80
+ name = 'hydra_tutorial_app' if name.empty?
81
+
82
+
83
+ $application_name = name
84
+
85
+ dir = $application_name.parameterize('_')
86
+ $application_root = dir
87
+
88
+ if File.exists? $application_root
89
+ say %Q{
90
+ #{$application_root} already exists. Either remove it or provide a different
91
+ application name.
92
+ }, Thor::Shell::Color::RED
93
+ exit
94
+ end
95
+
96
+ say %Q{
97
+ We'll generate a stub application #{$application_name} into the folder
98
+ #{$application_root}. But, first, lets check your Ruby environment.
99
+ }
100
+
101
+ end
102
+
103
+ def prerequisites
104
+ Prerequisites.start
105
+ end
106
+
107
+ def building_a_basic_rails_app
108
+ inside $application_root do
109
+ BuildingABasicRailsApp.start
110
+ end
111
+ end
112
+
113
+ def adding_our_models
114
+ inside $application_root do
115
+ AddingOurModels.start
116
+ end
117
+ end
118
+
119
+ def wiring_it_into_rails
120
+ inside $application_root do
121
+ WiringItIntoRails.start
122
+ end
123
+ end
124
+
125
+ def add_blacklight_and_hydra
126
+ inside $application_root do
127
+ AddBlacklightAndHydra.start
128
+ end
129
+ end
130
+
131
+ def fixup_for_hydra
132
+ inside $application_root do
133
+ FixupForHydra.start
134
+ end
135
+ end
136
+
137
+ def add_tests
138
+ inside $application_root do
139
+ AddTests.start
140
+ end
141
+ end
142
+
143
+ def cleanup
144
+ inside $application_root do
145
+ Cleanup.start
146
+ end
147
+ end
148
+
149
+ class Cleanup < Thor::Group
150
+
151
+ include Thor::Actions
152
+ include Rails::Generators::Actions
153
+ include TutorialActions
154
+
155
+ def start_everything
156
+ say %Q{
157
+ This is the end of the tutorial. We'll give you a final chance to look at the web application.
158
+ }, STATEMENT
159
+ rake 'jetty:stop'
160
+ rake 'jetty:start'
161
+ rails_server
162
+ end
163
+
164
+ def stop_jetty
165
+ rake 'jetty:stop'
166
+ end
167
+ end
168
+
169
+ class Prerequisites < Thor::Group
170
+ include Thor::Actions
171
+ include Rails::Generators::Actions
172
+ include TutorialActions
173
+
174
+ def install_ruby
175
+ return if $quick
176
+ say %Q{
177
+ Obviously, if you can run this tutorial, you have already installed ruby.
178
+ }, STATEMENT
179
+
180
+
181
+ ruby_executable = run 'which ruby', :capture => true
182
+
183
+ say %Q{
184
+ You are running this using:
185
+ #{ruby_executable}
186
+ }, STATEMENT
187
+
188
+ if ruby_executable =~ /rvm/ or ruby_executable =~ /rbenv/ or ruby_executable =~ /home/ or ruby_Executable =~ /Users/
189
+ say %Q{
190
+ It looks like you're using rvm/rbenv/etc. (with a gemset?) We'll use this environment to build the application.
191
+ }, STATEMENT
192
+
193
+ else
194
+
195
+ say %Q{
196
+ We checked, and it looks like you might be using a system-wide ruby. We suggest
197
+ you use somethng like rvm [1], rbenv [2], etc to manage your ruby projects.
198
+
199
+ You can continue and hope for the best, or go install one of these ruby managers, which may make your life easier.
200
+
201
+ [1] http://rvm.io/
202
+ [2] https://github.com/sstephenson/rbenv/
203
+ }, Thor::Shell::Color::RED
204
+
205
+ continue_prompt unless $quick
206
+
207
+ end
208
+
209
+ end
210
+
211
+ def install_bundler_and_rails
212
+ say %Q{
213
+ We're going to install some prerequisite gems in order to create our skeleton Rails application.
214
+ }, STATEMENT
215
+ run 'gem install bundler rails'
216
+ end
217
+
218
+ def new_rails_app
219
+ say %Q{
220
+ Now we'll create the application.
221
+ }, Thor::Shell::Color::YELLOW
222
+ run "rails new #{$application_root}"
223
+ run "cd #{$application_root}"
224
+ end
225
+
226
+ def out_of_the_box
227
+ return if $quick
228
+ say %Q{
229
+ Here's a chance to look around. You can see the structure of a Rails application.
230
+ In particular, look at:
231
+ ./app
232
+ ./config
233
+ ./lib
234
+ Gemfile
235
+ }, STATEMENT
236
+
237
+
238
+ say %Q{
239
+ If we launched the Rails application server, we can see the application running in the browser
240
+ and you can see if everything is working.
241
+ }, STATEMENT
242
+
243
+
244
+ inside $application_root do
245
+ rails_server unless $quick
246
+ end
247
+ end
248
+ end
249
+
250
+ class BuildingABasicRailsApp < Thor::Group
251
+ include Thor::Actions
252
+ include Rails::Generators::Actions
253
+ include TutorialActions
254
+
255
+ def self.source_paths
256
+ [File.join($base_templates_path, "building_a_basic_rails_app")]
257
+ end
258
+
259
+
260
+ def adding_dependencies
261
+
262
+ say %Q{
263
+ Fedora runs as a Java servlet inside a container like Tomcat or Jetty. Hydra provides a bundled
264
+ version of Fedora and Solr for testing and development.
265
+ }, STATEMENT
266
+
267
+ say %Q{
268
+ We'll download a copy now. It may take awhile.
269
+ }, STATEMENT
270
+ unless File.exists? '../jetty'
271
+ git :clone => 'git://github.com/projecthydra/hydra-jetty.git ../jetty'
272
+ end
273
+ run 'cp -R ../jetty jetty'
274
+
275
+ end
276
+
277
+ def jetty_configuration
278
+ say %Q{
279
+ We'll add some configuration yml files with information to connect to Solr and Fedora.
280
+ }, STATEMENT
281
+
282
+ copy_file 'solr.yml', 'config/solr.yml'
283
+ copy_file 'fedora.yml', 'config/fedora.yml'
284
+
285
+ say %Q{
286
+ Add the 'jettywrapper' gem, which adds Rake tasks for start and stop Jetty.
287
+ }, STATEMENT
288
+
289
+ gem 'jettywrapper'
290
+ run 'bundle install'
291
+
292
+ say %Q{
293
+ Starting Jetty
294
+ }, STATEMENT
295
+ rake 'jetty:start'
296
+
297
+ say %Q{
298
+ Take a look around. Jetty should be running on port 8983. You can see the Fedora server at
299
+
300
+ http://localhost:8983/fedora/
301
+
302
+ And a Solr index at
303
+
304
+ http://localhost:8983/solr/development/admin/
305
+ }, STATEMENT
306
+
307
+ continue_prompt unless $quick
308
+
309
+ end
310
+
311
+ # and then clean up some cruft
312
+ def remove_public_index
313
+ remove_file 'public/index.html'
314
+ end
315
+
316
+ end
317
+
318
+ class AddingOurModels < Thor::Group
319
+ include Thor::Actions
320
+ include Rails::Generators::Actions
321
+ include TutorialActions
322
+
323
+ def self.source_paths
324
+ [File.join($base_templates_path, "adding_our_models")]
325
+ end
326
+
327
+ def add_activefedora
328
+ say %Q{
329
+ The active-fedora gem provides a way to model Fedora objects within Ruby. It will help
330
+ you create Ruby models for creating, updating and reading objects from Fedora using a
331
+ domain-specific language (DSL) similar to the Rails' ActiveRecord.
332
+
333
+ The om gem provides mechanisms for mapping XML documents into Ruby.
334
+
335
+ We'll add both of these to the Gemfile.
336
+ }, STATEMENT
337
+
338
+ gem 'active-fedora'
339
+ gem 'om'
340
+ run 'bundle install'
341
+ end
342
+
343
+ def add_initial_model
344
+ say %Q{
345
+ Now we'll add a basic ActiveFedora stub model for a 'Record'.
346
+ }, STATEMENT
347
+
348
+ copy_file "basic_af_model.rb", "app/models/record.rb"
349
+
350
+ say %Q{
351
+ It looks like this:
352
+ }, STATEMENT
353
+
354
+ print_wrapped File.read('app/models/record.rb')
355
+ end
356
+
357
+ def rails_console_tour
358
+
359
+ say %Q{
360
+ Now we'll give you a chance to look at the Record model. If you launch the
361
+ Rails interactive console, we can create and manipulate our object:
362
+
363
+ ## CREATE
364
+ > obj = Record.new
365
+ # => #<Record:1571331701243443635 @pid="__DO_NOT_USE__" >
366
+ > obj.descMetadata.content = 'e.g. <my_xml_content />'
367
+ > obj.save
368
+
369
+ > obj.pid
370
+ # => e.g. 'changeme:1'
371
+
372
+ ## RETRIEVE
373
+ > obj = Record.find('changeme:1')
374
+ > ds = obj.descMetadata
375
+ # => #<ActiveFedora::NokogiriDatastream:3283711306477137919 @pid="changeme:1" @dsid="descMetadata" @controlGroup="X" @dirty="false" @mimeType="text/xml" >
376
+ > ds.content
377
+ # => (should be the XML document you added before)
378
+
379
+ ## UPDATE
380
+ # manipulating XML:
381
+ > ds.ng_xml.xpath('//my_xml_content')
382
+
383
+ ## DELETE
384
+ > obj.delete
385
+
386
+ }, STATEMENT
387
+
388
+
389
+ rails_console unless $quick
390
+ end
391
+
392
+ def enhance_model_with_contrieved_descmd
393
+ say %Q{
394
+ Instead of working with the Nokogiri XML document directly, we can use OM to
395
+ make querying an XML document easier. We'll replace the previous Record with a
396
+ OM-enabled document.
397
+ }
398
+ copy_file "basic_om_model.rb", "app/models/record.rb"
399
+ end
400
+
401
+ def testing_the_contrieved_descmd
402
+ say %Q{
403
+ If you launch the Rails interactive console, we can now create and manipulate our object
404
+ using methods provided by OM.
405
+
406
+ > obj = Record.new
407
+ > obj.descMetadata.title = "My object title"
408
+ > obj.save
409
+ > obj.descMetadata.content
410
+ # => An XML document with the title "My object title"
411
+ }, STATEMENT
412
+
413
+ rails_console unless $quick
414
+ end
415
+
416
+ def use_the_delegate_method
417
+ say %Q{
418
+ We can use the #delegate method to tell the model-object how to access these attributes.
419
+
420
+ > obj = Record.new
421
+ > obj.title = "My object title"
422
+ > obj.save
423
+ > obj.descMetadata.content
424
+ # => An XML document with the title "My object title"
425
+ }, STATEMENT
426
+
427
+ insert_into_file "app/models/record.rb", :after => %Q{has_metadata :name => "descMetadata", :type => DatastreamMetadata\n} do
428
+ "delegate :title, :to => 'descMetadata'\n"
429
+ end
430
+ end
431
+
432
+ def add_mods_model_with_mods_descmd
433
+ say %Q{
434
+ We'll now replace the contrieved XML metadata schema with a simple
435
+ MODS-based example, using an OM terminology we prepared earlier.
436
+
437
+ We'll put the MODS datastream in a separate module and file, so that
438
+ it can be easily reused in other ActiveFedora-based objects.
439
+ }, STATEMENT
440
+
441
+ copy_file "basic_mods_model.rb", "app/models/record.rb"
442
+ copy_file "mods_desc_metadata.rb", "app/models/mods_desc_metadata.rb"
443
+
444
+ say %Q{
445
+ If you launch the Rails interactive console, we can now create and manipulate our object
446
+ using methods provided by OM.
447
+
448
+ > obj = Record.new
449
+ > obj.title = "My object title"
450
+ > obj.save
451
+ > obj.descMetadata.content
452
+ # => A MODS XML document
453
+ }, STATEMENT
454
+
455
+ rails_console unless $quick
456
+ end
457
+ end
458
+
459
+ class WiringItIntoRails < Thor::Group
460
+ include Thor::Actions
461
+ include Rails::Generators::Actions
462
+ include TutorialActions
463
+
464
+ def self.source_paths
465
+ [File.join($base_templates_path, "wiring_it_into_rails")]
466
+ end
467
+
468
+ def record_generator
469
+ say %Q{
470
+ Now that we've set up our model and successfully added content into Fedora, now we want to
471
+ connect the model to a Rails web application.
472
+
473
+ We'll start by using the standard Rails generators to create a scaffold controller and views,
474
+ which will give us a place to start working.
475
+ }, STATEMENT
476
+
477
+ generate "scaffold_controller Record --no-helper --skip-test-framework"
478
+ route "resources :records"
479
+
480
+ say %Q{
481
+ If you look in ./app/views/records, you can see a set of Rails ERB templates.
482
+
483
+ ./app/controlers/records_controller.rb contains the controller that ties the model to the views.
484
+ }, STATEMENT
485
+
486
+ continue_prompt unless $quick
487
+ end
488
+
489
+ def add_new_form
490
+
491
+ say %Q{
492
+ The scaffold just provided the basic outline for an application, so we need to provide the guts for the
493
+ web form. Here's a simple one:
494
+ }, STATEMENT
495
+
496
+ copy_file "_form.html.erb", "app/views/records/_form.html.erb"
497
+ copy_file "show.html.erb", "app/views/records/show.html.erb"
498
+ end
499
+
500
+ def check_it_out
501
+
502
+ say %Q{
503
+ If we start the Rails server, we should now be able to visit the records in the browser, create new records,
504
+ and edit existing records. Start by creating a new record:
505
+ }, STATEMENT
506
+
507
+ rails_server '/records/new' unless $quick
508
+ end
509
+
510
+ end
511
+
512
+ class AddBlacklightAndHydra < Thor::Group
513
+ include Thor::Actions
514
+ include Rails::Generators::Actions
515
+ include TutorialActions
516
+
517
+ def add_gems
518
+ say %Q{
519
+ Thus far, we've been using component parts of the Hydra framework, but now we'll add in the whole framework so
520
+ we can take advantage of common patterns that have emerged in the Hydra community, including search, gated discovery,
521
+ etc.
522
+
523
+ We'll add a few new gems:
524
+
525
+ - blacklight provides a discovery interface on top of the Solr index
526
+ - hydra-head provides a number of common Hydra patterns
527
+ - devise is a standard Ruby gem for providing user-related functions, like registration, sign-in, etc.
528
+
529
+ }, STATEMENT
530
+ gem 'blacklight'
531
+ gem 'hydra-head'
532
+ gem 'devise'
533
+
534
+ run 'bundle install'
535
+ end
536
+
537
+ def run_generators
538
+
539
+ say %Q{
540
+ These gems provide generators for adding basic views, styles, and override points into your application. We'll run these
541
+ generators now.
542
+ }, STATEMENT
543
+ run 'rm config/solr.yml' # avoid meaningless conflict
544
+ generate 'blacklight', '--devise'
545
+ run 'rm config/solr.yml' # avoid meaningless conflict
546
+ generate 'hydra:head', 'User'
547
+ end
548
+
549
+ def db_migrate
550
+ say %Q{
551
+ Blacklight uses a SQL database for keeping track of user bookmarks, searches, etc. We'll run the migrations next:
552
+ }, STATEMENT
553
+ rake 'db:migrate'
554
+ rake 'db:test:prepare'
555
+ end
556
+
557
+ def hydra_jetty_conf
558
+ say %Q{
559
+ Hydra provides some configuration for Solr and Fedora. Use them.
560
+ }, STATEMENT
561
+ rake 'jetty:stop'
562
+ rake 'hydra:jetty:config'
563
+ rake 'jetty:start'
564
+ end
565
+ end
566
+
567
+ class FixupForHydra < Thor::Group
568
+ include Thor::Actions
569
+ include Rails::Generators::Actions
570
+ include TutorialActions
571
+
572
+ def do_it
573
+
574
+ say %Q{
575
+ We need to make a couple changes to our controller and model to make them fully-compliant objects by
576
+ teaching them about access rights.
577
+ }, STATEMENT
578
+
579
+ inject_into_class "app/controllers/records_controller.rb", 'RecordsController' do
580
+ " include Hydra::AssetsControllerHelper\n"
581
+ end
582
+
583
+ insert_into_file "app/controllers/records_controller.rb", :after => "@record = Record.new(params[:record])\n" do
584
+ " apply_depositor_metadata(@record)\n"
585
+ end
586
+
587
+ inject_into_class "app/models/record.rb", "Record" do
588
+ "
589
+ include Hydra::ModelMixins::CommonMetadata
590
+ include Hydra::ModelMethods
591
+ "
592
+ end
593
+
594
+ end
595
+
596
+ def look_at_it
597
+ say %Q{
598
+ Blacklight and Hydra-Head have added some new functionality to the application. We can now look at a search interface
599
+ (provided by Blacklight) and use gated discovery over our repository. By default, objects are only visible to their
600
+ creator.
601
+
602
+ Create some new objects, and then check out the search catalog at:
603
+
604
+ http://localhost:3000/catalog
605
+
606
+ }, STATEMENT
607
+
608
+ rails_server('/records/new') unless $quick
609
+ end
610
+
611
+ end
612
+
613
+ class AddTests < Thor::Group
614
+ include Thor::Actions
615
+ include Rails::Generators::Actions
616
+ include TutorialActions
617
+
618
+ def self.source_paths
619
+ [File.join($base_templates_path, "add_tests")]
620
+ end
621
+
622
+
623
+ def install_rspec
624
+ gem_group :development, :test do
625
+ gem 'rspec'
626
+ gem 'rspec-rails'
627
+ end
628
+ run 'bundle install'
629
+
630
+ generate 'rspec:install'
631
+ end
632
+
633
+ def write_our_first_test
634
+ copy_file 'records_controller_spec.rb', 'spec/controlers/records_controller_spec.rb'
635
+ end
636
+
637
+ def run_tests
638
+ run 'rspec'
639
+ end
640
+
641
+ def a_model_test
642
+ # copy_file 'record_test.rb', 'spec/models/record_test.rb'
643
+ end
644
+
645
+ end
646
+
647
+ class AddFileAssets
648
+
649
+ end
650
+
651
+ class SprinkeSomeBootstrapCSS
652
+
653
+ end
654
+
655
+ class AddCollections
656
+
657
+ end
658
+
659
+ class AddRightsEnforcement
660
+
661
+ end
662
+
663
+ class AddTechnicalMetadata
664
+
665
+ end
666
+ end
667
+
668
+ HydraOpenRepositoriesTutorialApp.start