calas-ruby-wsd 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (7) hide show
  1. data/CHANGELOG +1 -0
  2. data/Manifest +5 -0
  3. data/README.rdoc +56 -0
  4. data/Rakefile +16 -0
  5. data/lib/wsd.rb +48 -0
  6. data/ruby-wsd.gemspec +31 -0
  7. metadata +65 -0
data/CHANGELOG ADDED
@@ -0,0 +1 @@
1
+ v0.0.1. Initial version. Support for writing diagrams to png files and embbeding the diagrams in html.
data/Manifest ADDED
@@ -0,0 +1,5 @@
1
+ CHANGELOG
2
+ README.rdoc
3
+ Rakefile
4
+ lib/wsd.rb
5
+ Manifest
data/README.rdoc ADDED
@@ -0,0 +1,56 @@
1
+ = ruby-wsd
2
+
3
+ * http://github.com/calas/ruby-wsd/
4
+
5
+ == DESCRIPTION:
6
+
7
+ Ruby bindings for the http://www.websequencediagrams.com API
8
+
9
+ == FEATURES/PROBLEMS:
10
+
11
+ * FIX (list of features or problems)
12
+
13
+ == SYNOPSIS:
14
+
15
+ FIX (code sample of usage)
16
+
17
+ == REQUIREMENTS:
18
+
19
+ * FIX (list of requirements)
20
+
21
+ == INSTALL:
22
+
23
+ You can install +ruby-wsd+ directly from github:
24
+
25
+ sudo gem install calas-ruby-wsd -s http://gems.github.com
26
+
27
+ or you can compile sources
28
+
29
+ git clone <repo>
30
+ cd ruby-wsd
31
+ rake install
32
+
33
+ == LICENSE:
34
+
35
+ (The MIT License)
36
+
37
+ Copyright (c) 2008 Jorge Calás Lozano
38
+
39
+ Permission is hereby granted, free of charge, to any person obtaining
40
+ a copy of this software and associated documentation files (the
41
+ 'Software'), to deal in the Software without restriction, including
42
+ without limitation the rights to use, copy, modify, merge, publish,
43
+ distribute, sublicense, and/or sell copies of the Software, and to
44
+ permit persons to whom the Software is furnished to do so, subject to
45
+ the following conditions:
46
+
47
+ The above copyright notice and this permission notice shall be
48
+ included in all copies or substantial portions of the Software.
49
+
50
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
51
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
52
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
53
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
54
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
55
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
56
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,16 @@
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.url = 'http://github.com/calas/ruby-wsd/tree/master'
10
+ p.author = 'Jorge Calás Lozano'
11
+ p.email = 'calas@qvitta.net'
12
+ p.ignore_pattern = ['tmp/*']
13
+ p.development_dependencies = []
14
+ end
15
+
16
+ Dir['tasks/**/*.rake'].each { |t| load t }
data/lib/wsd.rb ADDED
@@ -0,0 +1,48 @@
1
+ require 'net/http'
2
+ require 'uri'
3
+ require 'open-uri'
4
+ require 'yaml'
5
+
6
+ class Wsd
7
+ VERSION = '0.0.1'
8
+ STYLES = %w(default earth modern-blue mscgen omegapple qsd rose roundgreen napkin)
9
+ BASE_URL = 'http://www.websequencediagrams.com'
10
+
11
+ def initialize(text, style=STYLES[0])
12
+ @style = style
13
+ @text = text
14
+ end
15
+
16
+ def to_html
17
+ output = "<div class='wsd' wsd_style='#{@style}'><pre>\n"
18
+ output << @text
19
+ output << "\n</pre></div>"
20
+ output << "<script type='text/javascript' src='http://www.websequencediagrams.com/service.js'></script>"
21
+ output
22
+ end
23
+
24
+ def write(file=nil)
25
+ file = file || default_file
26
+ File.open(file, "w+") { |f| f << open(diagram_url).read }
27
+ end
28
+
29
+ private
30
+
31
+ def diagram
32
+ YAML.load(Net::HTTP.post_form(form_post_url, :style => @style, :message => @text).body)
33
+ end
34
+
35
+ def form_post_url
36
+ URI.parse("#{BASE_URL}/index.php")
37
+ end
38
+
39
+ def diagram_url
40
+ "#{BASE_URL}/#{diagram['img']}"
41
+ end
42
+
43
+ def default_file
44
+ diagram_url.match(/img=(.+)$/)
45
+ file = "#{$1}.png"
46
+ end
47
+
48
+ end
data/ruby-wsd.gemspec ADDED
@@ -0,0 +1,31 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{ruby-wsd}
5
+ s.version = "0.0.1"
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-23}
10
+ s.description = %q{Ruby bindings for http://www.websequencediagrams.com}
11
+ s.email = %q{calas@qvitta.net}
12
+ s.extra_rdoc_files = ["CHANGELOG", "README.rdoc", "lib/wsd.rb"]
13
+ s.files = ["CHANGELOG", "README.rdoc", "Rakefile", "lib/wsd.rb", "Manifest", "ruby-wsd.gemspec"]
14
+ s.has_rdoc = true
15
+ s.homepage = %q{http://github.com/calas/ruby-wsd/tree/master}
16
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Ruby-wsd", "--main", "README.rdoc"]
17
+ s.require_paths = ["lib"]
18
+ s.rubyforge_project = %q{ruby-wsd}
19
+ s.rubygems_version = %q{1.3.1}
20
+ s.summary = %q{Ruby bindings for http://www.websequencediagrams.com}
21
+
22
+ if s.respond_to? :specification_version then
23
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
24
+ s.specification_version = 2
25
+
26
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
27
+ else
28
+ end
29
+ else
30
+ end
31
+ end
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: calas-ruby-wsd
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - "Jorge Cal\xC3\xA1s Lozano"
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-11-23 00:00:00 -08:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Ruby bindings for http://www.websequencediagrams.com
17
+ email: calas@qvitta.net
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - CHANGELOG
24
+ - README.rdoc
25
+ - lib/wsd.rb
26
+ files:
27
+ - CHANGELOG
28
+ - README.rdoc
29
+ - Rakefile
30
+ - lib/wsd.rb
31
+ - Manifest
32
+ - ruby-wsd.gemspec
33
+ has_rdoc: true
34
+ homepage: http://github.com/calas/ruby-wsd/tree/master
35
+ post_install_message:
36
+ rdoc_options:
37
+ - --line-numbers
38
+ - --inline-source
39
+ - --title
40
+ - Ruby-wsd
41
+ - --main
42
+ - README.rdoc
43
+ require_paths:
44
+ - lib
45
+ required_ruby_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: "0"
50
+ version:
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: "1.2"
56
+ version:
57
+ requirements: []
58
+
59
+ rubyforge_project: ruby-wsd
60
+ rubygems_version: 1.2.0
61
+ signing_key:
62
+ specification_version: 2
63
+ summary: Ruby bindings for http://www.websequencediagrams.com
64
+ test_files: []
65
+