rack-blogengine 0.1.1 → 0.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 446c1873fe807809dfd18aa400eb1b3a37db6f95
4
- data.tar.gz: f6ebc4f1cea67d33811cc1f69248014370505612
3
+ metadata.gz: c8e83d20847f61ee5f2de8dc0854604045dc93f0
4
+ data.tar.gz: 5c003d7a48d262f6cfa84bed2ec1d4d243682302
5
5
  SHA512:
6
- metadata.gz: ca3859f1001bb1ee76de9de867942747ed8266572bb997c28576824a060b786de2a7c8193dbabdda55da6e8a9806ae57a573e20c51e25c2f4a6ef935fa4555f7
7
- data.tar.gz: 8a9e02e79b2bcc773b92291f3ab1521d66fa92db77eac211fc290fda3f12f5f0602d8d8734236118312729db8a3dac8355e4cbe19b611666cadc2a8cd6779404
6
+ metadata.gz: 49d1f9f0203dc2ff8f28a566aedbf963d3cac1a4dedbe5241bc44b254208747b54bf76fb1eefd24d37d13ce0674736d5ac448ba08b7045fa85db91636650c041
7
+ data.tar.gz: 512e3a2e9b03e02b754ded438656213569ed2b8e430e806a0922019527c93b109149bd9c9eec9b786283c4c642b7410d99070505ac7083e83030ad634ae76aee
@@ -1,7 +1,9 @@
1
1
  require "rack/blogengine/version"
2
2
  require "rack/blogengine/doc_parser"
3
+ require "rack/blogengine/document"
3
4
  require "rack/blogengine/application"
4
5
  require "rack/blogengine/application_router"
6
+ require "rack/blogengine/operator"
5
7
 
6
8
  module Rack
7
9
  module Blogengine
@@ -13,34 +13,36 @@ module Rack
13
13
  print "\n"
14
14
  end
15
15
 
16
- # Method to run the cli command
17
- # @param [String] target
18
- def run(target)
19
- unless target.empty?
20
- $targetfolder = target
21
- app = Rack::Builder.new do
22
- use Rack::CommonLogger
23
- use Rack::ShowExceptions
16
+ # Method to run the cli command
17
+ # @param [String] target
18
+ def run(target)
19
+ unless target.empty?
20
+ system("cd #{target}")
21
+ $targetfolder = "#{Dir.pwd}/#{target}"
22
+ app = Rack::Builder.new do
23
+ use Rack::CommonLogger
24
+ use Rack::ShowExceptions
24
25
 
25
- map "/assets" do
26
- run Rack::Directory.new("#{$targetfolder}/assets")
27
- end
28
-
29
- use Rack::Lint
30
- run Rack::Blogengine::Application
26
+ map "/assets" do
27
+ run Rack::Directory.new("#{$targetfolder}/assets")
31
28
  end
32
29
 
33
- Rack::Server.start( :app => app, :Port => 3000 )
34
- else
35
- puts "Specify a targetfolder!"
30
+ use Rack::Lint
31
+ run Rack::Blogengine::Application
36
32
  end
37
- end
38
33
 
39
- # TODO write generate method to generate blog skeleton (assets, layout etc)
40
- def generate(folder)
34
+ Rack::Server.start( :app => app, :Port => 3000 )
35
+ else
36
+ puts "Specify a targetfolder!"
37
+ end
38
+ end
39
+
40
+ # Command to generate the folder skeleton
41
+ # @param [String] folder
42
+ def generate(folder)
41
43
  puts "Generating folder skeleton"
42
44
  system("mkdir #{folder} && mkdir #{folder}/assets && mkdir #{folder}/assets/layout && mkdir #{folder}/assets/js && mkdir #{folder}/assets/style && mkdir #{folder}/assets/images")
43
- end
45
+ end
44
46
  end
45
47
  end
46
48
  end
@@ -18,20 +18,32 @@ module Rack
18
18
  getFileContents(item)
19
19
  @html = fillFileContents(@layout)
20
20
 
21
- @document = {path: @path, html: @html}
21
+ @document = Document.new
22
+ @document.path = @path
23
+ @document.html = @html
24
+ @document.title = @title
25
+
22
26
  documents << @document
23
27
  end
24
28
 
25
- return documents
29
+ documents.each do |document|
30
+ document.exec_content_operator(documents, @target)
31
+ end
32
+
33
+ documentshashed = documents.map do |document|
34
+ document.to_hash
35
+ end
36
+
37
+ return documentshashed
26
38
  end
27
39
 
28
40
  # Get File Contents (path, title, content)
29
41
  # @param file
30
42
  def self.getFileContents(file)
31
- # do work on real items
32
43
  content_file = ::File.open("#{@target}/#{file}");
33
44
  content = content_file.read
34
45
 
46
+ # Replace Closing tags
35
47
  content["/path"] = "/close"
36
48
  content["/title"] = "/close"
37
49
  content["/content"] = "/close"
@@ -0,0 +1,22 @@
1
+ module Rack
2
+ module Blogengine
3
+ class Document
4
+ attr_accessor :path, :html, :title
5
+
6
+ def to_hash
7
+ hash = {}
8
+ instance_variables.each do
9
+ |var| hash[var.to_s.delete("@").to_sym] = instance_variable_get(var) unless var.to_s == "@title"
10
+ end
11
+ hash
12
+ end
13
+
14
+ def exec_content_operator(documents, target)
15
+ @html.scan(/\{\%(.*?)\%\}/).each do |contentoperator|
16
+ operator = Operator.new(target)
17
+ operator.send(contentoperator[0].strip.to_sym, documents, @html)
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,13 @@
1
+ class Operator
2
+ def initialize(target)
3
+ Dir.foreach("#{target}operator/") do |item|
4
+ extension = item.split(".")[1]
5
+ next if item == '.' or item == '..' or extension != "rb"
6
+ require "#{target}operator/#{item}"
7
+ end
8
+
9
+ extend UserOperator # load user operators
10
+ end
11
+
12
+ # define default operators here
13
+ end
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  module Blogengine
3
- VERSION = "0.1.1".freeze
3
+ VERSION = "0.1.2".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-blogengine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benny1992
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-14 00:00:00.000000000 Z
11
+ date: 2013-12-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -85,6 +85,8 @@ files:
85
85
  - lib/rack/blogengine/application_router.rb
86
86
  - lib/rack/blogengine/command_line_interface.rb
87
87
  - lib/rack/blogengine/doc_parser.rb
88
+ - lib/rack/blogengine/document.rb
89
+ - lib/rack/blogengine/operator.rb
88
90
  - lib/rack/blogengine/version.rb
89
91
  - rack-blogengine.gemspec
90
92
  homepage: ''
@@ -113,4 +115,3 @@ signing_key:
113
115
  specification_version: 4
114
116
  summary: Blogengine based on rack applications
115
117
  test_files: []
116
- has_rdoc: