yamljam 0.0.1 → 0.0.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.
data/.gitignore CHANGED
@@ -1 +1,2 @@
1
- test_files/
1
+ test_files/
2
+ *.gem
data/README.md CHANGED
@@ -1,4 +1,12 @@
1
1
  yamljam
2
2
  =======
3
3
 
4
- jam your yaml
4
+ jam your yaml
5
+ =======
6
+
7
+ This gem provides a way to jam files matching, currently, a very specific pattern into one file. Run it from a directory containing another directory containing yaml files, and it will merge them into one. for example, if you have:
8
+ en/homepage.yml
9
+ en/products.yml
10
+ en/about.yml
11
+
12
+ it will merge all of these into an en.yml file with the keys from the other yaml files included under the newly created en namespace. This is a work in progress and does not work recursively through directories yet, and is missing any kind of knobs and tweaks. Pull requests are welcome.
data/bin/yamljam CHANGED
@@ -6,5 +6,9 @@ if !ARGV[0] || ARGV[0] == "--help"
6
6
  puts "usage: yamljam <directory>"
7
7
  puts "Creates a <directory>.yml file containing the keys from all yml files found in <directory>. Does not work recursively yet!"
8
8
  else
9
- Yamljam::Concatenator.new.jam(Dir.getwd, ARGV[0])
9
+ begin
10
+ Yamljam::Jammer.new.jam(Dir.getwd, ARGV[0])
11
+ rescue Exception => ex
12
+ puts "failed due to exception: #{ex.class}! message was #{ex.message}"
13
+ end
10
14
  end
@@ -1,19 +1,21 @@
1
1
  module Yamljam
2
- class Concatenator
3
- def concatenate(input_files, output_file)
2
+ class Jammer
3
+ def concatenate(input_files, output_file)
4
4
  output_hashmap = merge_files(input_files)
5
5
  write_output(output_hashmap, output_file)
6
6
  end
7
7
 
8
8
  def write_output(output_hashmap, output_file)
9
- File.open(output_file, 'w') do |f|
10
- f.puts("# Generated by Yamljam. Do not directly edit this file.")
11
- f.write(output_hashmap.to_yaml)
12
- end
13
- rescue Exception => ex # if it's any solace I cringed when I wrote that
14
- puts "hit exception when writing output file! #{ex.class} #{ex.message} #{ex.backtrace}"
15
- raise ex
16
- end
9
+ begin
10
+ File.open(output_file, 'w') do |f|
11
+ f.puts("# Generated by Yamljam. Do not directly edit this file.")
12
+ f.write(output_hashmap.to_yaml)
13
+ end
14
+ rescue Exception => ex # if it's any solace I cringed when I wrote that
15
+ puts "hit exception when writing output file! #{ex.class} #{ex.message} #{ex.backtrace}"
16
+ raise ex
17
+ end
18
+ end
17
19
 
18
20
  def merge_files(input_files)
19
21
  {@namespace => input_files.map{|input_file| make_hashmap(input_file)}.reduce({}, &:merge)}
@@ -23,7 +25,7 @@ module Yamljam
23
25
  base_hashmap = YAML::load_file(input_file)
24
26
  end
25
27
 
26
- def jam(input_directory_path = nil, namespace)
28
+ def jam(input_directory_path, namespace)
27
29
  # input directory will contain #{namespace}.yml (output file, which will be blown away)
28
30
  # and a directory called #{namespace}. All files in the #{namespace} directory will be
29
31
  # assumed to be yaml input files if they end in .yml or .yaml, and ignored otherwise.
@@ -32,8 +34,8 @@ module Yamljam
32
34
  input_file_dir = File.join(input_directory_path, namespace)
33
35
  Dir.chdir(input_file_dir) do
34
36
  input_files = Dir.glob("*.yaml") + Dir.glob("*.yml")
35
- concatenate(input_files, File.join("..", "#{namespace}.yml"))
37
+ concatenate(input_files, File.join("..", namespace + ".yml"))
36
38
  end
37
39
  end
38
40
  end
39
- end
41
+ end
@@ -1,3 +1,3 @@
1
1
  module Yamljam
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,56 +1,74 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: yamljam
3
- version: !ruby/object:Gem::Version
4
- version: 0.0.1
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 2
10
+ version: 0.0.2
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Bill Abney
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2012-06-11 00:00:00.000000000Z
17
+
18
+ date: 2012-06-12 00:00:00 Z
13
19
  dependencies: []
14
- description: concatenates multiple yaml files from a subdirectory into one yaml file.
15
- Useful for splitting up and re-joining en.yml
16
- email:
20
+
21
+ description: concatenates multiple yaml files from a subdirectory into one yaml file. Useful for splitting up and re-joining en.yml
22
+ email:
17
23
  - bill.abney@gmail.com
18
- executables:
24
+ executables:
19
25
  - yamljam
20
26
  extensions: []
27
+
21
28
  extra_rdoc_files: []
22
- files:
29
+
30
+ files:
23
31
  - .gitignore
24
32
  - Gemfile
25
33
  - README.md
26
34
  - Rakefile
35
+ - bin/yamljam
27
36
  - lib/yamljam.rb
28
37
  - lib/yamljam/concatenator.rb
29
38
  - lib/yamljam/version.rb
30
39
  - yamljam.gemspec
31
- - bin/yamljam
32
- homepage: ''
40
+ homepage: ""
33
41
  licenses: []
42
+
34
43
  post_install_message:
35
44
  rdoc_options: []
36
- require_paths:
45
+
46
+ require_paths:
37
47
  - lib
38
- required_ruby_version: !ruby/object:Gem::Requirement
48
+ required_ruby_version: !ruby/object:Gem::Requirement
39
49
  none: false
40
- requirements:
41
- - - ! '>='
42
- - !ruby/object:Gem::Version
43
- version: '0'
44
- required_rubygems_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ hash: 3
54
+ segments:
55
+ - 0
56
+ version: "0"
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
45
58
  none: false
46
- requirements:
47
- - - ! '>='
48
- - !ruby/object:Gem::Version
49
- version: '0'
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ hash: 3
63
+ segments:
64
+ - 0
65
+ version: "0"
50
66
  requirements: []
67
+
51
68
  rubyforge_project: yamljam
52
69
  rubygems_version: 1.8.15
53
70
  signing_key:
54
71
  specification_version: 3
55
72
  summary: Jam your yaml files
56
73
  test_files: []
74
+