main 4.7.1 → 4.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/Rakefile +35 -19
  2. data/lib/main.rb +55 -24
  3. data/main.gemspec +10 -3
  4. metadata +48 -18
data/Rakefile CHANGED
@@ -3,9 +3,6 @@ This.author = "Ara T. Howard"
3
3
  This.email = "ara.t.howard@gmail.com"
4
4
  This.homepage = "https://github.com/ahoward/#{ This.lib }"
5
5
 
6
- task :license do
7
- open('LICENSE', 'w'){|fd| fd.puts "same as ruby's"}
8
- end
9
6
 
10
7
  task :default do
11
8
  puts((Rake::Task.tasks.map{|task| task.name.gsub(/::/,':')} - ['default']).sort)
@@ -90,7 +87,7 @@ task :gemspec do
90
87
  files = shiteless[Dir::glob("**/**")]
91
88
  executables = shiteless[Dir::glob("bin/*")].map{|exe| File.basename(exe)}
92
89
  #has_rdoc = true #File.exist?('doc')
93
- test_files = "test/#{ lib }.rb" if File.file?("test/#{ lib }.rb")
90
+ test_files = test(?e, "test/#{ lib }.rb") ? "test/#{ lib }.rb" : nil
94
91
  summary = object.respond_to?(:summary) ? object.summary : "summary: #{ lib } kicks the ass"
95
92
  description = object.respond_to?(:description) ? object.description : "description: #{ lib } kicks the ass"
96
93
 
@@ -103,38 +100,51 @@ task :gemspec do
103
100
  end
104
101
  extensions = [extensions].flatten.compact
105
102
 
103
+ # TODO
104
+ if This.dependencies.nil?
105
+ dependencies = []
106
+ else
107
+ case This.dependencies
108
+ when Hash
109
+ dependencies = This.dependencies.values
110
+ when Array
111
+ dependencies = This.dependencies
112
+ end
113
+ end
114
+
106
115
  template =
107
116
  if test(?e, 'gemspec.erb')
108
117
  Template{ IO.read('gemspec.erb') }
109
118
  else
110
119
  Template {
111
120
  <<-__
112
- ## #{ lib }.gemspec
121
+ ## <%= lib %>.gemspec
113
122
  #
114
123
 
115
124
  Gem::Specification::new do |spec|
116
- spec.name = #{ lib.inspect }
117
- spec.version = #{ version.inspect }
125
+ spec.name = <%= lib.inspect %>
126
+ spec.version = <%= version.inspect %>
118
127
  spec.platform = Gem::Platform::RUBY
119
- spec.summary = #{ lib.inspect }
120
- spec.description = #{ description.inspect }
128
+ spec.summary = <%= lib.inspect %>
129
+ spec.description = <%= description.inspect %>
121
130
 
122
- spec.files =\n#{ files.sort.pretty_inspect }
123
- spec.executables = #{ executables.inspect }
131
+ spec.files =\n<%= files.sort.pretty_inspect %>
132
+ spec.executables = <%= executables.inspect %>
124
133
 
125
134
  spec.require_path = "lib"
126
135
 
127
- spec.test_files = #{ test_files.inspect }
136
+ spec.test_files = <%= test_files.inspect %>
128
137
 
129
- ### spec.add_dependency 'lib', '>= version'
130
- #### spec.add_dependency 'map'
138
+ <% dependencies.each do |lib_version| %>
139
+ spec.add_dependency(*<%= Array(lib_version).flatten.inspect %>)
140
+ <% end %>
131
141
 
132
- spec.extensions.push(*#{ extensions.inspect })
142
+ spec.extensions.push(*<%= extensions.inspect %>)
133
143
 
134
- spec.rubyforge_project = #{ This.rubyforge_project.inspect }
135
- spec.author = #{ This.author.inspect }
136
- spec.email = #{ This.email.inspect }
137
- spec.homepage = #{ This.homepage.inspect }
144
+ spec.rubyforge_project = <%= This.rubyforge_project.inspect %>
145
+ spec.author = <%= This.author.inspect %>
146
+ spec.email = <%= This.email.inspect %>
147
+ spec.homepage = <%= This.homepage.inspect %>
138
148
  end
139
149
  __
140
150
  }
@@ -270,6 +280,12 @@ BEGIN {
270
280
  end
271
281
  This.version = version
272
282
 
283
+ # see if dependencies are export by the module
284
+ #
285
+ if This.object.respond_to?(:dependencies)
286
+ This.dependencies = This.object.dependencies
287
+ end
288
+
273
289
  # we need to know the name of the lib an it's version
274
290
  #
275
291
  abort('no lib') unless This.lib
data/lib/main.rb CHANGED
@@ -1,8 +1,7 @@
1
1
  module Main
2
- #
3
2
  # top level constants
4
3
  #
5
- Main::VERSION = '4.7.1' unless
4
+ Main::VERSION = '4.7.2' unless
6
5
  defined? Main::VERSION
7
6
  def self.version() Main::VERSION end
8
7
 
@@ -14,7 +13,41 @@ module Main
14
13
  Main::EXIT_FAILURE = 1 unless defined? Main::EXIT_FAILURE
15
14
  Main::EXIT_WARN = 42 unless defined? Main::EXIT_WARN
16
15
  Main::EXIT_WARNING = 42 unless defined? Main::EXIT_WARNING
16
+
17
+ ## deps
17
18
  #
19
+ def Main.dependencies
20
+ {
21
+ 'chronic' => [ 'chronic' , '~> 0.6.2' ] ,
22
+ 'fattr' => [ 'fattr' , '~> 2.2.0' ] ,
23
+ 'arrayfields' => [ 'arrayfields' , '~> 4.7.4' ] ,
24
+ 'map' => [ 'map' , '~> 4.3.0' ]
25
+ }
26
+ end
27
+
28
+ def Main.libdir(*args, &block)
29
+ @libdir ||= File.expand_path(__FILE__).sub(/\.rb$/,'')
30
+ args.empty? ? @libdir : File.join(@libdir, *args)
31
+ ensure
32
+ if block
33
+ begin
34
+ $LOAD_PATH.unshift(@libdir)
35
+ block.call()
36
+ ensure
37
+ $LOAD_PATH.shift()
38
+ end
39
+ end
40
+ end
41
+
42
+ def Main.load(*libs)
43
+ libs = libs.join(' ').scan(/[^\s+]+/)
44
+ Main.libdir{ libs.each{|lib| Kernel.load(lib) } }
45
+ end
46
+ end
47
+
48
+
49
+
50
+
18
51
  # built-in
19
52
  #
20
53
  require 'logger'
@@ -23,7 +56,7 @@ module Main
23
56
  require 'uri'
24
57
  require 'time'
25
58
  require 'date'
26
- #
59
+
27
60
  # use gems to pick up dependancies
28
61
  #
29
62
  begin
@@ -32,27 +65,25 @@ module Main
32
65
  42
33
66
  end
34
67
 
35
- begin
36
- require 'chronic'
37
- rescue LoadError
38
- 42
68
+ if defined?(gem)
69
+ Main.dependencies.each do |lib, dependency|
70
+ gem(*dependency)
71
+ require(lib)
72
+ end
39
73
  end
40
-
41
- require 'fattr'
42
- require 'arrayfields'
43
- require 'map'
44
- #
74
+
45
75
  # main's own libs
46
76
  #
47
- require libdir + 'stdext'
48
- require libdir + 'softspoken'
49
- require libdir + 'util'
50
- require libdir + 'logger'
51
- require libdir + 'usage'
52
- require libdir + 'cast'
53
- require libdir + 'parameter'
54
- require libdir + 'getoptlong'
55
- require libdir + 'mode'
56
- require libdir + 'program'
57
- require libdir + 'factories'
58
- end
77
+ Main.load %w[
78
+ stdext.rb
79
+ softspoken.rb
80
+ util.rb
81
+ logger.rb
82
+ usage.rb
83
+ cast.rb
84
+ parameter.rb
85
+ getoptlong.rb
86
+ mode.rb
87
+ program.rb
88
+ factories.rb
89
+ ]
data/main.gemspec CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  Gem::Specification::new do |spec|
5
5
  spec.name = "main"
6
- spec.version = "4.7.1"
6
+ spec.version = "4.7.2"
7
7
  spec.platform = Gem::Platform::RUBY
8
8
  spec.summary = "main"
9
9
  spec.description = "description: main kicks the ass"
@@ -54,8 +54,15 @@ Gem::Specification::new do |spec|
54
54
 
55
55
  spec.test_files = nil
56
56
 
57
- ### spec.add_dependency 'lib', '>= version'
58
- #### spec.add_dependency 'map'
57
+
58
+ spec.add_dependency(*["chronic", "~> 0.6.2"])
59
+
60
+ spec.add_dependency(*["fattr", "~> 2.2.0"])
61
+
62
+ spec.add_dependency(*["arrayfields", "~> 4.7.4"])
63
+
64
+ spec.add_dependency(*["map", "~> 4.3.0"])
65
+
59
66
 
60
67
  spec.extensions.push(*[])
61
68
 
metadata CHANGED
@@ -1,13 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: main
3
3
  version: !ruby/object:Gem::Version
4
- hash: 33
5
4
  prerelease:
6
- segments:
7
- - 4
8
- - 7
9
- - 1
10
- version: 4.7.1
5
+ version: 4.7.2
11
6
  platform: ruby
12
7
  authors:
13
8
  - Ara T. Howard
@@ -15,10 +10,52 @@ autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
12
 
18
- date: 2011-08-16 00:00:00 -06:00
19
- default_executable:
20
- dependencies: []
21
-
13
+ date: 2011-08-17 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: chronic
17
+ prerelease: false
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ~>
22
+ - !ruby/object:Gem::Version
23
+ version: 0.6.2
24
+ type: :runtime
25
+ version_requirements: *id001
26
+ - !ruby/object:Gem::Dependency
27
+ name: fattr
28
+ prerelease: false
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ~>
33
+ - !ruby/object:Gem::Version
34
+ version: 2.2.0
35
+ type: :runtime
36
+ version_requirements: *id002
37
+ - !ruby/object:Gem::Dependency
38
+ name: arrayfields
39
+ prerelease: false
40
+ requirement: &id003 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 4.7.4
46
+ type: :runtime
47
+ version_requirements: *id003
48
+ - !ruby/object:Gem::Dependency
49
+ name: map
50
+ prerelease: false
51
+ requirement: &id004 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ~>
55
+ - !ruby/object:Gem::Version
56
+ version: 4.3.0
57
+ type: :runtime
58
+ version_requirements: *id004
22
59
  description: "description: main kicks the ass"
23
60
  email: ara.t.howard@gmail.com
24
61
  executables: []
@@ -61,7 +98,6 @@ files:
61
98
  - samples/h.rb
62
99
  - samples/j.rb
63
100
  - test/main_test.rb
64
- has_rdoc: true
65
101
  homepage: https://github.com/ahoward/main
66
102
  licenses: []
67
103
 
@@ -75,23 +111,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
75
111
  requirements:
76
112
  - - ">="
77
113
  - !ruby/object:Gem::Version
78
- hash: 3
79
- segments:
80
- - 0
81
114
  version: "0"
82
115
  required_rubygems_version: !ruby/object:Gem::Requirement
83
116
  none: false
84
117
  requirements:
85
118
  - - ">="
86
119
  - !ruby/object:Gem::Version
87
- hash: 3
88
- segments:
89
- - 0
90
120
  version: "0"
91
121
  requirements: []
92
122
 
93
123
  rubyforge_project: codeforpeople
94
- rubygems_version: 1.4.2
124
+ rubygems_version: 1.7.2
95
125
  signing_key:
96
126
  specification_version: 3
97
127
  summary: main