narabi 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +22 -0
- data/README.md +4 -0
- data/features/parser.feature +9 -0
- data/features/step_definitions/parser_steps.rb +9 -1
- data/lib/narabi/parser.rb +7 -0
- data/lib/narabi/version.rb +1 -1
- metadata +2 -1
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2012 Technical Group Laboratory, Inc.
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
data/features/parser.feature
CHANGED
@@ -50,6 +50,14 @@ end
|
|
50
50
|
@output = Narabi::Instance.parse_line(@input)
|
51
51
|
end
|
52
52
|
|
53
|
-
ならば /^インスタンスは"(
|
53
|
+
ならば /^インスタンスは"(#{CAPTURE_STRING})"となること$/ do |expected_name|
|
54
54
|
@output[:name].should == expected_name
|
55
55
|
end
|
56
|
+
|
57
|
+
もし /^一行のタイトル文字列を解析する$/ do
|
58
|
+
@output = Narabi::Diagram.parse_line(@input)
|
59
|
+
end
|
60
|
+
|
61
|
+
ならば /^タイトルは"(#{CAPTURE_STRING})"となること$/ do |expected_title|
|
62
|
+
@output[:title].should == expected_title
|
63
|
+
end
|
data/lib/narabi/parser.rb
CHANGED
@@ -3,6 +3,7 @@ module Narabi
|
|
3
3
|
RESPONSE_REGEXP = /^(?<from>.+)-->(?<to>.+):\s?(?<body>.*)/
|
4
4
|
NOTE_REGEXP = /^note\s(?<from>(\s|\b|\d|\w|\W|^:)+):\s?(?<body>.*)/
|
5
5
|
INSTANCE_REGEXP = /^instance\s?(?<name>.+)/
|
6
|
+
TITLE_REGEXP = /^title\s(?<title>.+)/
|
6
7
|
|
7
8
|
class Base
|
8
9
|
def self.try_to_create(regexp, src)
|
@@ -47,6 +48,12 @@ module Narabi
|
|
47
48
|
end
|
48
49
|
end
|
49
50
|
|
51
|
+
class Diagram
|
52
|
+
def self.parse_line(src)
|
53
|
+
msg = Base.try_to_create(TITLE_REGEXP, src)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
50
57
|
def self.parse_line(src)
|
51
58
|
if msg = Message.create_return(src)
|
52
59
|
return msg
|
data/lib/narabi/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: narabi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -53,6 +53,7 @@ files:
|
|
53
53
|
- .gitignore
|
54
54
|
- .travis.yml
|
55
55
|
- Gemfile
|
56
|
+
- LICENSE
|
56
57
|
- README.md
|
57
58
|
- Rakefile
|
58
59
|
- features/parser.feature
|