r_kit 0.4.2 → 0.4.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.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/lib/r_kit/active_record_utility/active_record_extend.rb +31 -4
  3. data/lib/r_kit/active_record_utility/base/pool.rb +29 -0
  4. data/lib/r_kit/active_record_utility/base/publisher.rb +28 -0
  5. data/lib/r_kit/active_record_utility/base/series.rb +141 -0
  6. data/lib/r_kit/active_record_utility/base/tag.rb +17 -0
  7. data/lib/r_kit/active_record_utility/base.rb +70 -0
  8. data/lib/r_kit/active_record_utility/database_schema_error.rb +4 -4
  9. data/lib/r_kit/active_record_utility.rb +12 -3
  10. data/lib/r_kit/backtrace.rb +4 -0
  11. data/lib/r_kit/core/loader/dependency.rb +26 -0
  12. data/lib/r_kit/core/loader/load_path.rb +58 -0
  13. data/lib/r_kit/core/loader.rb +3 -89
  14. data/lib/r_kit/core.rb +10 -0
  15. data/lib/r_kit/css/lib/assets/stylesheets/r_kit/components/btn.scss +8 -0
  16. data/lib/r_kit/css/lib/assets/stylesheets/r_kit/components/pagination.scss +3 -0
  17. data/lib/r_kit/css/lib/assets/stylesheets/r_kit/components.scss +1 -0
  18. data/lib/r_kit/css/lib/assets/stylesheets/r_kit/variables/colors.scss +1 -1
  19. data/lib/r_kit/css.rb +12 -5
  20. data/lib/r_kit/{decorator → decoration}/action_view_base_extend.rb +2 -2
  21. data/lib/r_kit/{decorator → decoration}/active_record_extend.rb +16 -9
  22. data/lib/r_kit/decoration/base.rb +35 -0
  23. data/lib/r_kit/decoration/class.rb +22 -0
  24. data/lib/r_kit/decoration.rb +19 -0
  25. data/lib/r_kit/dsl/base/local_params.rb +13 -0
  26. data/lib/r_kit/dsl/base/params.rb +38 -0
  27. data/lib/r_kit/dsl/base/readonly.rb +16 -0
  28. data/lib/r_kit/dsl/base/thrust.rb +67 -0
  29. data/lib/r_kit/dsl/base.rb +68 -0
  30. data/lib/r_kit/dsl/dsl_definition_error.rb +10 -0
  31. data/lib/r_kit/dsl/dsl_extend.rb +10 -0
  32. data/lib/r_kit/dsl/dsl_standard_error.rb +9 -0
  33. data/lib/r_kit/dsl/module_extend.rb +22 -0
  34. data/lib/r_kit/dsl/no_lambda_error.rb +10 -0
  35. data/lib/r_kit/dsl.rb +21 -0
  36. data/lib/r_kit/pagination/active_record_extend.rb +23 -0
  37. data/lib/r_kit/pagination/base/page.rb +53 -0
  38. data/lib/r_kit/pagination/base.rb +153 -0
  39. data/lib/r_kit/pagination.rb +23 -0
  40. data/lib/r_kit/struct/collection_delegator.rb +24 -0
  41. data/lib/r_kit/struct/safe_struct.rb +35 -0
  42. data/lib/r_kit/struct/strong_struct.rb +17 -0
  43. data/lib/r_kit/struct.rb +8 -0
  44. data/lib/r_kit/utility/active_record_extend.rb +7 -0
  45. data/lib/r_kit/utility/array_extend.rb +10 -1
  46. data/lib/r_kit/utility/module_extend.rb +43 -0
  47. data/lib/r_kit/utility/object_extend.rb +33 -0
  48. data/lib/r_kit/utility/proc_extend.rb +41 -0
  49. data/lib/r_kit/utility/simple_delegator_extend.rb +12 -0
  50. data/lib/r_kit/utility/string_extend.rb +20 -0
  51. data/lib/r_kit/utility/symbol_extend.rb +1 -1
  52. data/lib/r_kit/utility.rb +4 -1
  53. data/lib/r_kit/version.rb +1 -1
  54. data/lib/r_kit.rb +9 -0
  55. data/r_kit.gemspec +1 -1
  56. metadata +41 -9
  57. data/lib/r_kit/active_record_utility/utility/tag.rb +0 -14
  58. data/lib/r_kit/active_record_utility/utility.rb +0 -53
  59. data/lib/r_kit/decorator/base.rb +0 -34
  60. data/lib/r_kit/decorator.rb +0 -13
@@ -0,0 +1,153 @@
1
+ class RKit::Pagination::Base < SimpleDelegator
2
+
3
+ # TODO: use collection delegator newly done in 'strcut'
4
+
5
+ alias :collection :__getobj__
6
+ alias :collection= :__setobj__
7
+
8
+ attr_accessor :page, :per_page
9
+
10
+ # TODO: should raise an error if has "limit" or "offset" values
11
+ def initialize collection, **options
12
+ raise if collection.values.keys.include_one? [:limit, :offset]
13
+
14
+ super collection
15
+
16
+ @page = options.fetch :page, 1
17
+ @per_page = options.fetch :per_page, RKit::Pagination.config.per_page[collection.klass]
18
+ end
19
+
20
+ def method_missing method_name, *args, &block
21
+ closure = super
22
+
23
+ case closure
24
+ when collection.class
25
+ self.collection = closure
26
+ self
27
+ else
28
+ closure
29
+ end
30
+ end
31
+
32
+ tap_attr_accessor :page
33
+ tap_attr_accessor :per_page
34
+
35
+ def total_pages
36
+ (collection.count / per_page.to_f).ceil
37
+ end
38
+
39
+
40
+ # TODO: limit & offset should raise a custom made error
41
+ def limit
42
+ raise
43
+ end
44
+
45
+ def offset
46
+ raise
47
+ end
48
+
49
+
50
+ include Enumerable
51
+
52
+ def limited_collection
53
+ collection
54
+ .limit(per_page)
55
+ .offset((page-1) * per_page)
56
+ end
57
+
58
+ def each &block
59
+ limited_collection.each &block
60
+ end
61
+
62
+ delegate :inspect, to: :limited_collection
63
+
64
+
65
+
66
+ def pages
67
+ (1..total_pages).map do |page|
68
+ RKit::Pagination::Base::Page.new self, page: page
69
+ end
70
+ end
71
+
72
+ def previous_page
73
+ pages.find{ |page| page.page == (self.page - 1) } || pages.first
74
+ end
75
+
76
+ def next_page
77
+ pages.find{ |page| page.page == (self.page + 1) } || pages.last
78
+ end
79
+
80
+
81
+
82
+ extend RKit::Decoration::ActiveRecordExtend
83
+ acts_as_decorables do
84
+
85
+ include Enumerable
86
+
87
+ def each &block
88
+ limited_collection.decorate.each &block
89
+ end
90
+
91
+
92
+ def pagination_tag
93
+ view.content_tag :nav, class: :pagination do
94
+ [previous_page_tag, pages_tag, next_page_tag].reduce(:safe_concat)
95
+ end
96
+ end
97
+
98
+ def previous_page_tag
99
+ previous_page.decorate.page_tag "<"
100
+ end
101
+
102
+ def pages_tag
103
+ pages.map(&:decorate).map(&:page_tag).reduce(:safe_concat)
104
+ end
105
+
106
+ def next_page_tag
107
+ next_page.decorate.page_tag ">"
108
+ end
109
+ end
110
+
111
+
112
+
113
+
114
+ # TODO: limited_collection, total_pages & pages can change, based on scopes or "page & per_page" config
115
+ # So we need a "@loaded" instance_variable
116
+ # that will have the same role as in AR::Relation
117
+ # -> either, can't scope if loaded
118
+ # -> either, empty the 3 "based on scope/config" variables
119
+ # --
120
+ # or, we don't memoize the 3 problematic vars
121
+ # wich will be my choice right now
122
+
123
+
124
+
125
+
126
+ # I need
127
+ # collection, records/instances/results/paginated_collection/limited_collection(as we use SQL 'limit')
128
+ # current page, total nb items, total pages
129
+
130
+ # calling could be : Articles.paginate(page: 2, per_page: 15).published
131
+ # note that published is _after_, but we still want to display 15 records
132
+ # Alternative call Articles.paginate.page(2).per_page(15)
133
+ # --
134
+ # the "per_page" will be settable either by an arg in the method,
135
+ # or by an option, per model, in the dsl (access by Article.all.instance_variable_get "@klass")
136
+ # or in the "pagination" config
137
+ # the "current page" will be 1 by default
138
+
139
+ # Raise an error if the collection has a "limit" or an "offset" (before or after pagination initialization)
140
+ # here is the pagination method scope : Paginator::Collection.new(scoped).limit(per).offset((page-1) * per)
141
+
142
+
143
+ # We also need a method "pagination_tag", in the view
144
+ # maybe use a decorator to do so.
145
+
146
+ # Define an option to use pagination based on instance, in this case, the "per_page" is set to one
147
+ # and the "pagination_tag" accept a block to display the "page number"
148
+
149
+
150
+ # Idea, the "current_page" info (to disable the current page link) could be an instance of a class (pagination::Page)
151
+ # so in that class, (or in her decorator), we could define the "link_to_page" method
152
+ # (and the "disabled_link_to", wich we will alias on self)
153
+ end
@@ -0,0 +1,23 @@
1
+ class RKit::Pagination
2
+
3
+ dependency :decoration
4
+ dependency :utility
5
+
6
+
7
+ load_path __FILE__, 'base.rb'
8
+ load_path __FILE__, 'base/page.rb'
9
+
10
+ load_path __FILE__, 'active_record_extend.rb'
11
+
12
+ # TODO: add a "wrap" option to the config method, that will be used like this
13
+ # config :per_page, 16, wrap: ->(value){ Hash.new(value) }
14
+ # in this case: this allow the user to only set a default number
15
+ # but we, in the code, need a hash with that default value
16
+ # so, in our use, the value "16" will be wrapped in a hash, as the default value of this hash
17
+ # and to the user, he only see a default "per_page" number. (he does not want to know that we use a hash in fact)
18
+ # --
19
+ # To do this, I think that we will need a serious rework of the "configurer" core class
20
+ # and consider each config value to be an instance of a "config_value" class (under the configurer namespace)
21
+ # (we did it once for "loader", we can do it again!)
22
+ config :per_page, Hash.new(16)
23
+ end
@@ -0,0 +1,24 @@
1
+ class CollectionDelegator < SimpleDelegator
2
+
3
+ alias :collection :__getobj__
4
+ alias :collection= :__setobj__
5
+
6
+ def method_missing method_name, *args, &block
7
+ closure = super
8
+
9
+ case closure
10
+ when collection.class
11
+ self.collection = closure
12
+ self
13
+ else
14
+ closure
15
+ end
16
+ end
17
+
18
+
19
+ include Enumerable
20
+
21
+ def each &block
22
+ collection.each &block
23
+ end
24
+ end
@@ -0,0 +1,35 @@
1
+ class SafeStruct
2
+
3
+ def self.new allowed:, defaults: {}
4
+ Class.new do
5
+ @allowed = allowed.map(&:ivar)
6
+ @defaults = defaults
7
+
8
+ def self.allowed() @allowed end
9
+ def self.defaults() @defaults end
10
+
11
+
12
+ attr_reader *allowed, default: proc{ |_, name| defaults[name] }
13
+ attr_writer *allowed
14
+
15
+ def initialize **options
16
+ options.keys.each do |name|
17
+ instance_variable_set "@#{ name }", options[name]
18
+ end
19
+ end
20
+
21
+ def instance_variable_set name, value
22
+ super if __class__.allowed.include? name
23
+ end
24
+
25
+
26
+ def to_hash
27
+ instance_variables.reduce({}) do |options, name|
28
+ options[name.lvar] = instance_variable_get name
29
+ options
30
+ end
31
+ end
32
+ end
33
+ end
34
+
35
+ end
@@ -0,0 +1,17 @@
1
+ class StrongStruct < SafeStruct
2
+
3
+ def self.new allowed:, defaults: {}
4
+ super.tap do |klass|
5
+
6
+ klass.send :define_method, :instance_variable_set, ->(name, value) do
7
+ if __class__.allowed.include? name
8
+ super(name, value)
9
+ else
10
+ raise NameError.new("unsafe key `#{ name }' for #{ __class__ }")
11
+ end
12
+ end
13
+
14
+ end
15
+ end
16
+
17
+ end
@@ -0,0 +1,8 @@
1
+ class RKit::Struct
2
+
3
+ dependency :utility
4
+
5
+ load_path __FILE__, 'safe_struct.rb'
6
+ load_path __FILE__, 'strong_struct.rb'
7
+
8
+ end
@@ -0,0 +1,7 @@
1
+ module ActiveRecord::ModelSchema::ClassMethods
2
+
3
+ def column_exists? column_name
4
+ !!columns_hash[column_name]
5
+ end
6
+
7
+ end
@@ -1,7 +1,16 @@
1
1
  class Array
2
2
 
3
3
  def include_all? values
4
- (self & Array(values)).size == size
4
+ (self & Array(values)).size == Array(values).size
5
+ end
6
+
7
+ def include_one? values
8
+ (self & Array(values)).size > 0
9
+ end
10
+
11
+
12
+ def rotate_left
13
+ push shift
5
14
  end
6
15
 
7
16
  end
@@ -0,0 +1,43 @@
1
+ class Module
2
+
3
+ delegate :underscore, :demodulize,
4
+ to: :name
5
+
6
+
7
+ alias :basic_attr_reader :attr_reader
8
+ def attr_reader *names, default: nil
9
+ if default
10
+ names.each do |name|
11
+ define_method name do
12
+ instance_variable_get("@#{ name }") ||
13
+ instance_variable_set("@#{ name }", default.is_a?(Proc) ? default.call(self, name) : default)
14
+ end
15
+ end
16
+ else
17
+ basic_attr_reader *names
18
+ end
19
+ end
20
+
21
+
22
+ # TODO: these writter are called like ".name(value)" to set and return self
23
+ # or like ".name" to read
24
+ # TODO: to be used in 'pagination', these need an "after" callback (to set @limited_collection to nil)
25
+ # TODO: and to be used in 'grid (base.rb, binding_accessor)', these need an "to" delegation object
26
+ def tap_attr_accessor *names
27
+ names.each do |name|
28
+ define_method name, ->(value = nil) do
29
+ if value
30
+ instance_variable_set "@#{ name }", value
31
+ self
32
+ else
33
+ instance_variable_get "@#{ name }"
34
+ end
35
+ end
36
+ end
37
+ end
38
+
39
+
40
+ def singleton_attr_reader *args, **options
41
+ singleton_class.send :attr_reader, *args, **options
42
+ end
43
+ end
@@ -0,0 +1,33 @@
1
+ class Object
2
+
3
+ # TODO: I do not know is this is a good idea or a terrible idea
4
+ # But in either cases, the method names are probably bad, cause too generic (I know it's the hole point)
5
+ # And may collapse with subclasses
6
+
7
+ # TODO: And btw, it is not even used in rkit, as it doens not fullfiled our needs
8
+
9
+ # TODO: return self if statement (or block), else, return "value"
10
+ def fetch statement = nil, value = nil, &block
11
+ state(statement, &block) ? self : value
12
+ end
13
+
14
+ def reverse_fetch statement = nil, value = nil, &block
15
+ !state(statement, &block) ? self : value
16
+ end
17
+
18
+ def state statement = nil, &block
19
+ if statement
20
+ case self
21
+ when statement
22
+ true
23
+ else
24
+ false
25
+ end
26
+ elsif block_given?
27
+ !!block.call(self)
28
+ else
29
+ raise ArgumentError, 'Must send either "statement" or "&block" argument.'
30
+ end
31
+ end
32
+
33
+ end
@@ -0,0 +1,41 @@
1
+ class Proc
2
+
3
+ def extract_parameters *args, **options, &block
4
+ before_rest = true
5
+
6
+ parameters.reduce({}) do |params, (type, name)|
7
+ value = case type
8
+ when :opt
9
+ # TODO: default_value? -> this will be set to nil, must define a warning, or raise an error
10
+ # TODO: this is a problem with declaration like: (arg1, arg2 = nil, *args, arg4)
11
+ # we can do smthng like:
12
+ # first proccess 'block'
13
+ # then process 'options'
14
+ # then process 'args'
15
+ # -> first process all req at the begining
16
+ # -> then process all req at the end
17
+ # -> then process all opt at the begining
18
+ # -> then process rest
19
+ # TODO: or, find thehow to access the default value
20
+ before_rest ? args.shift : args.pop
21
+ when :req
22
+ before_rest ? args.shift : args.pop
23
+ when :rest
24
+ before_rest = false
25
+ args
26
+ when :key
27
+ options.delete name # TODO: default_value? -> this will be set to nil
28
+ when :keyreq
29
+ options.delete name
30
+ when :keyrest
31
+ options
32
+ when :block
33
+ block
34
+ end
35
+
36
+ params[name] = value
37
+ params
38
+ end
39
+ end
40
+
41
+ end
@@ -0,0 +1,12 @@
1
+ class SimpleDelegator
2
+
3
+ # TODO: get some methods from decorator, like "class", "==="
4
+ # TODO: and add some custom like "inspect"
5
+
6
+ def self.getobj_attr_reader *names
7
+ names.each do |name|
8
+ define_method name, ->(){ __getobj__.instance_variable_get(name.ivar) }
9
+ end
10
+ end
11
+
12
+ end
@@ -0,0 +1,20 @@
1
+ class String
2
+
3
+ def to_boolean
4
+ !!(self =~ /^(true|t|yes|y|1)$/i)
5
+ end
6
+
7
+
8
+ def ivar
9
+ "@#{ self }"
10
+ end
11
+
12
+ def lvar
13
+ if self =~ /^@/
14
+ self[1..-1]
15
+ else
16
+ self
17
+ end
18
+ end
19
+
20
+ end
@@ -1,3 +1,3 @@
1
1
  class Symbol
2
- delegate :classify, to: :to_s
2
+ delegate :classify, :ivar, :lvar, to: :to_s
3
3
  end
data/lib/r_kit/utility.rb CHANGED
@@ -1,5 +1,8 @@
1
1
  class RKit::Utility
2
- UTILITIES = %i{array hash kernel symbol}
2
+ # TODO: this 'dir' line could be a utility extend
3
+ UTILITIES = Dir[File.join(File.dirname(__FILE__), "utility", "*.rb")].map do |file|
4
+ File.basename file, "_extend.rb"
5
+ end
3
6
 
4
7
 
5
8
  config :extends, true
data/lib/r_kit/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module RKit
2
- VERSION = '0.4.2'
2
+ VERSION = '0.4.3'
3
3
  end
data/lib/r_kit.rb CHANGED
@@ -6,7 +6,16 @@ module RKit
6
6
  # some kind of "--help" of unix commands
7
7
  end
8
8
 
9
+ delegate :loaded, to: 'RKit::Core::Loader'
9
10
 
11
+
12
+ # TODO: add a load priority order based on dependencies
13
+ # so if :X depend on :Y
14
+ # and I load like ".load :x, :y"
15
+ # it does not trigger the warn msg of dependency cause we first try to load :x, and :y is still not loaded
16
+ # instead, we detect that dependencie, and reorder the loading (so we just "require the core descriptive file")
17
+ # to put :y before :x
18
+ # (double profit, this will keep config on :y, that iserwise would be lost)
10
19
  def load *services
11
20
  load_service_from Array.wrap(services)
12
21
  end
data/r_kit.gemspec CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |gem|
9
9
  gem.authors = ["Thomas Petrachi"]
10
10
  gem.email = ["thomas.petrachi@vodeclic.com"]
11
11
  gem.description = %q{Rails tools box}
12
- gem.summary = %q{Rails tools box : Core extentions, Pagination, Decorator, CSS, Javascript, and others comming. A flexible gem that hold a number of basics services for rails applications.}
12
+ gem.summary = %q{Rails tools box : Core extentions, Pagination, Decoration, CSS, Javascript, and others comming. A flexible gem that hold a number of basics services for rails applications.}
13
13
  gem.homepage = "https://github.com/petrachi/r_kit"
14
14
  gem.license = 'MIT'
15
15
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: r_kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Petrachi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-17 00:00:00.000000000 Z
11
+ date: 2014-10-03 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Rails tools box
14
14
  email:
@@ -25,15 +25,20 @@ files:
25
25
  - lib/r_kit.rb
26
26
  - lib/r_kit/active_record_utility.rb
27
27
  - lib/r_kit/active_record_utility/active_record_extend.rb
28
+ - lib/r_kit/active_record_utility/base.rb
29
+ - lib/r_kit/active_record_utility/base/pool.rb
30
+ - lib/r_kit/active_record_utility/base/publisher.rb
31
+ - lib/r_kit/active_record_utility/base/series.rb
32
+ - lib/r_kit/active_record_utility/base/tag.rb
28
33
  - lib/r_kit/active_record_utility/database_schema_error.rb
29
- - lib/r_kit/active_record_utility/utility.rb
30
- - lib/r_kit/active_record_utility/utility/tag.rb
31
34
  - lib/r_kit/backtrace.rb
32
35
  - lib/r_kit/backtrace/kernel_extend.rb
33
36
  - lib/r_kit/core.rb
34
37
  - lib/r_kit/core/configurer.rb
35
38
  - lib/r_kit/core/engineer.rb
36
39
  - lib/r_kit/core/loader.rb
40
+ - lib/r_kit/core/loader/dependency.rb
41
+ - lib/r_kit/core/loader/load_path.rb
37
42
  - lib/r_kit/css.rb
38
43
  - lib/r_kit/css/lib/assets/stylesheets/r_kit.scss
39
44
  - lib/r_kit/css/lib/assets/stylesheets/r_kit/base.scss
@@ -47,6 +52,7 @@ files:
47
52
  - lib/r_kit/css/lib/assets/stylesheets/r_kit/base/typography/titles.scss
48
53
  - lib/r_kit/css/lib/assets/stylesheets/r_kit/components.scss
49
54
  - lib/r_kit/css/lib/assets/stylesheets/r_kit/components/btn.scss
55
+ - lib/r_kit/css/lib/assets/stylesheets/r_kit/components/pagination.scss
50
56
  - lib/r_kit/css/lib/assets/stylesheets/r_kit/mixins.scss
51
57
  - lib/r_kit/css/lib/assets/stylesheets/r_kit/mixins/animation.scss
52
58
  - lib/r_kit/css/lib/assets/stylesheets/r_kit/mixins/box-shadows.scss
@@ -58,10 +64,22 @@ files:
58
64
  - lib/r_kit/css/lib/assets/stylesheets/r_kit/variables.scss
59
65
  - lib/r_kit/css/lib/assets/stylesheets/r_kit/variables/colors.scss
60
66
  - lib/r_kit/css/sass_extend.rb
61
- - lib/r_kit/decorator.rb
62
- - lib/r_kit/decorator/action_view_base_extend.rb
63
- - lib/r_kit/decorator/active_record_extend.rb
64
- - lib/r_kit/decorator/base.rb
67
+ - lib/r_kit/decoration.rb
68
+ - lib/r_kit/decoration/action_view_base_extend.rb
69
+ - lib/r_kit/decoration/active_record_extend.rb
70
+ - lib/r_kit/decoration/base.rb
71
+ - lib/r_kit/decoration/class.rb
72
+ - lib/r_kit/dsl.rb
73
+ - lib/r_kit/dsl/base.rb
74
+ - lib/r_kit/dsl/base/local_params.rb
75
+ - lib/r_kit/dsl/base/params.rb
76
+ - lib/r_kit/dsl/base/readonly.rb
77
+ - lib/r_kit/dsl/base/thrust.rb
78
+ - lib/r_kit/dsl/dsl_definition_error.rb
79
+ - lib/r_kit/dsl/dsl_extend.rb
80
+ - lib/r_kit/dsl/dsl_standard_error.rb
81
+ - lib/r_kit/dsl/module_extend.rb
82
+ - lib/r_kit/dsl/no_lambda_error.rb
65
83
  - lib/r_kit/grid.rb
66
84
  - lib/r_kit/grid/base.rb
67
85
  - lib/r_kit/grid/base/grid.rb
@@ -75,10 +93,24 @@ files:
75
93
  - lib/r_kit/grid/lib/assets/stylesheets/r_kit/mixins/gris.scss
76
94
  - lib/r_kit/grid/lib/assets/stylesheets/r_kit/variables/grid.scss
77
95
  - lib/r_kit/grid/sass_extend.rb
96
+ - lib/r_kit/pagination.rb
97
+ - lib/r_kit/pagination/active_record_extend.rb
98
+ - lib/r_kit/pagination/base.rb
99
+ - lib/r_kit/pagination/base/page.rb
100
+ - lib/r_kit/struct.rb
101
+ - lib/r_kit/struct/collection_delegator.rb
102
+ - lib/r_kit/struct/safe_struct.rb
103
+ - lib/r_kit/struct/strong_struct.rb
78
104
  - lib/r_kit/utility.rb
105
+ - lib/r_kit/utility/active_record_extend.rb
79
106
  - lib/r_kit/utility/array_extend.rb
80
107
  - lib/r_kit/utility/hash_extend.rb
81
108
  - lib/r_kit/utility/kernel_extend.rb
109
+ - lib/r_kit/utility/module_extend.rb
110
+ - lib/r_kit/utility/object_extend.rb
111
+ - lib/r_kit/utility/proc_extend.rb
112
+ - lib/r_kit/utility/simple_delegator_extend.rb
113
+ - lib/r_kit/utility/string_extend.rb
82
114
  - lib/r_kit/utility/symbol_extend.rb
83
115
  - lib/r_kit/version.rb
84
116
  - r_kit.gemspec
@@ -105,7 +137,7 @@ rubyforge_project:
105
137
  rubygems_version: 2.3.0
106
138
  signing_key:
107
139
  specification_version: 4
108
- summary: 'Rails tools box : Core extentions, Pagination, Decorator, CSS, Javascript,
140
+ summary: 'Rails tools box : Core extentions, Pagination, Decoration, CSS, Javascript,
109
141
  and others comming. A flexible gem that hold a number of basics services for rails
110
142
  applications.'
111
143
  test_files: []
@@ -1,14 +0,0 @@
1
- class RKit::ActiveRecordUtility::Utility::Tag < RKit::ActiveRecordUtility::Utility
2
-
3
- def can_interfere?
4
- base.table_exists? && base.column_names.include?("tag")
5
- end
6
-
7
- def interfere!
8
- base.validates_presence_of :tag
9
- base.validates_uniqueness_of :tag
10
-
11
- base.send :define_method, :to_param, ->{ tag }
12
- base.send :define_singleton_method, :tagged, ->(tag){ find_by tag: tag }
13
- end
14
- end
@@ -1,53 +0,0 @@
1
- class RKit::ActiveRecordUtility::Utility
2
-
3
- attr_accessor :base, :method
4
-
5
- def initialize base, method:;
6
- @base = base
7
- @method = method
8
- end
9
-
10
-
11
- def interfere
12
- if can_interfere?
13
- interfere!
14
- interfered!
15
- else
16
- raise DatabaseSchemaError.new(base, method: method) unless running_script? /^rake db:/
17
- end
18
- end
19
-
20
-
21
- # TODO: private/protected ?
22
- def can_interfere?
23
- raise NotImplementedError, 'Subclasses must implement this method'
24
- end
25
-
26
- def interfere!
27
- raise NotImplementedError, 'Subclasses must implement this method'
28
- end
29
-
30
- def interfered!
31
- __class__.interfered base
32
- end
33
-
34
-
35
- module SingletonInheritance
36
- def self.extended base
37
- base.instance_variable_set :@extended, []
38
- end
39
-
40
- def interfered? base
41
- @extended.include? base
42
- end
43
-
44
- def interfered base
45
- @extended << base
46
- end
47
- end
48
-
49
- def self.inherited(subclass)
50
- subclass.extend SingletonInheritance
51
- super
52
- end
53
- end