xembly 0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1b8f2ff85e5b138cd297dfc6e21f04ea2edf282d
4
+ data.tar.gz: 199b12ceb49b9eb8b6a8e3d2d5463d61509a18c5
5
+ SHA512:
6
+ metadata.gz: 3bc249b66e60474edb0dee9f5465d0f17ab32e0eb0a16214af9dc512c7ec60a5269bfbac4bd7433fbc91d1f59f62e70a3abe4d8515632d96d999821757161053
7
+ data.tar.gz: e3a53c6c6b7741bfa46855a8b9a054c5d1e5d53b63099def1a6319cba1719f8ed41e6115f5a43df93c59667d6c1c247d3446ae2aecc6275da6916d39b6bc0225
data/.coveralls.yml ADDED
@@ -0,0 +1,2 @@
1
+ service_name: travis-pro
2
+ repo_token: vN9RXEgg4ZfLATYkLIbL3dxPcXWm5kQmM
data/.gitattributes ADDED
@@ -0,0 +1,7 @@
1
+ # Check out all text files in UNIX format, with LF as end of line
2
+ # Don't change this file. If you have any ideas about it, please
3
+ # submit a separate issue about it and we'll discuss.
4
+
5
+ * text=auto eol=lf
6
+ *.java ident
7
+ *.xml ident
data/.gitignore ADDED
@@ -0,0 +1,7 @@
1
+ coverage/
2
+ Gemfile.lock
3
+ .idea/
4
+ *.gem
5
+ .bundle/
6
+ .DS_Store
7
+ rdoc/
data/.rubocop.yml ADDED
@@ -0,0 +1,4 @@
1
+ MethodLength:
2
+ Max: 30
3
+ Style/ClassLength:
4
+ Max: 150
data/.rultor.yml ADDED
@@ -0,0 +1,28 @@
1
+ assets:
2
+ rubygems.yml: yegor256/home#assets/rubygems.yml
3
+ s3cfg: yegor256/home#assets/s3cfg
4
+ install: |
5
+ sudo apt-get update
6
+ sudo gem install pdd
7
+ release:
8
+ script: |-
9
+ sudo bundle install
10
+ rake
11
+ rm -rf *.gem
12
+ sed -i "s/1\.0\.snapshot/${tag}/g" lib/xembly/version.rb
13
+ git add lib/xembly/version.rb
14
+ git commit -m "version set to ${tag}"
15
+ gem build xembly.gemspec
16
+ chmod 0600 ../rubygems.yml
17
+ gem push *.gem --config-file ../rubygems.yml
18
+ sudo gem install xembly
19
+ pdd --source=$(pwd) --verbose --file=xembly-gem.xml -e=test/** -e=features/** -e=README.md
20
+ s3cmd --no-progress put xembly-gem.xml --config=../s3cfg s3://pdd.teamed.io/xembly-gem.xml
21
+ commanders:
22
+ - yegor256
23
+ architect:
24
+ - yegor256
25
+ - davvd
26
+ merge:
27
+ commanders: []
28
+ deploy: {}
data/.simplecov ADDED
@@ -0,0 +1,43 @@
1
+ # encoding: utf-8
2
+ #
3
+ # Copyright (c) 2016 Yegor Bugayenko
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the 'Software'), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+ require 'coveralls'
24
+
25
+ if Gem.win_platform? then
26
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
27
+ SimpleCov::Formatter::HTMLFormatter
28
+ ]
29
+ SimpleCov.start do
30
+ add_filter "/test/"
31
+ add_filter "/features/"
32
+ end
33
+ else
34
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new [
35
+ SimpleCov::Formatter::HTMLFormatter,
36
+ Coveralls::SimpleCov::Formatter
37
+ ]
38
+ SimpleCov.start do
39
+ add_filter "/test/"
40
+ add_filter "/features/"
41
+ minimum_coverage 90
42
+ end
43
+ end
data/.travis.yml ADDED
@@ -0,0 +1,12 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ cache: bundler
5
+ branches:
6
+ only:
7
+ - master
8
+ install:
9
+ - travis_retry bundle update
10
+ script:
11
+ - rake
12
+
data/Gemfile ADDED
@@ -0,0 +1,24 @@
1
+ # encoding: utf-8
2
+ #
3
+ # Copyright (c) 2016 Yegor Bugayenko
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the 'Software'), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+ source 'https://rubygems.org'
24
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2016 Yegor Bugayenko
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the 'Software'), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,32 @@
1
+ [![Made By Teamed.io](http://img.teamed.io/btn.svg)](http://www.teamed.io)
2
+ [![DevOps By Rultor.com](http://www.rultor.com/b/yegor256/xembly-gem)](http://www.rultor.com/p/yegor256/xembly-gem)
3
+ [![We recommend RubyMine](http://img.teamed.io/rubymine-recommend.svg)](https://www.jetbrains.com/ruby/)
4
+
5
+ [![Build Status](https://travis-ci.org/yegor256/xembly-gem.svg)](https://travis-ci.org/yegor256/xembly-gem)
6
+ [![Build status](https://ci.appveyor.com/api/projects/status/8e5dsjjemymfg510?svg=true)](https://ci.appveyor.com/project/yegor256/xembly-gem)
7
+ [![Gem Version](https://badge.fury.io/rb/xembly.svg)](http://badge.fury.io/rb/xembly)
8
+ [![Dependency Status](https://gemnasium.com/yegor256/xembly-gem.svg)](https://gemnasium.com/yegor256/xembly-gem)
9
+ [![Code Climate](http://img.shields.io/codeclimate/github/yegor256/xembly-gem.svg)](https://codeclimate.com/github/yegor256/xembly-gem)
10
+ [![Coverage Status](https://img.shields.io/coveralls/yegor256/xembly-gem.svg)](https://coveralls.io/r/yegor256/xembly-gem)
11
+
12
+ ## Assembly for XML
13
+
14
+ Read this [blog post](http://www.yegor256.com/2014/04/09/xembly-intro.html)
15
+ and check this project: [yegor256/xembly](https://github.com/yegor256/xembly)
16
+
17
+ ## How to Install?
18
+
19
+ You will need Ruby 2.0+:
20
+
21
+ ```bash
22
+ $ gem install xembly
23
+ ```
24
+
25
+ ## How to Run?
26
+
27
+ Run it locally and read its output:
28
+
29
+ ```bash
30
+ $ xembly --help
31
+ ```
32
+
data/Rakefile ADDED
@@ -0,0 +1,78 @@
1
+ # encoding: utf-8
2
+ #
3
+ # Copyright (c) 2016 Yegor Bugayenko
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the 'Software'), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+ require 'rubygems'
24
+ require 'rake'
25
+ require 'rdoc'
26
+ require 'rake/clean'
27
+
28
+ def name
29
+ @name ||= File.basename(Dir['*.gemspec'].first, '.*')
30
+ end
31
+
32
+ def version
33
+ Gem::Specification.load(Dir['*.gemspec'].first).version
34
+ end
35
+
36
+ task default: [:clean, :test, :features, :rubocop, :copyright]
37
+
38
+ require 'rake/testtask'
39
+ desc 'Run all unit tests'
40
+ Rake::TestTask.new(:test) do |test|
41
+ Rake::Cleaner.cleanup_files(['coverage'])
42
+ test.libs << 'lib' << 'test'
43
+ test.pattern = 'test/**/test_*.rb'
44
+ test.verbose = false
45
+ end
46
+
47
+ require 'rdoc/task'
48
+ desc 'Build RDoc documentation'
49
+ Rake::RDocTask.new do |rdoc|
50
+ rdoc.rdoc_dir = 'rdoc'
51
+ rdoc.title = "#{name} #{version}"
52
+ rdoc.rdoc_files.include('README*')
53
+ rdoc.rdoc_files.include('lib/**/*.rb')
54
+ end
55
+
56
+ require 'rubocop/rake_task'
57
+ desc 'Run RuboCop on all directories'
58
+ RuboCop::RakeTask.new(:rubocop) do |task|
59
+ task.fail_on_error = true
60
+ task.requires << 'rubocop-rspec'
61
+ end
62
+
63
+ require 'cucumber/rake/task'
64
+ Cucumber::Rake::Task.new(:features) do |t|
65
+ Rake::Cleaner.cleanup_files(['coverage'])
66
+ t.profile = 'travis'
67
+ end
68
+ Cucumber::Rake::Task.new(:"features:html") do |t|
69
+ t.profile = 'html_report'
70
+ end
71
+
72
+ task :copyright do
73
+ sh "grep -q -r '#{Date.today.strftime('%Y')}' \
74
+ --include '*.rb' \
75
+ --include '*.txt' \
76
+ --include 'Rakefile' \
77
+ ."
78
+ end
data/appveyor.yml ADDED
@@ -0,0 +1,20 @@
1
+ version: '{build}'
2
+ skip_tags: true
3
+ clone_depth: 10
4
+ branches:
5
+ only:
6
+ - master
7
+ except:
8
+ - gh-pages
9
+ os: Windows Server 2012
10
+ install:
11
+ - cmd: SET PATH=C:\Ruby200\bin;%PATH%
12
+ - cmd: ruby --version
13
+ build_script:
14
+ - bundle update
15
+ - bundle install
16
+ test_script:
17
+ - rake
18
+ cache:
19
+ - C:\Ruby200\bin -> xembly.gemspec
20
+ - C:\Ruby200\lib\ruby\gems\2.0.0 -> xembly.gemspec
data/bin/xembly ADDED
@@ -0,0 +1,67 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+ #
4
+ # Copyright (c) 2016 Yegor Bugayenko
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ # of this software and associated documentation files (the 'Software'), to deal
8
+ # in the Software without restriction, including without limitation the rights
9
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ # copies of the Software, and to permit persons to whom the Software is
11
+ # furnished to do so, subject to the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be included in all
14
+ # copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
19
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ # SOFTWARE.
23
+
24
+ STDOUT.sync = true
25
+
26
+ require 'xembly'
27
+ require 'slop'
28
+ require 'xembly/version'
29
+
30
+ opts = Slop.parse(ARGV, strict: true, help: true) do |o|
31
+ o.banner = "Usage (#{Xembly::VERSION}): xembly [options]"
32
+ o.on '-h', '--help', 'Print help' do
33
+ puts o
34
+ exit
35
+ end
36
+ o.on '-v', '--verbose', 'Enable verbose mode'
37
+ o.on '--version', 'Show current version' do
38
+ puts Xembly::VERSION
39
+ exit
40
+ end
41
+ o.string(
42
+ '-d',
43
+ '--dirs',
44
+ 'File path with Xembly directives (command line args by default)',
45
+ argument: :required
46
+ )
47
+ o.string(
48
+ '-x',
49
+ '--xml',
50
+ 'File to read XML from (stdin by default)',
51
+ argument: :required
52
+ )
53
+ o.string(
54
+ '-f',
55
+ '--file',
56
+ 'File to save XML into (stdout by default)',
57
+ argument: :required
58
+ )
59
+ end
60
+
61
+ fail '-f is mandatory when using -v' if opts.verbose? && !opts.file?
62
+
63
+ Encoding.default_external = Encoding::UTF_8
64
+ Encoding.default_internal = Encoding::UTF_8
65
+ output = Xembly::Base.new(opts).xml
66
+ file = opts.file? ? File.new(opts[:file], 'w') : STDOUT
67
+ file << output
data/cucumber.yml ADDED
@@ -0,0 +1,3 @@
1
+ default: --format pretty
2
+ travis: --format progress
3
+ html_report: --format progress --format html --out=features_report.html
@@ -0,0 +1,34 @@
1
+ Feature: Command Line Processing
2
+ As an owner of XML documetn I want to be able to
3
+ call Xembly as a command line tool and modify it
4
+
5
+ Scenario: Help can be printed
6
+ When I run bin/xembly with "--help"
7
+ Then Exit code is zero
8
+ And Stdout contains "-v, --verbose"
9
+
10
+ Scenario: Version can be printed
11
+ When I run bin/xembly with "--version"
12
+ Then Exit code is zero
13
+
14
+ Scenario: Simple XML manipulations
15
+ Given I have a "text.xml" file with content:
16
+ """
17
+ <books>
18
+ <book id="1"/>
19
+ <book id="2"/>
20
+ </books>
21
+ """
22
+ And I have a "dirs.txt" file with content:
23
+ """
24
+ XPATH "/books";
25
+ ADD "book";
26
+ """
27
+ When I run bin/xembly with "-v -d dirs.txt -f out.xml -x text.xml"
28
+ Then Exit code is zero
29
+ And Stdout contains "reading text.xml"
30
+ And XML file "out.xml" matches "/books[count(book) = 3]"
31
+
32
+ Scenario: Rejects unknown options
33
+ When I run bin/xembly with "--some-unknown-option"
34
+ Then Exit code is not zero
@@ -0,0 +1,22 @@
1
+ Feature: Gem Package
2
+ As a source code writer I want to be able to
3
+ package the Gem into .gem file
4
+
5
+ Scenario: Gem can be packaged
6
+ Given It is Unix
7
+ Given I have a "execs.rb" file with content:
8
+ """
9
+ #!/usr/bin/env ruby
10
+ require 'rubygems'
11
+ spec = Gem::Specification::load('./spec.rb')
12
+ fail 'no executables' if spec.executables.empty?
13
+ """
14
+ When I run bash with
15
+ """
16
+ cd xembly
17
+ gem build xembly.gemspec
18
+ gem specification --ruby xembly-*.gem > ../spec.rb
19
+ cd ..
20
+ ruby execs.rb
21
+ """
22
+ Then Exit code is zero
@@ -0,0 +1,98 @@
1
+ # encoding: utf-8
2
+ #
3
+ # Copyright (c) 2016 TechnoPark Corp.
4
+ # Copyright (c) 2016 Yegor Bugayenko
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ # of this software and associated documentation files (the 'Software'), to deal
8
+ # in the Software without restriction, including without limitation the rights
9
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ # copies of the Software, and to permit persons to whom the Software is
11
+ # furnished to do so, subject to the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be included in all
14
+ # copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
19
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ # SOFTWARE.
23
+
24
+ require 'xembly'
25
+ require 'nokogiri'
26
+ require 'tmpdir'
27
+ require 'slop'
28
+ require 'English'
29
+
30
+ Before do
31
+ @cwd = Dir.pwd
32
+ @dir = Dir.mktmpdir('test')
33
+ FileUtils.mkdir_p(@dir) unless File.exist?(@dir)
34
+ Dir.chdir(@dir)
35
+ end
36
+
37
+ After do
38
+ Dir.chdir(@cwd)
39
+ FileUtils.rm_rf(@dir) if File.exist?(@dir)
40
+ end
41
+
42
+ Given(/^I have a "([^"]*)" file with content:$/) do |file, text|
43
+ FileUtils.mkdir_p(File.dirname(file)) unless File.exist?(file)
44
+ File.open(file, 'w') do |f|
45
+ f.write(text.gsub(/\\xFF/, "\xFF"))
46
+ end
47
+ end
48
+
49
+ Then(/^XML matches "([^"]+)"$/) do |xpath|
50
+ fail "XML doesn't match \"#{xpath}\":\n#{@xml}" if @xml.xpath(xpath).empty?
51
+ end
52
+
53
+ When(/^I run bin\/xembly with "([^"]*)"$/) do |arg|
54
+ home = File.join(File.dirname(__FILE__), '../..')
55
+ @stdout = `ruby -I#{home}/lib #{home}/bin/xembly #{arg}`
56
+ @exitstatus = $CHILD_STATUS.exitstatus
57
+ end
58
+
59
+ Then(/^Stdout contains "([^"]*)"$/) do |txt|
60
+ unless @stdout.include?(txt)
61
+ fail "STDOUT doesn't contain '#{txt}':\n#{@stdout}"
62
+ end
63
+ end
64
+
65
+ Then(/^Stdout is empty$/) do
66
+ fail "STDOUT is not empty:\n#{@stdout}" unless @stdout == ''
67
+ end
68
+
69
+ Then(/^XML file "([^"]+)" matches "([^"]+)"$/) do |file, xpath|
70
+ fail "File #{file} doesn't exit" unless File.exist?(file)
71
+ xml = Nokogiri::XML.parse(File.read(file))
72
+ xml.remove_namespaces!
73
+ if xml.xpath(xpath).empty?
74
+ fail "XML file #{file} doesn't match \"#{xpath}\":\n#{xml}"
75
+ end
76
+ end
77
+
78
+ Then(/^Exit code is zero$/) do
79
+ fail "Non-zero exit code #{@exitstatus}" unless @exitstatus == 0
80
+ end
81
+
82
+ Then(/^Exit code is not zero$/) do
83
+ fail 'Zero exit code' if @exitstatus == 0
84
+ end
85
+
86
+ When(/^I run bash with$/) do |text|
87
+ FileUtils.copy_entry(@cwd, File.join(@dir, 'xembly'))
88
+ @stdout = `#{text}`
89
+ @exitstatus = $CHILD_STATUS.exitstatus
90
+ end
91
+
92
+ Given(/^It is Unix$/) do
93
+ pending if Gem.win_platform?
94
+ end
95
+
96
+ Given(/^It is Windows$/) do
97
+ pending unless Gem.win_platform?
98
+ end
@@ -0,0 +1,25 @@
1
+ # encoding: utf-8
2
+ #
3
+ # Copyright (c) 2016 TechnoPark Corp.
4
+ # Copyright (c) 2016 Yegor Bugayenko
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ # of this software and associated documentation files (the 'Software'), to deal
8
+ # in the Software without restriction, including without limitation the rights
9
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ # copies of the Software, and to permit persons to whom the Software is
11
+ # furnished to do so, subject to the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be included in all
14
+ # copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
19
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ # SOFTWARE.
23
+
24
+ require 'simplecov'
25
+ require 'xembly'
data/lib/xembly/add.rb ADDED
@@ -0,0 +1,44 @@
1
+ # encoding: utf-8
2
+ #
3
+ # Copyright (c) 2016 Yegor Bugayenko
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the 'Software'), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+ require 'nokogiri'
24
+
25
+ module Xembly
26
+ # ADD directive
27
+ class Add
28
+ # Ctor.
29
+ # +name+:: Node name to add
30
+ def initialize(name)
31
+ @name = name
32
+ end
33
+
34
+ def exec(dom, cursor)
35
+ after = []
36
+ cursor.each do |node|
37
+ child = Nokogiri::XML::Node.new(@name, dom)
38
+ node.add_child(child)
39
+ after.push(child)
40
+ end
41
+ after
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,41 @@
1
+ # encoding: utf-8
2
+ #
3
+ # Copyright (c) 2016 Yegor Bugayenko
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the 'Software'), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+ module Xembly
24
+ # ATTR directive
25
+ class Attr
26
+ # Ctor.
27
+ # +name+:: Attribute name
28
+ # +val+:: Attribute value
29
+ def initialize(name, value)
30
+ @name = name
31
+ @value = value
32
+ end
33
+
34
+ def exec(_, cursor)
35
+ cursor.each do |node|
36
+ node[@name] = @value
37
+ end
38
+ cursor
39
+ end
40
+ end
41
+ end