sequenceid 0.0.2 → 0.0.3

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/.DS_Store ADDED
Binary file
data/.README.swp ADDED
Binary file
data/.gitignore CHANGED
@@ -2,3 +2,5 @@
2
2
  .bundle
3
3
  Gemfile.lock
4
4
  pkg/*
5
+ .DS_Store
6
+ *.swp
data/README.md ADDED
@@ -0,0 +1,81 @@
1
+ # SequenceId
2
+
3
+ SequenceId is the gem for Rails 3 that allows for creating URL permalinks that start from 1 and increment in a continuum.
4
+ As an example for a SaaS based accounting application using SequenceId, you'll have the first three URL's for a new signup like:
5
+
6
+ http://company1.7vals.com/invoices/1
7
+ http://company1.7vals.com/invoices/2
8
+ http://company1.7vals.com/invoices/3
9
+
10
+ instead of:
11
+
12
+ http://company1.7vals.com/invoices/11232
13
+ http://company1.7vals.com/invoices/11240 #notice a jump of 8 id's due to other companies creating their invoices
14
+ http://company1.7vals.com/invoices/11242
15
+
16
+ ## SequenceId Features
17
+
18
+ SequenceId is a fairly straight forward gem and you need to ensure only ONE condition
19
+ Resource with sequenceid must be a NESTED resource
20
+
21
+ Back to our original example, if you want invoices to start from 1 for each new company, the Invoice RESOURCE is nested to the Company RESOURCE. The gem will check for the relationhip in the database (Invoice table in this case) and ensure the sequence_num (SequenceId column created in the table) and the parent resource_id are a secondary compound key in the nested resource's table.
22
+
23
+ SequenceId is compatible with Active Record **3.0**.
24
+
25
+ ## Docs, Info and Support
26
+
27
+ * [Bugs/Help](https://groups.google.com/group/sequenceid)
28
+ * Email: info@7vals.com
29
+
30
+ ## Rails Quickstart
31
+
32
+ rails new my_app
33
+
34
+ cd my_app
35
+
36
+ # add to Gemfile
37
+ gem "sequenceid"
38
+
39
+ rails generate sequenceid <parent resource> <nested resource> #eg rails generate sequenceid Company Invoice
40
+
41
+ rake db:migrate
42
+
43
+ # edit app/controller/invoices_controller.rb
44
+ # :id is NO LONGER a unique identifier since its the sequence_num, so you MUST edit the resource find in each of the actions (or create a before filter)
45
+ @company = Company.find(params[:company_id]) # or Company.find_by_name(request.subdomain)
46
+ @invoice = @company.invoices.find_by_sequence_num!(params[:id])
47
+
48
+ rails server
49
+
50
+ #i assuming you have 7vals mapped to localhost in your host file
51
+
52
+ GET http://company1.7vals.com:3000/invoices/1
53
+ Get http://company2.7vals.com:3000/invoices/1
54
+
55
+ ## Bugs
56
+
57
+ Please report them on the [Github issue tracker](http://github.com/alisyed/sequenceid/issues)
58
+ for this project.
59
+
60
+ If you have a bug to report, please include the following information:
61
+
62
+ * **Version information for SequenceId, Rails and Ruby.**
63
+ * Stack trace and error message.
64
+ * Any snippets of relevant model, view or controller code that shows how your
65
+ are using SequenceId
66
+
67
+ ## Credits
68
+
69
+ SequenceId was create by Syed Ali @ 7vals
70
+ * [7vals](http://www.7vals.com)
71
+
72
+ Special thanks to
73
+ * [cancan](https://github.com/ryanb/cancan)
74
+
75
+ * [FriendlyId](https://github.com/norman/friendly_id)
76
+
77
+ for serving as a template on certain best practices.
78
+
79
+ Thanks!
80
+
81
+ Copyright (c) 2011, released under the MIT license.
data/lib/.DS_Store ADDED
Binary file
@@ -2,7 +2,7 @@ require 'rails/generators/active_record'
2
2
 
3
3
  class SequenceidGenerator < ActiveRecord::Generators::Base
4
4
  #Rails::Generators::NamedBase
5
- desc "This generator is for sequenceid, which creates sequential id's in the URL for nested resources. Especially useful for SaaS based apps where the unique resource is likely a nested resource of company"
5
+ desc "This generator is for sequenceid, which creates sequential id's in the URL for nested resources. Especially useful for SaaS based apps where the unique resource is likely a nested resource of company\n Usage: rails generate sequenceid <parent resource> <nested resource>"
6
6
  ORM=ActiveRecord::Base #TODO: Make this generic for other ORM's
7
7
  source_root File.expand_path("../template",__FILE__)
8
8
 
@@ -47,6 +47,6 @@ class SequenceidGenerator < ActiveRecord::Generators::Base
47
47
  migration_template "migration.rb", "db/migrate/add_sequence_num_to_#{@nested_resource.to_s.downcase.pluralize}"
48
48
  #inject into model class module includeA
49
49
  @model_path ||= File.join("app", "models", "#{@nested_resource.to_s.underscore}.rb")
50
- inject_into_class(@model_path,@nested_resource,"sequenceid :'#{@parent_resource.to_s}','#{@nested_resource.to_s.downcase.pluralize}\n")
50
+ inject_into_class(@model_path,@nested_resource,"sequenceid '#{@parent_resource.to_s.downcase}','#{@nested_resource.to_s.downcase.pluralize}'\n")
51
51
  end
52
52
  end
Binary file
@@ -1,3 +1,3 @@
1
1
  module Sequenceid
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/sequenceid.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
10
10
  s.email = ["info@7vals.com"]
11
11
  s.homepage = ""
12
12
  s.summary = %q{Create resource URL's starting from 1 for each SaaS company}
13
- s.description = %q{For SaaS applications, there are times when we dont want to show the resource id to the user since its being shared with multiple companies that have signed up. And for scenarios where we want the URL to show numbers and not worded URL's like what friendly_id provide, this is the gem for you! It'll create id's sequentially starting from 1 for each relation parent/nested resource relation defined}
13
+ s.description = %q{For SaaS applications, there are times when we dont want to show the resource id to the user since its being shared with multiple companies that have signed up. And for scenarios where we want the URL to show numbers and not worded URL's like what friendly_id provide, this is the gem for you! It'll create id's sequentially starting from 1 for each relation parent/nested resource relation definedi\n Feel free to get in touch for any specific questions until the help, support group and readme are not done at info@7vals.com \n http://www.7vals.com}
14
14
 
15
15
  s.rubyforge_project = "sequenceid"
16
16
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequenceid
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Syed Ali
@@ -15,10 +15,10 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-05-26 00:00:00 Z
18
+ date: 2011-05-31 00:00:00 Z
19
19
  dependencies: []
20
20
 
21
- description: For SaaS applications, there are times when we dont want to show the resource id to the user since its being shared with multiple companies that have signed up. And for scenarios where we want the URL to show numbers and not worded URL's like what friendly_id provide, this is the gem for you! It'll create id's sequentially starting from 1 for each relation parent/nested resource relation defined
21
+ description: For SaaS applications, there are times when we dont want to show the resource id to the user since its being shared with multiple companies that have signed up. And for scenarios where we want the URL to show numbers and not worded URL's like what friendly_id provide, this is the gem for you! It'll create id's sequentially starting from 1 for each relation parent/nested resource relation definedi\n Feel free to get in touch for any specific questions until the help, support group and readme are not done at info@7vals.com \n http://www.7vals.com
22
22
  email:
23
23
  - info@7vals.com
24
24
  executables: []
@@ -28,12 +28,17 @@ extensions: []
28
28
  extra_rdoc_files: []
29
29
 
30
30
  files:
31
+ - .DS_Store
32
+ - .README.swp
31
33
  - .gitignore
32
34
  - Gemfile
35
+ - README.md
33
36
  - Rakefile
37
+ - lib/.DS_Store
34
38
  - lib/generators/sequenceid/sequenceid_generator.rb
35
39
  - lib/generators/sequenceid/template/migration.rb
36
40
  - lib/sequenceid.rb
41
+ - lib/sequenceid/.DS_Store
37
42
  - lib/sequenceid/model_adapters/active_record_adapter.rb
38
43
  - lib/sequenceid/model_adapters/sequenceid_logic.rb
39
44
  - lib/sequenceid/version.rb