potassium 1.3.3 → 1.3.4
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.
- checksums.yaml +4 -4
- data/.hound.yml +2 -0
- data/.rubocop.yml +3 -0
- data/.ruby_style.yml +2 -0
- data/CHANGELOG.md +12 -0
- data/README.md +16 -2
- data/lib/potassium/cli/commands/install.rb +56 -0
- data/lib/potassium/templates/application/assets/.rbenv-vars.example +1 -0
- data/lib/potassium/templates/application/helpers/gem-helpers.rb +12 -0
- data/lib/potassium/templates/application/helpers/recipe-helpers.rb +5 -0
- data/lib/potassium/templates/application/helpers/template-helpers.rb +8 -0
- data/lib/potassium/templates/application/helpers/variable-helpers.rb +8 -0
- data/lib/potassium/templates/application/recipe_generator.rb +14 -0
- data/lib/potassium/templates/application/recipe_template.rb +23 -0
- data/lib/potassium/templates/application/recipes/admin.rb +2 -2
- data/lib/potassium/templates/application/recipes/angular_admin.rb +1 -1
- data/lib/potassium/templates/application/recipes/asks/admin.rb +1 -1
- data/lib/potassium/templates/application/recipes/asks/{lang.rb → i18n.rb} +0 -0
- data/lib/potassium/templates/application/recipes/asks/paperclip.rb +2 -0
- data/lib/potassium/templates/application/recipes/checks/devise.rb +1 -0
- data/lib/potassium/templates/application/recipes/dependencies/admin.rb +3 -0
- data/lib/potassium/templates/application/recipes/paperclip.rb +20 -0
- data/lib/potassium/templates/application/recipes/rbenv.rb +20 -1
- data/lib/potassium/templates/application/template.rb +3 -1
- data/lib/potassium/version.rb +1 -1
- data/potassium.gemspec +1 -1
- metadata +27 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6bc7c7e4daf4fbcae5761bb994cfabc9db7d8d64
|
4
|
+
data.tar.gz: 919510d523b761b9c74a6d1bbdb23be36fd563e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ef25b0c7d589ee4afd3819beb04ecbf043c0cdb99d1dfe37fc728e3739eb3f37deae49a8e87b4207cdc28e2be24699062dc9171a3f3d3b086944f4eaa44605b
|
7
|
+
data.tar.gz: 8a69de0aee82d9192eb69e18529c97256672ee873bb8708f486d784da47a81315754ea2323c4a7fad653aff696928d974409c106dbf9824e66f06445c6ab113d
|
data/.hound.yml
ADDED
data/.rubocop.yml
ADDED
data/.ruby_style.yml
ADDED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## Unreleased
|
4
|
+
|
5
|
+
Features:
|
6
|
+
|
7
|
+
- Gets ruby version from http://ruby.platan.us/latest
|
8
|
+
- Adds the install command
|
9
|
+
|
3
10
|
## 1.3
|
4
11
|
|
5
12
|
Features:
|
@@ -61,3 +68,8 @@ Features:
|
|
61
68
|
|
62
69
|
Bugfixes:
|
63
70
|
- Removed `default_command` call to fix --version usage.
|
71
|
+
|
72
|
+
## 1.3.4
|
73
|
+
|
74
|
+
Bugfixes:
|
75
|
+
- Removed `rails` from the runtime dependencies due to terrible performance.
|
data/README.md
CHANGED
@@ -4,18 +4,32 @@ A Rails application generator from [Platanus](https://github.com/platanus), insp
|
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
|
-
|
7
|
+
First, be sure to have Rails 4.2+ installed on your system.
|
8
|
+
|
9
|
+
Then, install Potassium globally:
|
8
10
|
|
9
11
|
$ gem install potassium
|
10
12
|
|
11
13
|
## Usage
|
12
14
|
|
13
|
-
|
15
|
+
### Starting a new project from scratch
|
16
|
+
|
17
|
+
Use the `potassium create` command to create a new project:
|
14
18
|
|
15
19
|
$ potassium create project-name
|
16
20
|
|
17
21
|
It's important to note that it will perform a version check before running to ensure that you're using the latest potassium.
|
18
22
|
|
23
|
+
### Adding recipes to an existing project
|
24
|
+
|
25
|
+
Use the `potassium install` command to add a recipe to a project:
|
26
|
+
|
27
|
+
$ potassium install i18n
|
28
|
+
|
29
|
+
You can run the command on its own to view all the available recipes and select one:
|
30
|
+
|
31
|
+
$ potassium install
|
32
|
+
|
19
33
|
## What's inside Potassium?
|
20
34
|
|
21
35
|
Potassium Rails apps includes the following gems and technologies:
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'levenshtein'
|
2
|
+
require 'inquirer'
|
3
|
+
require "potassium/templates/application/recipe_generator"
|
4
|
+
|
5
|
+
module Potassium::CLI
|
6
|
+
desc "Installs a new feature or library"
|
7
|
+
command :install do |c|
|
8
|
+
c.action do |global_options, options, args|
|
9
|
+
if args.first.nil?
|
10
|
+
index = Ask.list('Select a recipe to install', recipe_name_list)
|
11
|
+
ARGV << recipe_name_list[index]
|
12
|
+
Potassium::RecipeGenerator.start
|
13
|
+
else
|
14
|
+
if recipe_exists?(args)
|
15
|
+
Potassium::RecipeGenerator.start
|
16
|
+
else
|
17
|
+
puts "Oops! Sorry, that recipe doesn't exist. Were you looking for this?: #{guess_recipe_name(args)}"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.recipe_exists?(args)
|
24
|
+
recipe_name_list.include?(args.first)
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.guess_recipe_name(args)
|
28
|
+
if recipe_exists?(args)
|
29
|
+
args.first
|
30
|
+
else
|
31
|
+
find_closest_recipe(recipe_name_list, args.first)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.recipe_name_list
|
36
|
+
@recipe_name_list ||= begin
|
37
|
+
source_root = File.expand_path('../../../templates/application/recipes', __FILE__)
|
38
|
+
files = Dir.entries(source_root).select { |e| e.end_with?('.rb') }
|
39
|
+
files.map { |e| e.gsub('.rb', '') }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.find_closest_recipe(recipe_list, possible_recipe)
|
44
|
+
return nil unless possible_recipe
|
45
|
+
highest_distance = 100
|
46
|
+
closest_match = nil
|
47
|
+
recipe_list.each do |recipe|
|
48
|
+
distance = Levenshtein.distance(recipe, possible_recipe)
|
49
|
+
if distance < highest_distance
|
50
|
+
highest_distance = distance
|
51
|
+
closest_match = recipe
|
52
|
+
end
|
53
|
+
end
|
54
|
+
closest_match
|
55
|
+
end
|
56
|
+
end
|
@@ -1,4 +1,16 @@
|
|
1
1
|
module GemHelpers
|
2
|
+
|
3
|
+
def gem_exists?(regex)
|
4
|
+
exists = false
|
5
|
+
File.open("Gemfile").each_line do |line|
|
6
|
+
if line =~ regex
|
7
|
+
exists = true
|
8
|
+
return
|
9
|
+
end
|
10
|
+
end
|
11
|
+
exists
|
12
|
+
end
|
13
|
+
|
2
14
|
def gather_gem(name, *attributes)
|
3
15
|
ensure_variable(:gems, {})
|
4
16
|
current_gem_groups = get(:current_gem_groups) || [:base]
|
@@ -1,4 +1,12 @@
|
|
1
1
|
module TemplateHelpers
|
2
|
+
def load_recipe(recipe)
|
3
|
+
return if exists?(recipe)
|
4
|
+
eval_file "recipes/checks/#{recipe}.rb" rescue Exception
|
5
|
+
eval_file "recipes/dependencies/#{recipe}.rb" rescue Exception
|
6
|
+
eval_file "recipes/asks/#{recipe}.rb" rescue Exception
|
7
|
+
eval_file "recipes/#{recipe}.rb"
|
8
|
+
end
|
9
|
+
|
2
10
|
def eval_file(source)
|
3
11
|
location = File.expand_path(find_in_source_paths(source))
|
4
12
|
unique_name = SecureRandom.hex
|
@@ -4,6 +4,10 @@ module VariableHelpers
|
|
4
4
|
@_data[key] = value
|
5
5
|
end
|
6
6
|
|
7
|
+
def selected?(key, value = nil)
|
8
|
+
value ? equals?(key, value) : get(key)
|
9
|
+
end
|
10
|
+
|
7
11
|
def get(key)
|
8
12
|
@_data ||= {}
|
9
13
|
@_data[key]
|
@@ -13,6 +17,10 @@ module VariableHelpers
|
|
13
17
|
get(key) == value
|
14
18
|
end
|
15
19
|
|
20
|
+
def exists?(key)
|
21
|
+
equals?("#{key}_exists".to_sym, true)
|
22
|
+
end
|
23
|
+
|
16
24
|
private
|
17
25
|
|
18
26
|
def ensure_variable(key, default_value)
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require "rails/generators"
|
2
|
+
require "rails/generators/rails/app/app_generator"
|
3
|
+
require "inquirer"
|
4
|
+
|
5
|
+
module Potassium
|
6
|
+
class RecipeGenerator < Rails::Generators::NamedBase
|
7
|
+
def run_generator
|
8
|
+
require_relative "./helpers/template-dsl"
|
9
|
+
TemplateDSL.extend_dsl(self, source_path: __FILE__)
|
10
|
+
template_location = File.expand_path('./recipe_template.rb', File.dirname(__FILE__))
|
11
|
+
instance_eval File.read(template_location), template_location
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
recipe = ARGV.first
|
2
|
+
|
3
|
+
# Consider all the recipe's questions as true
|
4
|
+
def selected?(key, val = nil); true; end
|
5
|
+
|
6
|
+
run_action(:recipe_loading) do
|
7
|
+
load_recipe(recipe)
|
8
|
+
end
|
9
|
+
|
10
|
+
run_action(:gem_install) do
|
11
|
+
build_gemfile
|
12
|
+
run "bundle install"
|
13
|
+
end
|
14
|
+
|
15
|
+
# Ensure all the recipe's callbacks are executed
|
16
|
+
get(:callbacks).each do |name, cbs|
|
17
|
+
|
18
|
+
puts "Processing #{name} callbacks"
|
19
|
+
cbs.each do |event, cb|
|
20
|
+
cb.each {|callback| instance_exec(&callback) }
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
set(:devise_exists, gem_exists?(/"devise"/))
|
@@ -0,0 +1,20 @@
|
|
1
|
+
if selected?(:paperclip)
|
2
|
+
gather_gem('paperclip', '~> 4.3')
|
3
|
+
|
4
|
+
gsub_file "config/environments/production.rb", /^end$/o do |match|
|
5
|
+
match = %q{
|
6
|
+
|
7
|
+
# Paperclip support for S3
|
8
|
+
config.paperclip_defaults = {
|
9
|
+
:storage => :s3,
|
10
|
+
:s3_credentials => {
|
11
|
+
:bucket => ENV['AWS_BUCKET']
|
12
|
+
}
|
13
|
+
}
|
14
|
+
end}
|
15
|
+
end
|
16
|
+
|
17
|
+
append_to_file '.rbenv-vars.example', 'AWS_BUCKET='
|
18
|
+
append_to_file '.rbenv-vars', 'AWS_BUCKET='
|
19
|
+
|
20
|
+
end
|
@@ -1,4 +1,23 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'semantic'
|
3
|
+
require 'pry'
|
4
|
+
|
5
|
+
def latest
|
6
|
+
printf 'Getting platanus latest ruby version...'
|
7
|
+
Net::HTTP.get(URI.parse('http://ruby.platan.us/latest'))
|
8
|
+
rescue
|
9
|
+
puts " not found, using #{RUBY_VERSION}"
|
10
|
+
RUBY_VERSION
|
11
|
+
end
|
12
|
+
|
13
|
+
def version_alias
|
14
|
+
version = latest
|
15
|
+
|
16
|
+
puts "using #{version}"
|
17
|
+
Semantic::Version.new(version).instance_eval { "#{major}.#{minor}" }
|
18
|
+
end
|
19
|
+
|
1
20
|
create_file '.rbenv-vars'
|
2
21
|
template 'assets/.rbenv-vars.example', '.rbenv-vars.example'
|
3
22
|
run "cp .rbenv-vars.example .rbenv-vars"
|
4
|
-
create_file '.ruby-version',
|
23
|
+
create_file '.ruby-version', version_alias
|
@@ -18,8 +18,9 @@ run_action(:asking) do
|
|
18
18
|
eval_file "recipes/asks/devise.rb"
|
19
19
|
eval_file "recipes/asks/admin.rb"
|
20
20
|
eval_file "recipes/asks/pundit.rb"
|
21
|
-
eval_file "recipes/asks/
|
21
|
+
eval_file "recipes/asks/i18n.rb"
|
22
22
|
eval_file "recipes/asks/api.rb"
|
23
|
+
eval_file "recipes/asks/paperclip.rb"
|
23
24
|
end
|
24
25
|
|
25
26
|
run_action(:recipe_loading) do
|
@@ -41,6 +42,7 @@ run_action(:recipe_loading) do
|
|
41
42
|
eval_file "recipes/git.rb"
|
42
43
|
eval_file "recipes/api.rb"
|
43
44
|
eval_file "recipes/rack-cors.rb"
|
45
|
+
eval_file "recipes/paperclip.rb"
|
44
46
|
end
|
45
47
|
|
46
48
|
say "Gathered enough information. Applying the template. Wait a minute.", :green
|
data/lib/potassium/version.rb
CHANGED
data/potassium.gemspec
CHANGED
@@ -21,8 +21,8 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.7"
|
22
22
|
spec.add_development_dependency "rake", "~> 10.0"
|
23
23
|
spec.add_runtime_dependency "gli", "~> 2.12.2"
|
24
|
-
spec.add_runtime_dependency "rails", "~> 4.2"
|
25
24
|
spec.add_runtime_dependency "inquirer", "~> 0.2"
|
26
25
|
spec.add_runtime_dependency "gems", "~> 0.8"
|
27
26
|
spec.add_runtime_dependency "semantic", "~> 1.4"
|
27
|
+
spec.add_runtime_dependency "levenshtein", "~> 0.2"
|
28
28
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: potassium
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- juliogarciag
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -53,61 +53,61 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 2.12.2
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: inquirer
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '0.2'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '0.2'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: gems
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '0.
|
75
|
+
version: '0.8'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '0.
|
82
|
+
version: '0.8'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: semantic
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '1.4'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '1.4'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: levenshtein
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
103
|
+
version: '0.2'
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
110
|
+
version: '0.2'
|
111
111
|
description: An application generator from Platanus
|
112
112
|
email:
|
113
113
|
- julioggonz@gmail.com
|
@@ -118,6 +118,9 @@ extra_rdoc_files: []
|
|
118
118
|
files:
|
119
119
|
- ".editorconfig"
|
120
120
|
- ".gitignore"
|
121
|
+
- ".hound.yml"
|
122
|
+
- ".rubocop.yml"
|
123
|
+
- ".ruby_style.yml"
|
121
124
|
- CHANGELOG.md
|
122
125
|
- Gemfile
|
123
126
|
- LICENSE.txt
|
@@ -128,6 +131,7 @@ files:
|
|
128
131
|
- lib/potassium.rb
|
129
132
|
- lib/potassium/cli.rb
|
130
133
|
- lib/potassium/cli/commands/create.rb
|
134
|
+
- lib/potassium/cli/commands/install.rb
|
131
135
|
- lib/potassium/newest_version_ensurer.rb
|
132
136
|
- lib/potassium/template_finder.rb
|
133
137
|
- lib/potassium/templates/application/assets/.bowerrc
|
@@ -152,9 +156,12 @@ files:
|
|
152
156
|
- lib/potassium/templates/application/helpers/callback-helpers.rb
|
153
157
|
- lib/potassium/templates/application/helpers/environment-helpers.rb
|
154
158
|
- lib/potassium/templates/application/helpers/gem-helpers.rb
|
159
|
+
- lib/potassium/templates/application/helpers/recipe-helpers.rb
|
155
160
|
- lib/potassium/templates/application/helpers/template-dsl.rb
|
156
161
|
- lib/potassium/templates/application/helpers/template-helpers.rb
|
157
162
|
- lib/potassium/templates/application/helpers/variable-helpers.rb
|
163
|
+
- lib/potassium/templates/application/recipe_generator.rb
|
164
|
+
- lib/potassium/templates/application/recipe_template.rb
|
158
165
|
- lib/potassium/templates/application/recipes/admin.rb
|
159
166
|
- lib/potassium/templates/application/recipes/angular_admin.rb
|
160
167
|
- lib/potassium/templates/application/recipes/api.rb
|
@@ -162,15 +169,19 @@ files:
|
|
162
169
|
- lib/potassium/templates/application/recipes/asks/api.rb
|
163
170
|
- lib/potassium/templates/application/recipes/asks/database.rb
|
164
171
|
- lib/potassium/templates/application/recipes/asks/devise.rb
|
165
|
-
- lib/potassium/templates/application/recipes/asks/
|
172
|
+
- lib/potassium/templates/application/recipes/asks/i18n.rb
|
173
|
+
- lib/potassium/templates/application/recipes/asks/paperclip.rb
|
166
174
|
- lib/potassium/templates/application/recipes/asks/pundit.rb
|
167
175
|
- lib/potassium/templates/application/recipes/aws_sdk.rb
|
168
176
|
- lib/potassium/templates/application/recipes/bower.rb
|
177
|
+
- lib/potassium/templates/application/recipes/checks/devise.rb
|
169
178
|
- lib/potassium/templates/application/recipes/database.rb
|
179
|
+
- lib/potassium/templates/application/recipes/dependencies/admin.rb
|
170
180
|
- lib/potassium/templates/application/recipes/devise.rb
|
171
181
|
- lib/potassium/templates/application/recipes/editorconfig.rb
|
172
182
|
- lib/potassium/templates/application/recipes/git.rb
|
173
183
|
- lib/potassium/templates/application/recipes/i18n.rb
|
184
|
+
- lib/potassium/templates/application/recipes/paperclip.rb
|
174
185
|
- lib/potassium/templates/application/recipes/production.rb
|
175
186
|
- lib/potassium/templates/application/recipes/pry.rb
|
176
187
|
- lib/potassium/templates/application/recipes/pundit.rb
|
@@ -203,7 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
203
214
|
version: '0'
|
204
215
|
requirements: []
|
205
216
|
rubyforge_project:
|
206
|
-
rubygems_version: 2.
|
217
|
+
rubygems_version: 2.4.5.1
|
207
218
|
signing_key:
|
208
219
|
specification_version: 4
|
209
220
|
summary: An application generator from Platanus
|