potassium 1.2.4 → 1.3.0

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: b04a7870f2d5f9ea1f6d44317fb454f055936c6a
4
- data.tar.gz: cf7db9e1b9697fa5fef3ef7c16349268c7c98744
3
+ metadata.gz: 84dfc5a86790a8f12766edb6d4630447f3dac300
4
+ data.tar.gz: 81532c09ffb2c7b03425593defffd65f7fa955c8
5
5
  SHA512:
6
- metadata.gz: 435f4c6bbcaa355f066da5fc7c3c39eb4d77214959b1f2a8521625d7b414c3561b607fa9cd9fdafe8059aef1c09d3cd41a33505c727ca84a4dff6239225f749f
7
- data.tar.gz: fbc899e85333d47a92cc2ee5896f691ff35651442b2f308ae9441143cfc5f18403c06d7c10c1894146820b05ec06b65f6deef1cbf8b9459bc374d29fedb3a8da
6
+ metadata.gz: 5887cd67d48c639629936273ae689add1119330412a32acccc0f4196672164569c631ddd633b6a1b4687a231d623425fe81a5d4fda72e99860a4c11d55426219
7
+ data.tar.gz: 3aea3f4d76d4113595962e423ba70e9adc537f77aaf54116ffb168282745fbdeb208665879db94a2bad7282d3d58d3890770ce11aa9e4e81886732ad7b089b14
data/CHANGELOG.md CHANGED
@@ -1,15 +1,39 @@
1
- ## 1.0.1
1
+ # Changelog
2
2
 
3
- Bugfixes:
4
- - Removed `default_command` call to fix --version usage.
3
+ ## 1.3
5
4
 
6
- ## 1.1.0
5
+ Features:
6
+ - Added update checking before the create command. It will (almost) force that potassium should be updated.
7
+
8
+ Chore:
9
+ - Returned to use SemVer because in 1.2.3 and 1.2.4 there were features and they should have been 1.3 and 1.4. This version will be 1.3 to not lose some versions in the void but new features means a second number jump and we will have to ensure that.
10
+
11
+ ## 1.2.4
12
+
13
+ Features:
14
+ - Added Rack CORS gem and config.
15
+
16
+ ## 1.2.3
7
17
 
8
18
  Bugfixes:
9
- - Fixed dependencies management.
19
+ - Fix database name to use when dashes are present.
10
20
 
11
21
  Features:
12
- - Added a question for choosing application language and integration with devise-i18n.
22
+ - Added optional API support that includes the following:
23
+ - A concern that offer standard responses to common errors.
24
+ - Versionist Support.
25
+ - `simple_token_authentication`, `active_model_serializers` and `responders` gem.
26
+ - A default responder for API common behavior.
27
+
28
+ ## 1.2.2
29
+
30
+ Bugfixes:
31
+ - Multiple changes to make it work correctly within rubygems.
32
+
33
+ ## 1.2.1
34
+
35
+ Refactor:
36
+ - Speed up `help` and `version` commands by lazily requiring rails dependencies.
13
37
 
14
38
  ## 1.2.0
15
39
 
@@ -25,29 +49,15 @@ Features:
25
49
  Chore:
26
50
  - Removed several questions for ActiveAdmin support.
27
51
 
28
- ## 1.2.1
29
-
30
- Refactor:
31
- - Speed up `help` and `version` commands by lazily requiring rails dependencies.
32
-
33
- ## 1.2.2
34
-
35
- Bugfixes:
36
- - Multiple changes to make it work correctly within rubygems.
37
-
38
- ## 1.2.3
52
+ ## 1.1.0
39
53
 
40
54
  Bugfixes:
41
- - Fix database name to use when dashes are present.
55
+ - Fixed dependencies management.
42
56
 
43
57
  Features:
44
- - Added optional API support that includes the following:
45
- - A concern that offer standard responses to common errors.
46
- - Versionist Support.
47
- - `simple_token_authentication`, `active_model_serializers` and `responders` gem.
48
- - A default responder for API common behavior.
58
+ - Added a question for choosing application language and integration with devise-i18n.
49
59
 
50
- ## 1.2.4
60
+ ## 1.0.1
51
61
 
52
- Features:
53
- - Added Rack CORS gem and config
62
+ Bugfixes:
63
+ - Removed `default_command` call to fix --version usage.
data/README.md CHANGED
@@ -14,6 +14,8 @@ Use the `potassium` command to create a new project:
14
14
 
15
15
  $ potassium create project-name
16
16
 
17
+ It's important to note that it will perform a version check before running to ensure that you're using the latest potassium.
18
+
17
19
  ## What's inside Potassium?
18
20
 
19
21
  Potassium Rails apps includes the following gems and technologies:
@@ -21,7 +23,7 @@ Potassium Rails apps includes the following gems and technologies:
21
23
  - [rbenv](https://github.com/sstephenson/rbenv) for managing the project's ruby version.
22
24
  - [rbenv-vars](https://github.com/sstephenson/rbenv-vars) for keeping secrets and by-server configurations.
23
25
  - [Bower](http://bower.io) for frontend assets packages.
24
- - [EditorConfig](http://editorconfig.org) for keeping all our editor configurations the same.
26
+ - [EditorConfig](http://editorconfig.org) for keeping all our editor configurations the same.
25
27
  - [pry](http://pryrepl.org) and [pry-byebug](https://github.com/deivid-rodriguez/pry-byebug) for a less painful debugging experience.
26
28
  - [RSpec](http://rspec.info) for unit and integration testing.
27
29
  - [FactoryGirl](https://github.com/thoughtbot/factory_girl) for test factories.
@@ -3,14 +3,29 @@ module Potassium::CLI
3
3
  arg 'app_path'
4
4
  command :create do |c|
5
5
  c.default_desc "Create a new project."
6
+ c.switch "version-check", default_value: true,
7
+ desc: "Performs a version check before running.",
8
+ negatable: true
9
+
6
10
  c.action do |global_options, options, args|
7
- require "potassium/templates/application/generator"
8
- require "potassium/template_finder"
11
+ require "potassium/newest_version_ensurer"
12
+
13
+ begin_creation = -> do
14
+ require "potassium/templates/application/generator"
15
+ require "potassium/template_finder"
16
+
17
+ template_finder = Potassium::TemplateFinder.new
18
+ template = template_finder.default_template
19
+ template.source_paths << Rails::Generators::AppGenerator.source_root
20
+ template.start
21
+ end
9
22
 
10
- template_finder = Potassium::TemplateFinder.new
11
- template = template_finder.default_template
12
- template.source_paths << Rails::Generators::AppGenerator.source_root
13
- template.start
23
+ if options["version-check"]
24
+ ensurer = Potassium::NewestVersionEnsurer.new
25
+ ensurer.ensure(&begin_creation)
26
+ else
27
+ begin_creation.call
28
+ end
14
29
  end
15
30
  end
16
31
  end
@@ -0,0 +1,57 @@
1
+ require "term/ansicolor"
2
+ require "gems"
3
+ require "semantic"
4
+ require "potassium/text_spinner"
5
+
6
+ module Potassium
7
+ class NewestVersionEnsurer
8
+ include Term::ANSIColor
9
+
10
+ def initialize(current_version = Potassium::VERSION)
11
+ self.current_version = Semantic::Version.new(current_version)
12
+ self.text_spinner = Potassium::TextSpinner.new
13
+ end
14
+
15
+ def ensure(&success_block)
16
+ spin_text("Checking your Potassium installation") { latest_version }
17
+
18
+ self.latest_version = Semantic::Version.new(
19
+ Gems.versions("potassium").first["number"]
20
+ )
21
+
22
+ if latest_version <= current_version
23
+ up_to_date
24
+ success_block.call
25
+ else
26
+ please_update
27
+ end
28
+ end
29
+
30
+ private
31
+
32
+ attr_accessor :latest_version, :current_version, :text_spinner
33
+
34
+ def up_to_date
35
+ puts green("\nYour Potassium installation is up to date.")
36
+ end
37
+
38
+ def please_update
39
+ puts red("\nYour Potassium installation is not up to date.")
40
+ puts red("Found: #{current_version}")
41
+ puts red("Expected: #{latest_version}\n")
42
+ print white("Please run: ")
43
+ print green("gem update potassium ")
44
+ print white("to upgrade your potassium installation.\n\n")
45
+ print white("If you really need to run this outdated version of potassium anyway, ")
46
+ print white("re-run this command with the ")
47
+ print black("--no-version-check")
48
+ puts white(" flag.")
49
+ end
50
+
51
+ def spin_text(message, &block)
52
+ text_spinner.wait_condition = block
53
+ text_spinner.base_message = message
54
+ text_spinner.start
55
+ end
56
+ end
57
+ end
@@ -25,3 +25,7 @@ after(:gem_install) do
25
25
 
26
26
  run "guard init"
27
27
  end
28
+
29
+ gsub_file 'config/environments/development.rb', /config.action_mailer.raise_delivery_errors = false\n/ do
30
+ "config.action_mailer.raise_delivery_errors = true"
31
+ end
@@ -0,0 +1,55 @@
1
+ module Potassium
2
+ # TODO: I don't know if this is a concern of this gem. Maybe we should move this later
3
+ class TextSpinner
4
+ attr_accessor :wait_condition, :base_message, :interval, :message_continuations,
5
+ :counter, :started
6
+
7
+ DEFAULT_ATTRIBUTES = {
8
+ wait_condition: -> { },
9
+ base_message: "",
10
+ interval: 0.4,
11
+ message_continuations: ["", ".", "..", "..."]
12
+ }
13
+
14
+ def initialize(attributes = {})
15
+ DEFAULT_ATTRIBUTES.merge(attributes).each do |key, value|
16
+ self.public_send("#{key}=", value)
17
+ end
18
+ self.started = false
19
+ self.counter = 0
20
+ end
21
+
22
+ def start
23
+ fail already_started_message if started
24
+ self.started = true
25
+
26
+ Thread.new do
27
+ loop do
28
+ break if wait_condition.call(counter)
29
+ print_message
30
+ sleep interval
31
+ self.counter += 1
32
+ end
33
+ clear_message
34
+ self.started = false
35
+ end
36
+ end
37
+
38
+ private
39
+
40
+ def print_message
41
+ message_continuation = message_continuations[counter] || begin
42
+ message_continuations[counter % message_continuations.size]
43
+ end
44
+ print "\r#{base_message}#{message_continuation}"
45
+ end
46
+
47
+ def clear_message
48
+ print "\r#{" " * (base_message.size * 2)}\r"
49
+ end
50
+
51
+ def already_started_message
52
+ "Please don't start this text spinner while is running. It can cause race conditions."
53
+ end
54
+ end
55
+ end
@@ -1,3 +1,3 @@
1
1
  module Potassium
2
- VERSION = "1.2.4"
2
+ VERSION = "1.3.0"
3
3
  end
data/potassium.gemspec CHANGED
@@ -23,4 +23,6 @@ Gem::Specification.new do |spec|
23
23
  spec.add_runtime_dependency "gli", "~> 2.12.2"
24
24
  spec.add_runtime_dependency "rails", "~> 4.2"
25
25
  spec.add_runtime_dependency "inquirer", "~> 0.2"
26
+ spec.add_runtime_dependency "gems", "~> 0.8"
27
+ spec.add_runtime_dependency "semantic", "~> 1.4"
26
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.2.4
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - juliogarciag
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-24 00:00:00.000000000 Z
11
+ date: 2015-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,6 +80,34 @@ dependencies:
80
80
  - - ~>
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0.2'
83
+ - !ruby/object:Gem::Dependency
84
+ name: gems
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: '0.8'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: '0.8'
97
+ - !ruby/object:Gem::Dependency
98
+ name: semantic
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ~>
102
+ - !ruby/object:Gem::Version
103
+ version: '1.4'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: '1.4'
83
111
  description: An application generator from Platanus
84
112
  email:
85
113
  - julioggonz@gmail.com
@@ -100,6 +128,7 @@ files:
100
128
  - lib/potassium.rb
101
129
  - lib/potassium/cli.rb
102
130
  - lib/potassium/cli/commands/create.rb
131
+ - lib/potassium/newest_version_ensurer.rb
103
132
  - lib/potassium/template_finder.rb
104
133
  - lib/potassium/templates/application/assets/.bowerrc
105
134
  - lib/potassium/templates/application/assets/.editorconfig
@@ -151,6 +180,7 @@ files:
151
180
  - lib/potassium/templates/application/recipes/testing.rb
152
181
  - lib/potassium/templates/application/recipes/unicorn.rb
153
182
  - lib/potassium/templates/application/template.rb
183
+ - lib/potassium/text_spinner.rb
154
184
  - lib/potassium/version.rb
155
185
  - potassium.gemspec
156
186
  homepage: https://github.com/platanus/potassium