dmorrill10-utils 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,9 +1,11 @@
1
1
  require "dmorrill10-utils/version"
2
2
 
3
+ require 'dmorrill10-utils/abstract'
3
4
  require 'dmorrill10-utils/class'
4
5
  require 'dmorrill10-utils/enumerable'
5
6
  require 'dmorrill10-utils/integer'
6
7
  require 'dmorrill10-utils/string_form_manipulation'
8
+ require 'dmorrill10-utils/script'
7
9
 
8
10
  module Dmorrill10
9
11
  module Utils
@@ -0,0 +1,18 @@
1
+ module Abstract
2
+ private
3
+
4
+ def abstract_class_name
5
+ self.class.ancestors.each_index do |i|
6
+ current_module_name = Module.nesting.last
7
+ if self.class.ancestors[i] == current_module_name
8
+ return self.class.ancestors[i - 1]
9
+ end
10
+ end
11
+ ''
12
+ end
13
+
14
+ def enforce_abstract(method)
15
+ puts "Please redefine #{abstract_class_name}##{method}"
16
+ exit 0
17
+ end
18
+ end
@@ -0,0 +1,29 @@
1
+ require File.expand_path('../abstract', __FILE__)
2
+
3
+ module Script
4
+ include Abstract
5
+
6
+ private
7
+
8
+ def proper_usage?
9
+ enforce_abstract __method__
10
+ end
11
+
12
+ def print_usage
13
+ enforce_abstract __method__
14
+ end
15
+
16
+ def run_script
17
+ enforce_abstract __method__
18
+ end
19
+
20
+ def run_script_if_run_as_script(file_being_run)
21
+ return unless file_being_run == $0
22
+
23
+ if proper_usage?
24
+ run_script
25
+ else
26
+ print_usage
27
+ end
28
+ end
29
+ end
@@ -1,5 +1,5 @@
1
1
  module Dmorrill10
2
2
  module Utils
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dmorrill10-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-17 00:00:00.000000000 Z
12
+ date: 2012-06-19 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Group of random Ruby mixin utility functions.
15
15
  email:
@@ -24,9 +24,11 @@ files:
24
24
  - Rakefile
25
25
  - dmorrill10-utils.gemspec
26
26
  - lib/dmorrill10-utils.rb
27
+ - lib/dmorrill10-utils/abstract.rb
27
28
  - lib/dmorrill10-utils/class.rb
28
29
  - lib/dmorrill10-utils/enumerable.rb
29
30
  - lib/dmorrill10-utils/integer.rb
31
+ - lib/dmorrill10-utils/script.rb
30
32
  - lib/dmorrill10-utils/string_form_manipulation.rb
31
33
  - lib/dmorrill10-utils/version.rb
32
34
  homepage: https://github.com/dmorrill10/dmorrill10-utils