rvmpow 0.0.1 → 0.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 331149c5c7feb8cc7ee2bf36ee98e655c3354b84
4
- data.tar.gz: 908b3a8f393c4cd2d3d5f651d29f7e28496363d5
3
+ metadata.gz: 478e19f8717b394dc0757fb6415bf43180db57ac
4
+ data.tar.gz: 21ec63316e571557dabec7b533cb04f671fcf015
5
5
  SHA512:
6
- metadata.gz: 77a4d571d1f037167b587e439744fb9414c1b3e06801868eb8b8e5521a892b64dc03cc4377f6e16fe572726cae7917235ba349ed0d612c374a92c922ed4718a5
7
- data.tar.gz: debcf93d4cd3d6144990dfc2b10eab8312734f8e0f379d9e207225a316bfa5b13172e19d3c1175ce4069772c46fe47f056db0881c100abb16680b5bf4ccc202f
6
+ metadata.gz: 3f164ea9ceda8f508aaf2a5bacad934ad92efe546cf69c076bbd5b992d5360277099ca437112d1533e1608ab3a6f74b90356b11e01d0ab8b7d1b31d76f5d9a06
7
+ data.tar.gz: 5d4c1a3e1861a8d5a5f54fe0ecf74fc8eef63724698edcb8e2b1b5e19703da087daaca316cdfcc6b9fe0325794a540605a4da1eb9daf8888963c0beafa9aef58
data/.gitignore CHANGED
@@ -15,3 +15,5 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ .ruby-version
19
+ .ruby-gemset
data/README.md CHANGED
@@ -11,6 +11,18 @@
11
11
 
12
12
  [Pow](http://pow.cx) needs to know what ruby and gemset is being used. rvm users can provide this information [manually](http://rvm.io/integration/pow) or install `rvmpow` and it'll handle it for you, including adding the new configuration file to .gitignore and linking the new app for immediate browsing.
13
13
 
14
+ **Words of caution**
15
+
16
+ I tested on newly created and updated rails apps, a bare minimal rack "*app*" and a bare minimal Sinatra app. Feedback is more than welcome.
17
+
18
+ `rvmpow` **will fail** if you are not using a gemset ([you should](https://rvm.io/gemsets) ;-) If this is an issue for enough people, I'll fix it, but I don't think it's good practice to have all your gems in your default gemset.
19
+
20
+ If you are already specifying the ruby version and gemset via .rvmrc or .ruby-version/.ruby-gemset or in your Gemfile, be aware that rvmpow uses Gemfile (which is a good thing if you're going to deploy to [heroku](https://www.heroku.com/) for instance). `rvmpow` will not change the gemfile if ruby and gemset information is present. I advise to remove it prior to running `rvmpow`. If you use one of the other metioned methods, move or delete the files prior to running `rvmpow`.
21
+
22
+ ## Examples
23
+
24
+ ### Rails
25
+
14
26
  ```
15
27
  ~/Documents/Dev/Rails ∆2.1.1 ›rails
16
28
  13:34 $ rvm-prompt
@@ -36,20 +48,111 @@ ruby-2.1.1@rails
36
48
  ~/Documents/Dev/Rails/newApp ∆2.1.1 ›rails
37
49
  ```
38
50
 
39
- If needed, you can pick individual action via `rvmpow add` or `rvmpow remove`.
51
+ ### Sinatra
40
52
 
41
- **Words of caution**
53
+ Minimal but working. ([source](http://rubylearning.com/blog/a-quick-introduction-to-rack/))
42
54
 
43
- I only tested on newly created and updated rails apps. Feedback is more than welcome.
55
+ Create a directory for your Sinatra app and do:
44
56
 
45
- If you are already specifying the ruby version and gemset via .rvmrc or .ruby-version/.ruby-gemset or in your Gemfile, be aware that rvmpow uses Gemfile (which is a good thing if you're going to deploy to [heroku](https://www.heroku.com/) for instance). `rvmpow` will not change the gemfile if ruby and gemset information is present. I advise to remove it prior to running `rvmpow`. If you use one of the other metioned methods, move or delete the files prior to running `rvmpow`.
57
+ ```
58
+ bundle init
59
+ ```
60
+
61
+ Edit the Gemfile as follows:
62
+
63
+ ```ruby
64
+ source "https://rubygems.org"
65
+
66
+ gem "sinatra"
67
+ gem "rvmpow"
68
+ ```
69
+
70
+ Back in the shell, run:
71
+
72
+ ```
73
+ bundle install
74
+ ```
75
+
76
+ Add the "*app*" file *my_sinatra.rb* :
77
+
78
+ ```ruby
79
+ require 'sinatra'
80
+
81
+ get '/' do
82
+ 'Welcome to Sinatra'
83
+ end
84
+ ```
85
+
86
+ Add the *config.ru* file:
87
+
88
+ ```ruby
89
+ require './my_sinatra'
90
+ run Sinatra::Application
91
+ ```
92
+
93
+ And let `rvmpow` do the rest:
94
+
95
+ ```
96
+ ~/Documents/Dev/Ruby/frank ∆2.1.1 ›sinatra
97
+ 15:01 $ rvm-prompt
98
+ ruby-2.1.1@sinatra
99
+ ~/Documents/Dev/Ruby/frank ∆2.1.1 ›sinatra
100
+ 15:01 $ rvmpow init --rackdev --show
101
+ Done Add .powenv file
102
+ Done Add app link in ~/.pow
103
+ Done Touch restart.txt file in ./tmp/
104
+ Done Add '.powenv' to ./.gitignore
105
+ Done Add rvm ruby and gemset information to ./Gemfile
106
+ Done Touch always_restart.txt file in ./tmp/
107
+ Done Open app in default browser
108
+ ~/Documents/Dev/Ruby/frank ∆2.1.1 ›sinatra
109
+ ```
110
+
111
+ ### Rack
112
+
113
+ Minimal but working. ([source](http://rubylearning.com/blog/a-quick-introduction-to-rack/))
114
+
115
+ Create a new directory for your Rack "*app*" with your app file *my_app.rb*:
116
+
117
+ ```ruby
118
+ class MyApp
119
+ def call env
120
+ [200, {"Content-Type" => "text/plain"}, ["Hi there!!! The time is #{Time.now}"]]
121
+ end
122
+ end
123
+ ```
124
+
125
+ Create *config.ru* to launch your app.
126
+
127
+ ```ruby
128
+ require './my_app'
129
+ run MyApp.new
130
+ ```
131
+
132
+ Then let rvmpow do the rest.
133
+
134
+ ```
135
+ ~/Documents/Dev/Ruby/Rack ∆2.1.1 ›rack
136
+ 12:18 $ rvm-prompt
137
+ ruby-2.1.1@rack
138
+ ~/Documents/Dev/Ruby/Rack ∆2.1.1 ›rails
139
+ 12:18 $ rvmpow init --rackdev --show
140
+ Done Add .powenv file
141
+ Done Add app link in ~/.pow
142
+ Done Touch restart.txt file in ./tmp/
143
+ Done Add '.powenv' to ./.gitignore
144
+ Done Add rvm ruby and gemset information to ./Gemfile
145
+ Done Touch always_restart.txt file in ./tmp/
146
+ Done Open app in default browser
147
+ ~/Documents/Dev/Ruby/Rack ∆2.1.1 ›rails
148
+ ```
46
149
 
47
150
  ## Installation
48
151
 
49
152
  Add this line to your application's Gemfile:
50
153
 
51
154
  ```
52
- gem 'toto'
155
+ gem 'rvmpow'
53
156
  ```
54
157
 
55
158
  And then execute:
@@ -61,7 +164,7 @@ $ bundle
61
164
  Or install it yourself as:
62
165
 
63
166
  ```
64
- $ gem install toto
167
+ $ gem install rvmpow
65
168
  ```
66
169
 
67
170
  ## Usage
@@ -85,6 +188,8 @@ To open the app after initialization, run:
85
188
  $ rvmpow open
86
189
  ```
87
190
 
191
+ If needed, you can pick individual actions via `rvmpow add` or `rvmpow remove`.
192
+
88
193
  rvmpow comes with extensive help built in, just run:
89
194
 
90
195
  ```
data/bin/rvmpow CHANGED
@@ -31,12 +31,17 @@ class Add < Thor
31
31
  exec_cmd { @pow.touchRestartFile }
32
32
  end
33
33
 
34
+ desc "always_restart", RvmPow::TOUCH_ALWAYS_RESTART
35
+ def always_restart
36
+ exec_cmd { @pow.touchAlwaysRestartFile}
37
+ end
38
+
34
39
  desc "gitignore", RvmPow::ADD_GITIGNORE
35
40
  def gitignore
36
41
  exec_cmd { @pow.gitignorePowenv }
37
42
  end
38
43
 
39
- desc "addRvmInfoToGemfile", RvmPow::ADD_GEMFILE
44
+ desc "gemfile", RvmPow::ADD_GEMFILE
40
45
  def gemfile
41
46
  exec_cmd { @pow.addRvmInfoToGemfile }
42
47
  end
@@ -61,6 +66,11 @@ class Remove < Thor
61
66
  exec_cmd { @pow.deleteRestartFile }
62
67
  end
63
68
 
69
+ desc "always_restart", RvmPow::REMOVE_ALWAYS_RESTART
70
+ def always_restart
71
+ exec_cmd { @pow.deleteAlwaysRestartFile }
72
+ end
73
+
64
74
  desc "powlink", RvmPow::REMOVE_LINK
65
75
  def powlink
66
76
  exec_cmd { @pow.deletePowLink }
@@ -100,6 +110,7 @@ class CLI < Thor
100
110
 
101
111
  LONGDESC
102
112
  option :show, type: :boolean, desc: "open in default browser"
113
+ option :rackdev, type: :boolean, desc: "reload the app on each request (rack only - not needed for rails apps)"
103
114
  def init
104
115
  exec_cmd {nil}
105
116
 
@@ -146,6 +157,15 @@ class CLI < Thor
146
157
  shitHappens = true
147
158
  end
148
159
 
160
+ if options[:rackdev]
161
+ if @pow.touchAlwaysRestartFile
162
+ say_status "Done", RvmPow::TOUCH_ALWAYS_RESTART, :green
163
+ else
164
+ say_status "Failed", RvmPow::TOUCH_ALWAYS_RESTART, :red
165
+ shitHappens = true
166
+ end
167
+ end
168
+
149
169
  if options[:show]
150
170
  if shitHappens
151
171
  say_status "Failed", "Open app in default browser canceled due to previous error(s)", :red
@@ -211,6 +231,14 @@ class CLI < Thor
211
231
  shitHappens = true
212
232
  end
213
233
 
234
+ if @pow.deleteAlwaysRestartFile
235
+ say_status "Done", RvmPow::REMOVE_ALWAYS_RESTART, :green
236
+ else
237
+ say_status "Failed", RvmPow::REMOVE_ALWAYS_RESTART, :red
238
+ shitHappens = true
239
+ end
240
+
241
+
214
242
  if shitHappens
215
243
  say "Reverting all changes failed.", :red
216
244
  end
data/lib/rvmpow.rb CHANGED
@@ -22,7 +22,19 @@ module RvmPow
22
22
 
23
23
  # create tmp/restart.txt file
24
24
  def touchRestartFile
25
- action = -> { FileUtils.touch(RvmPow::RESTART_FILE) }
25
+ action = -> do
26
+ createTmpDirIfNeeded
27
+ FileUtils.touch(RvmPow::RESTART_FILE)
28
+ end
29
+ fileAction action
30
+ end
31
+
32
+ # create tmp/always_restart.txt file
33
+ def touchAlwaysRestartFile
34
+ action = -> do
35
+ createTmpDirIfNeeded
36
+ FileUtils.touch(RvmPow::ALWAYS_RESTART_FILE)
37
+ end
26
38
  fileAction action
27
39
  end
28
40
 
@@ -83,6 +95,12 @@ module RvmPow
83
95
  fileAction action
84
96
  end
85
97
 
98
+ # removes always_restart.txt file from ./tmp/
99
+ def deleteAlwaysRestartFile
100
+ action = -> { FileUtils.rm_f RvmPow::ALWAYS_RESTART_FILE }
101
+ fileAction action
102
+ end
103
+
86
104
  # deletes the link is ~/.pow
87
105
  def deletePowLink
88
106
  action = -> { FileUtils.rm_f RvmPow::POW_LINK }
@@ -128,6 +146,10 @@ module RvmPow
128
146
  rvm[:gemset] = rvmArray[1]
129
147
  rvm
130
148
  end
149
+
150
+ def createTmpDirIfNeeded
151
+ FileUtils.mkdir('tmp') if !File.exist?('tmp')
152
+ end
131
153
  end
132
154
 
133
155
  end
@@ -3,6 +3,7 @@ module RvmPow
3
3
  RAKE_APP_DIRECTORY = File.expand_path('.')
4
4
  POW_ENV_FILE = "#{RAKE_APP_DIRECTORY}/.powenv"
5
5
  RESTART_FILE = "#{RAKE_APP_DIRECTORY}/tmp/restart.txt"
6
+ ALWAYS_RESTART_FILE = "#{RAKE_APP_DIRECTORY}/tmp/always_restart.txt"
6
7
  APP_NAME = RAKE_APP_DIRECTORY.split('/').last
7
8
  POW_LINK = "#{POW_PATH}/#{APP_NAME}"
8
9
  GITIGNORE_FILE = "#{RAKE_APP_DIRECTORY}/.gitignore"
@@ -18,6 +19,8 @@ module RvmPow
18
19
  REMOVE_LINK = "Remove app link from ~/.pow"
19
20
  TOUCH_RESTART = "Touch restart.txt file in ./tmp/"
20
21
  REMOVE_RESTART = "Remove restart.txt file from ./tmp/"
22
+ TOUCH_ALWAYS_RESTART = "Touch always_restart.txt file in ./tmp/"
23
+ REMOVE_ALWAYS_RESTART = "Remove always_restart.txt file from ./tmp/"
21
24
  ADD_GITIGNORE = "Add '.powenv' to ./.gitignore"
22
25
  REMOVE_GITIGNORE = "Remove .powenv from ./.gitignore"
23
26
  ADD_GEMFILE = "Add rvm ruby and gemset information to ./Gemfile"
@@ -1,3 +1,3 @@
1
1
  module RvmPow
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rvmpow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Olivier Robert
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-04 00:00:00.000000000 Z
11
+ date: 2014-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -79,8 +79,6 @@ extra_rdoc_files: []
79
79
  files:
80
80
  - ".gitignore"
81
81
  - ".rspec"
82
- - ".ruby-gemset"
83
- - ".ruby-version"
84
82
  - Gemfile
85
83
  - LICENSE.txt
86
84
  - README.md
data/.ruby-gemset DELETED
@@ -1 +0,0 @@
1
- gems
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- ruby-2.1.1