xot 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +4 -1
- data/VERSION +1 -1
- data/ext/xot/extconf.rb +5 -2
- data/lib/xot.rb +1 -1
- data/lib/xot/block_util.rb +22 -0
- data/lib/xot/load_path.rb +36 -0
- data/lib/xot/module.rb +12 -12
- data/lib/xot/rake.rb +97 -2
- data/task/gem.rake +7 -4
- data/test/helper.rb +10 -0
- data/test/{test_blockutil.rb → test_block_util.rb} +2 -2
- data/test/test_hookable.rb +1 -1
- data/test/{test_rake_helpers.rb → test_rake.rb} +5 -5
- data/test/test_setter.rb +1 -1
- data/test/test_tester.rb +1 -1
- data/xot.gemspec +7 -6
- metadata +13 -33
- data/lib/xot/blockutil.rb +0 -26
- data/lib/xot/rake/helpers.rb +0 -94
- data/lib/xot/rake/task.rb +0 -20
- data/test/helpers.rb +0 -7
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.5
|
data/ext/xot/extconf.rb
CHANGED
@@ -1,9 +1,12 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
3
|
|
4
|
-
|
4
|
+
File.expand_path('../../../lib', __FILE__).tap do |path|
|
5
|
+
$:.unshift path if !$:.include?(path) && File.directory?(path)
|
6
|
+
end
|
7
|
+
|
5
8
|
require 'mkmf'
|
6
|
-
require 'xot/rake
|
9
|
+
require 'xot/rake'
|
7
10
|
require 'xot/module'
|
8
11
|
|
9
12
|
include Xot::Rake
|
data/lib/xot.rb
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
|
4
|
+
module Xot
|
5
|
+
|
6
|
+
|
7
|
+
module BlockUtil
|
8
|
+
|
9
|
+
def instance_eval_or_block_call (recv, *args, &block)
|
10
|
+
if block.arity == 0
|
11
|
+
recv.instance_eval &block
|
12
|
+
else
|
13
|
+
block.call recv, *args
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
extend self
|
18
|
+
|
19
|
+
end# BlockUtil
|
20
|
+
|
21
|
+
|
22
|
+
end# Xot
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
|
4
|
+
module Xot
|
5
|
+
|
6
|
+
|
7
|
+
module LoadPath
|
8
|
+
|
9
|
+
def unshift_lib (base_dir, *module_names)
|
10
|
+
each_lib_dir_to_add base_dir, *module_names do |dir|
|
11
|
+
$LOCA_PATH.unshift dir
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def push_lib (base_dir, *module_names)
|
16
|
+
each_lib_dir_to_add base_dir, *module_names do |dir|
|
17
|
+
$LOAD_PATH.push dir
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
extend self
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def each_lib_dir_to_add (base_dir, *module_names)
|
26
|
+
module_names.each do |name|
|
27
|
+
dir = File.join base_dir, name.to_s.downcase, 'lib'
|
28
|
+
next if $LOAD_PATH.include?(dir) || !File.directory?(dir)
|
29
|
+
yield dir
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end# LoadPath
|
34
|
+
|
35
|
+
|
36
|
+
end# Xot
|
data/lib/xot/module.rb
CHANGED
@@ -4,22 +4,26 @@
|
|
4
4
|
module Xot
|
5
5
|
|
6
6
|
|
7
|
-
extend module
|
7
|
+
extend module ModuleInfo
|
8
8
|
|
9
|
-
def
|
10
|
-
|
9
|
+
def version ()
|
10
|
+
open(root_dir 'VERSION') {|f| f.readline.chomp}
|
11
|
+
end
|
12
|
+
|
13
|
+
def root_dir (path = '')
|
14
|
+
File.expand_path "../../../#{path}", __FILE__
|
11
15
|
end
|
12
16
|
|
13
17
|
def include_dirs ()
|
14
|
-
[
|
18
|
+
%w[include].map {|dir| root_dir dir}
|
15
19
|
end
|
16
20
|
|
17
|
-
def
|
18
|
-
%w[lib].map {|dir|
|
21
|
+
def lib_dirs ()
|
22
|
+
%w[lib].map {|dir| root_dir dir}
|
19
23
|
end
|
20
24
|
|
21
25
|
def task_dir ()
|
22
|
-
|
26
|
+
root_dir 'task'
|
23
27
|
end
|
24
28
|
|
25
29
|
def load_tasks (*names)
|
@@ -33,13 +37,9 @@ module Xot
|
|
33
37
|
end
|
34
38
|
end
|
35
39
|
|
36
|
-
def version ()
|
37
|
-
open(File.join root_dir, 'VERSION') {|f| f.readline.chomp}
|
38
|
-
end
|
39
|
-
|
40
40
|
self
|
41
41
|
|
42
|
-
end#
|
42
|
+
end# ModuleInfo
|
43
43
|
|
44
44
|
|
45
45
|
end# Xot
|
data/lib/xot/rake.rb
CHANGED
@@ -1,5 +1,100 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
3
|
|
4
|
-
require '
|
5
|
-
require '
|
4
|
+
require 'erb'
|
5
|
+
require 'pp'
|
6
|
+
|
7
|
+
|
8
|
+
module Xot
|
9
|
+
|
10
|
+
|
11
|
+
module Rake
|
12
|
+
|
13
|
+
|
14
|
+
def empty_task (*names)
|
15
|
+
names.each do |name|
|
16
|
+
task name => '.'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def glob (*patterns)
|
21
|
+
paths = []
|
22
|
+
patterns.each do |pattern|
|
23
|
+
paths.concat Dir.glob(pattern)
|
24
|
+
end
|
25
|
+
paths
|
26
|
+
end
|
27
|
+
|
28
|
+
def erb (str)
|
29
|
+
ERB.new(str, nil, "%").result binding
|
30
|
+
end
|
31
|
+
|
32
|
+
def compile (path, out)
|
33
|
+
open(path) do |input|
|
34
|
+
open(out, "w") do |output|
|
35
|
+
output.write erb(input.read)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
#rescue
|
39
|
+
end
|
40
|
+
|
41
|
+
def params (n, sep = "", &block)
|
42
|
+
raise "block not given." unless block
|
43
|
+
return "" if n == 0
|
44
|
+
(1..n).map(&block).join(sep)
|
45
|
+
end
|
46
|
+
|
47
|
+
def convertions (paths, convs)
|
48
|
+
raise "empty conversion." if convs.empty?
|
49
|
+
paths = paths.map do |path|
|
50
|
+
convpath = path
|
51
|
+
convs.each do |from, to|
|
52
|
+
convpath = convpath.sub(/#{from.gsub('.', '\.')}$/, to)
|
53
|
+
end
|
54
|
+
[path, convpath]
|
55
|
+
end
|
56
|
+
Hash[*paths.flatten]
|
57
|
+
end
|
58
|
+
|
59
|
+
def env (name, defval = nil)
|
60
|
+
case val = (ENV[name.to_s] || Object.const_get(name) rescue defval)
|
61
|
+
when /^\d+$/ then val.to_i
|
62
|
+
when 'true' then true
|
63
|
+
when 'false' then false
|
64
|
+
else val
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def header (mod)
|
69
|
+
puts "-- #{mod.to_s.capitalize} " + "-" * 50
|
70
|
+
end
|
71
|
+
|
72
|
+
def win32? ()
|
73
|
+
RUBY_PLATFORM =~ /mswin|ming|cygwin/
|
74
|
+
end
|
75
|
+
|
76
|
+
def mswin? ()
|
77
|
+
RUBY_PLATFORM =~ /mswin/
|
78
|
+
end
|
79
|
+
|
80
|
+
def ming? ()
|
81
|
+
RUBY_PLATFORM =~ /ming/
|
82
|
+
end
|
83
|
+
|
84
|
+
def cygwin? ()
|
85
|
+
RUBY_PLATFORM =~ /cygwin/
|
86
|
+
end
|
87
|
+
|
88
|
+
def cocoa? ()
|
89
|
+
RUBY_PLATFORM =~ /darwin/
|
90
|
+
end
|
91
|
+
|
92
|
+
def clang? ()
|
93
|
+
RbConfig::CONFIG['CXX'] =~ /clang/
|
94
|
+
end
|
95
|
+
|
96
|
+
|
97
|
+
end# Rake
|
98
|
+
|
99
|
+
|
100
|
+
end# Xot
|
data/task/gem.rake
CHANGED
@@ -19,7 +19,8 @@ namespace :gem do
|
|
19
19
|
|
20
20
|
gemspec = "#{name}.gemspec"
|
21
21
|
gemname = env :GEMNAME, name
|
22
|
-
|
22
|
+
gemver = mod.version
|
23
|
+
gemfile = "#{gemname}-#{gemver}.gem"
|
23
24
|
|
24
25
|
|
25
26
|
task :build => gemfile
|
@@ -33,14 +34,16 @@ namespace :gem do
|
|
33
34
|
end
|
34
35
|
|
35
36
|
task :uninstall do
|
36
|
-
sh %( #{gem} uninstall #{
|
37
|
+
sh %( #{gem} uninstall -x --version #{gemver} #{gemname} )
|
37
38
|
end
|
38
39
|
|
39
|
-
task :upload =>
|
40
|
+
task :upload => :test_install do
|
40
41
|
sh %( #{gem} push #{gemfile} )
|
41
42
|
end
|
42
43
|
|
43
|
-
|
44
|
+
task :test_install => [:install, :uninstall]
|
45
|
+
|
46
|
+
file gemfile => [:ext, :rdoc] do
|
44
47
|
sh %( #{gem} build #{gemspec} )
|
45
48
|
end
|
46
49
|
|
data/test/helper.rb
ADDED
data/test/test_hookable.rb
CHANGED
@@ -1,11 +1,9 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
3
|
|
4
|
-
require_relative '
|
4
|
+
require_relative 'helper'
|
5
5
|
require 'xot/rake'
|
6
6
|
|
7
|
-
include Xot::Rake
|
8
|
-
|
9
7
|
|
10
8
|
Const = 'const'
|
11
9
|
Zero = 0
|
@@ -18,7 +16,9 @@ TrueStr = 'true'
|
|
18
16
|
FalseStr = 'false'
|
19
17
|
|
20
18
|
|
21
|
-
class
|
19
|
+
class TestRake < Test::Unit::TestCase
|
20
|
+
|
21
|
+
include Xot::Rake
|
22
22
|
|
23
23
|
def test_set ()
|
24
24
|
assert_equal 'const', env(:Const, :dummy)
|
@@ -32,4 +32,4 @@ class TestRakeHelpers < Test::Unit::TestCase
|
|
32
32
|
assert_equal false, env(:FalseStr, :dummy)
|
33
33
|
end
|
34
34
|
|
35
|
-
end#
|
35
|
+
end# TestRake
|
data/test/test_setter.rb
CHANGED
data/test/test_tester.rb
CHANGED
data/xot.gemspec
CHANGED
@@ -1,19 +1,21 @@
|
|
1
1
|
# -*- mode: ruby; coding: utf-8 -*-
|
2
2
|
|
3
3
|
|
4
|
-
|
4
|
+
File.expand_path('../lib', __FILE__) do |path|
|
5
|
+
$:.unshift path if !$:.include?(path) && File.directory?(path)
|
6
|
+
end
|
5
7
|
|
6
8
|
require 'xot/module'
|
7
9
|
|
8
10
|
|
9
11
|
Gem::Specification.new do |s|
|
10
|
-
|
12
|
+
glob = -> *patterns do
|
11
13
|
patterns.map {|pat| Dir.glob(pat).to_a}.flatten
|
12
14
|
end
|
13
15
|
|
14
16
|
mod = Xot
|
15
17
|
name = mod.name.downcase
|
16
|
-
rdocs = glob *%w[README]
|
18
|
+
rdocs = glob.call *%w[README]
|
17
19
|
|
18
20
|
s.name = name
|
19
21
|
s.summary = 'A Utility library for C++ developemt.'
|
@@ -22,13 +24,12 @@ Gem::Specification.new do |s|
|
|
22
24
|
|
23
25
|
s.authors = %w[snori]
|
24
26
|
s.email = 'snori@xord.org'
|
25
|
-
s.homepage = "http://github.com/xord/#{name}"
|
27
|
+
s.homepage = "http://github.com/xord/#{name}/wiki"
|
26
28
|
|
27
29
|
s.platform = Gem::Platform::RUBY
|
28
30
|
s.required_ruby_version = '>=1.9.0'
|
29
31
|
|
30
|
-
s.add_runtime_dependency '
|
31
|
-
s.add_development_dependency 'rake'
|
32
|
+
s.add_runtime_dependency 'rake'
|
32
33
|
s.add_development_dependency 'gemcutter'
|
33
34
|
|
34
35
|
s.files = `git ls-files`.split $/
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,24 +9,8 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-04-
|
12
|
+
date: 2013-04-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
-
- !ruby/object:Gem::Dependency
|
15
|
-
name: bundler
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ! '>='
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: '0'
|
22
|
-
type: :runtime
|
23
|
-
prerelease: false
|
24
|
-
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ! '>='
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '0'
|
30
14
|
- !ruby/object:Gem::Dependency
|
31
15
|
name: rake
|
32
16
|
requirement: !ruby/object:Gem::Requirement
|
@@ -35,7 +19,7 @@ dependencies:
|
|
35
19
|
- - ! '>='
|
36
20
|
- !ruby/object:Gem::Version
|
37
21
|
version: '0'
|
38
|
-
type: :
|
22
|
+
type: :runtime
|
39
23
|
prerelease: false
|
40
24
|
version_requirements: !ruby/object:Gem::Requirement
|
41
25
|
none: false
|
@@ -83,12 +67,11 @@ files:
|
|
83
67
|
- include/xot/string.h
|
84
68
|
- include/xot/util.h
|
85
69
|
- lib/xot.rb
|
86
|
-
- lib/xot/
|
70
|
+
- lib/xot/block_util.rb
|
87
71
|
- lib/xot/hookable.rb
|
72
|
+
- lib/xot/load_path.rb
|
88
73
|
- lib/xot/module.rb
|
89
74
|
- lib/xot/rake.rb
|
90
|
-
- lib/xot/rake/helpers.rb
|
91
|
-
- lib/xot/rake/task.rb
|
92
75
|
- lib/xot/setter.rb
|
93
76
|
- src/debug.cpp
|
94
77
|
- src/defs.cpp
|
@@ -100,14 +83,14 @@ files:
|
|
100
83
|
- task/lib.rake
|
101
84
|
- task/submodule.rake
|
102
85
|
- task/test.rake
|
103
|
-
- test/
|
104
|
-
- test/
|
86
|
+
- test/helper.rb
|
87
|
+
- test/test_block_util.rb
|
105
88
|
- test/test_hookable.rb
|
106
|
-
- test/
|
89
|
+
- test/test_rake.rb
|
107
90
|
- test/test_setter.rb
|
108
91
|
- test/test_tester.rb
|
109
92
|
- xot.gemspec
|
110
|
-
homepage: http://github.com/xord/xot
|
93
|
+
homepage: http://github.com/xord/xot/wiki
|
111
94
|
licenses: []
|
112
95
|
post_install_message:
|
113
96
|
rdoc_options: []
|
@@ -125,19 +108,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
125
108
|
- - ! '>='
|
126
109
|
- !ruby/object:Gem::Version
|
127
110
|
version: '0'
|
128
|
-
segments:
|
129
|
-
- 0
|
130
|
-
hash: -2411393735546273344
|
131
111
|
requirements: []
|
132
112
|
rubyforge_project:
|
133
|
-
rubygems_version: 1.8.
|
113
|
+
rubygems_version: 1.8.24
|
134
114
|
signing_key:
|
135
115
|
specification_version: 3
|
136
116
|
summary: A Utility library for C++ developemt.
|
137
117
|
test_files:
|
138
|
-
- test/
|
139
|
-
- test/
|
118
|
+
- test/helper.rb
|
119
|
+
- test/test_block_util.rb
|
140
120
|
- test/test_hookable.rb
|
141
|
-
- test/
|
121
|
+
- test/test_rake.rb
|
142
122
|
- test/test_setter.rb
|
143
123
|
- test/test_tester.rb
|
data/lib/xot/blockutil.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
|
4
|
-
module Xot
|
5
|
-
|
6
|
-
|
7
|
-
module BlockUtil
|
8
|
-
|
9
|
-
extend module ClassMethods
|
10
|
-
|
11
|
-
def instance_eval_or_block_call (recv, *args, &block)
|
12
|
-
if block.arity == 0
|
13
|
-
recv.instance_eval &block
|
14
|
-
else
|
15
|
-
block.call recv, *args
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
self
|
20
|
-
|
21
|
-
end# ClassMethods
|
22
|
-
|
23
|
-
end# BlockUtil
|
24
|
-
|
25
|
-
|
26
|
-
end# Xot
|
data/lib/xot/rake/helpers.rb
DELETED
@@ -1,94 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
|
4
|
-
require 'erb'
|
5
|
-
require 'pp'
|
6
|
-
|
7
|
-
|
8
|
-
module Xot
|
9
|
-
|
10
|
-
|
11
|
-
module Rake
|
12
|
-
|
13
|
-
|
14
|
-
def glob (*patterns)
|
15
|
-
paths = []
|
16
|
-
patterns.each do |pattern|
|
17
|
-
paths.concat Dir.glob(pattern)
|
18
|
-
end
|
19
|
-
paths
|
20
|
-
end
|
21
|
-
|
22
|
-
def erb (str)
|
23
|
-
ERB.new(str, nil, "%").result binding
|
24
|
-
end
|
25
|
-
|
26
|
-
def compile (path, out)
|
27
|
-
open(path) do |input|
|
28
|
-
open(out, "w") do |output|
|
29
|
-
output.write erb(input.read)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
#rescue
|
33
|
-
end
|
34
|
-
|
35
|
-
def params (n, sep = "", &block)
|
36
|
-
raise "block not given." unless block
|
37
|
-
return "" if n == 0
|
38
|
-
(1..n).map(&block).join(sep)
|
39
|
-
end
|
40
|
-
|
41
|
-
def convertions (paths, convs)
|
42
|
-
raise "empty conversion." if convs.empty?
|
43
|
-
paths = paths.map do |path|
|
44
|
-
convpath = path
|
45
|
-
convs.each do |from, to|
|
46
|
-
convpath = convpath.sub(/#{from.gsub('.', '\.')}$/, to)
|
47
|
-
end
|
48
|
-
[path, convpath]
|
49
|
-
end
|
50
|
-
Hash[*paths.flatten]
|
51
|
-
end
|
52
|
-
|
53
|
-
def env (name, defval = nil)
|
54
|
-
case val = (ENV[name.to_s] || Object.const_get(name) rescue defval)
|
55
|
-
when /^\d+$/ then val.to_i
|
56
|
-
when 'true' then true
|
57
|
-
when 'false' then false
|
58
|
-
else val
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
def header (mod)
|
63
|
-
puts "-- #{mod.to_s.capitalize} " + "-" * 50
|
64
|
-
end
|
65
|
-
|
66
|
-
def win32? ()
|
67
|
-
RUBY_PLATFORM =~ /mswin|ming|cygwin/
|
68
|
-
end
|
69
|
-
|
70
|
-
def mswin? ()
|
71
|
-
RUBY_PLATFORM =~ /mswin/
|
72
|
-
end
|
73
|
-
|
74
|
-
def ming? ()
|
75
|
-
RUBY_PLATFORM =~ /ming/
|
76
|
-
end
|
77
|
-
|
78
|
-
def cygwin? ()
|
79
|
-
RUBY_PLATFORM =~ /cygwin/
|
80
|
-
end
|
81
|
-
|
82
|
-
def cocoa? ()
|
83
|
-
RUBY_PLATFORM =~ /darwin/
|
84
|
-
end
|
85
|
-
|
86
|
-
def clang? ()
|
87
|
-
RbConfig::CONFIG['CXX'] =~ /clang/
|
88
|
-
end
|
89
|
-
|
90
|
-
|
91
|
-
end# Rake
|
92
|
-
|
93
|
-
|
94
|
-
end# Xot
|
data/lib/xot/rake/task.rb
DELETED