ruby-wsd 0.0.3
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/CHANGELOG +5 -0
- data/Manifest +7 -0
- data/README.rdoc +79 -0
- data/Rakefile +17 -0
- data/bin/wsd +39 -0
- data/lib/wsd.rb +47 -0
- data/ruby-wsd.gemspec +33 -0
- metadata +67 -0
data/CHANGELOG
ADDED
data/Manifest
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
= ruby-wsd
|
2
|
+
|
3
|
+
* http://github.com/calas/ruby-wsd/tree/master/README.rdoc
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
Ruby bindings for the http://www.websequencediagrams.com API
|
8
|
+
|
9
|
+
== FEATURES/PROBLEMS:
|
10
|
+
|
11
|
+
Features:
|
12
|
+
|
13
|
+
* Diagrams can be written to a file with the +write+ instance method.
|
14
|
+
* Diagrams can be embbeded in HTML using the +to_html+ instance method.
|
15
|
+
|
16
|
+
Problems:
|
17
|
+
|
18
|
+
* Gem is not tested
|
19
|
+
* Source is undocumented
|
20
|
+
|
21
|
+
== SYNOPSIS:
|
22
|
+
|
23
|
+
require 'rubygems'
|
24
|
+
require 'wsd'
|
25
|
+
|
26
|
+
diagram = <<-DIAGRAM
|
27
|
+
note over Alice,Bob: Example diagram
|
28
|
+
Alice->Bob: look this beatiful diagrams
|
29
|
+
note right of Bob
|
30
|
+
Bob realizes he is tired of clicking
|
31
|
+
in MS Visio for creating diagrams
|
32
|
+
end note
|
33
|
+
Bob-->Alice: Thanks
|
34
|
+
DIAGRAM
|
35
|
+
|
36
|
+
d = Wsd.new(diagram, 'napkin')
|
37
|
+
d.write("diagram.png")
|
38
|
+
d.to_html
|
39
|
+
|
40
|
+
== REQUIREMENTS:
|
41
|
+
|
42
|
+
* None.
|
43
|
+
|
44
|
+
== INSTALL:
|
45
|
+
|
46
|
+
You can install +ruby-wsd+ directly from github:
|
47
|
+
|
48
|
+
sudo gem install calas-ruby-wsd -s http://gems.github.com
|
49
|
+
|
50
|
+
or you can compile sources
|
51
|
+
|
52
|
+
git clone git://github.com/calas/ruby-wsd.git
|
53
|
+
cd ruby-wsd
|
54
|
+
rake install
|
55
|
+
|
56
|
+
== LICENSE:
|
57
|
+
|
58
|
+
(The MIT License)
|
59
|
+
|
60
|
+
Copyright (c) 2008 Jorge Calás Lozano
|
61
|
+
|
62
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
63
|
+
a copy of this software and associated documentation files (the
|
64
|
+
'Software'), to deal in the Software without restriction, including
|
65
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
66
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
67
|
+
permit persons to whom the Software is furnished to do so, subject to
|
68
|
+
the following conditions:
|
69
|
+
|
70
|
+
The above copyright notice and this permission notice shall be
|
71
|
+
included in all copies or substantial portions of the Software.
|
72
|
+
|
73
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
74
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
75
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
76
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
77
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
78
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
79
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'echoe'
|
4
|
+
|
5
|
+
# Generate all the Rake tasks
|
6
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
7
|
+
Echoe.new('ruby-wsd') do |p|
|
8
|
+
p.description = 'Ruby bindings for http://www.websequencediagrams.com'
|
9
|
+
p.project = 'ruby-wsd'
|
10
|
+
p.url = 'http://github.com/calas/ruby-wsd/tree/master'
|
11
|
+
p.author = 'Jorge Calás Lozano'
|
12
|
+
p.email = 'calas@qvitta.net'
|
13
|
+
p.ignore_pattern = ['tmp/*']
|
14
|
+
p.development_dependencies = []
|
15
|
+
end
|
16
|
+
|
17
|
+
Dir['tasks/**/*.rake'].each { |t| load t }
|
data/bin/wsd
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems'
|
3
|
+
require 'wsd'
|
4
|
+
require 'optparse'
|
5
|
+
require 'pp'
|
6
|
+
|
7
|
+
options = {:style => 'default'}
|
8
|
+
OptionParser.new do |opts|
|
9
|
+
opts.banner = "Usage: wsd [options]"
|
10
|
+
|
11
|
+
opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
|
12
|
+
options[:verbose] = v
|
13
|
+
end
|
14
|
+
|
15
|
+
opts.on("-f [FILE]", "--file [FILE]", "Input file") do |f|
|
16
|
+
options[:file] = f
|
17
|
+
end
|
18
|
+
|
19
|
+
opts.on("-o [FILE]", "--output-file [FILE]", "Output file") do |f|
|
20
|
+
options[:outfile] = f
|
21
|
+
end
|
22
|
+
|
23
|
+
opts.on("-s [STYLE]", "--style [STYLE]", "Diagram Style") do |s|
|
24
|
+
options[:style] = s
|
25
|
+
end
|
26
|
+
|
27
|
+
opts.on("--all-styles", "Show all available styles") do |s|
|
28
|
+
options[:show_styles] = s
|
29
|
+
end
|
30
|
+
end.parse!
|
31
|
+
|
32
|
+
if options[:show_styles]
|
33
|
+
puts "Available styles:"
|
34
|
+
puts Wsd::STYLES.join(', ')
|
35
|
+
exit
|
36
|
+
end
|
37
|
+
|
38
|
+
d = Wsd.new(File.read(options[:file]), options[:style])
|
39
|
+
d.write(options[:outfile])
|
data/lib/wsd.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'uri'
|
3
|
+
require 'open-uri'
|
4
|
+
require 'yaml'
|
5
|
+
|
6
|
+
class Wsd
|
7
|
+
STYLES = %w(default earth modern-blue mscgen omegapple qsd rose roundgreen napkin)
|
8
|
+
BASE_URL = 'http://www.websequencediagrams.com'
|
9
|
+
|
10
|
+
def initialize(text, style=STYLES[0])
|
11
|
+
@style = style
|
12
|
+
@text = text
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_html
|
16
|
+
output = "<div class='wsd' wsd_style='#{@style}'><pre>\n"
|
17
|
+
output << @text
|
18
|
+
output << "\n</pre></div>"
|
19
|
+
output << "<script type='text/javascript' src='http://www.websequencediagrams.com/service.js'></script>"
|
20
|
+
output
|
21
|
+
end
|
22
|
+
|
23
|
+
def write(file=nil)
|
24
|
+
file = file || default_file
|
25
|
+
File.open(file, "w+") { |f| f << open(diagram_url).read }
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def diagram
|
31
|
+
YAML.load(Net::HTTP.post_form(form_post_url, :style => @style, :message => @text).body)
|
32
|
+
end
|
33
|
+
|
34
|
+
def form_post_url
|
35
|
+
URI.parse("#{BASE_URL}/index.php")
|
36
|
+
end
|
37
|
+
|
38
|
+
def diagram_url
|
39
|
+
"#{BASE_URL}/#{diagram['img']}"
|
40
|
+
end
|
41
|
+
|
42
|
+
def default_file
|
43
|
+
diagram_url.match(/img=(.+)$/)
|
44
|
+
file = "#{$1}.png"
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
data/ruby-wsd.gemspec
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{ruby-wsd}
|
5
|
+
s.version = "0.0.3"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Jorge Cal\303\241s Lozano"]
|
9
|
+
s.date = %q{2008-11-26}
|
10
|
+
s.default_executable = %q{wsd}
|
11
|
+
s.description = %q{Ruby bindings for http://www.websequencediagrams.com}
|
12
|
+
s.email = %q{calas@qvitta.net}
|
13
|
+
s.executables = ["wsd"]
|
14
|
+
s.extra_rdoc_files = ["bin/wsd", "CHANGELOG", "README.rdoc", "lib/wsd.rb"]
|
15
|
+
s.files = ["bin/wsd", "CHANGELOG", "README.rdoc", "Manifest", "Rakefile", "lib/wsd.rb", "ruby-wsd.gemspec"]
|
16
|
+
s.has_rdoc = true
|
17
|
+
s.homepage = %q{http://github.com/calas/ruby-wsd/tree/master}
|
18
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Ruby-wsd", "--main", "README.rdoc"]
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
s.rubyforge_project = %q{ruby-wsd}
|
21
|
+
s.rubygems_version = %q{1.3.1}
|
22
|
+
s.summary = %q{Ruby bindings for http://www.websequencediagrams.com}
|
23
|
+
|
24
|
+
if s.respond_to? :specification_version then
|
25
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
26
|
+
s.specification_version = 2
|
27
|
+
|
28
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
29
|
+
else
|
30
|
+
end
|
31
|
+
else
|
32
|
+
end
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruby-wsd
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- "Jorge Cal\xC3\xA1s Lozano"
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-11-26 00:00:00 +01:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Ruby bindings for http://www.websequencediagrams.com
|
17
|
+
email: calas@qvitta.net
|
18
|
+
executables:
|
19
|
+
- wsd
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- bin/wsd
|
24
|
+
- CHANGELOG
|
25
|
+
- README.rdoc
|
26
|
+
- lib/wsd.rb
|
27
|
+
files:
|
28
|
+
- bin/wsd
|
29
|
+
- CHANGELOG
|
30
|
+
- README.rdoc
|
31
|
+
- Manifest
|
32
|
+
- Rakefile
|
33
|
+
- lib/wsd.rb
|
34
|
+
- ruby-wsd.gemspec
|
35
|
+
has_rdoc: true
|
36
|
+
homepage: http://github.com/calas/ruby-wsd/tree/master
|
37
|
+
post_install_message:
|
38
|
+
rdoc_options:
|
39
|
+
- --line-numbers
|
40
|
+
- --inline-source
|
41
|
+
- --title
|
42
|
+
- Ruby-wsd
|
43
|
+
- --main
|
44
|
+
- README.rdoc
|
45
|
+
require_paths:
|
46
|
+
- lib
|
47
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: "0"
|
52
|
+
version:
|
53
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: "1.2"
|
58
|
+
version:
|
59
|
+
requirements: []
|
60
|
+
|
61
|
+
rubyforge_project: ruby-wsd
|
62
|
+
rubygems_version: 1.3.1
|
63
|
+
signing_key:
|
64
|
+
specification_version: 2
|
65
|
+
summary: Ruby bindings for http://www.websequencediagrams.com
|
66
|
+
test_files: []
|
67
|
+
|