mockup 0.0.2

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ Copyright (c) 2010 Robert R Evans
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.
21
+
data/README.textile ADDED
@@ -0,0 +1,29 @@
1
+ h1. Mockup
2
+
3
+ h2. Install
4
+
5
+ gem install mockup
6
+
7
+ h2. Usage
8
+
9
+ From the terminal do 'mockup help' to see:
10
+
11
+
12
+ <pre><code>
13
+ Usage: mockup create name --location /path/to/mockup
14
+
15
+ Mockup Options:
16
+
17
+ create: The name of the mockup project.
18
+ e.g. mockup create project
19
+ -l: Specify a location to create your mockup project.
20
+ e.g. mockup create project -l /path/to/mockup
21
+ convert: Convert an existing Compass project to a mockup project.
22
+ e.g. mockup convert
23
+ with-jquery Install jQuery and jQuery UI
24
+ e.g. mockup create project with-jquery
25
+ help View the Help Screen
26
+ version View the current version of mockup
27
+
28
+ </code></pre>
29
+
data/Rakefile ADDED
@@ -0,0 +1,111 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.unshift File.expand_path("../lib", __FILE__)
3
+
4
+ require 'rubygems'
5
+ require 'rubygems/specification'
6
+ require 'mockup'
7
+
8
+
9
+ def gemspec
10
+ @gemspec ||= begin
11
+ file = File.expand_path('../mockup.gemspec', __FILE__)
12
+ eval(File.read(file), binding, file)
13
+ end
14
+ end
15
+
16
+
17
+ require 'spec/rake/spectask'
18
+ Spec::Rake::SpecTask.new(:spec) do |spec|
19
+ spec.libs << 'lib' << 'spec'
20
+ spec.spec_files = FileList['spec/**/*_spec.rb']
21
+ spec.spec_opts = %w(-fs --color)
22
+ spec.ruby_opts = %w(-w)
23
+ end
24
+
25
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
26
+ spec.libs << 'lib' << 'spec'
27
+ spec.pattern = 'spec/**/*_spec.rb'
28
+ spec.rcov_opts = ["--sort coverage",
29
+ "--profile",
30
+ "--rails",
31
+ "--exclude /gems/,/Library/,spec"]
32
+ spec.rcov = true
33
+ end
34
+
35
+ task :spec => :check_dependencies
36
+
37
+
38
+ begin
39
+ require 'reek/adapters/rake_task'
40
+ Reek::RakeTask.new do |t|
41
+ t.fail_on_error = true
42
+ t.verbose = false
43
+ t.source_files = 'lib/**/*.rb'
44
+ end
45
+ rescue LoadError
46
+ task :reek do
47
+ abort "Reek is not available. In order to run reek, you must: sudo gem install reek"
48
+ end
49
+ end
50
+
51
+ begin
52
+ require 'roodi'
53
+ require 'roodi_task'
54
+ RoodiTask.new do |t|
55
+ t.verbose = false
56
+ end
57
+ rescue LoadError
58
+ task :roodi do
59
+ abort "Roodi is not available. In order to run roodi, you must: sudo gem install roodi"
60
+ end
61
+ end
62
+
63
+ task :default => :spec
64
+
65
+ begin
66
+ require 'yard'
67
+ YARD::Rake::YardocTask.new
68
+ rescue LoadError
69
+ task :yardoc do
70
+ abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
71
+ end
72
+ end
73
+
74
+
75
+
76
+
77
+ begin
78
+ require 'rake/gempackagetask'
79
+ rescue LoadError
80
+ task(:gem) { $stderr.puts "'gem install rake' to package gems" }
81
+ else
82
+ Rake::GemPackageTask.new(gemspec) do |pkg|
83
+ pkg.gem_spec = gemspec
84
+ end
85
+ task :gem => [:build, :gemspec]
86
+ end
87
+
88
+
89
+
90
+ desc "Validate Gemspec"
91
+ task :gemspec do
92
+ gemspec.validate
93
+ end
94
+
95
+ desc "Install the gem locally"
96
+ task :install => :package do
97
+ system "gem install pkg/#{gemspec.name}-#{gemspec.version}"
98
+ end
99
+
100
+ desc "Build the gem"
101
+ task :build do
102
+ mkdir_p "pkg"
103
+ system "gem build #{gemspec.name}.gemspec"
104
+ mv "#{gemspec.full_name}.gem", "pkg"
105
+ end
106
+
107
+ desc "Install Axe"
108
+ task :install => :gem do
109
+ system "gem install pkg/#{gemspec.full_name}.gem"
110
+ end
111
+
data/bin/mockup ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'mockup'
4
+ options = Mockup::Options.parse(ARGV)
5
+ location = options.location.nil? || options.location == '' ? Dir.pwd : options.location
6
+
7
+ if options.name.nil?
8
+ Mockup::Project.convert(options)
9
+ puts "~ Updated your compass project to utilize serve."
10
+ else
11
+ Mockup::Project.create(options)
12
+ puts "~ Your mockup, called #{options.name}, was created in the following directory: #{location}"
13
+ end
data/build.version ADDED
@@ -0,0 +1 @@
1
+ 0.0.2
@@ -0,0 +1,9 @@
1
+ class Object
2
+ def blank?
3
+ if respond_to?(:empty?)
4
+ nil? || empty?
5
+ else
6
+ nil?
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,15 @@
1
+ class String
2
+
3
+ def classify
4
+ self.underscore.split(/_/).each { |word| word.capitalize! }.join('')
5
+ end
6
+
7
+ def underscore
8
+ self.gsub(/-|\s+/, '_')
9
+ end
10
+
11
+ def reverse_classify
12
+ self.gsub(/([A-Z])/, ' \1').strip.split(/ /).each { |word| word.downcase! }.join('_')
13
+ end
14
+
15
+ end
@@ -0,0 +1,55 @@
1
+ module Mockup
2
+ class Options
3
+
4
+ def self.parse(args)
5
+ options = OpenStruct.new
6
+
7
+ ParseOptions.new(args) do |opts|
8
+
9
+ opts.value('create') do |name|
10
+ options.name = name
11
+ end
12
+
13
+ opts.boolean('convert') do |convert|
14
+ options.convert = !!convert
15
+ end
16
+
17
+ opts.value('-l', '--location') do |location|
18
+ options.location = location
19
+ end
20
+
21
+ opts.boolean('with-jquery') do |jquery|
22
+ options.jquery = !!jquery
23
+ end
24
+
25
+ opts.help('help', '-h') do
26
+ puts <<-HELP
27
+
28
+ Usage: mockup create name --location /path/to/mockup
29
+
30
+ Mockup Options:
31
+
32
+ create: The name of the mockup project.
33
+ e.g. mockup create project
34
+ -l: Specify a location to create your mockup project.
35
+ e.g. mockup create project -l /path/to/mockup
36
+ convert: Convert an existing Compass project to a mockup project.
37
+ e.g. mockup convert
38
+ with-jquery Install jQuery and jQuery UI
39
+ e.g. mockup create project with-jquery
40
+ help View the Help Screen
41
+ version View the current version of mockup
42
+
43
+ HELP
44
+ exit(0)
45
+ end
46
+
47
+ opts.version('-v', 'version') do
48
+ puts "Mockup's current version is #{Mockup.version}"
49
+ exit(0)
50
+ end
51
+ end
52
+ options
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,63 @@
1
+ class ParseOptions
2
+ def initialize(args, &block)
3
+ @args = args
4
+ instance_eval(&block) if block_given?
5
+ end
6
+
7
+
8
+ ##
9
+ # Version
10
+ #
11
+ def version(value, value2='', &block)
12
+ puts yield(block) if display_message(value, value2)
13
+ end
14
+
15
+
16
+ ##
17
+ # Help Menu
18
+ #
19
+ def help(value, value2='', &block)
20
+ puts yield(block) if display_message(value, value2)
21
+ end
22
+
23
+
24
+ ##
25
+ # Scan for values
26
+ #
27
+ def scan_for_value(v1, v2='', &block)
28
+ found = nil
29
+ @args.each_with_index do |value, index|
30
+ next if found
31
+ found = @args[index + 1] if (v1.to_s == value.to_s || v2.to_s == value.to_s)
32
+ end
33
+ yield found
34
+ end
35
+ alias_method :value, :scan_for_value
36
+
37
+
38
+ ##
39
+ # Boolean
40
+ #
41
+ def boolean(v1, v2='', &block)
42
+ found = false
43
+ @args.each do |value|
44
+ next if found
45
+ found = true if (v1.to_s == value.to_s || v2.to_s == value.to_s)
46
+ end
47
+ yield found
48
+ end
49
+
50
+
51
+ ##
52
+ # Display Message
53
+ #
54
+ def display_message(value, value2)
55
+ found = false
56
+ @args.each do |arg|
57
+ next if found
58
+ found = true if (value.to_s == arg.to_s || value2.to_s == arg.to_s)
59
+ end
60
+ found
61
+ end
62
+
63
+ end
@@ -0,0 +1,192 @@
1
+ module Mockup
2
+ class Project
3
+ class << self
4
+
5
+ attr_reader :location, :full_name, :name
6
+
7
+ def create(options)
8
+ @name = options.name || 'mockup'
9
+ @location = options.location ? File.join(File.expand_path(options.location), @name.underscore) : File.join(Dir.pwd, @name.underscore)
10
+ @full_name = git_config('user.name') || 'Your Full Name'
11
+
12
+ setup_base_project
13
+
14
+ FileUtils.mkdir_p(File.join(@location, 'sass'))
15
+ FileUtils.mkdir_p(File.join(@location, 'public/images'))
16
+ FileUtils.mkdir_p(File.join(@location, 'public/stylesheets'))
17
+ File.open(File.join(@location, "compass.config"), 'w+') { |f| f.puts compass_config }
18
+
19
+ install_jquery if options.jquery
20
+ end
21
+
22
+
23
+ def setup_base_project
24
+ FileUtils.mkdir_p(File.join(@location, 'public'))
25
+ FileUtils.mkdir_p(File.join(@location, 'tmp'))
26
+ FileUtils.mkdir_p(File.join(@location, 'views/layouts'))
27
+
28
+ FileUtils.touch(File.join(@location, 'README.mk'))
29
+ FileUtils.touch(File.join(@location, 'tmp/restart.txt'))
30
+
31
+ File.open(File.join(@location, "config.ru"), 'w+') { |f| f.puts config_ru }
32
+
33
+ File.open(File.join(@location, "LICENSE"), 'w+') { |f| f.puts license }
34
+ File.open(File.join(@location, ".gitignore"), 'w+') { |f| f.puts gitignore }
35
+ end
36
+
37
+
38
+
39
+
40
+
41
+ def convert(options)
42
+ @location = options.location ? File.join(File.expand_path(options.location)) : Dir.pwd
43
+ @full_name = git_config('user.name') || 'Your Full Name'
44
+ setup_base_project
45
+
46
+ # Move Compass files that were created.
47
+
48
+ FileUtils.mv(File.join(@location, 'images'), File.join(@location, 'public/')) if File.exists?(File.join(@location, 'images'))
49
+ FileUtils.mv(File.join(@location, 'stylesheets'), File.join(@location, 'public/')) if File.exists?(File.join(@location, 'stylesheets'))
50
+ FileUtils.mv(File.join(@location, 'javascripts'), File.join(@location, 'public/')) if File.exists?(File.join(@location, 'javascripts'))
51
+
52
+ # Move default src (from compass create) to sass
53
+ FileUtils.mv(File.join(@location, 'src'), File.join(@location, 'sass'))
54
+ FileUtils.cp(File.join(@location, 'config.rb'), File.join(@location, 'compass.config'))
55
+
56
+ install_jquery if options.jquery
57
+ end
58
+
59
+
60
+
61
+
62
+
63
+
64
+ def license
65
+ <<-LICENSE
66
+ Copyright (c) #{Time.now.year} #{@full_name}
67
+
68
+ Permission is hereby granted, free of charge, to any person obtaining
69
+ a copy of this software and associated documentation files (the
70
+ "Software"), to deal in the Software without restriction, including
71
+ without limitation the rights to use, copy, modify, merge, publish,
72
+ distribute, sublicense, and/or sell copies of the Software, and to
73
+ permit persons to whom the Software is furnished to do so, subject to
74
+ the following conditions:
75
+
76
+ The above copyright notice and this permission notice shall be
77
+ included in all copies or substantial portions of the Software.
78
+
79
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
80
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
81
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
82
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
83
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
84
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
85
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
86
+
87
+ LICENSE
88
+ end
89
+
90
+ def compass_config
91
+ <<-COMPASS_CONFIG
92
+ http_path = '/'
93
+ http_stylesheets_path = '/stylesheets'
94
+ http_images_path = '/images'
95
+ http_javascripts_path = '/javascripts'
96
+
97
+ sass_dir = 'sass'
98
+ css_dir = 'public/stylesheets'
99
+ images_dir = 'public/images'
100
+ javascripts_dir = 'public/javascripts'
101
+
102
+ relative_assets = true
103
+
104
+ COMPASS_CONFIG
105
+ end
106
+
107
+
108
+ def config_ru
109
+ <<-CONFIG_RU
110
+ gem 'activesupport'
111
+ gem 'serve', '~> 0.11.7'
112
+
113
+ require 'serve'
114
+ require 'serve/rack'
115
+
116
+ require 'sass/plugin/rack'
117
+ require 'compass'
118
+
119
+ # The project root directory
120
+ root = ::File.dirname(__FILE__)
121
+
122
+ # Compass
123
+ Compass.add_project_configuration(root + '/compass.config')
124
+ Compass.configure_sass_plugin!
125
+
126
+ # Rack Middleware
127
+ use Rack::ShowStatus # Nice looking 404s and other messages
128
+ use Rack::ShowExceptions # Nice looking errors
129
+ use Sass::Plugin::Rack # Compile Sass on the fly
130
+
131
+ # Rack Application
132
+ if ENV['SERVER_SOFTWARE'] =~ /passenger/i
133
+ # Passendger only needs the adapter
134
+ run Serve::RackAdapter.new(root + '/views')
135
+ else
136
+ # We use Rack::Cascade and Rack::Directory on other platforms to handle static
137
+ # assets
138
+ run Rack::Cascade.new([
139
+ Serve::RackAdapter.new(root + '/views'),
140
+ Rack::Directory.new(root + '/public')
141
+ ])
142
+ end
143
+ CONFIG_RU
144
+ end
145
+
146
+
147
+ def gitignore
148
+ <<-IGNORE
149
+ ## MAC OS
150
+ .DS_Store
151
+
152
+ ## TEXTMATE
153
+ *.tmproj
154
+ tmtags
155
+
156
+ ## EMACS
157
+ *~
158
+ \#*
159
+ .\#*
160
+
161
+ ## VIM
162
+ *.swp
163
+
164
+ ## PROJECT::GENERAL
165
+ coverage
166
+ rdoc
167
+ pkg
168
+
169
+ ## PROJECT::SPECIFIC
170
+ *.gem
171
+ IGNORE
172
+ end
173
+
174
+
175
+ def install_jquery
176
+ FileUtils.mkdir_p(File.join(@location, 'public/javascripts')) unless File.exists?(File.join(@location, 'javascripts'))
177
+ `curl -o #{File.join(@location, 'public/javascripts/jquery.js')} http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js`
178
+ `curl -o #{File.join(@location, 'public/javascripts/jquery_ui.js')} http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/jquery-ui.min.js`
179
+ FileUtils.touch(File.join(@location, 'public/javascripts/application.js'))
180
+ end
181
+
182
+
183
+ private
184
+
185
+ def git_config(key)
186
+ value = `git config #{key}`.chomp
187
+ value.empty? ? nil : value
188
+ end
189
+
190
+ end
191
+ end
192
+ end
@@ -0,0 +1,10 @@
1
+ module Mockup
2
+ module Version
3
+ MAJOR,MINOR,TINY = File.read(File.join(File.dirname(__FILE__), '../../build.version')).split('.')
4
+ STRING = [MAJOR, MINOR, TINY].join('.')
5
+ end
6
+
7
+ def self.version
8
+ Version::STRING
9
+ end
10
+ end
data/lib/mockup.rb ADDED
@@ -0,0 +1,17 @@
1
+ $:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
2
+
3
+ # Require Ruby Standard Libs
4
+ libraries = %w(fileutils date ostruct )
5
+ libraries.each { |lib| require lib }
6
+
7
+
8
+ base = File.expand_path(File.dirname(__FILE__))
9
+
10
+ # Require Class Extentions
11
+ Dir[File.join(File.join(base, 'core_ext'), '*.rb')].each { |file| require file }
12
+
13
+ # Require files
14
+ require File.join(base, 'mockup/version')
15
+ require File.join(base, 'mockup/parse_options')
16
+ require File.join(base, 'mockup/options')
17
+ require File.join(base, 'mockup/project')
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mockup
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 2
10
+ version: 0.0.2
11
+ platform: ruby
12
+ authors:
13
+ - Robert R Evans
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-09-23 00:00:00 -07:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: serve
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ hash: 61
30
+ segments:
31
+ - 0
32
+ - 11
33
+ - 7
34
+ version: 0.11.7
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: rspec
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ hash: 27
46
+ segments:
47
+ - 1
48
+ - 3
49
+ - 0
50
+ version: 1.3.0
51
+ type: :development
52
+ version_requirements: *id002
53
+ description: Longer description.
54
+ email:
55
+ - robert@codewranglers.org
56
+ executables:
57
+ - mockup
58
+ extensions: []
59
+
60
+ extra_rdoc_files: []
61
+
62
+ files:
63
+ - bin/mockup
64
+ - lib/core_ext/object.rb
65
+ - lib/core_ext/string.rb
66
+ - lib/mockup/options.rb
67
+ - lib/mockup/parse_options.rb
68
+ - lib/mockup/project.rb
69
+ - lib/mockup/version.rb
70
+ - lib/mockup.rb
71
+ - LICENSE
72
+ - README.textile
73
+ - Rakefile
74
+ - build.version
75
+ has_rdoc: true
76
+ homepage: http://github.com/revans/mockup
77
+ licenses: []
78
+
79
+ post_install_message:
80
+ rdoc_options: []
81
+
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ hash: 3
90
+ segments:
91
+ - 0
92
+ version: "0"
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ hash: 3
99
+ segments:
100
+ - 0
101
+ version: "0"
102
+ requirements: []
103
+
104
+ rubyforge_project:
105
+ rubygems_version: 1.3.7
106
+ signing_key:
107
+ specification_version: 3
108
+ summary: summary
109
+ test_files: []
110
+