ib_active_extension 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/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 [name of plugin creator]
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,13 @@
1
+ IbActiveExtension
2
+ =================
3
+
4
+ Introduction goes here.
5
+
6
+
7
+ Example
8
+ =======
9
+
10
+ Example goes here.
11
+
12
+
13
+ Copyright (c) 2010 [name of plugin creator], released under the MIT license
data/Rakefile ADDED
@@ -0,0 +1,47 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/rdoctask'
4
+ require 'rake/gempackagetask'
5
+
6
+ desc 'Default: run unit tests.'
7
+ task :default => :test
8
+
9
+ desc 'Test the ib_active_extension plugin.'
10
+ Rake::TestTask.new(:test) do |t|
11
+ t.libs << 'lib'
12
+ t.libs << 'test'
13
+ t.pattern = 'test/**/*_test.rb'
14
+ t.verbose = true
15
+ end
16
+
17
+ desc 'Generate documentation for the ib_active_extension plugin.'
18
+ Rake::RDocTask.new(:rdoc) do |rdoc|
19
+ rdoc.rdoc_dir = 'rdoc'
20
+ rdoc.title = 'IbActiveExtension'
21
+ rdoc.options << '--line-numbers' << '--inline-source'
22
+ rdoc.rdoc_files.include('README')
23
+ rdoc.rdoc_files.include('lib/**/*.rb')
24
+ end
25
+
26
+
27
+ PKG_FILES = FileList[
28
+ '[a-zA-Z]*',
29
+ 'lib/**/*'
30
+ ]
31
+
32
+ spec = Gem::Specification.new do |s|
33
+ s.name = "ib_active_extension"
34
+ s.version = "0.0.3"
35
+ s.author = "Alexey Stryi"
36
+ s.email = "alexey@ibissoft.se"
37
+ s.platform = Gem::Platform::RUBY
38
+ s.summary = "Ibissoft's extensions to Rails and Ruby Core"
39
+ s.files = PKG_FILES.to_a
40
+ s.require_path = "lib"
41
+ s.has_rdoc = false
42
+ end
43
+
44
+ desc 'Turn this plugin into a gem.'
45
+ Rake::GemPackageTask.new(spec) do |pkg|
46
+ pkg.gem_spec = spec
47
+ end
data/init.rb ADDED
@@ -0,0 +1,2 @@
1
+ # Include hook code here
2
+ require File.expand_path(File.join(File.dirname(__FILE__), "lib/ib_active_extension"))
data/install.rb ADDED
@@ -0,0 +1 @@
1
+ # Install hook code here
@@ -0,0 +1,52 @@
1
+ module IbActiveExtension
2
+
3
+ ###############################################################################
4
+ ### Class String Instance Methods ###
5
+ ###############################################################################
6
+
7
+ module String
8
+ module InstanceMethods
9
+
10
+ #############################################################################
11
+ def toAscii
12
+ (self.isutf8.nil?) ? self : self.unpack("U*").pack("C*")
13
+ end
14
+
15
+ #############################################################################
16
+ def to_arr
17
+ arr = []
18
+ self.each {|s| arr << s }
19
+ arr
20
+ end
21
+
22
+ #############################################################################
23
+ def to_bool
24
+ (self.downcase == "true") ? true : false
25
+ end
26
+
27
+ #############################################################################
28
+
29
+ def fix(replacer = "\\n")
30
+ txt = self.gsub(/(['"])/n) {'\\'+ "'" }
31
+
32
+ symbols = [ /\\r\\n|\r\n/, /\\r|\\n|\r|\n/, /<br\s*\/>|<br\s*>/ ]
33
+ symbols.each{|s|
34
+ txt = txt.gsub(s, replacer)
35
+ }
36
+
37
+ return txt
38
+ end
39
+
40
+ #############################################################################
41
+
42
+ def ellipsis(length=nil, elips = "...")
43
+ length ||= self.length
44
+ return self if self.length <= length
45
+ return self[0..length-1] + elips
46
+ end
47
+ #############################################################################
48
+ end #InstanceMethods
49
+ end #String
50
+ end #IbActiveExtension
51
+
52
+ String.send(:include, IbActiveExtension::String::InstanceMethods)
@@ -0,0 +1,4 @@
1
+ # IbActiveExtension
2
+
3
+ require File.expand_path(File.join(File.dirname(__FILE__), "core/string_extras"))
4
+ require File.expand_path(File.join(File.dirname(__FILE__), "rails_model/base"))
@@ -0,0 +1,56 @@
1
+ module IbActiveExtension
2
+ module RailsModel
3
+
4
+ ###############################################################################
5
+ ### Class ActiveRecord:Base Class Methods ###
6
+ ###############################################################################
7
+
8
+ module ClassMethods
9
+
10
+ #############################################################################
11
+ def sort_mapping(*params)
12
+ @sort_aliaces=params
13
+ end
14
+
15
+ #############################################################################
16
+ def get_special_sort_map
17
+ @sort_aliaces
18
+ end
19
+
20
+ #############################################################################
21
+ end #ClassMethods
22
+
23
+ ###############################################################################
24
+ ### Class ActiveRecord:Base Instance Methods ###
25
+ ###############################################################################
26
+
27
+ module InstanceMethods
28
+
29
+ #############################################################################
30
+ def getProp(prop_name, replacer = "\\n")
31
+ prop = prop_name.to_sym
32
+ if self.has_attribute? prop
33
+ value = self[prop]
34
+ elsif self.respond_to? prop
35
+ value = self.method(prop).call
36
+ else
37
+ value = ""
38
+ end
39
+
40
+ value = value.fix(replacer) if value.respond_to? :fix
41
+ value
42
+ end
43
+
44
+ #############################################################################
45
+ def to_s
46
+ fields = self.attribute_names
47
+ "'#{fields.map{|key| self.getProp(key)}.join("','")}'"
48
+ end
49
+
50
+ #############################################################################
51
+ end #InstanceMethods
52
+ end #RailsModel
53
+ end #IbActiveExtension
54
+
55
+ ActiveRecord::Base.send(:extend, IbActiveExtension::RailsModel::ClassMethods)
56
+ ActiveRecord::Base.send(:include, IbActiveExtension::RailsModel::InstanceMethods)
data/uninstall.rb ADDED
@@ -0,0 +1 @@
1
+ # Uninstall hook code here
metadata ADDED
@@ -0,0 +1,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ib_active_extension
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 3
9
+ version: 0.0.3
10
+ platform: ruby
11
+ authors:
12
+ - Alexey Stryi
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-03-24 00:00:00 +01:00
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description:
22
+ email: alexey@ibissoft.se
23
+ executables: []
24
+
25
+ extensions: []
26
+
27
+ extra_rdoc_files: []
28
+
29
+ files:
30
+ - init.rb
31
+ - install.rb
32
+ - MIT-LICENSE
33
+ - Rakefile
34
+ - README
35
+ - uninstall.rb
36
+ - lib/core/string_extras.rb
37
+ - lib/ib_active_extension.rb
38
+ - lib/rails_model/base.rb
39
+ has_rdoc: true
40
+ homepage:
41
+ licenses: []
42
+
43
+ post_install_message:
44
+ rdoc_options: []
45
+
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ segments:
53
+ - 0
54
+ version: "0"
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ segments:
60
+ - 0
61
+ version: "0"
62
+ requirements: []
63
+
64
+ rubyforge_project:
65
+ rubygems_version: 1.3.6
66
+ signing_key:
67
+ specification_version: 3
68
+ summary: Ibissoft's extensions to Rails and Ruby Core
69
+ test_files: []
70
+