hystorical 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
data/README.md
CHANGED
@@ -91,6 +91,14 @@ def index
|
|
91
91
|
end
|
92
92
|
```
|
93
93
|
|
94
|
+
### Generator
|
95
|
+
Hystorical comes with a generator that creates a migration to add `start_date` and `end_date` to the specified model.
|
96
|
+
|
97
|
+
```
|
98
|
+
$ rails g hystorical:dates Subscription
|
99
|
+
$ create db/migrate/20120917150948_add_start_date_end_date_to_subscriptions.rb
|
100
|
+
```
|
101
|
+
|
94
102
|
## Philosophy
|
95
103
|
This gem was created using TDD and README-driven development. The architecture was designed with a strong focus on modularity and extensibility. Using ruby's `Enumerable` methods to return current object was chosen because of it's great flexibility to adapt to all ruby projects. However, when working with large datasets stored in a relational database, using SQL would yield greater performance. An adapter was added for ActiveRecord, but extending this to another ORM (such as DataMapper or Mongoid) is as simple as creating a new class that defines all the methods in the public api and adding a conditional in `Hystorical.delegate_class`.
|
96
104
|
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Hystorical
|
2
|
+
class DatesGenerator < Rails::Generators::Base
|
3
|
+
include Rails::Generators::Migration
|
4
|
+
source_root File.expand_path('../templates', __FILE__)
|
5
|
+
argument :model, type: :string
|
6
|
+
|
7
|
+
def self.next_migration_number(path)
|
8
|
+
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
9
|
+
end
|
10
|
+
|
11
|
+
def hystorical_migration
|
12
|
+
migration_template 'migration.rb', File.join('db/migrate', "add_start_date_end_date_to_#{model.tableize}.rb")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/hystorical/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hystorical
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-09-
|
12
|
+
date: 2012-09-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -73,6 +73,9 @@ files:
|
|
73
73
|
- README.md
|
74
74
|
- Rakefile
|
75
75
|
- hystorical.gemspec
|
76
|
+
- lib/generators/hystorical/USAGE
|
77
|
+
- lib/generators/hystorical/dates_generator.rb
|
78
|
+
- lib/generators/hystorical/templates/migration.rb
|
76
79
|
- lib/hystorical.rb
|
77
80
|
- lib/hystorical/ar_relation.rb
|
78
81
|
- lib/hystorical/ruby_collection.rb
|