locker 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +4 -28
 - data/generators/locker/USAGE +11 -0
 - data/generators/locker/locker_generator.rb +28 -0
 - data/generators/locker/templates/migration.rb +16 -0
 - data/generators/locker/templates/model.rb +2 -0
 - data/lib/generators/locker/USAGE +1 -1
 - data/lib/locker/version.rb +1 -1
 - metadata +7 -3
 
    
        data/README.md
    CHANGED
    
    | 
         @@ -90,37 +90,13 @@ Otherwise you can just `gem install locker`. 
     | 
|
| 
       90 
90 
     | 
    
         | 
| 
       91 
91 
     | 
    
         
             
            This gem includes generators for Rails 3.0+:
         
     | 
| 
       92 
92 
     | 
    
         | 
| 
       93 
     | 
    
         
            -
             
     | 
| 
       94 
     | 
    
         
            -
            script/rails generate locker [ModelName]
         
     | 
| 
       95 
     | 
    
         
            -
            ```
         
     | 
| 
       96 
     | 
    
         
            -
             
     | 
| 
       97 
     | 
    
         
            -
            The 'ModelName' defaults to 'Lock'. This will generate the Lock model and its migration.
         
     | 
| 
      
 93 
     | 
    
         
            +
            `script/rails generate locker [ModelName]`
         
     | 
| 
       98 
94 
     | 
    
         | 
| 
       99 
     | 
    
         
            -
             
     | 
| 
      
 95 
     | 
    
         
            +
            In Rails 2.3.x+:
         
     | 
| 
       100 
96 
     | 
    
         | 
| 
       101 
     | 
    
         
            -
             
     | 
| 
       102 
     | 
    
         
            -
            class CreateLocks < ActiveRecord::Migration
         
     | 
| 
       103 
     | 
    
         
            -
              def self.up
         
     | 
| 
       104 
     | 
    
         
            -
                create_table :locks do |t|
         
     | 
| 
       105 
     | 
    
         
            -
                  t.string :locked_by
         
     | 
| 
       106 
     | 
    
         
            -
                  t.string :key
         
     | 
| 
       107 
     | 
    
         
            -
                  t.datetime :locked_at
         
     | 
| 
       108 
     | 
    
         
            -
                  t.datetime :locked_until
         
     | 
| 
       109 
     | 
    
         
            -
                end
         
     | 
| 
       110 
     | 
    
         
            -
             
     | 
| 
       111 
     | 
    
         
            -
                add_index :locks, :key, :unique => true
         
     | 
| 
       112 
     | 
    
         
            -
              end
         
     | 
| 
      
 97 
     | 
    
         
            +
            `script/generate locker [ModelName]`
         
     | 
| 
       113 
98 
     | 
    
         | 
| 
       114 
     | 
    
         
            -
             
     | 
| 
       115 
     | 
    
         
            -
                drop_table :locks
         
     | 
| 
       116 
     | 
    
         
            -
              end
         
     | 
| 
       117 
     | 
    
         
            -
            end
         
     | 
| 
       118 
     | 
    
         
            -
            ```
         
     | 
| 
       119 
     | 
    
         
            -
             
     | 
| 
       120 
     | 
    
         
            -
            ```ruby
         
     | 
| 
       121 
     | 
    
         
            -
            class Lock < ActiveRecord::Base
         
     | 
| 
       122 
     | 
    
         
            -
            end
         
     | 
| 
       123 
     | 
    
         
            -
            ```
         
     | 
| 
      
 99 
     | 
    
         
            +
            The 'ModelName' defaults to 'Lock' if not specified. This will generate the Lock model and its migration.
         
     | 
| 
       124 
100 
     | 
    
         | 
| 
       125 
101 
     | 
    
         
             
            ## Advanced Usage
         
     | 
| 
       126 
102 
     | 
    
         | 
| 
         @@ -0,0 +1,28 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            class LockerGenerator < Rails::Generator::Base
         
     | 
| 
      
 2 
     | 
    
         
            +
              attr_reader :name
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
              def initialize(runtime_args, runtime_options={})
         
     | 
| 
      
 5 
     | 
    
         
            +
                super
         
     | 
| 
      
 6 
     | 
    
         
            +
                @name = (runtime_args.first || "lock").underscore
         
     | 
| 
      
 7 
     | 
    
         
            +
              end
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
              def manifest
         
     | 
| 
      
 10 
     | 
    
         
            +
                record do |m|
         
     | 
| 
      
 11 
     | 
    
         
            +
                  m.directory "app/models"
         
     | 
| 
      
 12 
     | 
    
         
            +
                  m.template "model.rb", "app/models/#{name}.rb"
         
     | 
| 
      
 13 
     | 
    
         
            +
                  m.migration_template "migration.rb", "db/migrate", :migration_file_name => "create_#{plural_name}"
         
     | 
| 
      
 14 
     | 
    
         
            +
                end
         
     | 
| 
      
 15 
     | 
    
         
            +
              end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
              def plural_name
         
     | 
| 
      
 18 
     | 
    
         
            +
                name.pluralize
         
     | 
| 
      
 19 
     | 
    
         
            +
              end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
              def plural_class_name
         
     | 
| 
      
 22 
     | 
    
         
            +
                plural_name.camelize
         
     | 
| 
      
 23 
     | 
    
         
            +
              end
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
              def class_name
         
     | 
| 
      
 26 
     | 
    
         
            +
                name.camelize
         
     | 
| 
      
 27 
     | 
    
         
            +
              end
         
     | 
| 
      
 28 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,16 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            class Create<%= plural_class_name %> < ActiveRecord::Migration
         
     | 
| 
      
 2 
     | 
    
         
            +
              def self.up
         
     | 
| 
      
 3 
     | 
    
         
            +
                create_table :<%= plural_name %> do |t|
         
     | 
| 
      
 4 
     | 
    
         
            +
                  t.string :locked_by
         
     | 
| 
      
 5 
     | 
    
         
            +
                  t.string :key
         
     | 
| 
      
 6 
     | 
    
         
            +
                  t.datetime :locked_at
         
     | 
| 
      
 7 
     | 
    
         
            +
                  t.datetime :locked_until
         
     | 
| 
      
 8 
     | 
    
         
            +
                end
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                add_index :<%= plural_name %>, :key, :unique => true
         
     | 
| 
      
 11 
     | 
    
         
            +
              end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
              def self.down
         
     | 
| 
      
 14 
     | 
    
         
            +
                drop_table :<%= plural_name %>
         
     | 
| 
      
 15 
     | 
    
         
            +
              end
         
     | 
| 
      
 16 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/generators/locker/USAGE
    CHANGED
    
    
    
        data/lib/locker/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,13 +1,13 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification 
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: locker
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version 
         
     | 
| 
       4 
     | 
    
         
            -
              hash:  
     | 
| 
      
 4 
     | 
    
         
            +
              hash: 27
         
     | 
| 
       5 
5 
     | 
    
         
             
              prerelease: 
         
     | 
| 
       6 
6 
     | 
    
         
             
              segments: 
         
     | 
| 
       7 
7 
     | 
    
         
             
              - 0
         
     | 
| 
       8 
8 
     | 
    
         
             
              - 0
         
     | 
| 
       9 
     | 
    
         
            -
              -  
     | 
| 
       10 
     | 
    
         
            -
              version: 0.0. 
     | 
| 
      
 9 
     | 
    
         
            +
              - 2
         
     | 
| 
      
 10 
     | 
    
         
            +
              version: 0.0.2
         
     | 
| 
       11 
11 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       12 
12 
     | 
    
         
             
            authors: 
         
     | 
| 
       13 
13 
     | 
    
         
             
            - Nathan Sutton
         
     | 
| 
         @@ -93,6 +93,10 @@ files: 
     | 
|
| 
       93 
93 
     | 
    
         
             
            - README.md
         
     | 
| 
       94 
94 
     | 
    
         
             
            - Rakefile
         
     | 
| 
       95 
95 
     | 
    
         
             
            - autotest/discover.rb
         
     | 
| 
      
 96 
     | 
    
         
            +
            - generators/locker/USAGE
         
     | 
| 
      
 97 
     | 
    
         
            +
            - generators/locker/locker_generator.rb
         
     | 
| 
      
 98 
     | 
    
         
            +
            - generators/locker/templates/migration.rb
         
     | 
| 
      
 99 
     | 
    
         
            +
            - generators/locker/templates/model.rb
         
     | 
| 
       96 
100 
     | 
    
         
             
            - lib/generators/locker/USAGE
         
     | 
| 
       97 
101 
     | 
    
         
             
            - lib/generators/locker/locker_generator.rb
         
     | 
| 
       98 
102 
     | 
    
         
             
            - lib/generators/locker/templates/migration.rb
         
     |