readable_model 0.1.0

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1bec5630c1436e77ba7f9325b5cf99ba9f73a842
4
+ data.tar.gz: d78740cdd291a1ac96a759f99759a37083ce2c19
5
+ SHA512:
6
+ metadata.gz: 7a1574556457f4badd36eb97b48295a78573522bf6d51aeecb051ca1a1e3981058e6bd3d2142292df18fe5f5dd46ed7fb3ac19cb0533db639ec7743223b3293a
7
+ data.tar.gz: ba94589f75fbcafc20a10bdb1cb5443945f44c3d58d3b77fa297f76f86343c53b7541b5e2a9fa1e4716658f102fc8703c93aec919f69a364acf69c2ae42055cd
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in readable_model.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 senthil
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,113 @@
1
+ # ReadableModel
2
+
3
+ This gem doesn't do any logical opertaion. Just make the MVC - Model as much as readable.
4
+ This library adds the model template as per the rails style guide.
5
+ https://github.com/bbatsov/rails-style-guide#activerecord
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'readable_model'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install readable_model
22
+
23
+ ## Usage
24
+
25
+ ```ruby
26
+ rails generate scaffold scaffold_name
27
+ ```
28
+
29
+ or
30
+
31
+ ```ruby
32
+ rails generate model model_name
33
+ ```
34
+
35
+ Now check your model file
36
+
37
+ ## Before readable_model template
38
+
39
+ ```ruby
40
+ class User < ActiveRecord::Base
41
+ include UrlHelper
42
+ serialize :template
43
+ belongs_to :country
44
+
45
+ alias_attribute :subject, :title
46
+
47
+ has_one :photo
48
+ has_many :authentications, dependent: :destroy, inverse_of: :user
49
+ has_many :items, dependent: :destroy, counter_cache: true
50
+
51
+ self.table_name = "admin_users"
52
+ validates :email, presence: true
53
+ validates :username, presence: true
54
+
55
+ before_save :cook
56
+ after_create :update_item
57
+ validates :username, uniqueness: { case_sensitive: false }
58
+
59
+ COLORS = ['red', 'green', 'blue']
60
+ attr_accessor :date
61
+ @@per_page = 10
62
+ scope :blocked, -> { where(active: false }
63
+ delegate :name, :address, to: :order, prefix: :order
64
+ serialize :rule_options
65
+
66
+ def role
67
+ role_type.inquiry
68
+ end
69
+ end
70
+ ```
71
+ ## After readable_model template
72
+
73
+ ```ruby
74
+ class User < ActiveRecord::Base
75
+ include UrlHelper
76
+
77
+ # Default Scope
78
+ default_scope { where(active: true) }
79
+
80
+ # Configurations
81
+ self.table_name = "admin_users"
82
+ COLORS = ['red', 'green', 'blue']
83
+ @@per_page = 10
84
+
85
+ # Attributes
86
+ attr_accessor :date
87
+ alias_attribute :subject, :title
88
+ delegate :name, :address, to: :order, prefix: :order
89
+ serialize :template
90
+
91
+ # Associations
92
+ has_one :photo
93
+ has_many :authentications, dependent: :destroy, inverse_of: :user
94
+ has_many :items, dependent: :destroy, counter_cache: true
95
+ belongs_to :country
96
+
97
+ # Validations
98
+ validates :email, presence: true
99
+ validates :username, presence: true
100
+ validates :username, uniqueness: { case_sensitive: false }
101
+
102
+ # Callbacks
103
+ before_save :cook
104
+ after_create :update_item
105
+
106
+ # Scopes
107
+ scope :blocked, -> { where(active: false }
108
+
109
+ def role
110
+ role_type.inquiry
111
+ end
112
+ end
113
+ ```
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "readable_model"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,7 @@
1
+ module ReadableModel
2
+ class Railtie < Rails::Railtie
3
+ config.app_generators do |g|
4
+ g.templates.unshift File::expand_path('../../templates', __FILE__)
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ module ReadableModel
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,6 @@
1
+ require "readable_model/version"
2
+ require "readable_model/railtie"
3
+
4
+ module ReadableModel
5
+
6
+ end
@@ -0,0 +1,22 @@
1
+ <% module_namespacing do -%>
2
+ class <%= class_name %> < <%= parent_class_name.classify %>
3
+
4
+ # Default Scope
5
+
6
+ # Configurations
7
+
8
+ # Attributes
9
+ <% if attributes.any?(&:password_digest?) -%>
10
+ has_secure_password
11
+ <% end -%>
12
+
13
+ # Associations
14
+
15
+ # Validations
16
+
17
+ # Callbacks
18
+
19
+ # Scopes
20
+
21
+ end
22
+ <% end -%>
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'readable_model/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "readable_model"
8
+ spec.version = ReadableModel::VERSION
9
+ spec.authors = ["senthil"]
10
+ spec.email = ["rask.kumar@gmail.com"]
11
+
12
+ spec.summary = %q{Make Model as much as readable}
13
+ spec.description = %q{Make Model as much as readable}
14
+ spec.homepage = "https://github.com/senthil88/readable_model"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.8"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ end
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: readable_model
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - senthil
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-06-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.8'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.8'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: Make Model as much as readable
42
+ email:
43
+ - rask.kumar@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - bin/console
54
+ - bin/setup
55
+ - lib/readable_model.rb
56
+ - lib/readable_model/railtie.rb
57
+ - lib/readable_model/version.rb
58
+ - lib/templates/active_record/model/model.rb
59
+ - readable_model.gemspec
60
+ homepage: https://github.com/senthil88/readable_model
61
+ licenses:
62
+ - MIT
63
+ metadata: {}
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ requirements: []
79
+ rubyforge_project:
80
+ rubygems_version: 2.4.6
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: Make Model as much as readable
84
+ test_files: []