main 4.4.0 → 4.6.0
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/README.erb +3 -0
- data/Rakefile +5 -3
- data/TODO +5 -0
- data/lib/main.rb +2 -1
- data/lib/main/cast.rb +23 -13
- data/lib/main/program/class_methods.rb +2 -2
- metadata +22 -8
- data/a.rb +0 -33
- data/main.gemspec +0 -29
data/README.erb
CHANGED
data/Rakefile
CHANGED
@@ -80,6 +80,7 @@ task :gemspec do
|
|
80
80
|
spec.test_files = #{ test_files.inspect }
|
81
81
|
spec.add_dependency 'fattr', '>= 2.1.0'
|
82
82
|
spec.add_dependency 'arrayfields', '>= 4.7.4'
|
83
|
+
spec.add_dependency 'map', '>= 2.0.0'
|
83
84
|
|
84
85
|
spec.extensions.push(*#{ extensions.inspect })
|
85
86
|
|
@@ -92,8 +93,9 @@ task :gemspec do
|
|
92
93
|
}
|
93
94
|
end
|
94
95
|
|
95
|
-
|
96
|
-
This.gemspec = "
|
96
|
+
Fu.mkdir_p(This.pkgdir)
|
97
|
+
This.gemspec = File.join(This.pkgdir, "gemspec.rb")
|
98
|
+
open("#{ This.gemspec }", "w"){|fd| fd.puts(template)}
|
97
99
|
end
|
98
100
|
|
99
101
|
task :gem => [:clean, :gemspec] do
|
@@ -103,7 +105,7 @@ task :gem => [:clean, :gemspec] do
|
|
103
105
|
`#{ cmd }`
|
104
106
|
after = Dir['*.gem']
|
105
107
|
gem = ((after - before).first || after.first) or abort('no gem!')
|
106
|
-
Fu.mv
|
108
|
+
Fu.mv(gem, This.pkgdir)
|
107
109
|
This.gem = File.basename(gem)
|
108
110
|
end
|
109
111
|
|
data/TODO
CHANGED
data/lib/main.rb
CHANGED
@@ -2,7 +2,7 @@ module Main
|
|
2
2
|
#
|
3
3
|
# top level constants
|
4
4
|
#
|
5
|
-
Main::VERSION = '4.
|
5
|
+
Main::VERSION = '4.6.0' unless
|
6
6
|
defined? Main::VERSION
|
7
7
|
def self.version() Main::VERSION end
|
8
8
|
|
@@ -40,6 +40,7 @@ module Main
|
|
40
40
|
|
41
41
|
require 'fattr'
|
42
42
|
require 'arrayfields'
|
43
|
+
require 'map'
|
43
44
|
#
|
44
45
|
# main's own libs
|
45
46
|
#
|
data/lib/main/cast.rb
CHANGED
@@ -103,29 +103,39 @@ module Main
|
|
103
103
|
end
|
104
104
|
|
105
105
|
cast :list do |*objs|
|
106
|
-
[*objs].flatten.join(',').split(
|
106
|
+
[*objs].flatten.join(',').split(/[\n,]/).map{|item| item.strip}.delete_if{|item| item.strip.empty?}
|
107
107
|
end
|
108
108
|
|
109
|
-
|
109
|
+
# add list_of_xxx methods
|
110
|
+
#
|
110
111
|
List.dup.each do |type|
|
111
112
|
next if type.to_s =~ %r/list/
|
112
|
-
|
113
|
-
|
114
|
-
|
113
|
+
%W" list_of_#{ type } list_of_#{ type }s ".each do |m|
|
114
|
+
define_method m do |*objs|
|
115
|
+
list(*objs).map{|obj| send type, obj}
|
116
|
+
end
|
117
|
+
export m
|
118
|
+
List << m
|
115
119
|
end
|
116
|
-
export m
|
117
|
-
List << m
|
118
120
|
end
|
119
121
|
|
120
|
-
|
122
|
+
# add list_of_xxx_from_file
|
123
|
+
#
|
121
124
|
List.dup.each do |type|
|
122
125
|
next if type.to_s =~ %r/list/
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
+
%W" list_of_#{ type }_from_file list_of_#{ type }s_from_file ".each do |m|
|
127
|
+
define_method m do |*args|
|
128
|
+
buf = nil
|
129
|
+
if args.size == 1 and args.first.respond_to?(:read)
|
130
|
+
buf = args.first.read
|
131
|
+
else
|
132
|
+
open(*args){|io| buf = io.read}
|
133
|
+
end
|
134
|
+
send(m.sub(/_from_file/, ''), buf)
|
135
|
+
end
|
136
|
+
export m
|
137
|
+
List << m
|
126
138
|
end
|
127
|
-
export m
|
128
|
-
List << m
|
129
139
|
end
|
130
140
|
|
131
141
|
def self.[] sym
|
@@ -302,7 +302,7 @@ module Main
|
|
302
302
|
unless defined?(@config)
|
303
303
|
require 'yaml' unless defined?(YAML)
|
304
304
|
if test(?s, config_path)
|
305
|
-
@config = YAML.load(IO.read(config_path))
|
305
|
+
@config = Map.for(YAML.load(IO.read(config_path)))
|
306
306
|
else
|
307
307
|
config = args.last.is_a?(Hash) ? args.last : {}
|
308
308
|
lines = config.to_yaml.split(/\n/)
|
@@ -314,7 +314,7 @@ module Main
|
|
314
314
|
end
|
315
315
|
editor = ENV['EDITOR'] || ENV['EDIT'] || 'vi'
|
316
316
|
system("#{ editor.inspect } #{ config_path }")
|
317
|
-
@config = YAML.load(IO.read(config_path))
|
317
|
+
@config = Map.for(YAML.load(IO.read(config_path)))
|
318
318
|
end
|
319
319
|
end
|
320
320
|
@config
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: main
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 39
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 4
|
8
|
-
-
|
8
|
+
- 6
|
9
9
|
- 0
|
10
|
-
version: 4.
|
10
|
+
version: 4.6.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ara T. Howard
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-06-30 00:00:00 -06:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -50,6 +50,22 @@ dependencies:
|
|
50
50
|
version: 4.7.4
|
51
51
|
type: :runtime
|
52
52
|
version_requirements: *id002
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: map
|
55
|
+
prerelease: false
|
56
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
hash: 15
|
62
|
+
segments:
|
63
|
+
- 2
|
64
|
+
- 0
|
65
|
+
- 0
|
66
|
+
version: 2.0.0
|
67
|
+
type: :runtime
|
68
|
+
version_requirements: *id003
|
53
69
|
description: a class factory and dsl for generating command line programs real quick
|
54
70
|
email: ara.t.howard@gmail.com
|
55
71
|
executables: []
|
@@ -59,7 +75,6 @@ extensions: []
|
|
59
75
|
extra_rdoc_files: []
|
60
76
|
|
61
77
|
files:
|
62
|
-
- a.rb
|
63
78
|
- lib/main/cast.rb
|
64
79
|
- lib/main/dsl.rb
|
65
80
|
- lib/main/factories.rb
|
@@ -77,7 +92,6 @@ files:
|
|
77
92
|
- lib/main/util.rb
|
78
93
|
- lib/main.rb
|
79
94
|
- LICENSE
|
80
|
-
- main.gemspec
|
81
95
|
- Rakefile
|
82
96
|
- README
|
83
97
|
- README.erb
|
@@ -122,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
122
136
|
requirements: []
|
123
137
|
|
124
138
|
rubyforge_project: codeforpeople
|
125
|
-
rubygems_version: 1.
|
139
|
+
rubygems_version: 1.4.2
|
126
140
|
signing_key:
|
127
141
|
specification_version: 3
|
128
142
|
summary: main
|
data/a.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'main'
|
2
|
-
|
3
|
-
Main {
|
4
|
-
|
5
|
-
name :foobar
|
6
|
-
|
7
|
-
db {
|
8
|
-
create_table(:foo) do
|
9
|
-
primary_key :id
|
10
|
-
String :name
|
11
|
-
Float :price
|
12
|
-
end unless table_exists?(:foo)
|
13
|
-
}
|
14
|
-
|
15
|
-
config(
|
16
|
-
:email => 'your.addy@gmail.com',
|
17
|
-
:password => 'yourPa$$word'
|
18
|
-
)
|
19
|
-
|
20
|
-
io
|
21
|
-
|
22
|
-
|
23
|
-
def run
|
24
|
-
#p input.path
|
25
|
-
#p output.path
|
26
|
-
p params.map{|param| param.name}
|
27
|
-
output.puts(:foobar)
|
28
|
-
end
|
29
|
-
|
30
|
-
mode :foo do
|
31
|
-
params[:input].ignore!
|
32
|
-
end
|
33
|
-
}
|
data/main.gemspec
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
## main.gemspec
|
2
|
-
#
|
3
|
-
|
4
|
-
Gem::Specification::new do |spec|
|
5
|
-
spec.name = "main"
|
6
|
-
spec.description = 'a class factory and dsl for generating command line programs real quick'
|
7
|
-
spec.version = "4.4.0"
|
8
|
-
spec.platform = Gem::Platform::RUBY
|
9
|
-
spec.summary = "main"
|
10
|
-
|
11
|
-
spec.files = ["a.rb", "lib", "lib/main", "lib/main/cast.rb", "lib/main/dsl.rb", "lib/main/factories.rb", "lib/main/getoptlong.rb", "lib/main/logger.rb", "lib/main/mode.rb", "lib/main/parameter.rb", "lib/main/program", "lib/main/program/class_methods.rb", "lib/main/program/instance_methods.rb", "lib/main/program.rb", "lib/main/softspoken.rb", "lib/main/stdext.rb", "lib/main/test.rb", "lib/main/usage.rb", "lib/main/util.rb", "lib/main.rb", "LICENSE", "main.gemspec", "Rakefile", "README", "README.erb", "samples", "samples/a.rb", "samples/b.rb", "samples/c.rb", "samples/d.rb", "samples/e.rb", "samples/f.rb", "samples/g.rb", "samples/h.rb", "samples/j.rb", "test", "test/main.rb", "TODO"]
|
12
|
-
spec.executables = []
|
13
|
-
|
14
|
-
|
15
|
-
spec.require_path = "lib"
|
16
|
-
|
17
|
-
|
18
|
-
spec.has_rdoc = true
|
19
|
-
spec.test_files = "test/main.rb"
|
20
|
-
spec.add_dependency 'fattr', '>= 2.1.0'
|
21
|
-
spec.add_dependency 'arrayfields', '>= 4.7.4'
|
22
|
-
|
23
|
-
spec.extensions.push(*[])
|
24
|
-
|
25
|
-
spec.rubyforge_project = "codeforpeople"
|
26
|
-
spec.author = "Ara T. Howard"
|
27
|
-
spec.email = "ara.t.howard@gmail.com"
|
28
|
-
spec.homepage = "http://github.com/ahoward/main/tree/master"
|
29
|
-
end
|