markus 4.0.11 → 4.0.12

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: 61a7c81d7d3fa8cc762d85264060c00867f3ba14
4
- data.tar.gz: b2aad643efe380b28666b614dc4eb25f0e8fe649
3
+ metadata.gz: 5c823580a0bb0791242cc3f0f649de84e0bff7b6
4
+ data.tar.gz: 385b569f68399d927c3e481bc6780c9ec6b39292
5
5
  SHA512:
6
- metadata.gz: 8a35d5910a5570c831f275e7e8d59ec42eded484b5efae6e8fe0ee160edf5fdf71b92e8c80a1d216b4f553d27f9e3b887dc812b71ad75e4bbc3384b851cd231d
7
- data.tar.gz: 73b80f9b9be6f43e442aeda89cf06951b24af39d871212856638925492295ea6e4d0872efe546da90700e2f8282869b26aea2af35a09ebe46ec4acf6744ff6c5
6
+ metadata.gz: 395829a6126f862295ab7f42e1daf3d118eff71468191931c79593b43d624420ede122909a4ab11f5297873fc2a1b9e0104e30b48b82582fab01c70717f3926e
7
+ data.tar.gz: 2b457501d71a7025e5f7e29eda5b448026652e5fed5fdd45bd9258b8818a70a254b2a1f185dcfa3aeccdc3a5c5f7fe30e6783a89b0bb3ed2bb551f8a8630ae14
data/lib/markus.rb CHANGED
@@ -72,6 +72,24 @@ class MarkUS
72
72
  def element_!(name=nil, *args, &blk) #{{{
73
73
  __markus_method_missing name, *args, &blk
74
74
  end #}}}
75
+ def value_!(val) #{{{
76
+ case val
77
+ when String
78
+ content = "\"#{val.gsub(/"/,'\\\"')}\""
79
+ when Integer, Float
80
+ content = val
81
+ else
82
+ content = "null"
83
+ end
84
+ @__markus_level += 1
85
+ if self.class.__markus_indent
86
+ @__markus_buffer << "#{" " * @__markus_level}#{content},"
87
+ else
88
+ @__markus_buffer << "#{content},"
89
+ end
90
+ @__markus_level -= 1
91
+ nil
92
+ end #}}}
75
93
  def template_!(name,*args) #{{{
76
94
  instance_exec *args, &self.class.__markus_templates[name]
77
95
  end #}}}
data/markus.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "markus"
3
- s.version = "4.0.11"
3
+ s.version = "4.0.12"
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.license = "LGPL-3"
6
6
  s.summary = "MarkUS - Markup UnderScore. Quick n' dirty templating in the spirit of markaby."
data/test/change.mt_ CHANGED
@@ -3,7 +3,7 @@ class TestJsonChange < MarkUS
3
3
 
4
4
  template :main do
5
5
  element_! do
6
- query_ 63
6
+ query_ 73
7
7
  end
8
8
  end
9
9
  end
@@ -2,6 +2,6 @@ class ChangeIncludeCommon < MarkUS
2
2
  reload
3
3
 
4
4
  template :test do
5
- query_ 105
5
+ query_ 115
6
6
  end
7
7
  end
data/test/json.mt_ CHANGED
@@ -15,6 +15,7 @@ class TestJSON < MarkUS
15
15
  must_ do |array|
16
16
  bool_ do
17
17
  should_ do |array|
18
+ value_! "_score"
18
19
  nested_ do
19
20
  path_ "contact"
20
21
  query_ do
@@ -8,13 +8,13 @@ class TestBasicJSON < Minitest::Test
8
8
  def test_json
9
9
  s = TestJSON.new
10
10
  s.__markus_indent = true
11
- assert s.json_!(:main) == "\"from\": 1,\n\"size\": 6,\n\"query\": {\n \"filtered\": {\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"bool\": {\n \"should\": [\n {\n \"nested\": {\n \"path\": \"contact\",\n \"query\": {\n \"term\": {\n \"contact.durchwahl\": 1\n }\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"contact\",\n \"query\": {\n \"term\": {\n \"contact.durchwahl\": \"aaa\"\n }\n }\n }\n }\n ]\n }\n }\n ]\n }\n }\n }\n}"
11
+ assert s.json_!(:main) == "\"from\": 1,\n\"size\": 6,\n\"query\": {\n \"filtered\": {\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"bool\": {\n \"should\": [\n \"_score\",\n {\n \"nested\": {\n \"path\": \"contact\",\n \"query\": {\n \"term\": {\n \"contact.durchwahl\": 1\n }\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"contact\",\n \"query\": {\n \"term\": {\n \"contact.durchwahl\": \"aaa\"\n }\n }\n }\n }\n ]\n }\n }\n ]\n }\n }\n }\n}"
12
12
  end
13
13
 
14
14
  def test_json_noindent
15
15
  s = TestJSON.new
16
16
  s.__markus_indent = false
17
- assert s.json_!(:main) == "\"from\": 1,\"size\": 6,\"query\": {\"filtered\": {\"filter\": {\"bool\": {\"must\": [{\"bool\": {\"should\": [{\"nested\": {\"path\": \"contact\",\"query\": {\"term\": {\"contact.durchwahl\": 1}}}},{\"nested\": {\"path\": \"contact\",\"query\": {\"term\": {\"contact.durchwahl\": \"aaa\"}}}}]}}]}}}}"
17
+ assert s.json_!(:main) == "\"from\": 1,\"size\": 6,\"query\": {\"filtered\": {\"filter\": {\"bool\": {\"must\": [{\"bool\": {\"should\": [\"_score\",{\"nested\": {\"path\": \"contact\",\"query\": {\"term\": {\"contact.durchwahl\": 1}}}},{\"nested\": {\"path\": \"contact\",\"query\": {\"term\": {\"contact.durchwahl\": \"aaa\"}}}}]}}]}}}}"
18
18
  end
19
19
 
20
20
  def test_json_arguments
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: markus
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.11
4
+ version: 4.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juergen eTM Mangler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-16 00:00:00.000000000 Z
11
+ date: 2016-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest