wlang 2.1.2 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,8 @@
1
+ # 2.2.0 / 2013-03-05
2
+
3
+ * Added ATTR/VALUE pairs to the wlang command line tool, for passing data to templates
4
+ in an easy way.
5
+
1
6
  # 2.1.2 / 2012-01-15
2
7
 
3
8
  * Add backquote as supported tag symbol
data/Gemfile CHANGED
@@ -17,8 +17,6 @@ group :development do
17
17
  gem "rake", "~> 0.9.2"
18
18
  gem "bundler", "~> 1.0"
19
19
  gem "rspec", "~> 2.10.0"
20
- gem "yard", "~> 0.8.1"
21
- gem "bluecloth", "~> 2.2.0"
22
20
  gem "sinatra", :git => "git://github.com/sinatra/sinatra" #">= 1.4"
23
21
  gem "rack-test", "~> 0.6.1"
24
22
  end
@@ -12,7 +12,6 @@ GEM
12
12
  specs:
13
13
  awesome_print (1.0.2)
14
14
  backports (2.6.1)
15
- bluecloth (2.2.0)
16
15
  citrus (2.4.1)
17
16
  diff-lcs (1.1.3)
18
17
  path (1.3.1)
@@ -33,7 +32,6 @@ GEM
33
32
  rspec-mocks (2.10.1)
34
33
  temple (0.4.0)
35
34
  tilt (1.3.3)
36
- yard (0.8.1)
37
35
 
38
36
  PLATFORMS
39
37
  ruby
@@ -41,7 +39,6 @@ PLATFORMS
41
39
  DEPENDENCIES
42
40
  awesome_print (~> 1.0.2)
43
41
  backports (~> 2.6)
44
- bluecloth (~> 2.2.0)
45
42
  bundler (~> 1.0)
46
43
  citrus (~> 2.4.1)
47
44
  path (~> 1.3)
@@ -52,4 +49,3 @@ DEPENDENCIES
52
49
  sinatra!
53
50
  temple (~> 0.4.0)
54
51
  tilt (~> 1.3)
55
- yard (~> 0.8.1)
@@ -5,32 +5,50 @@ module WLang
5
5
  # wlang -- templating engine
6
6
  #
7
7
  # SYNOPSIS
8
- # Usage: wlang [options] TEMPLATE
8
+ # Usage: wlang [options] TEMPLATE [ATTR1 VALUE1 ATTR2 VALUE2]
9
9
  #
10
10
  # OPTIONS:
11
11
  # #{summarized_options}
12
12
  #
13
13
  # DESCRIPTION
14
- # This command invokes the wlang templating engine on TEMPLATE
15
- # and flushes the rendering result on standard output.
14
+ # This command invokes the wlang templating engine on TEMPLATE and flushes the
15
+ # rendering result on standard output.
16
+ #
17
+ # Commandline template data can be passed through ATTR and VALUE arguments.
16
18
  #
17
19
  class Command < Quickl::Command(__FILE__, __LINE__)
18
20
 
19
- options do |opt|
21
+ attr_reader :output
22
+ attr_reader :yaml_front_matter
23
+ attr_reader :ast
24
+ attr_reader :compiling_options
25
+ attr_reader :context
26
+ attr_reader :dialect
27
+ attr_reader :tpl_file
28
+ attr_reader :template
29
+
30
+ def initialize(*args)
31
+ require 'wlang/html'
32
+ super
20
33
  @output = nil
34
+ @yaml_front_matter = true
35
+ @ast = false
36
+ @compiling_options = {}
37
+ @context = {}
38
+ @dialect = WLang::Html
39
+ end
40
+
41
+ options do |opt|
21
42
  opt.on('--output=FILE', 'Render output in FILE') do |file|
22
43
  @output = file
23
44
  end
24
- @yaml_front_matter = true
25
45
  opt.on("--[no-]yaml-front-matter",
26
46
  "Enable/disable YAML front mater (defaults to true)") do |val|
27
47
  @yaml_front_matter = val
28
48
  end
29
- @ast = false
30
49
  opt.on('--ast', "Debugs the AST") do
31
50
  @ast = true
32
51
  end
33
- @compiling_options = {}
34
52
  opt.on('--[no-]auto-spacing') do |val|
35
53
  @compiling_options[:autospacing] = val
36
54
  end
@@ -63,20 +81,20 @@ module WLang
63
81
  private
64
82
 
65
83
  def install(argv)
66
- raise Quickl::Help unless argv.size == 1
84
+ raise Quickl::Help unless (argv.size % 2) == 1
67
85
 
68
86
  # template file
69
- unless File.file?(@tpl_file = argv.first)
87
+ unless (@tpl_file = Path(argv.shift)).exist?
70
88
  raise Quickl::Exit, "No such template #{tpl_file}"
71
89
  end
72
90
 
73
- # dialect
74
- require 'wlang/html'
75
- @dialect = WLang::Html
91
+ # context
92
+ argv.each_slice(2) do |(k,v)|
93
+ @context[k] = v
94
+ end
76
95
 
77
96
  # template and context
78
- @template = Template.new(File.read(@tpl_file), @compiling_options)
79
- @context = {}
97
+ @template = Template.new(@tpl_file, @compiling_options)
80
98
  end
81
99
 
82
100
  def with_output(&proc)
@@ -2,8 +2,8 @@ module WLang
2
2
  module Version
3
3
 
4
4
  MAJOR = 2
5
- MINOR = 1
6
- TINY = 2
5
+ MINOR = 2
6
+ TINY = 0
7
7
 
8
8
  def self.to_s
9
9
  [ MAJOR, MINOR, TINY ].join('.')
@@ -0,0 +1,60 @@
1
+ require 'spec_helper'
2
+ require 'wlang/command'
3
+ module WLang
4
+ describe Command, 'install' do
5
+
6
+ class Command
7
+ public :install
8
+ end
9
+
10
+ let(:cmd){ Command.new }
11
+
12
+ subject{
13
+ cmd.install(argv)
14
+ }
15
+
16
+ context 'with empty ARGV' do
17
+ let(:argv){ [] }
18
+
19
+ it 'raises an error' do
20
+ lambda{
21
+ subject
22
+ }.should raise_error
23
+ end
24
+ end
25
+
26
+ context 'with a single unexisting file' do
27
+ let(:argv){ [ "foo" ] }
28
+
29
+ it 'raises an error' do
30
+ lambda{
31
+ subject
32
+ }.should raise_error
33
+ end
34
+ end
35
+
36
+ context 'with a single existing file' do
37
+ let(:argv){ [ __FILE__ ] }
38
+
39
+ it 'sets the file correctly' do
40
+ subject
41
+ cmd.tpl_file.should eq(Path(__FILE__))
42
+ end
43
+ end
44
+
45
+ context 'with an existing file and key/value pairs' do
46
+ let(:argv){ [ __FILE__, "foo", "bar", "name", "wlang" ] }
47
+
48
+ it 'sets the file correctly' do
49
+ subject
50
+ cmd.tpl_file.should eq(Path(__FILE__))
51
+ end
52
+
53
+ it 'sets the context correctly' do
54
+ subject
55
+ cmd.context.should eq("foo" => "bar", "name" => "wlang")
56
+ end
57
+ end
58
+
59
+ end
60
+ end
@@ -128,8 +128,6 @@ Gem::Specification.new do |s|
128
128
  s.add_development_dependency("rake", "~> 0.9.2")
129
129
  s.add_development_dependency("bundler", "~> 1.0")
130
130
  s.add_development_dependency("rspec", "~> 2.10.0")
131
- s.add_development_dependency("yard", "~> 0.8.1")
132
- s.add_development_dependency("bluecloth", "~> 2.2.0")
133
131
  s.add_development_dependency("sinatra", ">= 1.4")
134
132
  s.add_development_dependency("rack-test", "~> 0.6.1")
135
133
  s.add_dependency("citrus", "~> 2.4.1")
@@ -1,6 +1,6 @@
1
1
  template-info:
2
2
  name: "rubygem.noe"
3
- version: 1.7.4
3
+ version: 2.0.0
4
4
  links:
5
5
  source: https://github.com/blambeau/noe
6
6
  manifest:
@@ -12,7 +12,7 @@ variables:
12
12
  upper:
13
13
  WLang
14
14
  version:
15
- 2.1.2
15
+ 2.2.0
16
16
  summary: |-
17
17
  WLang is a powerful code generation and templating engine
18
18
  description: |-
@@ -41,7 +41,5 @@ variables:
41
41
  - {name: rake, version: "~> 0.9.2", groups: [development]}
42
42
  - {name: bundler, version: "~> 1.0", groups: [development]}
43
43
  - {name: rspec, version: "~> 2.10.0", groups: [development]}
44
- - {name: yard, version: "~> 0.8.1", groups: [development]}
45
- - {name: bluecloth, version: "~> 2.2.0", groups: [development]}
46
44
  - {name: sinatra, version: ">= 1.4", groups: [development]}
47
45
  - {name: rack-test, version: "~> 0.6.1", groups: [development]}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wlang
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.2
4
+ version: 2.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-01-15 00:00:00.000000000 Z
13
+ date: 2013-03-05 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: awesome_print
@@ -92,38 +92,6 @@ dependencies:
92
92
  - - ~>
93
93
  - !ruby/object:Gem::Version
94
94
  version: 2.10.0
95
- - !ruby/object:Gem::Dependency
96
- name: yard
97
- requirement: !ruby/object:Gem::Requirement
98
- none: false
99
- requirements:
100
- - - ~>
101
- - !ruby/object:Gem::Version
102
- version: 0.8.1
103
- type: :development
104
- prerelease: false
105
- version_requirements: !ruby/object:Gem::Requirement
106
- none: false
107
- requirements:
108
- - - ~>
109
- - !ruby/object:Gem::Version
110
- version: 0.8.1
111
- - !ruby/object:Gem::Dependency
112
- name: bluecloth
113
- requirement: !ruby/object:Gem::Requirement
114
- none: false
115
- requirements:
116
- - - ~>
117
- - !ruby/object:Gem::Version
118
- version: 2.2.0
119
- type: :development
120
- prerelease: false
121
- version_requirements: !ruby/object:Gem::Requirement
122
- none: false
123
- requirements:
124
- - - ~>
125
- - !ruby/object:Gem::Version
126
- version: 2.2.0
127
95
  - !ruby/object:Gem::Dependency
128
96
  name: sinatra
129
97
  requirement: !ruby/object:Gem::Requirement
@@ -332,6 +300,7 @@ files:
332
300
  - spec/integration/tilt/test_wlang_template.rb
333
301
  - spec/spec_helper.rb
334
302
  - spec/test_wlang.rb
303
+ - spec/unit/command/test_install.rb
335
304
  - spec/unit/compiler/autospacing/test_right_strip.rb
336
305
  - spec/unit/compiler/autospacing/test_unindent.rb
337
306
  - spec/unit/compiler/test_dialect_enforcer.rb
@@ -397,7 +366,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
397
366
  version: '0'
398
367
  segments:
399
368
  - 0
400
- hash: 1886081471166054842
369
+ hash: 1035684278937019643
401
370
  required_rubygems_version: !ruby/object:Gem::Requirement
402
371
  none: false
403
372
  requirements:
@@ -406,7 +375,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
406
375
  version: '0'
407
376
  segments:
408
377
  - 0
409
- hash: 1886081471166054842
378
+ hash: 1035684278937019643
410
379
  requirements: []
411
380
  rubyforge_project:
412
381
  rubygems_version: 1.8.24
@@ -446,6 +415,7 @@ test_files:
446
415
  - spec/integration/tilt/test_wlang_template.rb
447
416
  - spec/spec_helper.rb
448
417
  - spec/test_wlang.rb
418
+ - spec/unit/command/test_install.rb
449
419
  - spec/unit/compiler/autospacing/test_right_strip.rb
450
420
  - spec/unit/compiler/autospacing/test_unindent.rb
451
421
  - spec/unit/compiler/test_dialect_enforcer.rb