sinatra-packrat 0.0.1 → 0.1.0

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 (3) hide show
  1. data/bin/packrat +27 -0
  2. data/lib/sinatra/packrat.rb +12 -13
  3. metadata +4 -4
data/bin/packrat ADDED
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "yaml"
4
+
5
+ config_path = ARGV[0]
6
+ config = YAML::load_file(config_path)
7
+
8
+ config["modules"].each do |mod|
9
+ next unless mod["git"]
10
+
11
+ if mod["path"]
12
+ repo_path = mod["path"]
13
+ else
14
+ repo_name = File.basename mod["git"], '.git'
15
+ repo_path = File.join 'modules/', repo_name
16
+ end
17
+
18
+ if File.directory? repo_path
19
+ Dir.chdir repo_path do
20
+ p "pulling from #{mod["git"]} into #{repo_path}"
21
+ `git pull #{mod["git"]} master`
22
+ end
23
+ else
24
+ p "cloning #{mod["git"]} into #{repo_path}"
25
+ `git clone #{mod["git"]} #{repo_path}`
26
+ end
27
+ end
@@ -42,10 +42,8 @@ module Sinatra
42
42
 
43
43
  klass = app
44
44
 
45
- Kernel.class_exec do
46
- define_method :packrat do |&block|
47
- klass.class_exec &block
48
- end
45
+ Kernel.send :define_method, :packrat do |&block|
46
+ klass.class_exec &block
49
47
  end
50
48
  end
51
49
 
@@ -91,21 +89,22 @@ module Sinatra
91
89
 
92
90
  config["modules"].each do |mod|
93
91
 
94
- case mod
95
- when String
96
- path = mod
97
- when Hash
92
+ if mod["path"]
98
93
  path = mod["path"]
99
- override_settings = mod["settings"]
94
+ elsif mod["git"]
95
+ git_repo = File.basename mod["git"], '.git'
96
+ path = File.join 'modules/', git_repo
100
97
  end
101
-
102
- full_module_path = File.join( caller_path, path )
98
+
99
+ full_path = File.join(caller_path, path)
100
+ override_settings = mod["settings"]
103
101
 
104
102
  if override_settings
105
- register_module( full_module_path, override_settings )
103
+ register_module( full_path, override_settings )
106
104
  else
107
- register_module full_module_path
105
+ register_module full_path
108
106
  end
107
+
109
108
  end
110
109
  end
111
110
 
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 0
8
7
  - 1
9
- version: 0.0.1
8
+ - 0
9
+ version: 0.1.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Brennan Roberts
@@ -21,8 +21,8 @@ dependencies: []
21
21
 
22
22
  description: Packrat is a Sinantra extension based around the idea of mixing and matching. With Packrat we can combine multiple Sinatra applications into one instance, where they can share configuration data, filters, css and other static assets. Creating a new site out of existing pieces should be as simple as cloning a series of pieces, and for each one, adding one line to a config file.
23
23
  email: brennan@oblong.com
24
- executables: []
25
-
24
+ executables:
25
+ - packrat
26
26
  extensions: []
27
27
 
28
28
  extra_rdoc_files: []