simple_site 0.0.1 → 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/README.rdoc +3 -0
- data/VERSION +1 -1
- data/lib/simple_site.rb +21 -5
- data/lib/simple_site/haml_context.rb +14 -0
- data/lib/simple_site/tasks.rb +77 -0
- data/simple_site.gemspec +4 -3
- data/test/test_simple_site.rb +30 -2
- metadata +6 -5
- data/lib/simple_site/haml_helper.rb +0 -8
data/README.rdoc
CHANGED
@@ -17,3 +17,6 @@ Description goes here.
|
|
17
17
|
Copyright (c) 2011 David Radcliffe. See LICENSE.txt for
|
18
18
|
further details.
|
19
19
|
|
20
|
+
== Dependency Status
|
21
|
+
|
22
|
+
{<img src="https://gemnasium.com/dwradcliffe/simple_site.png" alt="Dependency Status" />}[https://gemnasium.com/dwradcliffe/simple_site]
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2
|
data/lib/simple_site.rb
CHANGED
@@ -1,16 +1,32 @@
|
|
1
1
|
require 'aws/s3'
|
2
2
|
require 'uglifier'
|
3
|
+
require 'simple_site/tasks'
|
4
|
+
require 'simple_site/haml_context'
|
5
|
+
require 'haml'
|
3
6
|
|
4
7
|
class SimpleSite
|
5
8
|
|
9
|
+
attr_reader :options
|
10
|
+
|
6
11
|
def initialize(options = {})
|
7
|
-
@options =
|
12
|
+
@options = {}
|
13
|
+
@options[:buckets] ||= [options.delete(:bucket)].compact
|
14
|
+
options[:buckets].each {|bucket| @options[:buckets] << bucket } unless options[:buckets].nil?
|
15
|
+
@options.merge!(options)
|
8
16
|
@options[:js_files] ||= Dir['_js/*.js']
|
9
|
-
|
17
|
+
end
|
18
|
+
|
19
|
+
def js_files=(files)
|
20
|
+
@options[:js_files] = files
|
21
|
+
end
|
22
|
+
|
23
|
+
def buckets=(buckets)
|
24
|
+
@options[:buckets] = buckets
|
10
25
|
end
|
11
26
|
|
12
27
|
def generate_html
|
13
|
-
|
28
|
+
engine = Haml::Engine.new(File.read('_src/index.haml'))
|
29
|
+
File.open('public/index.html', 'w') {|f| f.write(engine.render(SimpleSite::HamlContext.new)) }
|
14
30
|
puts "Regenerated site!"
|
15
31
|
end
|
16
32
|
|
@@ -49,8 +65,8 @@ class SimpleSite
|
|
49
65
|
age = 7*24*60*60
|
50
66
|
options = {
|
51
67
|
:access => :public_read,
|
52
|
-
:cache_control => "max-age=#{age}"
|
53
|
-
:expires => age.from_now.httpdate
|
68
|
+
:cache_control => "max-age=#{age}"
|
69
|
+
# :expires => age.from_now.httpdate
|
54
70
|
}
|
55
71
|
puts " --> #{file}"
|
56
72
|
@options[:buckets].each do |bucket|
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/tasklib'
|
3
|
+
|
4
|
+
class SimpleSite
|
5
|
+
# Rake tasks for managing your site.
|
6
|
+
#
|
7
|
+
# Here's a basic usage example:
|
8
|
+
#
|
9
|
+
# SimpleSite::Tasks.new do |site|
|
10
|
+
# site.js_files = "site.js"
|
11
|
+
# site.buckets = %w(www.myawesomesite.com www.myotherdomain.com)
|
12
|
+
# end
|
13
|
+
class Tasks < ::Rake::TaskLib
|
14
|
+
|
15
|
+
attr_reader :site
|
16
|
+
|
17
|
+
def initialize(&site_building_block)
|
18
|
+
@site = SimpleSite.new
|
19
|
+
site_building_block.call @site
|
20
|
+
define
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def define
|
26
|
+
|
27
|
+
desc "Show SimpleSite config"
|
28
|
+
task :config do
|
29
|
+
|
30
|
+
puts " "
|
31
|
+
puts "SimpleSite config:"
|
32
|
+
puts "AWS S3 buckets: #{@site.options[:buckets].join(', ')}"
|
33
|
+
puts "JS files: #{@site.options[:js_files].join(', ')}"
|
34
|
+
puts " "
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
desc "Generate Entire Site"
|
39
|
+
task :gen => ["gen:html", "gen:css", "gen:js"]
|
40
|
+
|
41
|
+
namespace :gen do
|
42
|
+
|
43
|
+
desc "Generate HTML"
|
44
|
+
task :html do
|
45
|
+
@site.generate_html
|
46
|
+
end
|
47
|
+
|
48
|
+
desc "Generate CSS"
|
49
|
+
task :css do
|
50
|
+
@site.generate_css
|
51
|
+
end
|
52
|
+
|
53
|
+
desc "Generate JS"
|
54
|
+
task :js do
|
55
|
+
@site.generate_js
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
desc "Deploy website"
|
61
|
+
task :deploy do
|
62
|
+
@site.deploy!
|
63
|
+
end
|
64
|
+
|
65
|
+
namespace :deploy do
|
66
|
+
|
67
|
+
task :file do
|
68
|
+
@site.deploy_file!
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
data/simple_site.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "simple_site"
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["David Radcliffe"]
|
12
|
-
s.date = "2011-12-
|
12
|
+
s.date = "2011-12-27"
|
13
13
|
s.description = "Helps build simple websites using haml and sass. Compresses your js. Deploys to AWS S3."
|
14
14
|
s.email = "radcliffe.david@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -24,7 +24,8 @@ Gem::Specification.new do |s|
|
|
24
24
|
"Rakefile",
|
25
25
|
"VERSION",
|
26
26
|
"lib/simple_site.rb",
|
27
|
-
"lib/simple_site/
|
27
|
+
"lib/simple_site/haml_context.rb",
|
28
|
+
"lib/simple_site/tasks.rb",
|
28
29
|
"simple_site.gemspec",
|
29
30
|
"test/helper.rb",
|
30
31
|
"test/test_simple_site.rb"
|
data/test/test_simple_site.rb
CHANGED
@@ -1,7 +1,35 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
3
|
class TestSimpleSite < Test::Unit::TestCase
|
4
|
-
|
5
|
-
|
4
|
+
|
5
|
+
should "have empty buckets on init" do
|
6
|
+
s = SimpleSite.new
|
7
|
+
assert_equal [], s.options[:buckets]
|
6
8
|
end
|
9
|
+
|
10
|
+
should "have one bucket" do
|
11
|
+
s = SimpleSite.new(:bucket => 'www.myawesomesite.com')
|
12
|
+
assert_equal ['www.myawesomesite.com'], s.options[:buckets]
|
13
|
+
end
|
14
|
+
|
15
|
+
should "have two buckets" do
|
16
|
+
s = SimpleSite.new(:buckets => %w(www.myawesomesite.com www.myotherdomain.com))
|
17
|
+
assert_equal ['www.myawesomesite.com', 'www.myotherdomain.com'], s.options[:buckets]
|
18
|
+
end
|
19
|
+
|
20
|
+
should "have empty list of js files" do
|
21
|
+
s = SimpleSite.new
|
22
|
+
assert_equal [], s.options[:js_files]
|
23
|
+
end
|
24
|
+
|
25
|
+
should "have one js file" do
|
26
|
+
s = SimpleSite.new(:js_files => %w(site.js))
|
27
|
+
assert_equal ['site.js'], s.options[:js_files]
|
28
|
+
end
|
29
|
+
|
30
|
+
should "have two js files" do
|
31
|
+
s = SimpleSite.new(:js_files => %w(site.js lib.js))
|
32
|
+
assert_equal ['site.js', 'lib.js'], s.options[:js_files]
|
33
|
+
end
|
34
|
+
|
7
35
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_site
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- David Radcliffe
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-12-
|
18
|
+
date: 2011-12-27 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
type: :runtime
|
@@ -248,7 +248,8 @@ files:
|
|
248
248
|
- Rakefile
|
249
249
|
- VERSION
|
250
250
|
- lib/simple_site.rb
|
251
|
-
- lib/simple_site/
|
251
|
+
- lib/simple_site/haml_context.rb
|
252
|
+
- lib/simple_site/tasks.rb
|
252
253
|
- simple_site.gemspec
|
253
254
|
- test/helper.rb
|
254
255
|
- test/test_simple_site.rb
|