bling 0.1
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/bin/bling +87 -0
- data/lib/bling.rb +2 -0
- data/lib/bling/bling.rb +50 -0
- metadata +57 -0
data/bin/bling
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
gem 'bling'
|
5
|
+
require 'bling'
|
6
|
+
|
7
|
+
$task = <<-rakefile
|
8
|
+
require 'rubygems'
|
9
|
+
gem 'bling'
|
10
|
+
require 'bling'
|
11
|
+
|
12
|
+
namespace :bling do
|
13
|
+
desc 'shows gems that are required for the given env'
|
14
|
+
task :show do
|
15
|
+
file = File.join(File.dirname(__FILE__), "..", "..", "bling.yml")
|
16
|
+
Bling.new(file).list_gems(ENV['RAILS_ENV'])
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
rakefile
|
21
|
+
|
22
|
+
$yaml = <<-yml
|
23
|
+
all:
|
24
|
+
- name: rails
|
25
|
+
version: 3.0.0.beta
|
26
|
+
yml
|
27
|
+
|
28
|
+
$boot = <<-bootfile
|
29
|
+
begin
|
30
|
+
require 'rubygems'
|
31
|
+
gem 'bling'
|
32
|
+
require 'bling'
|
33
|
+
end
|
34
|
+
bootfile
|
35
|
+
|
36
|
+
$final = <<-output
|
37
|
+
You still need to do one thing before you're PROWLING, BABY!
|
38
|
+
|
39
|
+
You need to change the line in your application.rb from:
|
40
|
+
|
41
|
+
Bundler.require :default, Rails.env
|
42
|
+
|
43
|
+
to
|
44
|
+
|
45
|
+
Bling.new(File.join(File.dirname(__FILE__), "..", "bling.yml")).require_env(Rails.env)
|
46
|
+
output
|
47
|
+
|
48
|
+
def init
|
49
|
+
if !File.exists?("config/boot.rb")
|
50
|
+
puts "Needs to be run from Rails root directory"
|
51
|
+
exit(1)
|
52
|
+
end
|
53
|
+
|
54
|
+
File.open("lib/tasks/bling.rake", "w") do |f|
|
55
|
+
f.write($task)
|
56
|
+
end
|
57
|
+
|
58
|
+
File.open("config/boot.rb", "w") do |f|
|
59
|
+
f.write($boot)
|
60
|
+
end
|
61
|
+
|
62
|
+
File.open("bling.yml", "w") do |f|
|
63
|
+
f.write($yaml)
|
64
|
+
end
|
65
|
+
|
66
|
+
puts $final
|
67
|
+
end
|
68
|
+
|
69
|
+
def install
|
70
|
+
bling_file = "bling.yml"
|
71
|
+
|
72
|
+
if !File.exists?(bling_file)
|
73
|
+
puts "No bling file found"
|
74
|
+
exit(1)
|
75
|
+
end
|
76
|
+
|
77
|
+
Bling.new(bling_file).install_gems(ENV['RAILS_ENV'] || "development")
|
78
|
+
end
|
79
|
+
|
80
|
+
if ARGV[0] == "install"
|
81
|
+
install
|
82
|
+
elsif ARGV[0] == "init"
|
83
|
+
init
|
84
|
+
else
|
85
|
+
puts "Unrecognized command. Available command: install"
|
86
|
+
end
|
87
|
+
|
data/lib/bling.rb
ADDED
data/lib/bling/bling.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
|
3
|
+
class Bling
|
4
|
+
def initialize(bling_file = "bling.yml")
|
5
|
+
raise ArgumentError, "bling file not found" unless File.exists?(bling_file)
|
6
|
+
@yaml = YAML::load_file(bling_file)
|
7
|
+
end
|
8
|
+
|
9
|
+
def require_env(env = nil)
|
10
|
+
self.each_gem_for(env) do |entry|
|
11
|
+
gem *([entry['name'], entry['version']].compact)
|
12
|
+
require entry['lib'] || entry['name']
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def list_gems(env = nil)
|
17
|
+
self.each_gem_for(env) do |entry|
|
18
|
+
line = entry['name']
|
19
|
+
line += " [#{entry['version']}]" if entry['version']
|
20
|
+
$stdout.puts line
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def install_gems(env = nil)
|
25
|
+
only_if_present = lambda{|pre, val| val.to_s.empty? ? "" : " #{pre}#{val}"}
|
26
|
+
gem_installed = false
|
27
|
+
each_gem_for(env) do |entry|
|
28
|
+
begin
|
29
|
+
version = only_if_present.call('-v=', entry['version'].to_s.gsub(/[=~<>]/, ''))
|
30
|
+
source = only_if_present.call('--source=', entry['source'])
|
31
|
+
gem *([entry['name'], entry['version']].compact)
|
32
|
+
rescue Gem::LoadError
|
33
|
+
gem_installed = true
|
34
|
+
$stdout.puts "installing #{entry['name']} #{version}"
|
35
|
+
`gem install #{entry['name']} #{version} #{source} `
|
36
|
+
end
|
37
|
+
end
|
38
|
+
$stdout.puts "nothing to install!" unless gem_installed
|
39
|
+
end
|
40
|
+
|
41
|
+
protected
|
42
|
+
def each_gem_for(env, &block)
|
43
|
+
return unless @yaml
|
44
|
+
(@yaml['all'] | (@yaml[env] || [])).each do |entry|
|
45
|
+
yield entry if block_given?
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
|
metadata
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bling
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: "0.1"
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Terry Heath
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-02-19 00:00:00 -06:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: drop in replacement for bundler
|
17
|
+
email: theath@gmail.com
|
18
|
+
executables:
|
19
|
+
- bling
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
24
|
+
files:
|
25
|
+
- lib/bling.rb
|
26
|
+
- lib/bling/bling.rb
|
27
|
+
- bin/bling
|
28
|
+
has_rdoc: true
|
29
|
+
homepage: http://github.com/terrbear/prowl
|
30
|
+
licenses: []
|
31
|
+
|
32
|
+
post_install_message:
|
33
|
+
rdoc_options: []
|
34
|
+
|
35
|
+
require_paths:
|
36
|
+
- lib
|
37
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: "0"
|
42
|
+
version:
|
43
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: "0"
|
48
|
+
version:
|
49
|
+
requirements: []
|
50
|
+
|
51
|
+
rubyforge_project:
|
52
|
+
rubygems_version: 1.3.5
|
53
|
+
signing_key:
|
54
|
+
specification_version: 3
|
55
|
+
summary: bling bling gem management
|
56
|
+
test_files: []
|
57
|
+
|