hydra-editor 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +51 -0
- data/Rakefile +57 -0
- data/app/assets/javascripts/hydra-editor/editMetadata.js +4 -0
- data/app/assets/javascripts/hydra-editor/hydra-editor.js +2 -0
- data/app/assets/javascripts/hydra-editor/multiForm.js +58 -0
- data/app/assets/stylesheets/hydra-editor/application.css +13 -0
- data/app/assets/stylesheets/hydra-editor/hydra-editor.css +6 -0
- data/app/controllers/concerns/records_controller_behavior.rb +75 -0
- data/app/controllers/records_controller.rb +3 -0
- data/app/helpers/concerns/records_helper_behavior.rb +59 -0
- data/app/helpers/records_helper.rb +3 -0
- data/app/views/records/_edit_field.html.erb +15 -0
- data/app/views/records/_form.html.erb +16 -0
- data/app/views/records/choose_type.html.erb +8 -0
- data/app/views/records/edit.html.erb +3 -0
- data/app/views/records/edit_fields/_default.html.erb +10 -0
- data/app/views/records/edit_fields/_suffix.html.erb +6 -0
- data/app/views/records/new.html.erb +2 -0
- data/config/routes.rb +4 -0
- data/lib/hydra-editor.rb +12 -0
- data/lib/hydra_editor/engine.rb +8 -0
- data/lib/hydra_editor/version.rb +3 -0
- data/lib/tasks/hydra-editor_tasks.rake +4 -0
- data/spec/controllers/records_controller_spec.rb +101 -0
- data/spec/dummy/Gemfile +16 -0
- data/spec/dummy/Gemfile.lock +246 -0
- data/spec/dummy/README.rdoc +261 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/images/blacklight/bg.png +0 -0
- data/spec/dummy/app/assets/images/blacklight/border.png +0 -0
- data/spec/dummy/app/assets/images/blacklight/bul_sq_gry.gif +0 -0
- data/spec/dummy/app/assets/images/blacklight/checkmark.gif +0 -0
- data/spec/dummy/app/assets/images/blacklight/logo.png +0 -0
- data/spec/dummy/app/assets/images/blacklight/magnifying_glass.gif +0 -0
- data/spec/dummy/app/assets/images/blacklight/remove.gif +0 -0
- data/spec/dummy/app/assets/images/blacklight/separator.gif +0 -0
- data/spec/dummy/app/assets/images/blacklight/start_over.gif +0 -0
- data/spec/dummy/app/assets/images/rails.png +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +18 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/assets/stylesheets/blacklight.css.scss +4 -0
- data/spec/dummy/app/controllers/application_controller.rb +10 -0
- data/spec/dummy/app/controllers/catalog_controller.rb +170 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/models/solr_document.rb +33 -0
- data/spec/dummy/app/models/user.rb +22 -0
- data/spec/dummy/app/views/devise/confirmations/new.html.erb +12 -0
- data/spec/dummy/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
- data/spec/dummy/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
- data/spec/dummy/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
- data/spec/dummy/app/views/devise/passwords/edit.html.erb +16 -0
- data/spec/dummy/app/views/devise/passwords/new.html.erb +12 -0
- data/spec/dummy/app/views/devise/registrations/edit.html.erb +29 -0
- data/spec/dummy/app/views/devise/registrations/new.html.erb +18 -0
- data/spec/dummy/app/views/devise/sessions/new.html.erb +17 -0
- data/spec/dummy/app/views/devise/shared/_links.erb +25 -0
- data/spec/dummy/app/views/devise/unlocks/new.html.erb +12 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/SolrMarc/config-test.properties +37 -0
- data/spec/dummy/config/SolrMarc/config.properties +37 -0
- data/spec/dummy/config/SolrMarc/index.properties +97 -0
- data/spec/dummy/config/SolrMarc/index_scripts/dewey.bsh +47 -0
- data/spec/dummy/config/SolrMarc/index_scripts/format.bsh +126 -0
- data/spec/dummy/config/SolrMarc/translation_maps/README_MAPS +1 -0
- data/spec/dummy/config/SolrMarc/translation_maps/callnumber_map.properties +407 -0
- data/spec/dummy/config/SolrMarc/translation_maps/composition_era_map.properties +56 -0
- data/spec/dummy/config/SolrMarc/translation_maps/country_map.properties +379 -0
- data/spec/dummy/config/SolrMarc/translation_maps/format_map.properties +50 -0
- data/spec/dummy/config/SolrMarc/translation_maps/instrument_map.properties +101 -0
- data/spec/dummy/config/SolrMarc/translation_maps/language_map.properties +490 -0
- data/spec/dummy/config/application.rb +66 -0
- data/spec/dummy/config/boot.rb +6 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +67 -0
- data/spec/dummy/config/environments/test.rb +37 -0
- data/spec/dummy/config/fedora.yml +14 -0
- data/spec/dummy/config/initializers/action_dispatch_http_upload_monkey_patch.rb +12 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/devise.rb +240 -0
- data/spec/dummy/config/initializers/hydra_config.rb +28 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/mime_types.rb +12 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/jetty.yml +5 -0
- data/spec/dummy/config/locales/devise.en.yml +59 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/role_map_cucumber.yml +10 -0
- data/spec/dummy/config/role_map_development.yml +12 -0
- data/spec/dummy/config/role_map_production.yml +2 -0
- data/spec/dummy/config/role_map_test.yml +15 -0
- data/spec/dummy/config/routes.rb +66 -0
- data/spec/dummy/config/solr.yml +10 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/20130415215624_devise_create_users.rb +46 -0
- data/spec/dummy/db/migrate/20130415215633_create_searches.rb +16 -0
- data/spec/dummy/db/migrate/20130415215634_create_bookmarks.rb +18 -0
- data/spec/dummy/db/migrate/20130415215635_remove_editable_fields_from_bookmarks.rb +12 -0
- data/spec/dummy/db/migrate/20130415215636_add_user_types_to_bookmarks_searches.rb +16 -0
- data/spec/dummy/db/schema.rb +53 -0
- data/spec/dummy/db/seeds.rb +7 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/doc/README_FOR_APP +2 -0
- data/spec/dummy/fedora_conf/conf/development/fedora.fcfg +953 -0
- data/spec/dummy/fedora_conf/conf/test/fedora.fcfg +953 -0
- data/spec/dummy/lib/generators/test_app_generator.rb +26 -0
- data/spec/dummy/log/development.log +78 -0
- data/spec/dummy/log/test.log +2372 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/index.html +241 -0
- data/spec/dummy/public/robots.txt +5 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/dummy/solr_conf/conf/schema.xml +433 -0
- data/spec/dummy/solr_conf/conf/solrconfig.xml +158 -0
- data/spec/dummy/solr_conf/solr.xml +35 -0
- data/spec/dummy/test/performance/browsing_test.rb +12 -0
- data/spec/dummy/test/test_helper.rb +13 -0
- data/spec/factories/users.rb +13 -0
- data/spec/helpers/records_helper_spec.rb +20 -0
- data/spec/models/bookmark_spec.rb +7 -0
- data/spec/spec_helper.rb +23 -0
- data/spec/support/Gemfile +12 -0
- data/spec/support/audio.rb +18 -0
- data/spec/support/dummy_generator.rb +26 -0
- data/spec/support/lib/generators/test_app_generator.rb +26 -0
- metadata +410 -0
@@ -0,0 +1,8 @@
|
|
1
|
+
module HydraEditor
|
2
|
+
class Engine < ::Rails::Engine
|
3
|
+
engine_name 'hydra_editor'
|
4
|
+
config.paths.add "app/helpers/concerns", eager_load: true
|
5
|
+
config.paths.add "app/controllers/concerns", eager_load: true
|
6
|
+
config.paths.add "app/models/concerns", eager_load: true
|
7
|
+
end
|
8
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RecordsController do
|
4
|
+
describe "an admin" do
|
5
|
+
before do
|
6
|
+
HydraEditor.models = ['Audio', 'Pdf']
|
7
|
+
@user = FactoryGirl.create(:admin)
|
8
|
+
sign_in @user
|
9
|
+
end
|
10
|
+
describe "who goes to the new page" do
|
11
|
+
it "should be successful" do
|
12
|
+
get :new
|
13
|
+
response.should be_successful
|
14
|
+
response.should render_template(:choose_type)
|
15
|
+
end
|
16
|
+
it "should be successful" do
|
17
|
+
get :new, :type=>'Audio'
|
18
|
+
response.should be_successful
|
19
|
+
response.should render_template(:new)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "creating a new record" do
|
24
|
+
before do
|
25
|
+
stub_audio = Audio.new(pid: 'test:6')
|
26
|
+
stub_audio.stub(:persisted?).and_return(true)
|
27
|
+
Audio.should_receive(:new).and_return(stub_audio)
|
28
|
+
stub_audio.should_receive(:save).and_return(true)
|
29
|
+
end
|
30
|
+
it "should be successful" do
|
31
|
+
post :create, :type=>'Audio', :audio=>{:title=>"My title"}
|
32
|
+
response.should redirect_to("/catalog/#{assigns[:record].id}")
|
33
|
+
assigns[:record].title.should == ['My title']
|
34
|
+
end
|
35
|
+
it "should be successful with json" do
|
36
|
+
post :create, :type=>'Audio', :audio=>{:title=>"My title"}, :format=>:json
|
37
|
+
response.status.should == 201
|
38
|
+
end
|
39
|
+
describe "when set_attributes is overloaded" do
|
40
|
+
class RecordsController
|
41
|
+
def set_attributes
|
42
|
+
super
|
43
|
+
@record.inner_object.pid = 'tufts:0001'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
it "should run set_attributes" do
|
47
|
+
post :create, :type=>'Audio', :audio=>{:title=>"My title"}
|
48
|
+
response.should redirect_to("/catalog/#{assigns[:record].id}")
|
49
|
+
assigns[:record].pid.should == 'tufts:0001'
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "editing a record" do
|
55
|
+
before do
|
56
|
+
@audio = Audio.new(title: 'My title2', pid: 'test:7')
|
57
|
+
ActiveFedora::Base.should_receive(:find).with('test:7', cast:true).and_return(@audio)
|
58
|
+
controller.should_receive(:authorize!).with(:edit, @audio)
|
59
|
+
end
|
60
|
+
it "should be successful" do
|
61
|
+
get :edit, :id=>@audio.pid
|
62
|
+
response.should be_successful
|
63
|
+
assigns[:record].title.should == ['My title2']
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe "updating a record" do
|
68
|
+
before do
|
69
|
+
@audio = Audio.new(title: 'My title2', pid: 'test:7')
|
70
|
+
@audio.stub(:persisted?).and_return(true)
|
71
|
+
@audio.should_receive(:save).and_return(true)
|
72
|
+
ActiveFedora::Base.should_receive(:find).with('test:7', cast:true).and_return(@audio)
|
73
|
+
controller.should_receive(:authorize!).with(:update, @audio)
|
74
|
+
end
|
75
|
+
it "should be successful" do
|
76
|
+
put :update, :id=>@audio, :audio=>{:title=>"My title 3"}
|
77
|
+
response.should redirect_to("/catalog/#{assigns[:record].id}")
|
78
|
+
assigns[:record].title.should == ['My title 3']
|
79
|
+
end
|
80
|
+
it "should be successful with json" do
|
81
|
+
put :update, :id=>@audio, :audio=>{:title=>"My title"}, :format=>:json
|
82
|
+
response.status.should == 204
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
|
89
|
+
describe "a user without create ability" do
|
90
|
+
before do
|
91
|
+
@user = FactoryGirl.create(:user)
|
92
|
+
sign_in @user
|
93
|
+
controller.current_ability.cannot :create, ActiveFedora::Base
|
94
|
+
end
|
95
|
+
describe "who goes to the new page" do
|
96
|
+
it "should not be allowed" do
|
97
|
+
lambda { get :new }.should raise_error CanCan::AccessDenied
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
data/spec/dummy/Gemfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gem 'rails', '3.2.13'
|
4
|
+
gem 'sqlite3'
|
5
|
+
|
6
|
+
gem 'blacklight'
|
7
|
+
gem 'hydra-head'
|
8
|
+
gem 'hydra-editor', path: '../../'
|
9
|
+
|
10
|
+
|
11
|
+
gem "factory_girl_rails"
|
12
|
+
gem 'rspec-rails'
|
13
|
+
|
14
|
+
gem "devise"
|
15
|
+
gem "devise-guests", "~> 0.3"
|
16
|
+
gem "bootstrap-sass"
|
@@ -0,0 +1,246 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ../../
|
3
|
+
specs:
|
4
|
+
hydra-editor (0.0.1)
|
5
|
+
rails (~> 3.2.13)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
actionmailer (3.2.13)
|
11
|
+
actionpack (= 3.2.13)
|
12
|
+
mail (~> 2.5.3)
|
13
|
+
actionpack (3.2.13)
|
14
|
+
activemodel (= 3.2.13)
|
15
|
+
activesupport (= 3.2.13)
|
16
|
+
builder (~> 3.0.0)
|
17
|
+
erubis (~> 2.7.0)
|
18
|
+
journey (~> 1.0.4)
|
19
|
+
rack (~> 1.4.5)
|
20
|
+
rack-cache (~> 1.2)
|
21
|
+
rack-test (~> 0.6.1)
|
22
|
+
sprockets (~> 2.2.1)
|
23
|
+
active-fedora (6.0.0)
|
24
|
+
activeresource (>= 3.0.0)
|
25
|
+
activesupport (>= 3.0.0)
|
26
|
+
builder (~> 3.0.0)
|
27
|
+
deprecation
|
28
|
+
mediashelf-loggable
|
29
|
+
nom-xml (>= 0.5.1)
|
30
|
+
om (~> 2.0.0)
|
31
|
+
rdf
|
32
|
+
rdf-rdfxml (~> 1.0.0)
|
33
|
+
rsolr
|
34
|
+
rubydora (~> 1.5)
|
35
|
+
activemodel (3.2.13)
|
36
|
+
activesupport (= 3.2.13)
|
37
|
+
builder (~> 3.0.0)
|
38
|
+
activerecord (3.2.13)
|
39
|
+
activemodel (= 3.2.13)
|
40
|
+
activesupport (= 3.2.13)
|
41
|
+
arel (~> 3.0.2)
|
42
|
+
tzinfo (~> 0.3.29)
|
43
|
+
activeresource (3.2.13)
|
44
|
+
activemodel (= 3.2.13)
|
45
|
+
activesupport (= 3.2.13)
|
46
|
+
activesupport (3.2.13)
|
47
|
+
i18n (= 0.6.1)
|
48
|
+
multi_json (~> 1.0)
|
49
|
+
addressable (2.3.4)
|
50
|
+
arel (3.0.2)
|
51
|
+
backports (3.3.0)
|
52
|
+
bcrypt-ruby (3.0.1)
|
53
|
+
blacklight (4.2.0)
|
54
|
+
bootstrap-sass (~> 2.2.0)
|
55
|
+
kaminari (~> 0.13)
|
56
|
+
marc (>= 0.4.3, < 1.1)
|
57
|
+
nokogiri (~> 1.5)
|
58
|
+
rails (>= 3.2)
|
59
|
+
rsolr (~> 1.0.6)
|
60
|
+
sass-rails
|
61
|
+
block_helpers (0.3.3)
|
62
|
+
activesupport (>= 2.0)
|
63
|
+
bootstrap-sass (2.2.2.0)
|
64
|
+
sass (~> 3.2)
|
65
|
+
builder (3.0.4)
|
66
|
+
cancan (1.6.9)
|
67
|
+
childprocess (0.3.9)
|
68
|
+
ffi (~> 1.0, >= 1.0.11)
|
69
|
+
daemons (1.1.9)
|
70
|
+
deprecation (0.0.5)
|
71
|
+
activesupport
|
72
|
+
devise (2.2.3)
|
73
|
+
bcrypt-ruby (~> 3.0)
|
74
|
+
orm_adapter (~> 0.1)
|
75
|
+
railties (~> 3.1)
|
76
|
+
warden (~> 1.2.1)
|
77
|
+
devise-guests (0.3.1)
|
78
|
+
devise
|
79
|
+
diff-lcs (1.2.3)
|
80
|
+
equivalent-xml (0.3.0)
|
81
|
+
nokogiri (>= 1.4.3)
|
82
|
+
erubis (2.7.0)
|
83
|
+
factory_girl (4.2.0)
|
84
|
+
activesupport (>= 3.0.0)
|
85
|
+
factory_girl_rails (4.2.1)
|
86
|
+
factory_girl (~> 4.2.0)
|
87
|
+
railties (>= 3.0.0)
|
88
|
+
fastercsv (1.5.5)
|
89
|
+
ffi (1.7.0)
|
90
|
+
hike (1.2.2)
|
91
|
+
hooks (0.2.2)
|
92
|
+
hydra-access-controls (6.0.0)
|
93
|
+
active-fedora (>= 6.0.0)
|
94
|
+
activesupport
|
95
|
+
blacklight
|
96
|
+
cancan
|
97
|
+
deprecation
|
98
|
+
hydra-core (6.0.0)
|
99
|
+
active-fedora
|
100
|
+
blacklight (~> 4.0)
|
101
|
+
block_helpers
|
102
|
+
deprecation (>= 0.0.5)
|
103
|
+
hydra-access-controls (= 6.0.0)
|
104
|
+
jettywrapper (>= 1.4.1)
|
105
|
+
rails (~> 3.2.3)
|
106
|
+
hydra-head (6.0.0)
|
107
|
+
hydra-access-controls (= 6.0.0)
|
108
|
+
hydra-core (= 6.0.0)
|
109
|
+
rails (>= 3.2.6)
|
110
|
+
i18n (0.6.1)
|
111
|
+
jettywrapper (1.4.1)
|
112
|
+
activesupport (>= 3.0.0)
|
113
|
+
childprocess
|
114
|
+
i18n
|
115
|
+
logger
|
116
|
+
mediashelf-loggable
|
117
|
+
journey (1.0.4)
|
118
|
+
json (1.7.7)
|
119
|
+
kaminari (0.14.1)
|
120
|
+
actionpack (>= 3.0.0)
|
121
|
+
activesupport (>= 3.0.0)
|
122
|
+
logger (1.2.8)
|
123
|
+
mail (2.5.3)
|
124
|
+
i18n (>= 0.4.0)
|
125
|
+
mime-types (~> 1.16)
|
126
|
+
treetop (~> 1.4.8)
|
127
|
+
marc (0.5.0)
|
128
|
+
mediashelf-loggable (0.4.9)
|
129
|
+
mime-types (1.22)
|
130
|
+
multi_json (1.7.2)
|
131
|
+
nokogiri (1.5.9)
|
132
|
+
nom-xml (0.5.1)
|
133
|
+
activesupport
|
134
|
+
i18n
|
135
|
+
nokogiri
|
136
|
+
om (2.0.0)
|
137
|
+
activemodel
|
138
|
+
activesupport
|
139
|
+
deprecation
|
140
|
+
mediashelf-loggable
|
141
|
+
nokogiri (>= 1.4.2)
|
142
|
+
solrizer (~> 3.0.0)
|
143
|
+
orm_adapter (0.4.0)
|
144
|
+
polyglot (0.3.3)
|
145
|
+
rack (1.4.5)
|
146
|
+
rack-cache (1.2)
|
147
|
+
rack (>= 0.4)
|
148
|
+
rack-ssl (1.3.3)
|
149
|
+
rack
|
150
|
+
rack-test (0.6.2)
|
151
|
+
rack (>= 1.0)
|
152
|
+
rails (3.2.13)
|
153
|
+
actionmailer (= 3.2.13)
|
154
|
+
actionpack (= 3.2.13)
|
155
|
+
activerecord (= 3.2.13)
|
156
|
+
activeresource (= 3.2.13)
|
157
|
+
activesupport (= 3.2.13)
|
158
|
+
bundler (~> 1.0)
|
159
|
+
railties (= 3.2.13)
|
160
|
+
railties (3.2.13)
|
161
|
+
actionpack (= 3.2.13)
|
162
|
+
activesupport (= 3.2.13)
|
163
|
+
rack-ssl (~> 1.3.2)
|
164
|
+
rake (>= 0.8.7)
|
165
|
+
rdoc (~> 3.4)
|
166
|
+
thor (>= 0.14.6, < 2.0)
|
167
|
+
rake (10.0.4)
|
168
|
+
rdf (1.0.5)
|
169
|
+
addressable (>= 2.2)
|
170
|
+
rdf-rdfxml (1.0.1)
|
171
|
+
rdf (>= 1.0)
|
172
|
+
rdf-xsd (>= 1.0)
|
173
|
+
rdf-xsd (1.0.0)
|
174
|
+
backports
|
175
|
+
nokogiri (>= 1.5.0)
|
176
|
+
rdf (>= 0.3.4)
|
177
|
+
rdoc (3.12.2)
|
178
|
+
json (~> 1.4)
|
179
|
+
rest-client (1.6.7)
|
180
|
+
mime-types (>= 1.16)
|
181
|
+
rsolr (1.0.9)
|
182
|
+
builder (>= 2.1.2)
|
183
|
+
rspec-core (2.13.1)
|
184
|
+
rspec-expectations (2.13.0)
|
185
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
186
|
+
rspec-mocks (2.13.1)
|
187
|
+
rspec-rails (2.13.0)
|
188
|
+
actionpack (>= 3.0)
|
189
|
+
activesupport (>= 3.0)
|
190
|
+
railties (>= 3.0)
|
191
|
+
rspec-core (~> 2.13.0)
|
192
|
+
rspec-expectations (~> 2.13.0)
|
193
|
+
rspec-mocks (~> 2.13.0)
|
194
|
+
rubydora (1.6.1)
|
195
|
+
activemodel
|
196
|
+
activesupport
|
197
|
+
deprecation
|
198
|
+
equivalent-xml
|
199
|
+
fastercsv
|
200
|
+
hooks
|
201
|
+
mime-types
|
202
|
+
nokogiri
|
203
|
+
rest-client
|
204
|
+
sass (3.2.7)
|
205
|
+
sass-rails (3.2.6)
|
206
|
+
railties (~> 3.2.0)
|
207
|
+
sass (>= 3.1.10)
|
208
|
+
tilt (~> 1.3)
|
209
|
+
solrizer (3.0.0)
|
210
|
+
activesupport
|
211
|
+
daemons
|
212
|
+
mediashelf-loggable (~> 0.4.7)
|
213
|
+
nokogiri
|
214
|
+
stomp
|
215
|
+
xml-simple
|
216
|
+
sprockets (2.2.2)
|
217
|
+
hike (~> 1.2)
|
218
|
+
multi_json (~> 1.0)
|
219
|
+
rack (~> 1.0)
|
220
|
+
tilt (~> 1.1, != 1.3.0)
|
221
|
+
sqlite3 (1.3.7)
|
222
|
+
stomp (1.2.9)
|
223
|
+
thor (0.18.1)
|
224
|
+
tilt (1.3.7)
|
225
|
+
treetop (1.4.12)
|
226
|
+
polyglot
|
227
|
+
polyglot (>= 0.3.1)
|
228
|
+
tzinfo (0.3.37)
|
229
|
+
warden (1.2.1)
|
230
|
+
rack (>= 1.0)
|
231
|
+
xml-simple (1.1.2)
|
232
|
+
|
233
|
+
PLATFORMS
|
234
|
+
ruby
|
235
|
+
|
236
|
+
DEPENDENCIES
|
237
|
+
blacklight
|
238
|
+
bootstrap-sass
|
239
|
+
devise
|
240
|
+
devise-guests (~> 0.3)
|
241
|
+
factory_girl_rails
|
242
|
+
hydra-editor!
|
243
|
+
hydra-head
|
244
|
+
rails (= 3.2.13)
|
245
|
+
rspec-rails
|
246
|
+
sqlite3
|
@@ -0,0 +1,261 @@
|
|
1
|
+
== Welcome to Rails
|
2
|
+
|
3
|
+
Rails is a web-application framework that includes everything needed to create
|
4
|
+
database-backed web applications according to the Model-View-Control pattern.
|
5
|
+
|
6
|
+
This pattern splits the view (also called the presentation) into "dumb"
|
7
|
+
templates that are primarily responsible for inserting pre-built data in between
|
8
|
+
HTML tags. The model contains the "smart" domain objects (such as Account,
|
9
|
+
Product, Person, Post) that holds all the business logic and knows how to
|
10
|
+
persist themselves to a database. The controller handles the incoming requests
|
11
|
+
(such as Save New Account, Update Product, Show Post) by manipulating the model
|
12
|
+
and directing data to the view.
|
13
|
+
|
14
|
+
In Rails, the model is handled by what's called an object-relational mapping
|
15
|
+
layer entitled Active Record. This layer allows you to present the data from
|
16
|
+
database rows as objects and embellish these data objects with business logic
|
17
|
+
methods. You can read more about Active Record in
|
18
|
+
link:files/vendor/rails/activerecord/README.html.
|
19
|
+
|
20
|
+
The controller and view are handled by the Action Pack, which handles both
|
21
|
+
layers by its two parts: Action View and Action Controller. These two layers
|
22
|
+
are bundled in a single package due to their heavy interdependence. This is
|
23
|
+
unlike the relationship between the Active Record and Action Pack that is much
|
24
|
+
more separate. Each of these packages can be used independently outside of
|
25
|
+
Rails. You can read more about Action Pack in
|
26
|
+
link:files/vendor/rails/actionpack/README.html.
|
27
|
+
|
28
|
+
|
29
|
+
== Getting Started
|
30
|
+
|
31
|
+
1. At the command prompt, create a new Rails application:
|
32
|
+
<tt>rails new myapp</tt> (where <tt>myapp</tt> is the application name)
|
33
|
+
|
34
|
+
2. Change directory to <tt>myapp</tt> and start the web server:
|
35
|
+
<tt>cd myapp; rails server</tt> (run with --help for options)
|
36
|
+
|
37
|
+
3. Go to http://localhost:3000/ and you'll see:
|
38
|
+
"Welcome aboard: You're riding Ruby on Rails!"
|
39
|
+
|
40
|
+
4. Follow the guidelines to start developing your application. You can find
|
41
|
+
the following resources handy:
|
42
|
+
|
43
|
+
* The Getting Started Guide: http://guides.rubyonrails.org/getting_started.html
|
44
|
+
* Ruby on Rails Tutorial Book: http://www.railstutorial.org/
|
45
|
+
|
46
|
+
|
47
|
+
== Debugging Rails
|
48
|
+
|
49
|
+
Sometimes your application goes wrong. Fortunately there are a lot of tools that
|
50
|
+
will help you debug it and get it back on the rails.
|
51
|
+
|
52
|
+
First area to check is the application log files. Have "tail -f" commands
|
53
|
+
running on the server.log and development.log. Rails will automatically display
|
54
|
+
debugging and runtime information to these files. Debugging info will also be
|
55
|
+
shown in the browser on requests from 127.0.0.1.
|
56
|
+
|
57
|
+
You can also log your own messages directly into the log file from your code
|
58
|
+
using the Ruby logger class from inside your controllers. Example:
|
59
|
+
|
60
|
+
class WeblogController < ActionController::Base
|
61
|
+
def destroy
|
62
|
+
@weblog = Weblog.find(params[:id])
|
63
|
+
@weblog.destroy
|
64
|
+
logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!")
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
The result will be a message in your log file along the lines of:
|
69
|
+
|
70
|
+
Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1!
|
71
|
+
|
72
|
+
More information on how to use the logger is at http://www.ruby-doc.org/core/
|
73
|
+
|
74
|
+
Also, Ruby documentation can be found at http://www.ruby-lang.org/. There are
|
75
|
+
several books available online as well:
|
76
|
+
|
77
|
+
* Programming Ruby: http://www.ruby-doc.org/docs/ProgrammingRuby/ (Pickaxe)
|
78
|
+
* Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
|
79
|
+
|
80
|
+
These two books will bring you up to speed on the Ruby language and also on
|
81
|
+
programming in general.
|
82
|
+
|
83
|
+
|
84
|
+
== Debugger
|
85
|
+
|
86
|
+
Debugger support is available through the debugger command when you start your
|
87
|
+
Mongrel or WEBrick server with --debugger. This means that you can break out of
|
88
|
+
execution at any point in the code, investigate and change the model, and then,
|
89
|
+
resume execution! You need to install ruby-debug to run the server in debugging
|
90
|
+
mode. With gems, use <tt>sudo gem install ruby-debug</tt>. Example:
|
91
|
+
|
92
|
+
class WeblogController < ActionController::Base
|
93
|
+
def index
|
94
|
+
@posts = Post.all
|
95
|
+
debugger
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
So the controller will accept the action, run the first line, then present you
|
100
|
+
with a IRB prompt in the server window. Here you can do things like:
|
101
|
+
|
102
|
+
>> @posts.inspect
|
103
|
+
=> "[#<Post:0x14a6be8
|
104
|
+
@attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>,
|
105
|
+
#<Post:0x14a6620
|
106
|
+
@attributes={"title"=>"Rails", "body"=>"Only ten..", "id"=>"2"}>]"
|
107
|
+
>> @posts.first.title = "hello from a debugger"
|
108
|
+
=> "hello from a debugger"
|
109
|
+
|
110
|
+
...and even better, you can examine how your runtime objects actually work:
|
111
|
+
|
112
|
+
>> f = @posts.first
|
113
|
+
=> #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
|
114
|
+
>> f.
|
115
|
+
Display all 152 possibilities? (y or n)
|
116
|
+
|
117
|
+
Finally, when you're ready to resume execution, you can enter "cont".
|
118
|
+
|
119
|
+
|
120
|
+
== Console
|
121
|
+
|
122
|
+
The console is a Ruby shell, which allows you to interact with your
|
123
|
+
application's domain model. Here you'll have all parts of the application
|
124
|
+
configured, just like it is when the application is running. You can inspect
|
125
|
+
domain models, change values, and save to the database. Starting the script
|
126
|
+
without arguments will launch it in the development environment.
|
127
|
+
|
128
|
+
To start the console, run <tt>rails console</tt> from the application
|
129
|
+
directory.
|
130
|
+
|
131
|
+
Options:
|
132
|
+
|
133
|
+
* Passing the <tt>-s, --sandbox</tt> argument will rollback any modifications
|
134
|
+
made to the database.
|
135
|
+
* Passing an environment name as an argument will load the corresponding
|
136
|
+
environment. Example: <tt>rails console production</tt>.
|
137
|
+
|
138
|
+
To reload your controllers and models after launching the console run
|
139
|
+
<tt>reload!</tt>
|
140
|
+
|
141
|
+
More information about irb can be found at:
|
142
|
+
link:http://www.rubycentral.org/pickaxe/irb.html
|
143
|
+
|
144
|
+
|
145
|
+
== dbconsole
|
146
|
+
|
147
|
+
You can go to the command line of your database directly through <tt>rails
|
148
|
+
dbconsole</tt>. You would be connected to the database with the credentials
|
149
|
+
defined in database.yml. Starting the script without arguments will connect you
|
150
|
+
to the development database. Passing an argument will connect you to a different
|
151
|
+
database, like <tt>rails dbconsole production</tt>. Currently works for MySQL,
|
152
|
+
PostgreSQL and SQLite 3.
|
153
|
+
|
154
|
+
== Description of Contents
|
155
|
+
|
156
|
+
The default directory structure of a generated Ruby on Rails application:
|
157
|
+
|
158
|
+
|-- app
|
159
|
+
| |-- assets
|
160
|
+
| | |-- images
|
161
|
+
| | |-- javascripts
|
162
|
+
| | `-- stylesheets
|
163
|
+
| |-- controllers
|
164
|
+
| |-- helpers
|
165
|
+
| |-- mailers
|
166
|
+
| |-- models
|
167
|
+
| `-- views
|
168
|
+
| `-- layouts
|
169
|
+
|-- config
|
170
|
+
| |-- environments
|
171
|
+
| |-- initializers
|
172
|
+
| `-- locales
|
173
|
+
|-- db
|
174
|
+
|-- doc
|
175
|
+
|-- lib
|
176
|
+
| |-- assets
|
177
|
+
| `-- tasks
|
178
|
+
|-- log
|
179
|
+
|-- public
|
180
|
+
|-- script
|
181
|
+
|-- test
|
182
|
+
| |-- fixtures
|
183
|
+
| |-- functional
|
184
|
+
| |-- integration
|
185
|
+
| |-- performance
|
186
|
+
| `-- unit
|
187
|
+
|-- tmp
|
188
|
+
| `-- cache
|
189
|
+
| `-- assets
|
190
|
+
`-- vendor
|
191
|
+
|-- assets
|
192
|
+
| |-- javascripts
|
193
|
+
| `-- stylesheets
|
194
|
+
`-- plugins
|
195
|
+
|
196
|
+
app
|
197
|
+
Holds all the code that's specific to this particular application.
|
198
|
+
|
199
|
+
app/assets
|
200
|
+
Contains subdirectories for images, stylesheets, and JavaScript files.
|
201
|
+
|
202
|
+
app/controllers
|
203
|
+
Holds controllers that should be named like weblogs_controller.rb for
|
204
|
+
automated URL mapping. All controllers should descend from
|
205
|
+
ApplicationController which itself descends from ActionController::Base.
|
206
|
+
|
207
|
+
app/models
|
208
|
+
Holds models that should be named like post.rb. Models descend from
|
209
|
+
ActiveRecord::Base by default.
|
210
|
+
|
211
|
+
app/views
|
212
|
+
Holds the template files for the view that should be named like
|
213
|
+
weblogs/index.html.erb for the WeblogsController#index action. All views use
|
214
|
+
eRuby syntax by default.
|
215
|
+
|
216
|
+
app/views/layouts
|
217
|
+
Holds the template files for layouts to be used with views. This models the
|
218
|
+
common header/footer method of wrapping views. In your views, define a layout
|
219
|
+
using the <tt>layout :default</tt> and create a file named default.html.erb.
|
220
|
+
Inside default.html.erb, call <% yield %> to render the view using this
|
221
|
+
layout.
|
222
|
+
|
223
|
+
app/helpers
|
224
|
+
Holds view helpers that should be named like weblogs_helper.rb. These are
|
225
|
+
generated for you automatically when using generators for controllers.
|
226
|
+
Helpers can be used to wrap functionality for your views into methods.
|
227
|
+
|
228
|
+
config
|
229
|
+
Configuration files for the Rails environment, the routing map, the database,
|
230
|
+
and other dependencies.
|
231
|
+
|
232
|
+
db
|
233
|
+
Contains the database schema in schema.rb. db/migrate contains all the
|
234
|
+
sequence of Migrations for your schema.
|
235
|
+
|
236
|
+
doc
|
237
|
+
This directory is where your application documentation will be stored when
|
238
|
+
generated using <tt>rake doc:app</tt>
|
239
|
+
|
240
|
+
lib
|
241
|
+
Application specific libraries. Basically, any kind of custom code that
|
242
|
+
doesn't belong under controllers, models, or helpers. This directory is in
|
243
|
+
the load path.
|
244
|
+
|
245
|
+
public
|
246
|
+
The directory available for the web server. Also contains the dispatchers and the
|
247
|
+
default HTML files. This should be set as the DOCUMENT_ROOT of your web
|
248
|
+
server.
|
249
|
+
|
250
|
+
script
|
251
|
+
Helper scripts for automation and generation.
|
252
|
+
|
253
|
+
test
|
254
|
+
Unit and functional tests along with fixtures. When using the rails generate
|
255
|
+
command, template test files will be generated for you and placed in this
|
256
|
+
directory.
|
257
|
+
|
258
|
+
vendor
|
259
|
+
External libraries that the application depends on. Also includes the plugins
|
260
|
+
subdirectory. If the app has frozen rails, those gems also go here, under
|
261
|
+
vendor/rails/. This directory is in the load path.
|