qwik2md 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3106526347f3ea2c05225be6df24e05292b86169
4
- data.tar.gz: 4575f2c43c033351f79d3ac1f07e7cc0df7e3e6c
3
+ metadata.gz: a8c3145aa48df052282672c7665b53aa1c0dc04b
4
+ data.tar.gz: 433f158cd8e49e082d862e1d2e2c70d37d24db3a
5
5
  SHA512:
6
- metadata.gz: 96e6b6f0987accd4dbf92be60fc2375b101ad92e850958a7636d5e99e7fe40b317da34db066f4bccbee7b1288ae5b9974c7c78e6a751d2e4effb0ce16566c442
7
- data.tar.gz: ea52c9a2cad57459dcd208f6969ae1d7cfb88d608303db7fd964c2a22d1e9b1954cb22e453a425b0cf9067cdaf38da0145abf798fa8bba4a795377f94d2f72f2
6
+ metadata.gz: d2a8cb6833c80f071305be0153c5b55ca2cb77103b9aee4f7498944221d0e39af193711868625cb7a4cc5dc18788b51b014abc3593f5b1314193ff25c19eb65e
7
+ data.tar.gz: c6f380e45db77dcf88436c345d795c8aa05405fa200540a865e79dd4d19c1fb85e63b59253d3f04d55d9e72074da78ba9265bb52610799d8d4e63ffb87ec4171
@@ -1,3 +1,3 @@
1
1
  module Qwik2md
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
data/lib/qwik2md.rb CHANGED
@@ -6,12 +6,94 @@ require 'qwik/wabisabi-format-xml'
6
6
  require 'reverse_markdown'
7
7
  require 'qwik/action'
8
8
  require 'qwik/loadlib'
9
+ require 'qwik/config'
10
+ require 'qwik/request'
11
+ require 'qwik/response'
12
+ require 'qwik/farm'
13
+ require 'qwik/test-module-path'
9
14
 
10
- require 'ostruct'
15
+ require 'webrick'
16
+ require 'logger'
11
17
 
12
18
  Qwik::LoadLibrary.load_libs_here('qwik/act-*')
13
19
 
14
20
  module Qwik2md
21
+ class Action
22
+ def initialize(dir)
23
+ @dir = dir
24
+ end
25
+
26
+ def resolve_all_plugin(tree)
27
+ action.resolve_all_plugin(tree)
28
+ end
29
+
30
+ private
31
+
32
+ def action
33
+ @action ||= Qwik::Action.new.tap do |action|
34
+ action.init(config, memory, req, res)
35
+ _site = site
36
+ action.instance_eval {
37
+ @site = _site;
38
+ }
39
+ end
40
+ end
41
+
42
+ def memory
43
+ @memory ||= Qwik::ServerMemory.new(config).tap do |memory|
44
+ logfile = File.join(@dir, '.test/testlog.txt')
45
+ loglevel = WEBrick::Log::INFO
46
+ logger = WEBrick::Log::new(logfile, loglevel)
47
+ memory[:logger] = logger
48
+
49
+ burylogfile = File.join(@dir, '.test/testburylog.txt')
50
+ log = ::Logger.new(burylogfile)
51
+ log.level = ::Logger::INFO
52
+ memory[:bury_log] = log
53
+ end
54
+ end
55
+
56
+ def site
57
+ @site ||= memory.farm.get_site('test')
58
+ end
59
+
60
+ def req
61
+ @req ||= Qwik::Request.new(config)
62
+ end
63
+
64
+ def res
65
+ @res ||= Qwik::Response.new(config)
66
+ end
67
+
68
+ def config
69
+ @config ||= Qwik::Config.new.tap do |config|
70
+ config.update(Qwik::Config::DebugConfig)
71
+ config.update(Qwik::Config::TestConfig)
72
+
73
+ %i(
74
+ sites_dir
75
+ grave_dir
76
+ cache_dir
77
+ etc_dir
78
+ log_dir
79
+ ).each do |key|
80
+ config[key] = File.join(@dir, config[key])
81
+ end
82
+
83
+ config.sites_dir.path.check_directory
84
+ config.grave_dir.path.check_directory
85
+ config.cache_dir.path.check_directory
86
+ config.etc_dir.path.check_directory
87
+ config.log_dir.path.check_directory
88
+
89
+ wwwdir = config.sites_dir.path + 'www'
90
+ wwwdir.setup
91
+ dir = config.sites_dir.path + 'test'
92
+ dir.setup
93
+ end
94
+ end
95
+ end
96
+
15
97
  class << self
16
98
  def convert(qwik_str)
17
99
  Converter.new(qwik_str).convert
@@ -24,12 +106,14 @@ module Qwik2md
24
106
  end
25
107
 
26
108
  def convert
27
- ReverseMarkdown.convert(to_html)
109
+ Dir.mktmpdir do |dir|
110
+ ReverseMarkdown.convert(to_html(dir))
111
+ end
28
112
  end
29
113
 
30
114
  private
31
115
 
32
- def to_html
116
+ def to_html(dir)
33
117
  str =
34
118
  if Qwik::EmodePreProcessor.emode?(@qwik_str)
35
119
  Qwik::EmodePreProcessor.preprocess(@qwik_str)
@@ -39,14 +123,7 @@ module Qwik2md
39
123
 
40
124
  tokens = Qwik::TextTokenizer.tokenize(str)
41
125
  tree = Qwik::TextParser.make_tree(tokens)
42
- action = Qwik::Action.new
43
- action.init(OpenStruct.new(test: true), nil, nil, nil)
44
- action.instance_eval do
45
- @site = Object.new
46
- def @site.resolve_all_ref(tree)
47
- tree
48
- end
49
- end
126
+ action = Action.new(dir)
50
127
  tree = action.resolve_all_plugin(tree)
51
128
  tree.format_xml
52
129
  end
@@ -94,7 +94,7 @@ module Qwik
94
94
 
95
95
  def self.parse(str)
96
96
  array = []
97
- str.each {|line|
97
+ str.each_line {|line|
98
98
  firstchar = line[0, 1]
99
99
  next unless SIGNATURE.include?(firstchar)
100
100
  ar = line.chomp.split(firstchar)
@@ -5,7 +5,7 @@
5
5
  require 'webrick/log'
6
6
 
7
7
  $LOAD_PATH.unshift '..' unless $LOAD_PATH.include? '..'
8
- require 'qwik/testunit'
8
+
9
9
  require 'qwik/test-module-path'
10
10
  require 'qwik/test-module-public'
11
11
  require 'qwik/request'
@@ -241,13 +241,13 @@ module TestSession
241
241
  return assert_equal(e, nil) if elem.nil?
242
242
  return assert_equal(e, elem.inside.get_single)
243
243
  end
244
-
244
+
245
245
  def ok_title(e, res=@res)
246
246
  elem = res.body.get_path('//title')
247
247
  return assert_equal(e, nil) if elem.nil?
248
248
  return assert_equal(e, elem.inside.get_single[0])
249
249
  end
250
-
250
+
251
251
  def assert_text(e, tag, res=@res)
252
252
  elem = res.body.get_tag(tag)
253
253
  return assert_equal(e, nil) if elem.nil?
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qwik2md
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fumiaki MATSUSHIMA
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-03-16 00:00:00.000000000 Z
11
+ date: 2016-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: htree