fairytale 0.8.1.1 → 1.0.0

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.
@@ -0,0 +1,5 @@
1
+ .DS_Store
2
+ Icon?
3
+ ._*
4
+ .Trashes
5
+ *.gem
File without changes
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in spotigit.gemspec
4
+ gemspec
@@ -0,0 +1,24 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ fairytale (1.0.0)
5
+ json (~> 1.7.5)
6
+ sanitize (~> 2.0.3)
7
+ thor (~> 0.16.0)
8
+ tilt (~> 1.3.3)
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ json (1.7.5)
14
+ nokogiri (1.5.5)
15
+ sanitize (2.0.3)
16
+ nokogiri (>= 1.4.4, < 1.6)
17
+ thor (0.16.0)
18
+ tilt (1.3.3)
19
+
20
+ PLATFORMS
21
+ ruby
22
+
23
+ DEPENDENCIES
24
+ fairytale!
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2012 Michael Mokrysz
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
@@ -0,0 +1,20 @@
1
+ # Fairytale
2
+
3
+ Fairytale is a Ruby static-site compiler designed to work as closely as possible to the process of building a dynamic site. Building with it is designed to closely resemble building with [Sinatra](http://sinatrarb.com):
4
+
5
+ # mysite.rb
6
+ require 'fairytale'
7
+
8
+ get '/' do
9
+ "Hello world!"
10
+ end
11
+
12
+ Install the gem and run with:
13
+
14
+ gem install fairytale
15
+ ruby -rubygems mysite.rb
16
+
17
+ Compiled files go into the ./webroot directory.
18
+
19
+ ## Credits
20
+ Licensed under MIT, created by [Michael Mokrysz](https://46bit.com). A lot of credit has to go to the [Sinatra](http://sinatrarb.com) team.
File without changes
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "thor"
4
+ require "json"
5
+ require "fileutils"
6
+
7
+ module Fairytale
8
+ class Thorytale < Thor
9
+ attr_accessor :config
10
+
11
+ desc "new APP_NAME", "Generates new Fairytale app."
12
+
13
+ def new name
14
+ tidy_name = name.downcase.gsub " ", "-"
15
+ path = File.expand_path name
16
+
17
+ if File.exists? path
18
+ say "Directory #{name} already exists.", :red
19
+ exit
20
+ end
21
+
22
+ say "Created Fairytale app \"#{name}\" successfully!", :green
23
+ FileUtils.cp_r "#{fairytale_gem_path}/data/new", path
24
+ end
25
+
26
+ desc "build", "Compile Fairytale app in current directory."
27
+
28
+ def build
29
+ load_config
30
+
31
+ require @config["application_script"].gsub(".rb", "")
32
+ end
33
+
34
+ protected
35
+ def load_config
36
+ config_file = File.open("Fairyfile", "r")
37
+ @config = JSON.parse config_file.read
38
+ end
39
+
40
+ def fairytale_gem_path
41
+ Gem::Specification.find_by_name("fairytale").gem_dir
42
+ end
43
+ end
44
+
45
+ Fairytale::Thorytale.start
46
+ end
File without changes
@@ -0,0 +1,5 @@
1
+ .DS_Store
2
+ Icon?
3
+ ._*
4
+ .Trashes
5
+ *.gem
File without changes
@@ -0,0 +1,3 @@
1
+ {
2
+ "application_script": "./application.rb"
3
+ }
@@ -0,0 +1,3 @@
1
+ source :rubygems
2
+
3
+ gem "fairytale", "~> 1.0.0"
@@ -0,0 +1,6 @@
1
+ require "fairytale"
2
+
3
+ get "/" do
4
+ @content = md :index
5
+ erb :index
6
+ end
File without changes
@@ -0,0 +1,3 @@
1
+ # Welcome to Fairytale
2
+
3
+ This content is in ./content/index.md and is written in lovely Markdown.
File without changes
File without changes
File without changes
@@ -0,0 +1,3 @@
1
+ <%= @content %>
2
+
3
+ <p>This view is ./views/index.erb and is written in simple ERB.</p>
@@ -0,0 +1,12 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8" />
5
+
6
+ <title>Welcome to your new Fairytale site.</title>
7
+ </head>
8
+ <body>
9
+ <%= yield %>
10
+ <p>This view is ./views/layout.erb and stores the site layout in simple ERB.</p>
11
+ </body>
12
+ </html>
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'fairytale/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "fairytale"
8
+ gem.version = Fairytale::VERSION
9
+ gem.authors = ["Michael Mokrysz"]
10
+ gem.email = ["hi@46bit.com"]
11
+ gem.description = "A programmer's static site compiler."
12
+ gem.summary = "Fairytale is a Sinatra-reminiscent static site compilation tool, perfect for when you want to build something exactly how you like it."
13
+ gem.homepage = "http://rubygems.org/gems/fairytale"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = ["fairytale"]
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_dependency "thor", "~> 0.16.0"
21
+ gem.add_dependency "json", "~> 1.7.5"
22
+ gem.add_dependency "tilt", "~> 1.3.3"
23
+ gem.add_dependency "sanitize", "~> 2.0.3"
24
+ end
File without changes
@@ -4,29 +4,33 @@ require 'fairytale/helpers'
4
4
 
5
5
  module Fairytale
6
6
  include Fairytale::Helpers
7
-
8
- def get url, layout = :"views/layout.erb", &block
7
+
8
+ def path
9
+ File.expand_path "./"
10
+ end
11
+
12
+ def get url, layout = "views/layout.erb", &block
9
13
  @url = url
10
-
14
+
11
15
  print "Building #{url} ... "
12
16
  view_content = block.call
13
-
17
+
14
18
  unless layout.nil?
15
19
  view_content = tilt(layout) { view_content }
16
20
  end
17
-
21
+
18
22
  save url, view_content
19
23
  print "saved"
20
-
24
+
21
25
  reset
22
26
  puts
23
27
  end
24
-
28
+
25
29
  # Present merely to mirror Sinatra
26
30
  def before &block
27
31
  block.call
28
32
  end
29
-
33
+
30
34
  protected
31
35
  def save url, content
32
36
  path = "public#{url}"
@@ -34,11 +38,11 @@ module Fairytale
34
38
  FileUtils.mkdir_p File.dirname path
35
39
  File.open(path, "w+") { |f| f.write content }
36
40
  end
37
-
41
+
38
42
  # Resets this object, ready for the next 'request'
39
43
  def reset
40
44
  instance_variables.each { |var_symbol| instance_variable_set var_symbol, nil }
41
45
  end
42
46
  end
43
47
 
44
- include Fairytale
48
+ include Fairytale
File without changes
@@ -6,33 +6,33 @@ require 'digest/sha1'
6
6
  module Fairytale
7
7
  module Helpers
8
8
  def md file, params = {}, &block
9
- file = "content/#{file.to_s}" if file.class == Symbol
9
+ file = "#{Fairytale.path}/content/#{file.to_s}.md" if file.class == Symbol
10
10
  tilt(file, params, &block)
11
11
  end
12
-
12
+
13
13
  def erb file, params = {}, &block
14
- file = "views/#{file.to_s}.erb" if file.class == Symbol
14
+ file = "#{Fairytale.path}/views/#{file.to_s}.erb" if file.class == Symbol
15
15
  tilt(file, params, &block)
16
16
  end
17
-
17
+
18
18
  def sass file, params = {}, &block
19
- file = "public/assets/css/#{file.to_s}.sass" if file.class == Symbol
19
+ file = "#{Fairytale.path}/public/assets/css/#{file.to_s}.sass" if file.class == Symbol
20
20
  tilt(file, params, &block)
21
21
  end
22
-
22
+
23
23
  def scss file, params = {}, &block
24
- file = "public/assets/css/#{file.to_s}.scss" if file.class == Symbol
24
+ file = "#{Fairytale.path}/public/assets/css/#{file.to_s}.scss" if file.class == Symbol
25
25
  tilt(file, params, &block)
26
26
  end
27
-
27
+
28
28
  def tilt file, engine_options = {}, &block
29
29
  engine_options ||= {}
30
30
  template = Tilt.new file.to_s, nil, engine_options
31
31
  template.render(self) { block.call }
32
32
  end
33
-
33
+
34
34
  def md5 file
35
35
  Digest::SHA1.hexdigest File.read(file)
36
36
  end
37
37
  end
38
- end
38
+ end
@@ -0,0 +1,3 @@
1
+ module Fairytale
2
+ VERSION = "1.0.0"
3
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fairytale
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1.1
4
+ version: 1.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,17 +9,107 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-27 00:00:00.000000000 Z
13
- dependencies: []
14
- description: Sinatra is awesome for building sites. Fairytale brings its power and
15
- freedom to static site compilation.
16
- email: hi@46bit.com
17
- executables: []
12
+ date: 2012-11-17 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: thor
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.16.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 0.16.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: json
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 1.7.5
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 1.7.5
46
+ - !ruby/object:Gem::Dependency
47
+ name: tilt
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 1.3.3
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 1.3.3
62
+ - !ruby/object:Gem::Dependency
63
+ name: sanitize
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: 2.0.3
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 2.0.3
78
+ description: A programmer's static site compiler.
79
+ email:
80
+ - hi@46bit.com
81
+ executables:
82
+ - fairytale
18
83
  extensions: []
19
84
  extra_rdoc_files: []
20
85
  files:
86
+ - .gitignore
87
+ - .gitkeep
88
+ - Gemfile
89
+ - Gemfile.lock
90
+ - LICENSE.md
91
+ - README.md
92
+ - bin/.gitkeep
93
+ - bin/fairytale
94
+ - data/.gitkeep
95
+ - data/new/.gitignore
96
+ - data/new/.gitkeep
97
+ - data/new/Fairyfile
98
+ - data/new/Gemfile
99
+ - data/new/application.rb
100
+ - data/new/content/.gitkeep
101
+ - data/new/content/index.md
102
+ - data/new/public/.gitkeep
103
+ - data/new/public/robots.txt
104
+ - data/new/views/.gitkeep
105
+ - data/new/views/index.erb
106
+ - data/new/views/layout.erb
107
+ - fairytale.gemspec
108
+ - lib/.gitkeep
21
109
  - lib/fairytale.rb
110
+ - lib/fairytale/.gitkeep
22
111
  - lib/fairytale/helpers.rb
112
+ - lib/fairytale/version.rb
23
113
  homepage: http://rubygems.org/gems/fairytale
24
114
  licenses: []
25
115
  post_install_message:
@@ -40,8 +130,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
40
130
  version: '0'
41
131
  requirements: []
42
132
  rubyforge_project:
43
- rubygems_version: 1.8.21
133
+ rubygems_version: 1.8.24
44
134
  signing_key:
45
135
  specification_version: 3
46
- summary: Sinatra-like static site compiler.
136
+ summary: Fairytale is a Sinatra-reminiscent static site compilation tool, perfect
137
+ for when you want to build something exactly how you like it.
47
138
  test_files: []