Skip to content

Commit 90e8fae

Browse files
committed
Rename the generator and config file names
1 parent 61ec144 commit 90e8fae

File tree

7 files changed

+69
-59
lines changed

7 files changed

+69
-59
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ You will need to have an existing Amazon DynamoDB session table in order for the
1717
application to work. You can generate a migration file for the session table
1818
with the following command:
1919

20-
rails generate dynamo_db_session_handler
20+
rails generate sessionstore:dynamodb
2121

2222
To create the table, run migrations as normal with:
2323

lib/rails/generators/dynamo_db_session_handler/USAGE

Lines changed: 0 additions & 12 deletions
This file was deleted.

lib/rails/generators/dynamo_db_session_handler/dynamo_db_session_handler_generator.rb

Lines changed: 0 additions & 46 deletions
This file was deleted.
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License"). You
4+
# may not use this file except in compliance with the License. A copy of
5+
# the License is located at
6+
#
7+
# http://aws.amazon.com/apache2.0/
8+
#
9+
# or in the "license" file accompanying this file. This file is
10+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11+
# ANY KIND, either express or implied. See the License for the specific
12+
# language governing permissions and limitations under the License.
13+
14+
require 'rails/generators/named_base'
15+
16+
# This class generates
17+
# a migration file for deleting and creating
18+
# a DynamoDB sessions table.
19+
module Sessionstore
20+
module Generators
21+
class DynamodbGenerator < Rails::Generators::NamedBase
22+
include Rails::Generators::Migration
23+
24+
source_root File.expand_path('templates', File.dirname(__FILE__))
25+
26+
# Desired name of migration class
27+
argument :name, :type => :string, :default => "sessionstore_migration"
28+
29+
# @return [Rails Migration File] migration file for creation and deletion of
30+
# session table.
31+
def generate_migration_file
32+
migration_template "sessionstore_migration.rb",
33+
"#{Rails.root}/db/migrate/#{file_name}"
34+
end
35+
36+
37+
def copy_sample_config_file
38+
file = File.join("sessionstore", "dynamodb.yml")
39+
template file, File.join(Rails.root, "config", file)
40+
end
41+
42+
private
43+
44+
# @return [String] filename
45+
def file_name
46+
name.underscore
47+
end
48+
49+
# @return [String] migration version using time stamp YYYYMMDDHHSS
50+
def self.next_migration_number(dir = nil)
51+
Time.now.utc.strftime("%Y%m%d%H%M%S")
52+
end
53+
end
54+
end
55+
end
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Description:
2+
Generates a migration file for deleting and a creating a DynamoDB
3+
sessions table, and a configuration file for the session store.
4+
5+
Example:
6+
rails generate sessionstore:dynamodb <MigrationName>
7+
8+
This will create:
9+
db/migrate/VERSION_migration_name.rb
10+
config/sessionstore/dynamodb.yml
11+
12+
The migration will be run when the command rake db:migrate is run
13+
in the command line.

0 commit comments

Comments
 (0)