ocean-rails 6.0.1 → 6.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5b293b0bc6aea7b3f4dfb8be54347c3bc4edc4ab
4
- data.tar.gz: d9bc449a6991f8da2d6190e21843ae8a9dae7a5e
3
+ metadata.gz: f3c466d14a4377353e6066a920473a01bfab2ae6
4
+ data.tar.gz: bbe416f156a3ceb38c99d3b7d7f8f3034778d9f4
5
5
  SHA512:
6
- metadata.gz: f519f38524ec7a2d2b60558e30ba9c0c3e1077e3c1f5abd5ee2eacc7600c3efdb0c1e45af279e95101d6aa2a0e32b4e58937297e2a1b8d832c4cf5b9f5f62dd9
7
- data.tar.gz: 14da6157c34aa3031ee4399674d22c6618e2ed3ecbb0b5c50aa1932396918694010a9649f04f8bfd0778fd74cb319c0d266d59c253dea8d635515d77a9380157
6
+ metadata.gz: e9ecd343b2596ddcd880671a4c4b3a000dcb61549700bccbcb195aa5e35529a16264593c30809d0b453e15973070ab848bb4d5ad294c39ac823e85b5fc2b89f7
7
+ data.tar.gz: 28d9e635e2dc146d360a048daa5f60612ce4e7740fc4616cb755e41d975eed76fc4de7f3bb407847bf780d757448137f49eb506c01911bfb06ccd7bbda2d3fe1
data/README.rdoc CHANGED
@@ -3,10 +3,24 @@
3
3
  This repository contains the Ocean ruby gem, containing common framework functionality
4
4
  for the Ruby on Rails part of the architecture.
5
5
 
6
- Ocean requires Ruby 2.0 and Ruby on Rails 4.0.0 or later.
6
+ Ocean requires Ruby 2.2 and Ruby on Rails 4.2.0 or later.
7
7
 
8
8
  {<img src="https://badge.fury.io/rb/ocean-rails.png" alt="Gem Version" />}[http://badge.fury.io/rb/ocean-rails]
9
9
 
10
+ === What does ocean-rails provide?
11
+
12
+ * base classes for Ocean controllers and models (both SQL and DynamoDB).
13
+ * the Api class, which encapsulates all logic for calling other API services. This includes authentication, authorisation, support for BAN and PURGE, making HTTP requests with retries and backoff, sequentially and in parallel, helpers for running AsyncJobs, sending mail, raising Ocean Semaphores, and much more. Many of these are very useful even outside of the Ocean context.
14
+ * the RemoteResource class, which allows you to use a remote Ocean resource as if it were local, with full abstraction of hyperlinks and attributes.
15
+ * classes which implement Ocean's aggressive caching for controllers and models, and which provide abstractions for collections, matching, searches, grouping, and paging.
16
+ * controller renderers for collections and errors of various kinds.
17
+ * the AliveController, which is inherited by all Ocean services. Its only action, +index+, is called by Varnish to determine that the service is operational. Fail-over is performed automatically as a result.
18
+ * the ErrorController, which intercepts all errors and converts them to the standard Ocean JSON format in the response body.
19
+ * the logger for the aggregated ZeroMQ Ocean log.
20
+ * templates and generators to set up new Ocean applications and Ocean resources.
21
+
22
+ Thus, the +ocean-rails+ gem provides all the abstractions you need for creating very terse and powerful controller and model code. It's a good idea to browse the documentation.
23
+
10
24
 
11
25
  === Documentation
12
26
  * Ocean gem on Rubygems: https://rubygems.org/gems/ocean-rails
@@ -18,58 +32,7 @@ Ocean requires Ruby 2.0 and Ruby on Rails 4.0.0 or later.
18
32
 
19
33
  === Creating an Ocean Rails app
20
34
 
21
- The ocean gem provides an application template and generator to quickly and easily set up
22
- a complete Rails application for Ocean. Simply execute the following in your terminal:
23
-
24
- rails new the_app_name -m https://raw.github.com/OceanDev/ocean-rails/master/template.rb
25
-
26
- Answer yes to all overwrite queries.
27
-
28
- There is only one piece of manual setup to perform. You must supply the Ocean app with
29
- your site-specific data: the base domain name, the password for Auth, etc. To do this,
30
- simply edit <code>config/config.yml</code>.
31
-
32
- There is also a file called <code>config.yml.example</code> in the
33
- same directory for reference. Don't change it: it is under version control. The file
34
- you should change, <code>config/config.yml</code>, isn't, as it will contain site-specific and/or
35
- confidential data.
36
-
37
- There are no specs to run at this point: all functionality provided by the +ocean-rails+
38
- gem already is exhaustively tested in the +ocean-rails+ spec suite.
39
-
40
-
41
- === Creating an Ocean Resource
42
-
43
- To create an aggressively cached Ocean resource based on an SQL model, do the following:
44
-
45
- rails g scaffold quux name:string description:string \
46
- lock_version:integer created_by:string updated_by:string
47
-
48
- This will create the basic model and associated model and controller scaffolding code,
49
- which we will modify shortly. Now run
50
-
51
- rake db:migrate
52
-
53
- This will create the SQL table for the resource. Next, we need to replace the HTML-centric
54
- scaffold code generated above with RESTful JSON scaffold code for Ocean:
55
-
56
- rails g ocean_scaffold quux
57
-
58
- Answer yes to all overwrite queries. Now examine +config/routes.rb+. You will find a new resource
59
- declaration for quuxes. Move it inside the versioned scope and add and +except:+ clause to exclude
60
- the Rails controller actions not used in a REST Api:
61
-
62
- scope "v1" do
63
- resource :quuxes, except: [:new, :edit]
64
- end
65
-
66
- To verify that everything works as it should, run the tests:
67
-
68
- rspec
69
-
70
- All tests should pass. The test coverage should be very close to 100%. A FactoryGirl factory for the new model will be created, there will be model unit tests to check for the presence of all attributes and to verify collection searches, routing tests, controller tests for each action, and view tests to verify that the JSON representation is complete and correct.
71
-
72
- You can now proceed to tailor the new resource to your needs. You will want to add other attributes to the model or remove some or all of the default ones; you can change the JSON representation by modifying the view; and you might want to add or remove controller actions, e.g. to support secondary collections and relations to other resources. And as you no doubt are a responsible, informed developer, you will of course do all this using TDD and/or BDD techniques.
35
+ Cf. the tutorial at http://wiki.oceanframework.net/index.php/Tutorial for information on about how to set up an Ocean Rails app and create Ocean Resources for it.
73
36
 
74
37
 
75
38
  === Running the specs
@@ -112,35 +75,6 @@ With DynamoDB Local running, you should now be able to do
112
75
  All tests should pass.
113
76
 
114
77
 
115
- === Cleaning up the DB
116
-
117
- You might want to add the following to your spec_helper.rb file, before the +RSpec.configure+
118
- block:
119
-
120
- # DynamoDB table cleaner
121
- CHEF_ENV = "master" unless defined?(CHEF_ENV)
122
- regexp = Regexp.new("^.+_#{CHEF_ENV}_[0-9]{1,3}-[0-9]{1,3}-[0-9]{1,3}-[0-9]{1,3}_(test|dev)$")
123
- cleaner = lambda {
124
- c = Aws::DynamoDB::Client.new
125
- c.list_tables.table_names.each do |t|
126
- begin
127
- c.delete_table({table_name: t}) if t =~ regexp
128
- rescue Aws::DynamoDB::Errors::LimitExceededException
129
- sleep 1
130
- retry
131
- end
132
- end
133
- }
134
-
135
- Then, inside the +RSpec.configure+ block:
136
-
137
- config.before(:suite) { cleaner.call }
138
- config.after(:suite) { cleaner.call }
139
-
140
- This will remove only those tables created by the specs on this particular machine and
141
- environment. This is safe even on AWS and for parallel testing.
142
-
143
-
144
78
  === Rails console
145
79
 
146
80
  The Rails console is available from the built-in dummy application:
@@ -159,14 +93,6 @@ To enable HTTP traffic:
159
93
  Please refer to the +webmock+ gem documentation for full information. It's possible to
160
94
  prevent traffic only to specific hosts (e.g. +localhost+).
161
95
 
162
- You may also need to initialise the table connection:
163
-
164
- CloudModel.establish_db_connection
165
-
166
- This will, amongst other things, also create the CloudModel table if it doesn't already
167
- exist. On Amazon, this will take a little while. With +fake_dynamo+, it's practically
168
- instant.
169
-
170
96
  When you leave the console, you must navigate back to the Rails directory (<tt>cd ../..</tt>)
171
97
  in order to be able to run RSpec again.
172
98
 
@@ -85,6 +85,10 @@ class OceanSetupGenerator < Rails::Generators::NamedBase #:nodoc: all
85
85
  template "aws.yml.example", "#{Rails.root}/config/aws.yml"
86
86
  end
87
87
 
88
+ def install_default_cache_time_file
89
+ template "default_cache_time.rb", "#{Rails.root}/config/initializers/default_cache_time.rb"
90
+ end
91
+
88
92
  def replace_gemfile
89
93
  remove_file "#{Rails.root}/Gemfile"
90
94
  copy_file "Gemfile", "#{Rails.root}/Gemfile"
@@ -0,0 +1 @@
1
+ DEFAULT_CACHE_TIME = 1.week
data/lib/ocean/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ocean
2
- VERSION = "6.0.1"
2
+ VERSION = "6.1.0"
3
3
  end
@@ -5,7 +5,7 @@ require_dependency "<%= namespaced_file_path %>/application_controller"
5
5
  <% module_namespacing do -%>
6
6
  class <%= controller_class_name %>Controller < ApplicationController
7
7
 
8
- ocean_resource_controller required_attributes: [:lock_version, :name, :description]
8
+ ocean_resource_controller required_attributes: [:lock_version]
9
9
 
10
10
  before_action :find_<%= singular_table_name %>, :only => [:show, :update, :destroy]
11
11
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ocean-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.1
4
+ version: 6.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Bengtson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-18 00:00:00.000000000 Z
11
+ date: 2016-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typhoeus
@@ -254,6 +254,7 @@ files:
254
254
  - lib/generators/ocean_setup/templates/application_controller.rb
255
255
  - lib/generators/ocean_setup/templates/aws.yml.example
256
256
  - lib/generators/ocean_setup/templates/config.yml.example
257
+ - lib/generators/ocean_setup/templates/default_cache_time.rb
257
258
  - lib/generators/ocean_setup/templates/gitignore
258
259
  - lib/generators/ocean_setup/templates/hyperlinks.rb
259
260
  - lib/generators/ocean_setup/templates/routes.rb