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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d270b6f797cf029c49ba3aa13e96cdb190fed249
4
- data.tar.gz: 29cadc875f9b81886507a97a2ed54d560551ecd9
3
+ metadata.gz: cb7909eff5a6d709c262d1ae5df2b3fc459c00d0
4
+ data.tar.gz: 305a533d4365ea8521bb15914dbf10d0ffacaacf
5
5
  SHA512:
6
- metadata.gz: fa16e04200b3f55760b2676a249f594e2ee34fbeb6019ba2029c9b51dca97b155a13e1924c551d690bbbae925305c513bfea255e8d27d50cfa68ff3987adf838
7
- data.tar.gz: c335280ab1081cbfce62aa5934d670c93facabf19ad10ec0675c14acd2007136a97388d6e4c5810b01c934fd9889e685ec3c9cdcf5a5b433c09ed92cd2da2680
6
+ metadata.gz: d611ceb14d9d91e637c9d4c9bf08c7c1d3c159285c216869d8758b63c64eafc0688e1a7405a2dc5076584e0acde54ee8ca300565a54ceaf60c56a5ea65d09645
7
+ data.tar.gz: 5e94e029d66df6128e936d093c0346fd08699b4ec1a4f15a17aa1b47e64526f228fa091094c27a539e6b20066cd739a95381c106ab81fed3a9da439fed4d49f2
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .idea
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in agape-red-recipes-red-recipes.gemspec
4
+ gemspec
@@ -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.
@@ -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
@@ -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,12 @@
1
+ module AgapeRedRecipes
2
+ module Bundler
3
+ # Generic bundle command
4
+ # Defaults to "install"
5
+ def bundle(command = nil)
6
+ command ||= "install"
7
+ ::Bundler.with_clean_env do
8
+ run "bundle #{command}"
9
+ end
10
+ end
11
+ end
12
+ 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,4 @@
1
+ module AgapeRedRecipes
2
+ class Engine < Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module AgapeRedRecipes
2
+ VERSION = "0.0.6"
3
+ 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.5
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