rept 0.1.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/lib/rept4diff.rb ADDED
@@ -0,0 +1,225 @@
1
+ #! ruby -Ks
2
+
3
+ require 'optparse'
4
+ require File.join(File.dirname(__FILE__), 'yamltext')
5
+ require 'pathname'
6
+ require File.join(File.dirname(__FILE__), 'lib')
7
+ require 'test/unit/assertions'
8
+ include Test::Unit::Assertions
9
+
10
+ # ���b�Z�[�W�ꗗ
11
+ $init = YamlText.new(File.join(File.dirname(__FILE__), 'init.yaml'))
12
+ $text = YamlText.new(File.join(File.dirname(__FILE__), 'rept4diff.yaml'))
13
+
14
+ # �o�[�W�����ԍ�
15
+ Version = $init.get('version')
16
+
17
+ class Parser
18
+ def initialize(fname, args)
19
+ @data = []
20
+ @args = args
21
+
22
+ open(fname) do |file|
23
+ file.each do |line|
24
+ @data << convertString(line, args)
25
+ end
26
+ end
27
+ end
28
+
29
+ def parse
30
+ # �o�͌���
31
+ @result = []
32
+
33
+ # Args�w�b�_
34
+ @result << "Args:\n"
35
+ @args.each do |arg|
36
+ @result << " #{arg}\n"
37
+ end
38
+
39
+ # ����
40
+ @tokens = []
41
+
42
+ # ������
43
+ lexicalAnalysis
44
+
45
+ # �\�����
46
+ syntaxAnalysis
47
+ end
48
+
49
+ # ������
50
+ def lexicalAnalysis
51
+ @data.size.times do |index|
52
+ @tokens << token(index)
53
+ end
54
+ end
55
+
56
+ # ������擾
57
+ def token(index)
58
+ line = @data[index]
59
+
60
+ if (line =~ /^Index:\s+(.+)$/)
61
+ return :index
62
+ elsif (isPrevIndex(index))
63
+ if (line =~ /^@@\s+([+-]\d+,\d+)/)
64
+ if ($1 == "-0,0")
65
+ return :create
66
+ else
67
+ return :insert
68
+ end
69
+ else
70
+ return :none
71
+ end
72
+ elsif (line =~ /^\+/)
73
+ return :add
74
+ elsif (line =~ /^\-/)
75
+ return :minus
76
+ else
77
+ return :around
78
+ end
79
+
80
+ assert(nil, $text.get('error_token'))
81
+ return :none
82
+ end
83
+
84
+ def isPrevIndex(index)
85
+ while true
86
+ index -= 1
87
+ next if (@tokens[index] == :none)
88
+ return (@tokens[index] == :index)
89
+ end
90
+
91
+ false
92
+ end
93
+
94
+ class Context
95
+ attr_accessor :index
96
+
97
+ def initialize(data, tokens)
98
+ @data = data
99
+ @tokens = tokens
100
+ @index = 0
101
+ end
102
+
103
+ def continue?
104
+ @index < @tokens.size
105
+ end
106
+
107
+ def end?
108
+ !continue?
109
+ end
110
+
111
+ def token
112
+ @tokens[@index]
113
+ end
114
+
115
+ def line
116
+ @data[@index]
117
+ end
118
+ end
119
+
120
+ # �\�����
121
+ def syntaxAnalysis
122
+ context = Context.new(@data, @tokens)
123
+
124
+ until context.end?
125
+ case context.token
126
+ when :index
127
+ syntaxIndex(context)
128
+ when :create
129
+ syntaxCreate(context)
130
+ when :insert
131
+ syntaxInsert(context)
132
+ else
133
+ context.index += 1
134
+ end
135
+ end
136
+ end
137
+
138
+ def syntaxIndex(context)
139
+ line = context.line
140
+
141
+ if (line =~ /^Index:\s+(.+)$/)
142
+ @result << line.gsub(/^Index:\s+(.+)$/, 'Index: ' + relative_path($1))
143
+ else
144
+ @result << line
145
+ end
146
+
147
+ context.index += 1
148
+ end
149
+
150
+ def syntaxCreate(context)
151
+ context.index += 1
152
+
153
+ while context.continue? && context.token == :add
154
+ @result << context.line.gsub(/^\+/, "")
155
+ context.index += 1
156
+ end
157
+ end
158
+
159
+ def syntaxInsert(context)
160
+ context.index += 1
161
+
162
+ prevToken = nil
163
+ isFirstAdd = false
164
+
165
+ until context.end?
166
+ line = context.line
167
+
168
+ case context.token
169
+ when :minus
170
+ # :minus�����͓ǂݔ�΂�
171
+ context.index += 1
172
+ next
173
+ when :add
174
+ @result << "\n" if (prevToken == :around && isFirstAdd)
175
+ @result << "-->" + line.gsub(/^\+/, "")
176
+ isFirstAdd = true
177
+ when :around
178
+ @result << line if (prevToken == :add)
179
+ else
180
+ break
181
+ end
182
+
183
+ prevToken = context.token
184
+ context.index += 1
185
+ end
186
+ end
187
+
188
+ def convertString(string, args)
189
+ s = string.clone
190
+
191
+ args.each_with_index do |arg, index|
192
+ s.gsub!(arg, "ReptName#{index + 1}")
193
+ s.gsub!(arg.downcaseHead, "reptName#{index + 1}")
194
+ s.gsub!(arg.downcase, "reptname#{index + 1}")
195
+ s.gsub!(arg.upcase, "REPTNAME#{index + 1}")
196
+ s.gsub!(arg.joinUnderbar, "rept_name#{index + 1}")
197
+ end
198
+
199
+ s
200
+ end
201
+
202
+ def result
203
+ @result
204
+ end
205
+ end
206
+
207
+ def rept4diff
208
+ # �I�v�V��������
209
+ output = $stdout
210
+
211
+ opt = OptionParser.new($text.get('command_line'))
212
+ opt.on('-o �t�@�C����', '--output', $text.get('output')) {|v| output = open(v, "wb") }
213
+ opt.parse!
214
+
215
+ # ���s�{��
216
+ if (ARGV.size > 1)
217
+ parser = Parser.new(fname, args)
218
+ parser.parse
219
+ output.print parser.result
220
+ else
221
+ puts opt.help
222
+ end
223
+ end
224
+
225
+
@@ -0,0 +1,10 @@
1
+ # �R�}���h���C���̐���
2
+ command_line: "rept4diff [option] diff_file ReptName1��� ReptName2��� ..."
3
+
4
+ # �o�̓I�v�V����
5
+ output: "�o�̓t�@�C�����A���w��̏ꍇ�͕W���o�͂ɏo�͂��܂�"
6
+
7
+ # �����͒��̃G���[
8
+ error_token: "�����͒��ɃG���[���������܂���"
9
+
10
+ # @insert
data/lib/yamltext.rb ADDED
@@ -0,0 +1,19 @@
1
+ #! ruby
2
+
3
+ require 'yaml'
4
+
5
+ class YamlText
6
+ def initialize(file_name)
7
+ @data = YAML.load(open(file_name){|f| f.read})
8
+ end
9
+
10
+ def get(name, *variables)
11
+ str = @data[name]
12
+
13
+ variables.each_with_index do |v, index|
14
+ str = str.gsub('$' + (index + 1).to_s, v.to_s)
15
+ end
16
+
17
+ str
18
+ end
19
+ end
data/rakefile ADDED
@@ -0,0 +1,65 @@
1
+ require 'rake/packagetask'
2
+ require 'rake/testtask'
3
+ require 'rake/gempackagetask'
4
+ require File.join(File.dirname(__FILE__), 'lib/yamltext')
5
+ require 'rubygems'
6
+
7
+ # ���ʃp�����[�^
8
+ $init = YamlText.new(File.join(File.dirname(__FILE__), 'lib/init.yaml'))
9
+
10
+ # �p�b�P�[�W�t�@�C�����X�g
11
+ PKG_FILES = FileList["rakefile", "bin/*", "lib/*", "sample/*/*/*", "test/*"]
12
+
13
+ def cp_with_mkdir(src, dst)
14
+ dirname = File::dirname(dst)
15
+ mkdir_p dirname if (!FileTest.exist? dirname)
16
+ cp src, dst
17
+ end
18
+
19
+ # sourceforge���̃��|�W�g���ɃR�s�[
20
+ desc "copy rept/ to rept-sourceforge/"
21
+ task :publish do
22
+ PKG_FILES.each do |src|
23
+ cp_with_mkdir src, '../rept-sourceforge/' + src
24
+ end
25
+ end
26
+
27
+ # ���j�b�g�e�X�g���s
28
+ Rake::TestTask.new do |t|
29
+ t.libs << File.expand_path('lib')
30
+ t.test_files = FileList["test/test_*.rb"]
31
+ t.warning = true
32
+ t.verbose = true
33
+ end
34
+
35
+ # �p�b�P�[�W�쐬
36
+ Rake::PackageTask.new("rept", $init.get('version')) do |p|
37
+ p.package_dir = "./pkg"
38
+ p.package_files.include(PKG_FILES)
39
+ p.need_tar_gz = true
40
+ end
41
+
42
+ # gem�쐬
43
+ spec = Gem::Specification.new do |s|
44
+ s.platform = Gem::Platform::RUBY
45
+ s.name = 'rept'
46
+ s.summary = "rept summary"
47
+ s.description = <<EOF
48
+ rept description
49
+ EOF
50
+ s.author = "ongaeshi"
51
+ s.email = ""
52
+ s.homepage = "http://rubyforge.org/projects/rept/"
53
+ s.files = PKG_FILES
54
+ s.has_rdoc = true
55
+ s.rubyforge_project = "rept"
56
+ s.executables = ['rept', 'rept4diff']
57
+ s.default_executable = 'rept'
58
+ s.version = $init.get('version')
59
+ end
60
+
61
+ Rake::GemPackageTask.new(spec) do |pkg|
62
+ pkg.need_tar_gz = true
63
+ end
64
+
65
+ task :default => [:test, :repackage]
@@ -0,0 +1,47 @@
1
+ Args:
2
+ �N���X��
3
+ �N���X�̊T�v
4
+ Index: ReptName1.cpp
5
+ // --------------------------------------------------------------------------
6
+ /**
7
+ * ReptName2�A����
8
+ */
9
+
10
+ #include "ReptName1.h"
11
+
12
+ ReptName1::ReptName1()
13
+ : reptName1_(0)
14
+ {
15
+ }
16
+
17
+ void ReptName1::method1()
18
+ {
19
+ }
20
+
21
+ int ReptName1::method2() const
22
+ {
23
+ return 0
24
+ }
25
+
26
+ Index: ReptName1.h
27
+ // --------------------------------------------------------------------------
28
+ /**
29
+ * ReptName2�A�w�b�_
30
+ */
31
+
32
+ class ReptName1 {
33
+ public:
34
+ ReptName1();
35
+ ~ReptName1();
36
+
37
+ public:
38
+ void method1();
39
+ int method2() const;
40
+
41
+ private:
42
+ int reptName1_;
43
+ };
44
+
45
+ Index: makefile
46
+ --> ReptName1.cpp \
47
+ # @insert srcfiles
@@ -0,0 +1,6 @@
1
+ #
2
+ # makefile
3
+ #
4
+
5
+ SRC_FILES = \
6
+ # @insert srcfiles
@@ -0,0 +1,24 @@
1
+ // --------------------------------------------------------------------------
2
+ /**
3
+ * Root�A����
4
+ */
5
+
6
+ #include "Root.h"
7
+
8
+ // --------------------------------------------------------------------------
9
+ /**
10
+ * �R���X�g���N�^
11
+ */
12
+ Root::Root()
13
+ {
14
+ // @insert constructor
15
+ }
16
+
17
+ // --------------------------------------------------------------------------
18
+ /**
19
+ * �f�X�g���N�^
20
+ */
21
+ Root::~Root()
22
+ {
23
+ // @insert destructor
24
+ }
@@ -0,0 +1,14 @@
1
+ // --------------------------------------------------------------------------
2
+ /**
3
+ * Root�A�w�b�_
4
+ */
5
+
6
+ class Root {
7
+ public:
8
+ Root();
9
+ ~Root();
10
+
11
+ private:
12
+ // @insert member
13
+ };
14
+
@@ -0,0 +1,54 @@
1
+ Args:
2
+ �lj�����N���X
3
+ �N���X�̐���
4
+ Index: Root.h
5
+ --> ReptName1* reptName1_; // ReptName2
6
+ // @insert member
7
+ Index: Root.cpp
8
+ --> reptName1_ = new ReptName1();
9
+ // @insert constructor
10
+
11
+ // @insert destructor
12
+ --> delete reptName1_;
13
+ Index: makefile
14
+ --> reptname1 \
15
+ # @insert srcdirs
16
+ Index: reptname1/ReptName1.h
17
+ // --------------------------------------------------------------------------
18
+ /**
19
+ * ReptName2
20
+ */
21
+
22
+ class ReptName1 {
23
+ public:
24
+ ReptName1();
25
+ ~ReptName1() {}
26
+ };
27
+
28
+ Index: reptname1/ReptName1.cpp
29
+ // --------------------------------------------------------------------------
30
+ /**
31
+ * ReptName2
32
+ */
33
+
34
+ #include "ReptName1.h"
35
+
36
+ // --------------------------------------------------------------------------
37
+ /**
38
+ * �R���X�g���N�^
39
+ */
40
+ ReptName1::ReptName1()
41
+ {
42
+ }
43
+
44
+ Index: reptname1/makefile
45
+ #
46
+ # makefile
47
+ #
48
+
49
+ SRC_FILES = \
50
+ ReptName1.cpp \
51
+ # @insert srcfiles
52
+
53
+ SRC_DIRS = \
54
+ # @insert srcdirs
@@ -0,0 +1,9 @@
1
+ #
2
+ # makefile
3
+ #
4
+
5
+ SRC_FILES = \
6
+ # @insert srcfiles
7
+
8
+ SRC_DIRS = \
9
+ # @insert srcdirs
@@ -0,0 +1,30 @@
1
+ enum {
2
+ Kind_High_Attack,
3
+ Kind_High_Term
4
+ };
5
+
6
+ const char* HighSymbol[] = {
7
+ "Attack",
8
+ // @insert High
9
+ };
10
+
11
+ enum {
12
+ Kind_Middle_Defence,
13
+ Kind_Middle_Term
14
+ };
15
+
16
+ const char* MiddleSymbol[] = {
17
+ "Defence",
18
+ // @insert Middle
19
+ };
20
+
21
+ enum {
22
+ Kind_Low_Escape,
23
+ Kind_Low_Term
24
+ };
25
+
26
+ const char* LowSymbol[] = {
27
+ "Escape",
28
+ // @insert Low
29
+ };
30
+
@@ -0,0 +1,24 @@
1
+ Args:
2
+ �lj�����f�[�^
3
+ �f�[�^���(High or Middle or Low)
4
+ Index: data.h
5
+ --> Kind_ReptName2_ReptName1,
6
+ Kind_ReptName2_Term
7
+
8
+ --> "ReptName1",
9
+ // @insert ReptName2
10
+ Index: ReptName1.h
11
+ // --------------------------------------------------------------------------
12
+ /**
13
+ * ReptName1(�D��x ReptName2)
14
+ */
15
+
16
+ class ReptName1 {
17
+ public:
18
+ ReptName1() {}
19
+ ~ReptName1() {}
20
+
21
+ public:
22
+ void doReptName1() {}
23
+ };
24
+
@@ -0,0 +1,98 @@
1
+ Args:
2
+ �A�v����(�L������)
3
+ Index: reptname1/rakefile
4
+ require 'rake/packagetask'
5
+ require 'rake/testtask'
6
+ require 'rake/gempackagetask'
7
+
8
+ # �o�[�W�����ԍ�
9
+ VERSION = '0.0.0'
10
+
11
+ # �p�b�P�[�W�t�@�C�����X�g
12
+ PKG_FILES = FileList["rakefile", "bin/*", "lib/*", "test/*"]
13
+
14
+ # ���j�b�g�e�X�g���s
15
+ Rake::TestTask.new do |t|
16
+ t.libs << File.expand_path('lib')
17
+ t.test_files = FileList["test/test_*.rb"]
18
+ t.warning = true
19
+ t.verbose = true
20
+ end
21
+
22
+ # �p�b�P�[�W�쐬
23
+ Rake::PackageTask.new("reptname1", VERSION) do |p|
24
+ p.package_dir = "./pkg"
25
+ p.package_files.include(PKG_FILES)
26
+ p.need_tar_gz = true
27
+ end
28
+
29
+ # gem�쐬
30
+ spec = Gem::Specification.new do |s|
31
+ s.platform = Gem::Platform::RUBY
32
+ s.name = 'reptname1'
33
+ s.summary = "reptname1 summary"
34
+ s.description = "reptname1 description"
35
+ s.author = ""
36
+ s.email = ""
37
+ s.homepage = ""
38
+ s.files = PKG_FILES
39
+ s.has_rdoc = true
40
+ s.rubyforge_project = "reptname1"
41
+ s.executables = ['reptname1']
42
+ s.default_executable = 'reptname1'
43
+ s.version = VERSION
44
+ end
45
+
46
+ Rake::GemPackageTask.new(spec) do |pkg|
47
+ pkg.need_tar_gz = true
48
+ end
49
+
50
+ task :default => [:test, :repackage]
51
+
52
+ Index: reptname1/bin/reptname1
53
+ #!/usr/bin/env ruby
54
+
55
+ begin
56
+ require 'reptname1'
57
+ rescue LoadError
58
+ require 'rubygems'
59
+ require 'reptname1'
60
+ end
61
+
62
+ reptname1
63
+ Index: reptname1/bin/reptname1_local
64
+ #!/usr/bin/env ruby
65
+
66
+ require File.join(File.dirname(__FILE__), '../lib/hoge')
67
+
68
+ reptname1
69
+ Index: reptname1/lib/reptname1.rb
70
+ require 'optparse'
71
+
72
+ def reptname1
73
+ opt = OptionParser.new('reptname1 [option]')
74
+ opt.parse!
75
+
76
+ if (ARGV.size > 0)
77
+ # ReptName1���C������
78
+ else
79
+ puts opt.help
80
+ end
81
+ end
82
+ Index: reptname1/test/test_reptname1.rb
83
+ require 'test/unit'
84
+ require 'reptname1'
85
+
86
+ class TC_ReptName1 < Test::Unit::TestCase
87
+ def setup
88
+ end
89
+
90
+ def teardown
91
+ end
92
+
93
+ def test_reptname1
94
+ assert_equal(0, 0)
95
+ end
96
+ end
97
+
98
+
data/test/addTest.rept ADDED
@@ -0,0 +1,22 @@
1
+ Args:
2
+ �e�X�g�N���X��
3
+ Index: test.rb
4
+ -->require 'test_reptname1.rb'
5
+ # @insert
6
+ Index: test_reptname1.rb
7
+ require 'test/unit'
8
+ require '../bin/reptname1'
9
+
10
+ class TC_ReptName1 < Test::Unit::TestCase
11
+ def setup
12
+ # @obj = ReptName1.new
13
+ end
14
+
15
+ def teardown
16
+ end
17
+
18
+ def test_ReptName1
19
+ # assert_equal("ReptName1", @obj.ReptName1)
20
+ end
21
+ end
22
+
@@ -0,0 +1,10 @@
1
+ 111111
2
+ 222222
3
+ 333333
4
+ 444444
5
+ 555555
6
+ 666666
7
+ 777777
8
+ 888888
9
+ 999999
10
+ 000000
@@ -0,0 +1,11 @@
1
+ 111111
2
+ ******
3
+ 222222
4
+ 333333
5
+ 444444
6
+ 555555
7
+ 666666
8
+ 777777
9
+ 888888
10
+ 999999
11
+ 000000
@@ -0,0 +1,12 @@
1
+ 111111
2
+ ******
3
+ ******
4
+ 222222
5
+ 333333
6
+ 444444
7
+ 555555
8
+ 666666
9
+ 777777
10
+ 888888
11
+ 999999
12
+ 000000
@@ -0,0 +1,12 @@
1
+ 111111
2
+ ******
3
+ ******
4
+ 222222
5
+ 333333
6
+ 444444
7
+ 555555
8
+ 666666
9
+ 777777
10
+ 888888
11
+ 999999
12
+ 000000