Permalink
Browse files

Merge pull request #3 from codemis/master

Rails 3 Generator
  • Loading branch information...
2 parents aedbcf4 + aa6791b commit e2f5621cf39fb6853f3c5933468589415ccfd11c @kevintyll committed Mar 16, 2012
View
@@ -106,6 +106,8 @@ Acceptable hash keys and their weighting in score calculation:
== INSTALL:
+==== Rails 2.0
+
* To install the gem:
sudo gem install kevintyll-ofac
* To create the necessary db migration, from the command line, run:
@@ -118,6 +120,21 @@ Acceptable hash keys and their weighting in score calculation:
* The OFAC data is not updated with any regularity, but you can sign up for email notifications when the data changes at
http://www.treas.gov/offices/enforcement/ofac/sdn/index.shtml.
+==== Rails 3.0
+
+* To create the necessary db migration, from the command line, run:
+ rails generate ofac_migration:build
+* To add the gem to your Rails project:
+===== Add the gem to your Gemfile:
+ gem "ofac", "~> 1.3.0"
+===== Run the Bundler install command
+ bundle install
+* To load your table with the current OFAC data, from the command line, run:
+ rake ofac:update_data
+
+ * The OFAC data is not updated with any regularity, but you can sign up for email notifications when the data changes at
+ http://www.treas.gov/offices/enforcement/ofac/sdn/index.shtml.
+
== Copyright
Copyright (c) 2009 Kevin Tyll. See LICENSE for details.
View
@@ -1,5 +1,5 @@
---
-:major: 1
-:minor: 2
-:patch: 5
+:patch: 0
:build:
+:major: 1
+:minor: 3
@@ -0,0 +1,29 @@
+require 'rails'
+
+module OfacMigration
+ module Generators
+ class BuildGenerator < ::Rails::Generators::Base
+ include Rails::Generators::Migration
+ source_root File.expand_path('../templates', __FILE__)
+ desc "Adds the migration for the ofac_sdns table."
+
+ # Get the next migration number
+ #
+ def self.next_migration_number(path)
+ unless @prev_migration_nr
+ @prev_migration_nr = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i
+ else
+ @prev_migration_nr += 1
+ end
+ @prev_migration_nr.to_s
+ end
+
+ # copy the migration file over
+ #
+ def copy_migrations
+ migration_template "create_ofac_sdns.rb", "db/migrate/create_ofac_sdns.rb"
+ end
+
+ end
+ end
+end
@@ -0,0 +1,31 @@
+class CreateOfacSdns < ActiveRecord::Migration
+
+ def self.up
+ create_table :ofac_sdns do |t|
+ t.text :name
+ t.string :sdn_type
+ t.string :program
+ t.string :title
+ t.string :vessel_call_sign
+ t.string :vessel_type
+ t.string :vessel_tonnage
+ t.string :gross_registered_tonnage
+ t.string :vessel_flag
+ t.string :vessel_owner
+ t.text :remarks
+ t.text :address
+ t.string :city
+ t.string :country
+ t.string :address_remarks
+ t.string :alternate_identity_type
+ t.text :alternate_identity_name
+ t.string :alternate_identity_remarks
+ t.timestamps
+ end
+ add_index :ofac_sdns, :sdn_type
+ end
+
+ def self.down
+ drop_table :ofac_sdns
+ end
+end
View
@@ -115,7 +115,8 @@ Gem::Specification.new do |s|
s.post_install_message = %q{For more information on ofac, see http://kevintyll.github.com/ofac/
* To create the necessary db migration, from the command line, run:
- script/generate ofac_migration
+ script/generate ofac_migration for Rails 2 applications
+ rails generate ofac_migration:build for Rails 3 applications
* Require the gem in your environment.rb file in the Rails::Initializer block:
config.gem 'kevintyll-ofac', :lib => 'ofac'
* To load your table with the current OFAC data, from the command line, run:

0 comments on commit e2f5621

Please sign in to comment.