wireframe 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Bryan Liles
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,29 @@
1
+ = wireframe
2
+
3
+ Generate images to use in wireframe document or website
4
+
5
+ $ wireframe image <size> <output>
6
+
7
+ where:
8
+
9
+ size = w+h -- 80+10 or 800+200
10
+ output = path where you want it to go
11
+
12
+ == Status
13
+
14
+ I'm sure this is broken for real right now. Error checking is
15
+ minimal.
16
+
17
+ == Note on Patches/Pull Requests
18
+
19
+ * Fork the project.
20
+ * Make your feature addition or bug fix.
21
+ * Add tests for it. This is important so I don't break it in a
22
+ future version unintentionally.
23
+ * Commit, do not mess with rakefile, version, or history.
24
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
25
+ * Send me a pull request. Bonus points for topic branches.
26
+
27
+ == Copyright
28
+
29
+ Copyright (c) 2010 Bryan Liles. See LICENSE for details.
@@ -0,0 +1,79 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "wireframe"
8
+ gem.summary = "Generate images suitable for wireframes"
9
+ gem.description = "Generate images suitable for wireframes"
10
+ gem.email = "bryan@osesm.com"
11
+ gem.homepage = "http://github.com/bryanl/wireframe"
12
+ gem.authors = ["Bryan Liles"]
13
+ gem.add_dependency('rmagick', '>= 2.13.1')
14
+ gem.add_development_dependency('rr')
15
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
16
+ end
17
+ Jeweler::GemcutterTasks.new
18
+ rescue LoadError
19
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
20
+ end
21
+
22
+ require 'rake/testtask'
23
+ Rake::TestTask.new(:test) do |test|
24
+ test.libs << 'lib' << 'test'
25
+ test.pattern = 'test/**/test_*.rb'
26
+ test.verbose = true
27
+ end
28
+
29
+ begin
30
+ require 'rcov/rcovtask'
31
+ Rcov::RcovTask.new do |test|
32
+ test.libs << 'test'
33
+ test.pattern = 'test/**/test_*.rb'
34
+ test.verbose = true
35
+ end
36
+ rescue LoadError
37
+ task :rcov do
38
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
39
+ end
40
+ end
41
+
42
+ task :test => :check_dependencies
43
+
44
+ begin
45
+ require 'reek/adapters/rake_task'
46
+ Reek::RakeTask.new do |t|
47
+ t.fail_on_error = true
48
+ t.verbose = false
49
+ t.source_files = 'lib/**/*.rb'
50
+ end
51
+ rescue LoadError
52
+ task :reek do
53
+ abort "Reek is not available. In order to run reek, you must: sudo gem install reek"
54
+ end
55
+ end
56
+
57
+ begin
58
+ require 'roodi'
59
+ require 'roodi_task'
60
+ RoodiTask.new do |t|
61
+ t.verbose = false
62
+ end
63
+ rescue LoadError
64
+ task :roodi do
65
+ abort "Roodi is not available. In order to run roodi, you must: sudo gem install roodi"
66
+ end
67
+ end
68
+
69
+ task :default => :test
70
+
71
+ require 'rake/rdoctask'
72
+ Rake::RDocTask.new do |rdoc|
73
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
74
+
75
+ rdoc.rdoc_dir = 'rdoc'
76
+ rdoc.title = "wireframe #{version}"
77
+ rdoc.rdoc_files.include('README*')
78
+ rdoc.rdoc_files.include('lib/**/*.rb')
79
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
4
+ require 'wireframe'
5
+
6
+ exit Wireframe::Application.run!(*ARGV)
7
+
@@ -0,0 +1,8 @@
1
+ require 'RMagick'
2
+
3
+ require 'wireframe/image'
4
+ require 'wireframe/math'
5
+ require 'wireframe/application'
6
+
7
+ module Wireframe
8
+ end
@@ -0,0 +1,17 @@
1
+ module Wireframe
2
+ class Application
3
+ class << self
4
+ def run!(*arguments)
5
+ if arguments.size != 3
6
+ puts "usage: wireframe image <size> <output file>"
7
+ exit 1
8
+ end
9
+
10
+ class_name, coordinates, output = arguments
11
+ sketcher = Wireframe.const_get class_name.capitalize
12
+ image = sketcher.new coordinates
13
+ File.open(output, 'w') {|f| f.write(image.draw)}
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,37 @@
1
+ module Wireframe
2
+ class Image
3
+ def initialize(coordinates)
4
+ math = Math.new(coordinates)
5
+ @height = math.height
6
+ @width = math.width
7
+
8
+ @canvas = Magick::Image.new(@width, @height) do
9
+ self.background_color = 'white'
10
+ end
11
+
12
+ end
13
+
14
+ def draw
15
+ gc = Magick::Draw.new
16
+ gc.stroke('black')
17
+
18
+ draw_lines(gc)
19
+ draw_box(gc)
20
+
21
+ gc.draw(@canvas)
22
+ @canvas.to_blob {self.format = "PNG"}
23
+ end
24
+
25
+ private
26
+
27
+ def draw_box(gc)
28
+ gc.fill_opacity(0)
29
+ gc.rectangle(1, 1, @width - 1, @height - 1)
30
+ end
31
+
32
+ def draw_lines(gc)
33
+ gc.line(1, 1, @width - 1, @height - 1)
34
+ gc.line(1, @height - 1, @width - 1, 1)
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,21 @@
1
+ module Wireframe
2
+ class Math
3
+ def initialize(coordinates)
4
+ @coordinates = coordinates
5
+ end
6
+
7
+ def height
8
+ match[2].to_i
9
+ end
10
+
11
+ def width
12
+ match[1].to_i
13
+ end
14
+
15
+ private
16
+
17
+ def match
18
+ @coordinates.match(/^(\d+)\+(\d+)$/)
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,29 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+
4
+ require 'rr'
5
+
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
8
+ require 'wireframe'
9
+
10
+ class Test::Unit::TestCase
11
+ include RR::Adapters::TestUnit
12
+
13
+
14
+ class << self
15
+ def test(name, &block)
16
+ test_name = "test_#{name.gsub(/\s+/,'_')}".to_sym
17
+ defined = instance_method(test_name) rescue false
18
+ raise "#{test_name} is already defined in #{self}" if defined
19
+ if block_given?
20
+ define_method(test_name, &block)
21
+ else
22
+ define_method(test_name) do
23
+ flunk "No implementation provided for #{name}"
24
+ end
25
+ end
26
+ end
27
+ end
28
+
29
+ end
@@ -0,0 +1,26 @@
1
+ require 'helper'
2
+
3
+ class TestImage < Test::Unit::TestCase
4
+
5
+ test "create an image given the proper coordinates" do
6
+ image = Wireframe::Image.new("50+10").draw
7
+ assert_not_nil image
8
+ end
9
+
10
+ test "should draw an image of the proper width" do
11
+ image = Wireframe::Image.new("50+10").draw
12
+ assert_equal 50, image_from_string(image).columns
13
+ end
14
+
15
+ test "should draw an image of the proper height" do
16
+ image = Wireframe::Image.new("50+10").draw
17
+ assert_equal 10, image_from_string(image).rows
18
+ end
19
+
20
+ private
21
+
22
+ def image_from_string(string)
23
+ Magick::Image.from_blob(string)[0]
24
+ end
25
+
26
+ end
@@ -0,0 +1,12 @@
1
+ require 'helper'
2
+
3
+ class TestMath < Test::Unit::TestCase
4
+
5
+ test "create the length and width from a coordinate" do
6
+ math = Wireframe::Math.new "50+10"
7
+ assert_equal 10, math.height
8
+ assert_equal 50, math.width
9
+ end
10
+
11
+ end
12
+
@@ -0,0 +1,65 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{wireframe}
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Bryan Liles"]
12
+ s.date = %q{2010-06-21}
13
+ s.default_executable = %q{wireframe}
14
+ s.description = %q{Generate images suitable for wireframes}
15
+ s.email = %q{bryan@osesm.com}
16
+ s.executables = ["wireframe"]
17
+ s.extra_rdoc_files = [
18
+ "LICENSE",
19
+ "README.rdoc"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ ".gitignore",
24
+ "LICENSE",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "bin/wireframe",
29
+ "lib/wireframe.rb",
30
+ "lib/wireframe/application.rb",
31
+ "lib/wireframe/image.rb",
32
+ "lib/wireframe/math.rb",
33
+ "test/helper.rb",
34
+ "test/test_image.rb",
35
+ "test/test_math.rb",
36
+ "wireframe.gemspec"
37
+ ]
38
+ s.homepage = %q{http://github.com/bryanl/wireframe}
39
+ s.rdoc_options = ["--charset=UTF-8"]
40
+ s.require_paths = ["lib"]
41
+ s.rubygems_version = %q{1.3.7}
42
+ s.summary = %q{Generate images suitable for wireframes}
43
+ s.test_files = [
44
+ "test/helper.rb",
45
+ "test/test_image.rb",
46
+ "test/test_math.rb"
47
+ ]
48
+
49
+ if s.respond_to? :specification_version then
50
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
51
+ s.specification_version = 3
52
+
53
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
54
+ s.add_runtime_dependency(%q<rmagick>, [">= 2.13.1"])
55
+ s.add_development_dependency(%q<rr>, [">= 0"])
56
+ else
57
+ s.add_dependency(%q<rmagick>, [">= 2.13.1"])
58
+ s.add_dependency(%q<rr>, [">= 0"])
59
+ end
60
+ else
61
+ s.add_dependency(%q<rmagick>, [">= 2.13.1"])
62
+ s.add_dependency(%q<rr>, [">= 0"])
63
+ end
64
+ end
65
+
metadata ADDED
@@ -0,0 +1,113 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: wireframe
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Bryan Liles
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-06-21 00:00:00 -04:00
19
+ default_executable: wireframe
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: rmagick
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 57
30
+ segments:
31
+ - 2
32
+ - 13
33
+ - 1
34
+ version: 2.13.1
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: rr
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 3
46
+ segments:
47
+ - 0
48
+ version: "0"
49
+ type: :development
50
+ version_requirements: *id002
51
+ description: Generate images suitable for wireframes
52
+ email: bryan@osesm.com
53
+ executables:
54
+ - wireframe
55
+ extensions: []
56
+
57
+ extra_rdoc_files:
58
+ - LICENSE
59
+ - README.rdoc
60
+ files:
61
+ - .document
62
+ - .gitignore
63
+ - LICENSE
64
+ - README.rdoc
65
+ - Rakefile
66
+ - VERSION
67
+ - bin/wireframe
68
+ - lib/wireframe.rb
69
+ - lib/wireframe/application.rb
70
+ - lib/wireframe/image.rb
71
+ - lib/wireframe/math.rb
72
+ - test/helper.rb
73
+ - test/test_image.rb
74
+ - test/test_math.rb
75
+ - wireframe.gemspec
76
+ has_rdoc: true
77
+ homepage: http://github.com/bryanl/wireframe
78
+ licenses: []
79
+
80
+ post_install_message:
81
+ rdoc_options:
82
+ - --charset=UTF-8
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ hash: 3
91
+ segments:
92
+ - 0
93
+ version: "0"
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ none: false
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ hash: 3
100
+ segments:
101
+ - 0
102
+ version: "0"
103
+ requirements: []
104
+
105
+ rubyforge_project:
106
+ rubygems_version: 1.3.7
107
+ signing_key:
108
+ specification_version: 3
109
+ summary: Generate images suitable for wireframes
110
+ test_files:
111
+ - test/helper.rb
112
+ - test/test_image.rb
113
+ - test/test_math.rb