filegen 0.4.1 → 0.4.3

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: 8d9f441a26f9e6601791aa1fe6e83301c46dbac9
4
- data.tar.gz: cfe9f0bd4544e817dc3c3ca003b2f01a6a161d71
3
+ metadata.gz: e274f34d1c3bdb315d61f8a64256f639189a7013
4
+ data.tar.gz: b8933b8b512918fe7c0e7491ad0fa0c25e7770b9
5
5
  SHA512:
6
- metadata.gz: 01c3b27f2ab41b16f2bb5bec395e8f2515eadb0bdb1f1f9be3941e86b528cf839e885ca43449903877d95f27cc1da35f5ef7a1d4244d7e2e1164ee70f963a763
7
- data.tar.gz: 6040a9e540c5a6bb6468f16b84cd456364edfeeea6453d7e8cc76511541ae4e697e559f7919f1f505cda36579b5e8dfcda7cfcd7d6846a7bec3f492abdfb936f
6
+ metadata.gz: 0de6d52b07d2cc21a39c4af931553fda06c69614921bdecff0da36a4bd69d2ba954919cea05bfdcd572768a918454f4baaf6b75ca17edf8fc66e3eea661dba09
7
+ data.tar.gz: e79a8ebd0721599d9806b0bda60bc7e22278f0907bd3a773d8c6cb4939f33420452b36018c31373b9e41a5e1ba206e1174f1fb902c64c1848601e94f650f2388
data/.gitignore CHANGED
@@ -1,3 +1,5 @@
1
+ *.xz
2
+ *.gz
1
3
  *.gem
2
4
  *.rbc
3
5
  .bundle
data/.rspec CHANGED
@@ -1,3 +1,4 @@
1
+ --require rspec/legacy_formatters
1
2
  --format Fuubar
2
3
  --order rand
3
4
  --color
File without changes
data/Gemfile CHANGED
@@ -1,34 +1,37 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in filegen.gemspec
3
+ # use gem spec
4
4
  gemspec
5
5
 
6
- group :test do
7
- gem 'aruba'
8
- gem 'cucumber'
9
- gem 'fuubar'
10
- gem 'rspec'
11
- gem 'simplecov'
12
- gem 'rubocop'
13
- gem 'coveralls'
14
- end
6
+ group :development, :test do
7
+ if RUBY_VERSION < '2.0.0'
8
+ gem 'pry-debugger', require: false
9
+ gem 'debugger'
10
+ gem 'debugger-completion', require: false
11
+ else
12
+ gem 'pry-byebug', require: false
13
+ gem 'byebug'
14
+ end
15
15
 
16
- group :development do
17
- gem 'debugger'
18
- gem 'awesome_print'
19
- gem 'debugger-completion'
20
- gem 'pry'
21
- gem 'pry-debugger'
22
- gem 'pry-doc'
23
- gem 'tmrb'
24
- gem 'yard'
16
+ gem 'activesupport', require: false
17
+ gem 'aruba', require: false
18
+ gem 'awesome_print', require: 'ap'
19
+ gem 'bundler', '~> 1.3', require: false
20
+ gem 'coveralls', require: false
21
+ gem 'cucumber', require: false
22
+ gem 'erubis'
23
+ gem 'fedux_org-stdlib', require: false
24
+ gem 'fuubar'
25
25
  gem 'github-markup'
26
+ gem 'pry', require: false
27
+ gem 'pry-doc', require: false
28
+ gem 'rake', require: false
26
29
  gem 'redcarpet'
30
+ gem 'rspec', require: false
31
+ gem 'rspec-legacy_formatters', require: false
32
+ gem 'rubocop', require: false
33
+ gem 'simplecov'
34
+ gem 'tmrb', require: false
35
+ gem 'versionomy'
36
+ gem 'yard', require: false
27
37
  end
28
-
29
- gem 'rake', group: [:development, :test]
30
- gem 'fedux_org-stdlib', group: [:development, :test]
31
- gem 'bundler', '~> 1.3', group: [:development, :test]
32
- gem 'erubis', group: [:development, :test]
33
- gem 'versionomy', group: [:development, :test]
34
- gem 'activesupport', group: [:development, :test]
data/README.md CHANGED
@@ -208,4 +208,4 @@ chmod +x <wrapper>
208
208
 
209
209
  ## Contributing
210
210
 
211
- Please have a look at the {file:README.DEVELOPER.md developer readme}
211
+ Please have a look at the {file:CONTRIBUTING.md contribution guide}
data/Rakefile CHANGED
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env rake
2
2
 
3
+ $LOAD_PATH << File.expand_path('../lib', __FILE__)
4
+
3
5
  #require 'bundler'
4
6
  #Bundler.require :default, :test, :development
5
7
 
@@ -26,3 +26,14 @@ Feature: Error handling
26
26
  File "template1.abc" is not a valid erb template: file ending erb
27
27
  """
28
28
 
29
+ @wip
30
+ Scenario: Non existing YAML-file
31
+ Given a file named "template.erb" with:
32
+ """
33
+ Hello <%= lookup('name') %>!
34
+ """
35
+ When I run `filegen -y input.yaml template.erb`
36
+ Then the stderr should contain:
37
+ """
38
+ Yaml-file "input.yaml" not found
39
+ """
@@ -2,7 +2,12 @@
2
2
  $LOAD_PATH.unshift File.expand_path('../../../lib', __FILE__)
3
3
 
4
4
  unless ENV['CI'] == 'true'
5
- require 'debugger'
5
+ if RUBY_VERSION < '2.0.0'
6
+ require 'debugger'
7
+ else
8
+ require 'byebug'
9
+ end
10
+
6
11
  require 'pry'
7
12
  end
8
13
 
@@ -6,6 +6,8 @@ require 'ostruct'
6
6
  require 'logger'
7
7
  require 'active_support/hash_with_indifferent_access'
8
8
  require 'stringio'
9
+ require 'json'
10
+ require 'psych'
9
11
 
10
12
  require 'filegen/version'
11
13
  require 'filegen/ui'
@@ -13,8 +13,8 @@ module Filegen
13
13
  # Create data source
14
14
  def initialize(file)
15
15
  @source = HashWithIndifferentAccess.new(Psych.load_file(file))
16
- rescue
17
- @source = HashWithIndifferentAccess.new
16
+ rescue Errno::ENOENT
17
+ raise Exceptions::YamlFileNotFound, JSON.dump(file: file)
18
18
  end
19
19
 
20
20
  def fetch(key, default_value = nil)
@@ -16,5 +16,8 @@ module Filegen
16
16
 
17
17
  # raised if a given erb template has syntax errors in it
18
18
  class ErbTemplateHasSyntaxErrors < Exception; end
19
+
20
+ # raised if yaml file cannot be found
21
+ class YamlFileNotFound < Exception; end
19
22
  end
20
23
  end
@@ -32,15 +32,18 @@ module Filegen
32
32
  generator.compile(options.source, options.destination)
33
33
 
34
34
  exitstatus = 0
35
- rescue RuntimeError => e
36
- Filegen::Ui.error e.message
37
- exitstatus = 1
38
35
  rescue Interrupt
39
36
  Filegen::Ui.warning 'You told me to stop command execution.'
40
37
  exitstatus = 2
41
38
  rescue Exceptions::ErbTemplateHasSyntaxErrors => e
42
39
  Filegen::Ui.error "Syntax error in ERB-Template: \n" + e.message
43
40
  exitstatus = 3
41
+ rescue Exceptions::YamlFileNotFound => e
42
+ Filegen::Ui.error "Yaml-file \"#{JSON.parse(e.message)['file']}\" not found."
43
+ exitstatus = 4
44
+ rescue StandardError => e
45
+ Filegen::Ui.error "#{e.class} - #{e.message}"
46
+ exitstatus = 99
44
47
  end
45
48
 
46
49
  @kernel.exit(exitstatus)
@@ -1,4 +1,4 @@
1
1
  #main Filegen
2
2
  module Filegen
3
- VERSION = '0.4.1'
3
+ VERSION = '0.4.3'
4
4
  end
@@ -0,0 +1,38 @@
1
+ # Maintainer: Max Meyer <dev@fedux.org>
2
+ pkgname=filegen
3
+ pkgver=0.4.1
4
+ pkgrel=1
5
+ pkgdesc="generating files made easy"
6
+ arch=(i686 x86_64)
7
+ url="https://github.com/dg-vrnetze/${pkgname}"
8
+ license=('MIT')
9
+ depends=(ruby)
10
+ makedepends=(rubygems)
11
+ source=(http://gems.rubyforge.org/gems/$pkgname-$pkgver.gem)
12
+ noextract=($pkgname-$pkgver.gem)
13
+ sha256sums=('34b0c3082b41bf44c0d2b4f906871c135e651a84de9d3be124d2f45ff4b79881')
14
+
15
+ package() {
16
+ cd "$srcdir"
17
+
18
+ _library_dir=/usr/lib/${pkgname}
19
+ _share_dir="${_library_dir}/gems/${pkgname}-${pkgver}/share"
20
+ _systemd_dir=/usr/lib/systemd/system
21
+ _bin_dir=/usr/bin
22
+
23
+ install -d ${pkgdir}${_library_dir}
24
+ install -d ${pkgdir}${_bin_dir}
25
+
26
+ gem install --env-shebang --wrappers --no-ri --no-rdoc --install-dir ${pkgdir}/${_library_dir} $pkgname
27
+
28
+ echo '#!/usr/bin/env bash' >> ${pkgdir}${_bin_dir}/${pkgname}
29
+ echo "export GEM_HOME='${_library_dir}'" >> ${pkgdir}${_bin_dir}/${pkgname}
30
+ echo "export GEM_PATH='${_library_dir}'" >> ${pkgdir}${_bin_dir}/${pkgname}
31
+ echo "export GEM_ROOT='${_library_dir}'" >> ${pkgdir}${_bin_dir}/${pkgname}
32
+ echo "exec ${_library_dir}/gems/${pkgname}-${pkgver}/bin/${pkgname} \$*" >> ${pkgdir}${_bin_dir}/${pkgname}
33
+
34
+ chmod a+x ${pkgdir}${_bin_dir}/${pkgname}
35
+ rm -r ${pkgdir}${_library_dir}/cache
36
+ }
37
+
38
+ # vim:set ts=2 sw=2 et:
@@ -2,6 +2,12 @@
2
2
  require 'spec_helper'
3
3
 
4
4
  describe DataSources::Yaml do
5
+ context '#initialize' do
6
+ it 'raises an exception if the yaml file cannot be found' do
7
+ expect { DataSources::Yaml.new('not valid file') }.to raise_error Exceptions::YamlFileNotFound
8
+ end
9
+ end
10
+
5
11
  context '#fetch' do
6
12
  it 'retrieves variables from yaml file' do
7
13
  file = create_file('blub.yaml', <<-EOF.strip_heredoc
@@ -32,10 +38,5 @@ describe DataSources::Yaml do
32
38
  source = DataSources::Yaml.new(file)
33
39
  expect(source.fetch('NOT_MY_NAME')).to be_nil
34
40
  end
35
-
36
- it 'returns nil if file cannot be found' do
37
- source = DataSources::Yaml.new('not valid file')
38
- expect(source.fetch('NOT_MY_NAME')).to be_nil
39
- end
40
41
  end
41
42
  end
@@ -1,5 +1,10 @@
1
1
  # encoding: utf-8
2
2
  unless ENV['CI'] == 'true'
3
- require 'debugger'
3
+ if RUBY_VERSION < '2.0.0'
4
+ require 'debugger'
5
+ else
6
+ require 'byebug'
7
+ end
8
+
4
9
  require 'pry'
5
10
  end
@@ -1,6 +1,5 @@
1
1
  # encoding: utf-8
2
2
  RSpec.configure do |c|
3
- c.treat_symbols_as_metadata_keys_with_true_values = true
4
3
  c.filter_run focus: true
5
4
  c.run_all_when_everything_filtered = true
6
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: filegen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dennis Günnewig
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-24 00:00:00.000000000 Z
11
+ date: 2014-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -40,9 +40,9 @@ files:
40
40
  - ".travis.yml"
41
41
  - ".yardopts"
42
42
  - CHANGELOG.md
43
+ - CONTRIBUTING.md
43
44
  - Gemfile
44
45
  - LICENSE.md
45
- - README.DEVELOPER.md
46
46
  - README.md
47
47
  - Rakefile
48
48
  - bin/filegen
@@ -70,6 +70,7 @@ files:
70
70
  - lib/filegen/version.rb
71
71
  - rubocop-todo.yml
72
72
  - scripts/terminal
73
+ - share/archlinux/PKGBUILD
73
74
  - spec/data_source_builder_spec.rb
74
75
  - spec/data_sources/environment_spec.rb
75
76
  - spec/data_sources/yaml_spec.rb
@@ -79,11 +80,11 @@ files:
79
80
  - spec/ruby_gen_spec.rb
80
81
  - spec/rubygen_spec.rb
81
82
  - spec/spec_helper.rb
82
- - spec/support/config.rb
83
83
  - spec/support/debugging.rb
84
84
  - spec/support/environment.rb
85
85
  - spec/support/filesystem.rb
86
86
  - spec/support/here_doc.rb
87
+ - spec/support/rspec.rb
87
88
  homepage: https://github.com/dg-vrnetze/filegen
88
89
  licenses:
89
90
  - MIT
@@ -124,9 +125,9 @@ test_files:
124
125
  - spec/ruby_gen_spec.rb
125
126
  - spec/rubygen_spec.rb
126
127
  - spec/spec_helper.rb
127
- - spec/support/config.rb
128
128
  - spec/support/debugging.rb
129
129
  - spec/support/environment.rb
130
130
  - spec/support/filesystem.rb
131
131
  - spec/support/here_doc.rb
132
+ - spec/support/rspec.rb
132
133
  has_rdoc: