fertilizer 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fertilizer.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Haris KRAJINA
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Fertilizer
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'fertilizer'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install fertilizer
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/fertilizer/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Haris KRAJINA"]
6
+ gem.email = ["haris.krajina@gmail.com"]
7
+ gem.description = %q{Fertilizer is simple gem used to enrich new rails projects with configuration setup, object extensions, console extensions etc.}
8
+ gem.summary = %q{Take a look at Fertilizer's generator and use taks to add features to your rails projects.}
9
+ gem.homepage = "https://github.com/hkraji/fertilizer"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "fertilizer"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Fertilizer::VERSION
17
+
18
+ gem.add_dependency "rails", "~> 3.0"
19
+ end
@@ -0,0 +1,60 @@
1
+ # Following module allows us to call following IRB commands:
2
+ #
3
+ # * reload_lib - reloads whole lib folder meaning you don't have to restart irb
4
+ # * cls - clears IRB console
5
+ # * code - displays source code for method with given instance/class
6
+
7
+ module ConsoleExtensions
8
+ # Reload lib configuration from console
9
+ def reload_lib
10
+ path = File.join( Rails.root, 'lib')
11
+ failures = []
12
+ Dir.glob("#{path}/**/*.rb").each { |file|
13
+ puts "loading: #{file.inspect} ... "
14
+ begin
15
+ if !(file.include? 'reload.rb')
16
+ load file
17
+ end
18
+ rescue => ex
19
+ failures << file
20
+ end
21
+ }
22
+
23
+ # this second pass is here to try to catch anything that
24
+ # is dependent on something else
25
+ # could be improved, but is working fine for my needs
26
+ double_failures = []
27
+ for file in failures
28
+ begin
29
+ # don't reload yourself
30
+ if !(file.include? 'reload.rb')
31
+ load file
32
+ end
33
+ rescue => ex1
34
+ double_failures << file
35
+ end
36
+ end
37
+
38
+ if double_failures.size > 0
39
+ puts "these files failed twice"
40
+ for file in double_failures
41
+ puts file
42
+ end
43
+ end
44
+ end
45
+
46
+ def cls
47
+ system('cls')
48
+ end
49
+
50
+ # Takes instance/class, method and displays source code and comments
51
+ def code(ints_or_clazz, method)
52
+ method = method.to_sym
53
+ clazz = ints_or_clazz.is_a?(Class) ? ints_or_clazz : ints_or_clazz.class
54
+ puts "** Comments: "
55
+ clazz.instance_method(method).comment.display
56
+ puts "** Source:"
57
+ clazz.instance_method(method).source.display
58
+ end
59
+
60
+ end
@@ -0,0 +1,32 @@
1
+ def colputs(array)
2
+ def num_columns; 4; end
3
+ def col_width; 25; end
4
+ def force_length(x)
5
+ x = x.to_s
6
+ max_length = col_width+2
7
+ if x.length > max_length
8
+ x = x[0..max_length-4] + '...'
9
+ end
10
+ x += (' '*max_length)
11
+ x[0..max_length-1]
12
+ end
13
+ def get_element(array, i) # displays in column order instead of row order
14
+ num_rows = (array.length/num_columns)+1
15
+ col = i % num_columns
16
+ row = i / num_columns
17
+ array[col*num_rows+row]
18
+ end
19
+ for i in (0..array.length)
20
+ print force_length(get_element(array, i))
21
+ print " "
22
+ puts if (i % num_columns) == (num_columns-1)
23
+ end
24
+ nil
25
+ end
26
+
27
+ class Object
28
+ # Return only the methods not present on basic objects
29
+ def show_methods
30
+ colputs (self.methods - Object.new.methods).sort
31
+ end
32
+ end
@@ -0,0 +1,3 @@
1
+ module Fertilizer
2
+ VERSION = "0.1.1"
3
+ end
data/lib/fertilizer.rb ADDED
@@ -0,0 +1,28 @@
1
+ require "fertilizer/version"
2
+
3
+ module Fertilizer
4
+
5
+ # <-- CONSOLE EXTENSION (CONSOLE ONLY)-->
6
+ # Following part of code is active with the start of IRB console.
7
+ # Details about features can be seen in console_extensions module.
8
+
9
+ if defined?(Rails::Console)
10
+ require 'fertilizer/console_extensions'
11
+ include ConsoleExtensions
12
+
13
+ # include all modules from lib/poc folder
14
+ Dir.chdir('lib') do
15
+ Dir["poc/*.rb"].each do |file|
16
+ require file
17
+ eval "include #{File.basename(file).gsub(/\.rb/,'').camelize}"
18
+ end
19
+ end
20
+ end
21
+
22
+ # <-- OBJECT EXTENSIONS (CONSOLE ONLY)-->
23
+ if defined?(Rails::Console)
24
+ require 'fertilizer/object_extensions'
25
+ include ObjectExtensions
26
+ end
27
+
28
+ end
@@ -0,0 +1,10 @@
1
+ Fertilizier
2
+ =============
3
+
4
+ # Generate MVC
5
+
6
+ rails generate fertilizer OPTION
7
+
8
+ OPTION values:
9
+
10
+ ALL - generates all helpers (entered bellow) [DEFAULT]
@@ -0,0 +1,19 @@
1
+ require 'rails/generators'
2
+
3
+ class AriGenerator < Rails::Generators::Base
4
+ include Rails::Generators::Migration
5
+
6
+ =begin
7
+ argument :generator_option, :type => :string, :default => "all"
8
+
9
+ def self.source_root
10
+ @source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'initializers/'))
11
+ end
12
+
13
+ def create
14
+ template 'ferilizier_console.rb', File.join('config', 'initializers', 'ferilizier_console.rb')
15
+ end
16
+ =end
17
+
18
+
19
+ end
@@ -0,0 +1,17 @@
1
+ # Following part of code is active with the start of IRB console.
2
+ # Details about features can be seen in console_extensions module.
3
+
4
+ if defined?(Rails::Console)
5
+ require 'fertilizer/console_extensions'
6
+ include ConsoleExtensions
7
+
8
+ # include all modules from lib/poc folder
9
+ Dir.chdir('lib') do
10
+ Dir["poc/*.rb"].each do |file|
11
+ require file
12
+ eval "include #{File.basename(file).gsub(/\.rb/,'').camelize}"
13
+ end
14
+ end
15
+
16
+ end
17
+
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fertilizer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Haris KRAJINA
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-06-12 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails
16
+ requirement: &22530756 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '3.0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *22530756
25
+ description: Fertilizer is simple gem used to enrich new rails projects with configuration
26
+ setup, object extensions, console extensions etc.
27
+ email:
28
+ - haris.krajina@gmail.com
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - .gitignore
34
+ - Gemfile
35
+ - LICENSE
36
+ - README.md
37
+ - Rakefile
38
+ - fertilizer.gemspec
39
+ - lib/fertilizer.rb
40
+ - lib/fertilizer/console_extensions.rb
41
+ - lib/fertilizer/object_extensions.rb
42
+ - lib/fertilizer/version.rb
43
+ - lib/generators/USAGE
44
+ - lib/generators/fertilizer_generator.rb
45
+ - lib/generators/templates/fertilizer_console.rb
46
+ homepage: https://github.com/hkraji/fertilizer
47
+ licenses: []
48
+ post_install_message:
49
+ rdoc_options: []
50
+ require_paths:
51
+ - lib
52
+ required_ruby_version: !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ! '>='
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ! '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ requirements: []
65
+ rubyforge_project:
66
+ rubygems_version: 1.8.16
67
+ signing_key:
68
+ specification_version: 3
69
+ summary: Take a look at Fertilizer's generator and use taks to add features to your
70
+ rails projects.
71
+ test_files: []