agape-red-recipes 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +33 -0
- data/Rakefile +1 -0
- data/agape-red-recipes.gemspec +23 -0
- data/lib/agape-red-recipes/modules/bundler.rb +12 -0
- data/lib/agape-red-recipes/modules/gemfile.rb +80 -0
- data/lib/agape-red-recipes/modules/gems.rb +20 -0
- data/lib/agape-red-recipes/recipes.rb +4 -0
- data/lib/agape-red-recipes/version.rb +3 -0
- data/lib/generators/recipe_generator.rb +50 -0
- metadata +14 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb7909eff5a6d709c262d1ae5df2b3fc459c00d0
|
4
|
+
data.tar.gz: 305a533d4365ea8521bb15914dbf10d0ffacaacf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d611ceb14d9d91e637c9d4c9bf08c7c1d3c159285c216869d8758b63c64eafc0688e1a7405a2dc5076584e0acde54ee8ca300565a54ceaf60c56a5ea65d09645
|
7
|
+
data.tar.gz: 5e94e029d66df6128e936d093c0346fd08699b4ec1a4f15a17aa1b47e64526f228fa091094c27a539e6b20066cd739a95381c106ab81fed3a9da439fed4d49f2
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Agape Red, Inc
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# Agape Red Recipes
|
2
|
+
|
3
|
+
This gem will allow you to run various recipes in your rails apps.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'agape-red-recipes'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
Once the gem is installed you can install recipes by running
|
18
|
+
|
19
|
+
rails g recipe recipe_name [options]
|
20
|
+
|
21
|
+
`recipe_name` can be the name of any repo under the organization AgapeRedRecipes.
|
22
|
+
|
23
|
+
`options` are space seperated key:value args
|
24
|
+
|
25
|
+
rails g recipe_name key1:value1 key2:value2
|
26
|
+
|
27
|
+
## Contributing
|
28
|
+
|
29
|
+
1. Fork it
|
30
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
31
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
32
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
33
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'agape-red-recipes/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "agape-red-recipes"
|
8
|
+
spec.version = AgapeRedRecipes::VERSION
|
9
|
+
spec.authors = ["David Kerber"]
|
10
|
+
spec.email = ["dave@agapered.com"]
|
11
|
+
spec.description = %q{Allows you to run various recipes against your rails apps. }
|
12
|
+
spec.summary = %q{Automates installing various add ons and plugins for your app.}
|
13
|
+
spec.homepage = "https://github.com/agaperedrecipes/agape-red-recipes"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
module AgapeRedRecipes
|
2
|
+
module Gemfile
|
3
|
+
def gem_group_exists?(*names)
|
4
|
+
name = names.map(&:inspect).join(", ")
|
5
|
+
|
6
|
+
File.open("Gemfile") do |file|
|
7
|
+
file.read.include? "\ngroup #{name} do"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def gem_group(*names, &block)
|
12
|
+
name = names.map(&:inspect).join(", ")
|
13
|
+
|
14
|
+
if gem_group_exists?(*names)
|
15
|
+
@in_group = true
|
16
|
+
@current_group = name
|
17
|
+
instance_eval(&block)
|
18
|
+
@current_group = nil
|
19
|
+
@in_group = false
|
20
|
+
else
|
21
|
+
super(*names, &block)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def gem(*args)
|
26
|
+
options = args.extract_options!
|
27
|
+
name, version = args
|
28
|
+
|
29
|
+
# Set the message to be shown in logs. Uses the git repo if one is given,
|
30
|
+
# otherwise use name (version).
|
31
|
+
parts, message = [ "'#{name}'" ], name
|
32
|
+
if version ||= options.delete(:version)
|
33
|
+
parts << "'#{version}'"
|
34
|
+
message << " (#{version})"
|
35
|
+
end
|
36
|
+
message = options[:git] if options[:git]
|
37
|
+
|
38
|
+
log :gemfile, message
|
39
|
+
|
40
|
+
options.each do |option, value|
|
41
|
+
parts << "#{option}: '#{value}'"
|
42
|
+
end
|
43
|
+
|
44
|
+
@@installed_gem_names ||= Gem::Specification.map &:name
|
45
|
+
return if @@installed_gem_names.include? name
|
46
|
+
|
47
|
+
in_root do
|
48
|
+
str = "gem #{parts.join(', ')}"
|
49
|
+
str = " " + str if @in_group
|
50
|
+
str = "\n" + str
|
51
|
+
|
52
|
+
if @current_group
|
53
|
+
insert_at_end_of_line_containing 'Gemfile', str, "group #{@current_group} do"
|
54
|
+
else
|
55
|
+
append_file 'Gemfile', str, verbose: false
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def insert_at_end_of_line_containing(file_name, insert, contents)
|
62
|
+
open(file_name, 'r+') do |file|
|
63
|
+
|
64
|
+
while !file.eof?
|
65
|
+
break if file.readline.include? contents
|
66
|
+
end
|
67
|
+
|
68
|
+
# Move back to the end of the previous line
|
69
|
+
file.seek file.pos - 1
|
70
|
+
|
71
|
+
position = file.pos
|
72
|
+
rest_of_file = file.read
|
73
|
+
file.seek position
|
74
|
+
|
75
|
+
file.write insert
|
76
|
+
file.write rest_of_file
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module AgapeRedRecipes
|
2
|
+
module Gems
|
3
|
+
|
4
|
+
def missing_gems?(*gem_names)
|
5
|
+
gem_names = [gem_names].flatten
|
6
|
+
gem_names - all_gem_names
|
7
|
+
end
|
8
|
+
|
9
|
+
def require_gems!(*gem_names)
|
10
|
+
missing_gems = missing_gems?(gem_names)
|
11
|
+
return if missing_gems.empty?
|
12
|
+
abort "Please install the gems #{missing_gems.join(" and ")} before installing."
|
13
|
+
end
|
14
|
+
|
15
|
+
def all_gem_names
|
16
|
+
Gem::Specification.collect &:name
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'agape-red-recipes/modules/bundler'
|
2
|
+
require 'agape-red-recipes/modules/gemfile'
|
3
|
+
require 'agape-red-recipes/modules/gems'
|
4
|
+
|
5
|
+
class RecipeGenerator < Rails::Generators::Base
|
6
|
+
include AgapeRedRecipes::Bundler
|
7
|
+
include AgapeRedRecipes::Gemfile
|
8
|
+
include AgapeRedRecipes::Gems
|
9
|
+
|
10
|
+
argument :recipe_name, type: :string, default: 'list'
|
11
|
+
argument :settings, type: :array, default: []
|
12
|
+
|
13
|
+
def generate_recipe
|
14
|
+
the_options = {}
|
15
|
+
settings.each{|s| data = s.split(':'); the_options[data[0]] = data[1] }
|
16
|
+
|
17
|
+
if recipe_name == 'list'
|
18
|
+
list_repos
|
19
|
+
else
|
20
|
+
apply_recipe recipe_name, the_options
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
def list_repos
|
26
|
+
require 'net/http'
|
27
|
+
require 'uri'
|
28
|
+
|
29
|
+
def open(url)
|
30
|
+
Net::HTTP.get(URI.parse(url))
|
31
|
+
end
|
32
|
+
|
33
|
+
page_content = JSON.parse(open('https://api.github.com/users/AgapeRedRecipes/repos'))
|
34
|
+
repos = page_content.map{|repo| repo['name']}.select{|repo| repo != 'agape-red-recipes'}
|
35
|
+
puts "You can apply the following recipes using `rails g recipe [recipe_name] [options]`"
|
36
|
+
repos.each{|r| puts " #{r.downcase}" }
|
37
|
+
end
|
38
|
+
|
39
|
+
def apply_recipe the_recipe, the_options
|
40
|
+
if the_recipe.include?('.')
|
41
|
+
RecipeGenerator.source_root(Rails.root)
|
42
|
+
apply the_recipe, the_options
|
43
|
+
elsif the_recipe.starts_with?('http')
|
44
|
+
apply the_recipe, the_options
|
45
|
+
else
|
46
|
+
apply "https://raw.github.com/AgapeRedRecipes/#{the_recipe}/master/recipe.rb", the_options
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: agape-red-recipes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Kerber
|
@@ -44,7 +44,19 @@ email:
|
|
44
44
|
executables: []
|
45
45
|
extensions: []
|
46
46
|
extra_rdoc_files: []
|
47
|
-
files:
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- agape-red-recipes.gemspec
|
54
|
+
- lib/agape-red-recipes/modules/bundler.rb
|
55
|
+
- lib/agape-red-recipes/modules/gemfile.rb
|
56
|
+
- lib/agape-red-recipes/modules/gems.rb
|
57
|
+
- lib/agape-red-recipes/recipes.rb
|
58
|
+
- lib/agape-red-recipes/version.rb
|
59
|
+
- lib/generators/recipe_generator.rb
|
48
60
|
homepage: https://github.com/agaperedrecipes/agape-red-recipes
|
49
61
|
licenses:
|
50
62
|
- MIT
|