filegen 0.1.1 → 0.1.2

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.
Files changed (4) hide show
  1. data/README.md +34 -0
  2. data/Rakefile +6 -1
  3. data/lib/filegen/version.rb +1 -1
  4. metadata +1 -1
data/README.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  [![Build Status](https://travis-ci.org/dg-vrnetze/filegen.png?branch=master)](https://travis-ci.org/dg-vrnetze/filegen)
4
4
  [![Code Climate](https://codeclimate.com/github/dg-vrnetze/filegen.png)](https://codeclimate.com/github/dg-vrnetze/filegen)
5
+ [![Coverage Status](https://coveralls.io/repos/dg-vrnetze/filegen/badge.png?branch=master)](https://coveralls.io/r/dg-vrnetze/filegen?branch=master)
5
6
 
6
7
  Have you ever felt the need to generate files based on environment variables or
7
8
  yaml files? If your answer is yes, then `filegen` can be quite helpful for
@@ -118,6 +119,39 @@ And get the following result.
118
119
  Hello my name is: Karl
119
120
  ```
120
121
 
122
+ ## Use Cases
123
+
124
+ ### RPM packaging
125
+
126
+ Say you would like to package a ruby-based application for a rpm-based
127
+ distribution. You can build a rpm package for each gem it depends on or build
128
+ one rpm for the whole application containing all needed gems. After using the
129
+ first approach at first I switched to the second one at last: No need to care
130
+ about different version of one rubygem as dependency of different applications.
131
+
132
+ To make this possible I decided to use a small wrapper which sets all
133
+ neccessary paths: `GEM_PATH`, `GEM_ROOT` and `GEM_HOME`. After that it executes
134
+ the ruby application. Because every application resists below a different path,
135
+ I needed to generate a different wrapper for each application. For this I use
136
+ this small template:
137
+
138
+ ```erb
139
+ #!/usr/bin/env bash
140
+
141
+ export GEM_ROOT='<%= lookup('SOFTWARE_LIB') %>'
142
+ export GEM_PATH='<%= lookup('SOFTWARE_LIB') %>'
143
+ export GEM_HOME='<%= lookup('SOFTWARE_LIB') %>'
144
+
145
+ exec <%= lookup('SOFTWARE_BINARY') %> $*
146
+ ```
147
+
148
+ The wrapper is then generated within the rpm spec:
149
+
150
+ ```
151
+ SOFTWARE_BINARY=<path to rubygems bin> SOFTWARE_LIB=<library_path> filegen gem.erb > <wrapper>
152
+ chmod +x <wrapper>
153
+ ```
154
+
121
155
  ## Future
122
156
 
123
157
  * Maybe I will add additional data sources. Please see the
data/Rakefile CHANGED
@@ -32,6 +32,10 @@ def pkg_directory
32
32
  File.join(root_directory, 'pkg')
33
33
  end
34
34
 
35
+ def gem_directory
36
+ File.join(root_directory, 'vendor', 'cache')
37
+ end
38
+
35
39
  task :default => 'gem:build'
36
40
 
37
41
  file gem_file => 'gem:build'
@@ -43,7 +47,8 @@ end
43
47
  namespace :gem do
44
48
  desc 'build tar file'
45
49
  task :package => [gem_file, tmp_directory] do
46
- FileUtils.mv File.join(pkg_directory,"#{software}-#{version}.gem"), tmp_directory
50
+ FileUtils.mv File.join(pkg_directory, "#{software}-#{version}.gem"), tmp_directory
51
+ FileUtils.mv File.join(gem_directory, "moneta-0.7.20.gem"), tmp_directory
47
52
 
48
53
  Dir.chdir('tmp') do
49
54
  sh "tar -czf #{tar_file} #{File.basename tmp_directory}"
@@ -1,4 +1,4 @@
1
1
  #main Filegen
2
2
  module Filegen
3
- VERSION = '0.1.1'
3
+ VERSION = '0.1.2'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: filegen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: