elf_manifesto 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. data/.DS_Store +0 -0
  2. data/.gitignore +6 -0
  3. data/.rvmrc +1 -0
  4. data/Elf_Manifesto.gemspec +43 -0
  5. data/Gemfile +4 -0
  6. data/Guardfile +29 -0
  7. data/Rakefile +1 -0
  8. data/bin/manifesto +131 -0
  9. data/coverage/.resultset.json +75 -0
  10. data/coverage/assets/0.5.3/app.js +88 -0
  11. data/coverage/assets/0.5.3/fancybox/blank.gif +0 -0
  12. data/coverage/assets/0.5.3/fancybox/fancy_close.png +0 -0
  13. data/coverage/assets/0.5.3/fancybox/fancy_loading.png +0 -0
  14. data/coverage/assets/0.5.3/fancybox/fancy_nav_left.png +0 -0
  15. data/coverage/assets/0.5.3/fancybox/fancy_nav_right.png +0 -0
  16. data/coverage/assets/0.5.3/fancybox/fancy_shadow_e.png +0 -0
  17. data/coverage/assets/0.5.3/fancybox/fancy_shadow_n.png +0 -0
  18. data/coverage/assets/0.5.3/fancybox/fancy_shadow_ne.png +0 -0
  19. data/coverage/assets/0.5.3/fancybox/fancy_shadow_nw.png +0 -0
  20. data/coverage/assets/0.5.3/fancybox/fancy_shadow_s.png +0 -0
  21. data/coverage/assets/0.5.3/fancybox/fancy_shadow_se.png +0 -0
  22. data/coverage/assets/0.5.3/fancybox/fancy_shadow_sw.png +0 -0
  23. data/coverage/assets/0.5.3/fancybox/fancy_shadow_w.png +0 -0
  24. data/coverage/assets/0.5.3/fancybox/fancy_title_left.png +0 -0
  25. data/coverage/assets/0.5.3/fancybox/fancy_title_main.png +0 -0
  26. data/coverage/assets/0.5.3/fancybox/fancy_title_over.png +0 -0
  27. data/coverage/assets/0.5.3/fancybox/fancy_title_right.png +0 -0
  28. data/coverage/assets/0.5.3/fancybox/fancybox-x.png +0 -0
  29. data/coverage/assets/0.5.3/fancybox/fancybox-y.png +0 -0
  30. data/coverage/assets/0.5.3/fancybox/fancybox.png +0 -0
  31. data/coverage/assets/0.5.3/fancybox/jquery.fancybox-1.3.1.css +363 -0
  32. data/coverage/assets/0.5.3/fancybox/jquery.fancybox-1.3.1.pack.js +44 -0
  33. data/coverage/assets/0.5.3/favicon_green.png +0 -0
  34. data/coverage/assets/0.5.3/favicon_red.png +0 -0
  35. data/coverage/assets/0.5.3/favicon_yellow.png +0 -0
  36. data/coverage/assets/0.5.3/highlight.css +129 -0
  37. data/coverage/assets/0.5.3/highlight.pack.js +1 -0
  38. data/coverage/assets/0.5.3/jquery-1.6.2.min.js +18 -0
  39. data/coverage/assets/0.5.3/jquery.dataTables.min.js +152 -0
  40. data/coverage/assets/0.5.3/jquery.timeago.js +141 -0
  41. data/coverage/assets/0.5.3/jquery.url.js +174 -0
  42. data/coverage/assets/0.5.3/loading.gif +0 -0
  43. data/coverage/assets/0.5.3/magnify.png +0 -0
  44. data/coverage/assets/0.5.3/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  45. data/coverage/assets/0.5.3/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  46. data/coverage/assets/0.5.3/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  47. data/coverage/assets/0.5.3/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  48. data/coverage/assets/0.5.3/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  49. data/coverage/assets/0.5.3/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  50. data/coverage/assets/0.5.3/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  51. data/coverage/assets/0.5.3/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  52. data/coverage/assets/0.5.3/smoothness/images/ui-icons_222222_256x240.png +0 -0
  53. data/coverage/assets/0.5.3/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
  54. data/coverage/assets/0.5.3/smoothness/images/ui-icons_454545_256x240.png +0 -0
  55. data/coverage/assets/0.5.3/smoothness/images/ui-icons_888888_256x240.png +0 -0
  56. data/coverage/assets/0.5.3/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
  57. data/coverage/assets/0.5.3/smoothness/jquery-ui-1.8.4.custom.css +295 -0
  58. data/coverage/assets/0.5.3/stylesheet.css +383 -0
  59. data/coverage/index.html +155 -0
  60. data/features/create_a_manifest.feature +75 -0
  61. data/features/step_definitions/create_a_manifest_steps.rb +13 -0
  62. data/features/step_definitions/use_built_in_templates_steps.rb +42 -0
  63. data/features/support/env.rb +13 -0
  64. data/features/use_built_in_templates.feature +78 -0
  65. data/features/use_config_files.feature +31 -0
  66. data/lib/.DS_Store +0 -0
  67. data/lib/Elf_Manifesto/version.rb +4 -0
  68. data/lib/Elf_Manifesto.rb +5 -0
  69. data/lib/elf_manifesto/manifest_maker.rb +61 -0
  70. data/lib/templates/imsmanifest.xml.mustache +55 -0
  71. data/lib/templates/simple.mustache +15 -0
  72. data/readme.md +110 -0
  73. data/spec/lib/elf_manifesto/manifest_maker_spec.rb +154 -0
  74. data/spec/spec_helper.rb +5 -0
  75. metadata +268 -0
data/.DS_Store ADDED
Binary file
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ tmp/*
6
+ lib/templates/tmp/*
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm --create 1.9.2@thinqi
@@ -0,0 +1,43 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "elf_manifesto/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "elf_manifesto"
7
+ s.version = ElfManifesto::VERSION
8
+ s.authors = ["Darren Wallace"]
9
+ s.email = ["wallace@midweekcrisis.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{Creates file manifests from provided templates}
12
+ s.description = %q{Primarily used for creating SCORM manifests. Uses mustache templates and file info to create manifests. Intended for use from the command line or on the build server.}
13
+
14
+ s.rubyforge_project = "ELF_Manifesto"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ # specify any dependencies here; for example:
22
+ # s.add_development_dependency "rspec"
23
+ # s.add_runtime_dependency "rest-client"
24
+
25
+ s.add_development_dependency "rake", "~> 0.9.2.2"
26
+ s.add_development_dependency "bundler", "~> 1.0.21"
27
+ s.add_development_dependency "rspec", "~> 2.7.0"
28
+ s.add_development_dependency "cucumber", "~> 1.1.4"
29
+ s.add_development_dependency "guard-cucumber", "~> 0.7.4"
30
+ s.add_development_dependency "aruba", "~> 0.4.9"
31
+ s.add_development_dependency 'simplecov', '>= 0.4.0'
32
+
33
+ if RUBY_PLATFORM.downcase.include?("darwin")
34
+ s.add_development_dependency "guard-rspec"
35
+ s.add_development_dependency "growl"
36
+ s.add_development_dependency "rb-fsevent"
37
+ end
38
+
39
+ s.add_runtime_dependency "commander", "~> 4.0.6"
40
+ s.add_runtime_dependency "mustache", "~> 0.99.4"
41
+
42
+
43
+ end
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in elf_manifesto.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,29 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard 'rspec', :version => 2 do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
+ watch('spec/spec_helper.rb') { "spec" }
8
+
9
+ # # Rails example
10
+ # watch(%r{^spec/.+_spec\.rb$})
11
+ # watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
12
+ # watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
13
+ # watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
14
+ # watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
15
+ # watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
16
+ # watch('spec/spec_helper.rb') { "spec" }
17
+ # watch('config/routes.rb') { "spec/routing" }
18
+ # watch('app/controllers/application_controller.rb') { "spec/controllers" }
19
+ # # Capybara request specs
20
+ # watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
21
+ end
22
+
23
+
24
+ guard 'cucumber' do
25
+ watch(%r{^features/.+\.feature$})
26
+ watch(%r{^features/support/.+$}) { 'features' }
27
+ watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' }
28
+ # watch(%r{^bin/.+$}) {'features'}
29
+ end
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/manifesto ADDED
@@ -0,0 +1,131 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'commander/import'
5
+ require 'elf_manifesto'
6
+ require 'elf_manifesto/manifest_maker'
7
+ require 'ostruct'
8
+
9
+ program :version, ElfManifesto::VERSION
10
+ program :description, 'Creates file manifests from file collections and mustache templates'
11
+
12
+ #
13
+ command :create do |c|
14
+ c.syntax = 'manifesto create [options]'
15
+ c.summary = 'creates a manifest file'
16
+ c.description = 'Create a manifest from file collections and a template'
17
+ c.example 'Create a manifest from template.mustache and the jpgs in the images directory', "manifesto --template template.mustache 'images/*.jpg'"
18
+ c.example 'Pass arbitrary properties to be used in the template', "manifesto --template template.mustache --properties '{ id: 1234 }' images/*.jpg'"
19
+
20
+ c.option '-m', '--template STRING', String, 'Template file'
21
+ c.option '-o', '--output_file STRING', String, 'Target for manifest output'
22
+ c.option '-p', '--properties STRING', String, 'Property hash'
23
+ c.option '-s', '--sample_template STRING', String, 'Name of a supplied template'
24
+ c.option '-c', '--config_file STRING', String, 'Path to a config file. Overrides any other options'
25
+
26
+
27
+ c.action do |args, options|
28
+ # TODO - This logic is horrible. Refactor
29
+ if ((options.sample_template.nil? && options.template.nil? && options.config_file.nil?) || (args.empty? && options.config_file.nil?))
30
+ say <<-MESSAGE
31
+ Manifesto! throw me a frickin' bone here!
32
+ I need some parameters
33
+ Use --help to find out how
34
+ MESSAGE
35
+ elsif !(options.config_file.nil?)
36
+ config_file = File.open(options.config_file, 'rb')
37
+ config_options = eval(config_file.read)
38
+ # n.b. uses OpenStruct to treat hashes as dot notation
39
+ config_options[:template] = get_template_path OpenStruct.new config_options
40
+ manifesto = ElfManifesto::ManifestMaker.new(config_options)
41
+ else
42
+ # Select a template file
43
+ template = get_template_path options
44
+ requested_template = options.template || options.sample_template
45
+
46
+ message = ""
47
+ message += "Creating manifest from #{template} with:" unless options.output_file.nil?
48
+
49
+ # test for a valid templates
50
+ if template.nil? || !File.exists?(template)
51
+ raise "Bad template selection: #{requested_template}"
52
+ end
53
+
54
+ props = {}
55
+ props = eval(options.properties) unless options.properties.nil?
56
+
57
+ ops = {
58
+ template: template,
59
+ globs: args,
60
+ props: props
61
+ }
62
+
63
+ manifesto = ElfManifesto::ManifestMaker.new(ops)
64
+ end
65
+ end
66
+ end
67
+
68
+ command "list templates" do |c|
69
+ c.syntax = 'list templates'
70
+ c.summary = 'Lists the built in templates available'
71
+ c.description = ''
72
+ c.example 'List all build in templates', 'manifesto list templates'
73
+ # c.option '--some-switch', 'Some switch that does something'
74
+ c.action do |args, options|
75
+ path_to_templates = File.expand_path('../lib/templates', File.dirname(__FILE__)) # absolute path to the templates directory relative to this file.
76
+ puts "Available Templates:"
77
+ templates = Dir.glob(File.join path_to_templates, '**', '*.*' )
78
+ templates.each do |template|
79
+ puts File.basename template
80
+ end
81
+ # Do something or c.when_called Tmp::Commands::List
82
+ end
83
+
84
+ command "show template" do |c|
85
+ c.syntax = 'show template |template name|'
86
+ c.summary = 'Shows the contents of a built in template'
87
+ c.description = ''
88
+ c.example 'Show the contents of the imsmanifest.mustache template', 'manifesto show template imsmanifest'
89
+ # c.option '--some-switch', 'Some switch that does something'
90
+ c.action do |args, options|
91
+ path_to_templates = File.expand_path('../lib/templates', File.dirname(__FILE__)) # absolute path to the templates directory relative to this file.
92
+ template = get_sample_template(args.first)
93
+ if template.nil?
94
+ raise "Template does not exist: #{args.first}"
95
+ end
96
+ template_file = File.open(template, "rb")
97
+ puts template_file.read
98
+ end
99
+ end
100
+ end
101
+
102
+ default_command :create
103
+ alias_command :list, :'list templates'
104
+ alias_command :show, :'show template'
105
+
106
+
107
+ private
108
+
109
+ def get_template_path options
110
+ if options.template.nil?
111
+ template = get_sample_template options.sample_template
112
+ else
113
+ # test for an underscore prefix, which denotes a built-in template
114
+ if options.template =~ /^_/i
115
+ template = get_sample_template options.template
116
+ else
117
+ template = options.template
118
+ end
119
+ end
120
+ template
121
+ end
122
+
123
+ def get_sample_template template_name
124
+ # strip any _ prefix
125
+ target = template_name.sub('_','')
126
+ templates_path = File.expand_path( '../lib/templates', File.dirname(__FILE__))
127
+ templates_files = Dir.glob(File.join(templates_path, '**','*.*'))
128
+ selected_template = templates_files.select do |file|
129
+ File.basename(file) =~ /#{target}/i
130
+ end.first
131
+ end
@@ -0,0 +1,75 @@
1
+ {
2
+ "Cucumber Features": {
3
+ "coverage": {
4
+ },
5
+ "timestamp": 1324569020
6
+ },
7
+ "RSpec": {
8
+ "coverage": {
9
+ "/Users/wallace/wip/Workspace/Elf_Manifesto/lib/elf_manifesto/manifest_maker.rb": [
10
+ 1,
11
+ null,
12
+ 1,
13
+ null,
14
+ 1,
15
+ null,
16
+ 1,
17
+ null,
18
+ null,
19
+ null,
20
+ null,
21
+ null,
22
+ null,
23
+ null,
24
+ null,
25
+ null,
26
+ null,
27
+ null,
28
+ null,
29
+ null,
30
+ null,
31
+ 1,
32
+ 8,
33
+ 8,
34
+ 8,
35
+ 8,
36
+ 8,
37
+ 8,
38
+ 8,
39
+ null,
40
+ 8,
41
+ null,
42
+ null,
43
+ 1,
44
+ null,
45
+ null,
46
+ null,
47
+ null,
48
+ null,
49
+ null,
50
+ null,
51
+ null,
52
+ 1,
53
+ 8,
54
+ 8,
55
+ null,
56
+ 8,
57
+ null,
58
+ 18,
59
+ 18,
60
+ 18,
61
+ 18,
62
+ 18,
63
+ 18,
64
+ null,
65
+ 8,
66
+ null,
67
+ null,
68
+ null,
69
+ null,
70
+ null
71
+ ]
72
+ },
73
+ "timestamp": 1324562274
74
+ }
75
+ }
@@ -0,0 +1,88 @@
1
+ $(document).ready(function() {
2
+ // Configuration for fancy sortable tables for source file groups
3
+ $('.file_list').dataTable({
4
+ "aaSorting": [[ 1, "asc" ]],
5
+ "bPaginate": false,
6
+ "bJQueryUI": true,
7
+ "aoColumns": [
8
+ null,
9
+ { "sType": "percent" },
10
+ null,
11
+ null,
12
+ null,
13
+ null,
14
+ null
15
+ ]
16
+ });
17
+
18
+ // Syntax highlight all files up front - deactivated
19
+ // $('.source_table pre code').each(function(i, e) {hljs.highlightBlock(e, ' ')});
20
+
21
+ // Syntax highlight source files on first toggle of the file view popup
22
+ $("a.src_link").click(function() {
23
+ // Get the source file element that corresponds to the clicked element
24
+ var source_table = $($(this).attr('href'));
25
+
26
+ // If not highlighted yet, do it!
27
+ if (!source_table.hasClass('highlighted')) {
28
+ source_table.find('pre code').each(function(i, e) {hljs.highlightBlock(e, ' ')});
29
+ source_table.addClass('highlighted');
30
+ };
31
+ });
32
+
33
+ // Set-up of popup for source file views
34
+ $("a.src_link").fancybox({
35
+ 'hideOnContentClick': true,
36
+ 'centerOnScroll': true,
37
+ 'width': '90%',
38
+ 'padding': 0,
39
+ 'transitionIn': 'elastic'
40
+ });
41
+
42
+ // Hide src files and file list container after load
43
+ $('.source_files').hide();
44
+ $('.file_list_container').hide();
45
+
46
+ // Add tabs based upon existing file_list_containers
47
+ $('.file_list_container h2').each(function(){
48
+ var container_id = $(this).parent().attr('id');
49
+ var group_name = $(this).find('.group_name').first().html();
50
+ var covered_percent = $(this).find('.covered_percent').first().html();
51
+
52
+ $('.group_tabs').append('<li><a href="#' + container_id + '">' + group_name + ' ('+ covered_percent +')</a></li>');
53
+ });
54
+
55
+ $('.group_tabs a').each( function() {
56
+ $(this).addClass($(this).attr('href').replace('#', ''));
57
+ });
58
+
59
+ // Make sure tabs don't get ugly focus borders when active
60
+ $('.group_tabs a').live('focus', function() { $(this).blur(); });
61
+
62
+ var favicon_path = $('link[rel="shortcut icon"]').attr('href');
63
+ $('.group_tabs a').live('click', function(){
64
+ if (!$(this).parent().hasClass('active')) {
65
+ $('.group_tabs a').parent().removeClass('active');
66
+ $(this).parent().addClass('active');
67
+ $('.file_list_container').hide();
68
+ $(".file_list_container" + $(this).attr('href')).show();
69
+ window.location.href = window.location.href.split('#')[0] + $(this).attr('href').replace('#', '#_');
70
+
71
+ // Force favicon reload - otherwise the location change containing anchor would drop the favicon...
72
+ // Works only on firefox, but still... - Anyone know a better solution to force favicon on local file?
73
+ $('link[rel="shortcut icon"]').remove();
74
+ $('head').append('<link rel="shortcut icon" type="image/png" href="'+ favicon_path +'" />');
75
+ };
76
+ return false;
77
+ });
78
+
79
+ if (jQuery.url.attr('anchor')) {
80
+ $('.group_tabs a.'+jQuery.url.attr('anchor').replace('_', '')).click();
81
+ } else {
82
+ $('.group_tabs a:first').click();
83
+ };
84
+
85
+ $("abbr.timeago").timeago();
86
+ $('#loading').fadeOut();
87
+ $('#wrapper').show();
88
+ });