rvmpow 0.0.1
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 +7 -0
 - data/.gitignore +17 -0
 - data/.rspec +2 -0
 - data/.ruby-gemset +1 -0
 - data/.ruby-version +1 -0
 - data/Gemfile +4 -0
 - data/LICENSE.txt +22 -0
 - data/README.md +100 -0
 - data/Rakefile +1 -0
 - data/bin/rvmpow +226 -0
 - data/lib/rvmpow.rb +133 -0
 - data/lib/rvmpow/constants.rb +49 -0
 - data/lib/rvmpow/shared_private_methods.rb +32 -0
 - data/lib/rvmpow/version.rb +3 -0
 - data/rvmpow.gemspec +27 -0
 - data/spec/lib/rvmpow_spec.rb +6 -0
 - data/spec/spec_helper.rb +17 -0
 - metadata +122 -0
 
    
        checksums.yaml
    ADDED
    
    | 
         @@ -0,0 +1,7 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ---
         
     | 
| 
      
 2 
     | 
    
         
            +
            SHA1:
         
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 331149c5c7feb8cc7ee2bf36ee98e655c3354b84
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 908b3a8f393c4cd2d3d5f651d29f7e28496363d5
         
     | 
| 
      
 5 
     | 
    
         
            +
            SHA512:
         
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 77a4d571d1f037167b587e439744fb9414c1b3e06801868eb8b8e5521a892b64dc03cc4377f6e16fe572726cae7917235ba349ed0d612c374a92c922ed4718a5
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: debcf93d4cd3d6144990dfc2b10eab8312734f8e0f379d9e207225a316bfa5b13172e19d3c1175ce4069772c46fe47f056db0881c100abb16680b5bf4ccc202f
         
     | 
    
        data/.gitignore
    ADDED
    
    
    
        data/.rspec
    ADDED
    
    
    
        data/.ruby-gemset
    ADDED
    
    | 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            gems
         
     | 
    
        data/.ruby-version
    ADDED
    
    | 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ruby-2.1.1
         
     | 
    
        data/Gemfile
    ADDED
    
    
    
        data/LICENSE.txt
    ADDED
    
    | 
         @@ -0,0 +1,22 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            Copyright (c) 2014 Olibob
         
     | 
| 
      
 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,100 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # Rvmpow
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            [](http://badge.fury.io/rb/rvmpow)
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            `rvmpow` is usefull only if you:
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            - use MacOS X
         
     | 
| 
      
 8 
     | 
    
         
            +
            - use [rvm](http://rvm.io)
         
     | 
| 
      
 9 
     | 
    
         
            +
            - use [pow](http://pow.cx)
         
     | 
| 
      
 10 
     | 
    
         
            +
            - are a [rails](http://rubyonrails.org/) developper or develop [Rack](https://rack.github.io/) apps
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 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 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            ```
         
     | 
| 
      
 15 
     | 
    
         
            +
            ~/Documents/Dev/Rails  ∆2.1.1 ›rails
         
     | 
| 
      
 16 
     | 
    
         
            +
            13:34 $ rvm-prompt
         
     | 
| 
      
 17 
     | 
    
         
            +
            ruby-2.1.1@rails
         
     | 
| 
      
 18 
     | 
    
         
            +
            ~/Documents/Dev/Rails  ∆2.1.1 ›rails
         
     | 
| 
      
 19 
     | 
    
         
            +
            13:34 $ rails new newApp
         
     | 
| 
      
 20 
     | 
    
         
            +
            ...
         
     | 
| 
      
 21 
     | 
    
         
            +
            13:35 $ cd newApp/
         
     | 
| 
      
 22 
     | 
    
         
            +
            ~/Documents/Dev/Rails/newApp  ∆2.1.1 ›rails
         
     | 
| 
      
 23 
     | 
    
         
            +
            13:35 $ rvmpow init
         
     | 
| 
      
 24 
     | 
    
         
            +
                    Done  Create .powenv file
         
     | 
| 
      
 25 
     | 
    
         
            +
                    Done  Create pow link
         
     | 
| 
      
 26 
     | 
    
         
            +
                    Done  Touch restart file
         
     | 
| 
      
 27 
     | 
    
         
            +
                    Done  Add .powenv to .gitignore
         
     | 
| 
      
 28 
     | 
    
         
            +
                    Done  Add ruby and gemset info to Gemfile
         
     | 
| 
      
 29 
     | 
    
         
            +
            ~/Documents/Dev/Rails/newApp  ∆2.1.1 ›rails
         
     | 
| 
      
 30 
     | 
    
         
            +
            13:35 $ rvmpow clear
         
     | 
| 
      
 31 
     | 
    
         
            +
                    Done  Remove rvmpow entries from .gitignore
         
     | 
| 
      
 32 
     | 
    
         
            +
                    Done  Remove rvmpow entries from Gemfile
         
     | 
| 
      
 33 
     | 
    
         
            +
                    Done  Delete .powenv file
         
     | 
| 
      
 34 
     | 
    
         
            +
                    Done  Delete restart file
         
     | 
| 
      
 35 
     | 
    
         
            +
                    Done  Delete pow link
         
     | 
| 
      
 36 
     | 
    
         
            +
            ~/Documents/Dev/Rails/newApp  ∆2.1.1 ›rails
         
     | 
| 
      
 37 
     | 
    
         
            +
            ```
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
            If needed, you can pick individual action via `rvmpow add` or `rvmpow remove`.
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
            **Words of caution**
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
            I only tested on newly created and updated rails apps. Feedback is more than welcome.
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 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`.
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
            ## Installation
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
            Add this line to your application's Gemfile:
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
            ```
         
     | 
| 
      
 52 
     | 
    
         
            +
            gem 'toto'
         
     | 
| 
      
 53 
     | 
    
         
            +
            ```
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
            And then execute:
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
            ```
         
     | 
| 
      
 58 
     | 
    
         
            +
            $ bundle
         
     | 
| 
      
 59 
     | 
    
         
            +
            ```
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
            Or install it yourself as:
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
            ```
         
     | 
| 
      
 64 
     | 
    
         
            +
            $ gem install toto
         
     | 
| 
      
 65 
     | 
    
         
            +
            ```
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
            ## Usage
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
            Make sure you are in the root directory of your Rack app before running `rvmpow`
         
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
      
 71 
     | 
    
         
            +
            ```
         
     | 
| 
      
 72 
     | 
    
         
            +
            $ rvmpow init
         
     | 
| 
      
 73 
     | 
    
         
            +
            ```
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
            To open the app in your default browser directly after initialization, run:
         
     | 
| 
      
 76 
     | 
    
         
            +
             
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
      
 78 
     | 
    
         
            +
            ```
         
     | 
| 
      
 79 
     | 
    
         
            +
            $ rvmpow init --show
         
     | 
| 
      
 80 
     | 
    
         
            +
            ```
         
     | 
| 
      
 81 
     | 
    
         
            +
             
     | 
| 
      
 82 
     | 
    
         
            +
            To open the app after initialization, run:
         
     | 
| 
      
 83 
     | 
    
         
            +
             
     | 
| 
      
 84 
     | 
    
         
            +
            ```
         
     | 
| 
      
 85 
     | 
    
         
            +
            $ rvmpow open
         
     | 
| 
      
 86 
     | 
    
         
            +
            ```
         
     | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
      
 88 
     | 
    
         
            +
            rvmpow comes with extensive help built in, just run:
         
     | 
| 
      
 89 
     | 
    
         
            +
             
     | 
| 
      
 90 
     | 
    
         
            +
            ```
         
     | 
| 
      
 91 
     | 
    
         
            +
            $ rvmpow
         
     | 
| 
      
 92 
     | 
    
         
            +
            ```
         
     | 
| 
      
 93 
     | 
    
         
            +
             
     | 
| 
      
 94 
     | 
    
         
            +
            ## Contributing
         
     | 
| 
      
 95 
     | 
    
         
            +
             
     | 
| 
      
 96 
     | 
    
         
            +
            1. Fork it ( http://github.com/<my-github-username>/rvmpow/fork )
         
     | 
| 
      
 97 
     | 
    
         
            +
            2. Create your feature branch (`git checkout -b my-new-feature`)
         
     | 
| 
      
 98 
     | 
    
         
            +
            3. Commit your changes (`git commit -am 'Add some feature'`)
         
     | 
| 
      
 99 
     | 
    
         
            +
            4. Push to the branch (`git push origin my-new-feature`)
         
     | 
| 
      
 100 
     | 
    
         
            +
            5. Create new Pull Request
         
     | 
    
        data/Rakefile
    ADDED
    
    | 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require "bundler/gem_tasks"
         
     | 
    
        data/bin/rvmpow
    ADDED
    
    | 
         @@ -0,0 +1,226 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            #!/usr/bin/env ruby
         
     | 
| 
      
 2 
     | 
    
         
            +
            # encoding: utf-8
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            # TODO: include private part from CLI in all Thor classes.
         
     | 
| 
      
 5 
     | 
    
         
            +
            #  			Create constants for repetitive strings.
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            require 'thor'
         
     | 
| 
      
 8 
     | 
    
         
            +
            require 'rvmpow'
         
     | 
| 
      
 9 
     | 
    
         
            +
            require 'rvmpow/shared_private_methods'
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            class Add < Thor
         
     | 
| 
      
 12 
     | 
    
         
            +
            	include Shared
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            	def initialize(*args)
         
     | 
| 
      
 15 
     | 
    
         
            +
            	  super
         
     | 
| 
      
 16 
     | 
    
         
            +
            	  @pow = RvmPow::Pow.new
         
     | 
| 
      
 17 
     | 
    
         
            +
            	end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            	desc "powenv", RvmPow::ADD_POWENV
         
     | 
| 
      
 20 
     | 
    
         
            +
            	def powenv
         
     | 
| 
      
 21 
     | 
    
         
            +
            		exec_cmd { @pow.createPowenvFile }
         
     | 
| 
      
 22 
     | 
    
         
            +
            	end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
            	desc "powlink", RvmPow::ADD_LINK
         
     | 
| 
      
 25 
     | 
    
         
            +
            	def powlink
         
     | 
| 
      
 26 
     | 
    
         
            +
            		exec_cmd { @pow.createPowLink }
         
     | 
| 
      
 27 
     | 
    
         
            +
            	end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
            	desc "restart", RvmPow::TOUCH_RESTART
         
     | 
| 
      
 30 
     | 
    
         
            +
            	def restart
         
     | 
| 
      
 31 
     | 
    
         
            +
            		exec_cmd { @pow.touchRestartFile }
         
     | 
| 
      
 32 
     | 
    
         
            +
            	end
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
            	desc "gitignore", RvmPow::ADD_GITIGNORE
         
     | 
| 
      
 35 
     | 
    
         
            +
            	def gitignore
         
     | 
| 
      
 36 
     | 
    
         
            +
            		exec_cmd { @pow.gitignorePowenv }
         
     | 
| 
      
 37 
     | 
    
         
            +
            	end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
            	desc "addRvmInfoToGemfile", RvmPow::ADD_GEMFILE
         
     | 
| 
      
 40 
     | 
    
         
            +
            	def gemfile
         
     | 
| 
      
 41 
     | 
    
         
            +
            		exec_cmd { @pow.addRvmInfoToGemfile }
         
     | 
| 
      
 42 
     | 
    
         
            +
            	end
         
     | 
| 
      
 43 
     | 
    
         
            +
            end
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
            class Remove < Thor
         
     | 
| 
      
 47 
     | 
    
         
            +
            	include Shared
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
            	def initialize(*args)
         
     | 
| 
      
 50 
     | 
    
         
            +
            	  super
         
     | 
| 
      
 51 
     | 
    
         
            +
            	  @pow = RvmPow::Pow.new
         
     | 
| 
      
 52 
     | 
    
         
            +
            	end
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
            	desc "powenv", RvmPow::REMOVE_POWENV
         
     | 
| 
      
 55 
     | 
    
         
            +
            	def powenv
         
     | 
| 
      
 56 
     | 
    
         
            +
            		exec_cmd { @pow.deletePowenvFile }
         
     | 
| 
      
 57 
     | 
    
         
            +
            	end
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
            	desc "restart", RvmPow::REMOVE_RESTART
         
     | 
| 
      
 60 
     | 
    
         
            +
            	def restart
         
     | 
| 
      
 61 
     | 
    
         
            +
            		exec_cmd { @pow.deleteRestartFile }
         
     | 
| 
      
 62 
     | 
    
         
            +
            	end
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
            	desc "powlink", RvmPow::REMOVE_LINK
         
     | 
| 
      
 65 
     | 
    
         
            +
            	def powlink
         
     | 
| 
      
 66 
     | 
    
         
            +
            		exec_cmd { @pow.deletePowLink }
         
     | 
| 
      
 67 
     | 
    
         
            +
            	end
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
            	desc "gitignore", RvmPow::REMOVE_GITIGNORE
         
     | 
| 
      
 70 
     | 
    
         
            +
            	def gitignore
         
     | 
| 
      
 71 
     | 
    
         
            +
            		exec_cmd { @pow.restoreGitignore }
         
     | 
| 
      
 72 
     | 
    
         
            +
            	end
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
      
 74 
     | 
    
         
            +
            	desc "gemfile", RvmPow::REMOVE_GEMFILE
         
     | 
| 
      
 75 
     | 
    
         
            +
            	def gemfile
         
     | 
| 
      
 76 
     | 
    
         
            +
            		exec_cmd {@pow.restoreGemfile }
         
     | 
| 
      
 77 
     | 
    
         
            +
            	end
         
     | 
| 
      
 78 
     | 
    
         
            +
            end
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
      
 80 
     | 
    
         
            +
             
     | 
| 
      
 81 
     | 
    
         
            +
            class CLI < Thor
         
     | 
| 
      
 82 
     | 
    
         
            +
            	include Shared
         
     | 
| 
      
 83 
     | 
    
         
            +
             
     | 
| 
      
 84 
     | 
    
         
            +
            	def initialize(*args)
         
     | 
| 
      
 85 
     | 
    
         
            +
            	  super
         
     | 
| 
      
 86 
     | 
    
         
            +
            	  @pow = RvmPow::Pow.new
         
     | 
| 
      
 87 
     | 
    
         
            +
            	end
         
     | 
| 
      
 88 
     | 
    
         
            +
             
     | 
| 
      
 89 
     | 
    
         
            +
             
     | 
| 
      
 90 
     | 
    
         
            +
            	desc "init", "enable pow"
         
     | 
| 
      
 91 
     | 
    
         
            +
            	long_desc <<-LONGDESC
         
     | 
| 
      
 92 
     | 
    
         
            +
            		`rvmpow init` will:
         
     | 
| 
      
 93 
     | 
    
         
            +
             
     | 
| 
      
 94 
     | 
    
         
            +
            		- create a '.powenv' file in the current directory.
         
     | 
| 
      
 95 
     | 
    
         
            +
            		\x5- add .powenv to the .gitignore file.
         
     | 
| 
      
 96 
     | 
    
         
            +
            		\x5- add app link in ~/.pow
         
     | 
| 
      
 97 
     | 
    
         
            +
            		\x5- add ruby and gemset info to Gemfile.
         
     | 
| 
      
 98 
     | 
    
         
            +
            		\x5- touch restart.txt in ./tmp/
         
     | 
| 
      
 99 
     | 
    
         
            +
             
     | 
| 
      
 100 
     | 
    
         
            +
             
     | 
| 
      
 101 
     | 
    
         
            +
            	LONGDESC
         
     | 
| 
      
 102 
     | 
    
         
            +
            	option :show, type: :boolean, desc: "open in default browser"
         
     | 
| 
      
 103 
     | 
    
         
            +
            	def init
         
     | 
| 
      
 104 
     | 
    
         
            +
            		exec_cmd {nil}
         
     | 
| 
      
 105 
     | 
    
         
            +
             
     | 
| 
      
 106 
     | 
    
         
            +
            		shitHappens = false
         
     | 
| 
      
 107 
     | 
    
         
            +
             
     | 
| 
      
 108 
     | 
    
         
            +
            		# fail safe to avoid multiple initializations
         
     | 
| 
      
 109 
     | 
    
         
            +
            		if File.exists?('.powenv')
         
     | 
| 
      
 110 
     | 
    
         
            +
            			say "Initialization aborted.\nLooks like you already ran it on this project."
         
     | 
| 
      
 111 
     | 
    
         
            +
            			exit 0
         
     | 
| 
      
 112 
     | 
    
         
            +
            		end
         
     | 
| 
      
 113 
     | 
    
         
            +
             
     | 
| 
      
 114 
     | 
    
         
            +
            		if @pow.createPowenvFile
         
     | 
| 
      
 115 
     | 
    
         
            +
            			say_status "Done", RvmPow::ADD_POWENV, :green
         
     | 
| 
      
 116 
     | 
    
         
            +
            		else
         
     | 
| 
      
 117 
     | 
    
         
            +
            			say_status "Failed", RvmPow::ADD_POWENV, :red
         
     | 
| 
      
 118 
     | 
    
         
            +
            			shitHappens = true
         
     | 
| 
      
 119 
     | 
    
         
            +
            		end
         
     | 
| 
      
 120 
     | 
    
         
            +
             
     | 
| 
      
 121 
     | 
    
         
            +
            		if @pow.createPowLink
         
     | 
| 
      
 122 
     | 
    
         
            +
            			say_status "Done", RvmPow::ADD_LINK, :green
         
     | 
| 
      
 123 
     | 
    
         
            +
            		else
         
     | 
| 
      
 124 
     | 
    
         
            +
            			say_status "Failed", RvmPow::ADD_LINK, :red
         
     | 
| 
      
 125 
     | 
    
         
            +
            			shitHappens = true
         
     | 
| 
      
 126 
     | 
    
         
            +
            		end
         
     | 
| 
      
 127 
     | 
    
         
            +
             
     | 
| 
      
 128 
     | 
    
         
            +
            		if @pow.touchRestartFile
         
     | 
| 
      
 129 
     | 
    
         
            +
            			say_status "Done", RvmPow::TOUCH_RESTART, :green
         
     | 
| 
      
 130 
     | 
    
         
            +
            		else
         
     | 
| 
      
 131 
     | 
    
         
            +
            			say_status "Failed", RvmPow::TOUCH_RESTART, :red
         
     | 
| 
      
 132 
     | 
    
         
            +
            			shitHappens = true
         
     | 
| 
      
 133 
     | 
    
         
            +
            		end
         
     | 
| 
      
 134 
     | 
    
         
            +
             
     | 
| 
      
 135 
     | 
    
         
            +
            		if @pow.gitignorePowenv
         
     | 
| 
      
 136 
     | 
    
         
            +
            			say_status "Done", RvmPow::ADD_GITIGNORE, :green
         
     | 
| 
      
 137 
     | 
    
         
            +
            		else
         
     | 
| 
      
 138 
     | 
    
         
            +
            			say_status "Failed", RvmPow::ADD_GITIGNORE, :red
         
     | 
| 
      
 139 
     | 
    
         
            +
            			shitHappens = true
         
     | 
| 
      
 140 
     | 
    
         
            +
            		end
         
     | 
| 
      
 141 
     | 
    
         
            +
             
     | 
| 
      
 142 
     | 
    
         
            +
            		if @pow.addRvmInfoToGemfile
         
     | 
| 
      
 143 
     | 
    
         
            +
            			say_status "Done", RvmPow::ADD_GEMFILE, :green
         
     | 
| 
      
 144 
     | 
    
         
            +
            		else
         
     | 
| 
      
 145 
     | 
    
         
            +
            			say_status "Failed", RvmPow::ADD_GEMFILE, :red
         
     | 
| 
      
 146 
     | 
    
         
            +
            			shitHappens = true
         
     | 
| 
      
 147 
     | 
    
         
            +
            		end
         
     | 
| 
      
 148 
     | 
    
         
            +
             
     | 
| 
      
 149 
     | 
    
         
            +
            		if options[:show]
         
     | 
| 
      
 150 
     | 
    
         
            +
            			if shitHappens
         
     | 
| 
      
 151 
     | 
    
         
            +
            				say_status "Failed", "Open app in default browser canceled due to previous error(s)", :red
         
     | 
| 
      
 152 
     | 
    
         
            +
            				say "Initialization failed.", :red
         
     | 
| 
      
 153 
     | 
    
         
            +
            			else
         
     | 
| 
      
 154 
     | 
    
         
            +
            				say_status "Done", "Open app in default browser", :green
         
     | 
| 
      
 155 
     | 
    
         
            +
            				open
         
     | 
| 
      
 156 
     | 
    
         
            +
            			end
         
     | 
| 
      
 157 
     | 
    
         
            +
            		end
         
     | 
| 
      
 158 
     | 
    
         
            +
            	end
         
     | 
| 
      
 159 
     | 
    
         
            +
             
     | 
| 
      
 160 
     | 
    
         
            +
             
     | 
| 
      
 161 
     | 
    
         
            +
            	desc "open", "open the current Rack app in the default browser"
         
     | 
| 
      
 162 
     | 
    
         
            +
            	def open
         
     | 
| 
      
 163 
     | 
    
         
            +
            		%x(open http://#{RvmPow::APP_NAME}.dev)
         
     | 
| 
      
 164 
     | 
    
         
            +
            	end
         
     | 
| 
      
 165 
     | 
    
         
            +
             
     | 
| 
      
 166 
     | 
    
         
            +
             
     | 
| 
      
 167 
     | 
    
         
            +
            	desc "clear", "disable pow"
         
     | 
| 
      
 168 
     | 
    
         
            +
            	long_desc <<-LONGDESC
         
     | 
| 
      
 169 
     | 
    
         
            +
            		`rvmpow clear` will remove only the files necessary for pow.
         
     | 
| 
      
 170 
     | 
    
         
            +
             
     | 
| 
      
 171 
     | 
    
         
            +
            		It's essentially reverting to the state before you ran `rvmpow init`
         
     | 
| 
      
 172 
     | 
    
         
            +
             
     | 
| 
      
 173 
     | 
    
         
            +
             
     | 
| 
      
 174 
     | 
    
         
            +
            	LONGDESC
         
     | 
| 
      
 175 
     | 
    
         
            +
            	def clear
         
     | 
| 
      
 176 
     | 
    
         
            +
            		exec_cmd {nil}
         
     | 
| 
      
 177 
     | 
    
         
            +
            		shitHappens = false
         
     | 
| 
      
 178 
     | 
    
         
            +
             
     | 
| 
      
 179 
     | 
    
         
            +
            		if @pow.restoreGitignore
         
     | 
| 
      
 180 
     | 
    
         
            +
            			say_status "Done", RvmPow::REMOVE_GITIGNORE, :green
         
     | 
| 
      
 181 
     | 
    
         
            +
            		else
         
     | 
| 
      
 182 
     | 
    
         
            +
            			say_status "Failed", RvmPow::REMOVE_GITIGNORE, :red
         
     | 
| 
      
 183 
     | 
    
         
            +
            			shitHappens = true
         
     | 
| 
      
 184 
     | 
    
         
            +
            		end
         
     | 
| 
      
 185 
     | 
    
         
            +
             
     | 
| 
      
 186 
     | 
    
         
            +
            		if @pow.restoreGemfile
         
     | 
| 
      
 187 
     | 
    
         
            +
            			say_status "Done", RvmPow::REMOVE_GEMFILE, :green
         
     | 
| 
      
 188 
     | 
    
         
            +
            		else
         
     | 
| 
      
 189 
     | 
    
         
            +
            			say_status "Failed", RvmPow::REMOVE_GEMFILE, :red
         
     | 
| 
      
 190 
     | 
    
         
            +
            			shitHappens = true
         
     | 
| 
      
 191 
     | 
    
         
            +
            		end
         
     | 
| 
      
 192 
     | 
    
         
            +
             
     | 
| 
      
 193 
     | 
    
         
            +
            		if @pow.deletePowenvFile
         
     | 
| 
      
 194 
     | 
    
         
            +
            			say_status "Done", RvmPow::REMOVE_POWENV, :green
         
     | 
| 
      
 195 
     | 
    
         
            +
            		else
         
     | 
| 
      
 196 
     | 
    
         
            +
            			say_status "Failed", RvmPow::REMOVE_POWENV, :red
         
     | 
| 
      
 197 
     | 
    
         
            +
            			shitHappens = true
         
     | 
| 
      
 198 
     | 
    
         
            +
            		end
         
     | 
| 
      
 199 
     | 
    
         
            +
             
     | 
| 
      
 200 
     | 
    
         
            +
            		if @pow.deleteRestartFile
         
     | 
| 
      
 201 
     | 
    
         
            +
            			say_status "Done", RvmPow::REMOVE_RESTART, :green
         
     | 
| 
      
 202 
     | 
    
         
            +
            		else
         
     | 
| 
      
 203 
     | 
    
         
            +
            			say_status "Failed", RvmPow::REMOVE_RESTART, :red
         
     | 
| 
      
 204 
     | 
    
         
            +
            			shitHappens = true
         
     | 
| 
      
 205 
     | 
    
         
            +
            		end
         
     | 
| 
      
 206 
     | 
    
         
            +
             
     | 
| 
      
 207 
     | 
    
         
            +
            		if @pow.deletePowLink
         
     | 
| 
      
 208 
     | 
    
         
            +
            			say_status "Done", RvmPow::REMOVE_LINK, :green
         
     | 
| 
      
 209 
     | 
    
         
            +
            		else
         
     | 
| 
      
 210 
     | 
    
         
            +
            			say_status "Failed", RvmPow::REMOVE_LINK, :red
         
     | 
| 
      
 211 
     | 
    
         
            +
            			shitHappens = true
         
     | 
| 
      
 212 
     | 
    
         
            +
            		end
         
     | 
| 
      
 213 
     | 
    
         
            +
             
     | 
| 
      
 214 
     | 
    
         
            +
            		if shitHappens
         
     | 
| 
      
 215 
     | 
    
         
            +
            			say "Reverting all changes failed.", :red
         
     | 
| 
      
 216 
     | 
    
         
            +
            		end
         
     | 
| 
      
 217 
     | 
    
         
            +
            	end
         
     | 
| 
      
 218 
     | 
    
         
            +
             
     | 
| 
      
 219 
     | 
    
         
            +
            	desc "add SUBCOMMAND", "add specific options"
         
     | 
| 
      
 220 
     | 
    
         
            +
            	subcommand "add", Add
         
     | 
| 
      
 221 
     | 
    
         
            +
             
     | 
| 
      
 222 
     | 
    
         
            +
            	desc "remove SUBCOMMAND", "remove specific options"
         
     | 
| 
      
 223 
     | 
    
         
            +
            	subcommand "remove", Remove
         
     | 
| 
      
 224 
     | 
    
         
            +
            end
         
     | 
| 
      
 225 
     | 
    
         
            +
             
     | 
| 
      
 226 
     | 
    
         
            +
            CLI.start(ARGV)
         
     | 
    
        data/lib/rvmpow.rb
    ADDED
    
    | 
         @@ -0,0 +1,133 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require "rvmpow/version"
         
     | 
| 
      
 2 
     | 
    
         
            +
            require "rvmpow/constants"
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'tempfile'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'fileutils'
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            module RvmPow
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            	class Pow
         
     | 
| 
      
 9 
     | 
    
         
            +
            		# create .poenv in current dirrectory
         
     | 
| 
      
 10 
     | 
    
         
            +
            		def createPowenvFile
         
     | 
| 
      
 11 
     | 
    
         
            +
            			action = -> do
         
     | 
| 
      
 12 
     | 
    
         
            +
            				File.open(RvmPow::POW_ENV_FILE, "w+") { |file| file.puts RvmPow::POWENV  }
         
     | 
| 
      
 13 
     | 
    
         
            +
            			end
         
     | 
| 
      
 14 
     | 
    
         
            +
            			fileAction action
         
     | 
| 
      
 15 
     | 
    
         
            +
            		end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            		# link current app to ~/.pow directory
         
     | 
| 
      
 18 
     | 
    
         
            +
            		def createPowLink
         
     | 
| 
      
 19 
     | 
    
         
            +
            			action = -> { File.symlink(RvmPow::RAKE_APP_DIRECTORY, RvmPow::POW_LINK) }
         
     | 
| 
      
 20 
     | 
    
         
            +
            			fileAction action
         
     | 
| 
      
 21 
     | 
    
         
            +
            		end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
            		# create tmp/restart.txt file
         
     | 
| 
      
 24 
     | 
    
         
            +
            		def touchRestartFile
         
     | 
| 
      
 25 
     | 
    
         
            +
            			action = -> { FileUtils.touch(RvmPow::RESTART_FILE) }
         
     | 
| 
      
 26 
     | 
    
         
            +
            			fileAction action
         
     | 
| 
      
 27 
     | 
    
         
            +
            		end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
            		# add .powenv to .gitignore
         
     | 
| 
      
 30 
     | 
    
         
            +
            		def gitignorePowenv
         
     | 
| 
      
 31 
     | 
    
         
            +
            			action = -> do
         
     | 
| 
      
 32 
     | 
    
         
            +
            				File.open(RvmPow::GITIGNORE_FILE, 'a') { |file| file.puts RvmPow::GITIGNORE_ENTRY }
         
     | 
| 
      
 33 
     | 
    
         
            +
            			end
         
     | 
| 
      
 34 
     | 
    
         
            +
            			fileAction action
         
     | 
| 
      
 35 
     | 
    
         
            +
            		end
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
            		# add rvm ruby and gemset to Gemfile
         
     | 
| 
      
 38 
     | 
    
         
            +
            		def addRvmInfoToGemfile
         
     | 
| 
      
 39 
     | 
    
         
            +
            			action = -> do
         
     | 
| 
      
 40 
     | 
    
         
            +
            				rvm = rvmInfo
         
     | 
| 
      
 41 
     | 
    
         
            +
            				File.open(RvmPow::GEMFILE, 'a+') do |file|
         
     | 
| 
      
 42 
     | 
    
         
            +
            					s = file.read
         
     | 
| 
      
 43 
     | 
    
         
            +
            					if (s.match(/ruby\s'\d(\.\d)+'/) || s.match(/ruby-gemset=/))
         
     | 
| 
      
 44 
     | 
    
         
            +
            						puts "\truby or gemset information already present in Gemfile"
         
     | 
| 
      
 45 
     | 
    
         
            +
            					else
         
     | 
| 
      
 46 
     | 
    
         
            +
            						file.puts "\n# rvmpow\nruby '#{rvm[:ruby]}'\n#ruby-gemset=#{rvm[:gemset]}"
         
     | 
| 
      
 47 
     | 
    
         
            +
            					end
         
     | 
| 
      
 48 
     | 
    
         
            +
            				end
         
     | 
| 
      
 49 
     | 
    
         
            +
            			end
         
     | 
| 
      
 50 
     | 
    
         
            +
            			fileAction action
         
     | 
| 
      
 51 
     | 
    
         
            +
            		end
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
            		# removes rvmpow entries from .gitignore
         
     | 
| 
      
 54 
     | 
    
         
            +
            		def restoreGitignore
         
     | 
| 
      
 55 
     | 
    
         
            +
            			action = -> { removeFromFile(RvmPow::GITIGNORE_FILE, RvmPow::GITIGNORE_MATCHER) }
         
     | 
| 
      
 56 
     | 
    
         
            +
            			fileAction action
         
     | 
| 
      
 57 
     | 
    
         
            +
            		end
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
            		# removes rvmpow entries from Gemfile
         
     | 
| 
      
 60 
     | 
    
         
            +
            		def restoreGemfile
         
     | 
| 
      
 61 
     | 
    
         
            +
            			action = -> do
         
     | 
| 
      
 62 
     | 
    
         
            +
            				File.open(RvmPow::GEMFILE, 'r') do |file|
         
     | 
| 
      
 63 
     | 
    
         
            +
            					s = file.read
         
     | 
| 
      
 64 
     | 
    
         
            +
            					if !(s.match(/^#\srvmpow$/))
         
     | 
| 
      
 65 
     | 
    
         
            +
            						puts "\tNo rvmpow entry found, continuing ..."
         
     | 
| 
      
 66 
     | 
    
         
            +
            					else
         
     | 
| 
      
 67 
     | 
    
         
            +
            						removeFromFile(RvmPow::GEMFILE, RvmPow::GEMFILE_MATCHER)
         
     | 
| 
      
 68 
     | 
    
         
            +
            					end
         
     | 
| 
      
 69 
     | 
    
         
            +
            				end
         
     | 
| 
      
 70 
     | 
    
         
            +
            			end
         
     | 
| 
      
 71 
     | 
    
         
            +
            			fileAction action
         
     | 
| 
      
 72 
     | 
    
         
            +
            		end
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
      
 74 
     | 
    
         
            +
            		# removes .powenv
         
     | 
| 
      
 75 
     | 
    
         
            +
            		def deletePowenvFile
         
     | 
| 
      
 76 
     | 
    
         
            +
            			action = -> { FileUtils.rm_f RvmPow::POW_ENV_FILE }
         
     | 
| 
      
 77 
     | 
    
         
            +
            			fileAction action
         
     | 
| 
      
 78 
     | 
    
         
            +
            		end
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
      
 80 
     | 
    
         
            +
            		# removes restart.txt file from ./tmp/
         
     | 
| 
      
 81 
     | 
    
         
            +
            		def deleteRestartFile
         
     | 
| 
      
 82 
     | 
    
         
            +
            			action = -> { FileUtils.rm_f RvmPow::RESTART_FILE }
         
     | 
| 
      
 83 
     | 
    
         
            +
            			fileAction action
         
     | 
| 
      
 84 
     | 
    
         
            +
            		end
         
     | 
| 
      
 85 
     | 
    
         
            +
             
     | 
| 
      
 86 
     | 
    
         
            +
            		# deletes the link is ~/.pow
         
     | 
| 
      
 87 
     | 
    
         
            +
            		def deletePowLink
         
     | 
| 
      
 88 
     | 
    
         
            +
            			action = -> { FileUtils.rm_f RvmPow::POW_LINK }
         
     | 
| 
      
 89 
     | 
    
         
            +
            			fileAction action
         
     | 
| 
      
 90 
     | 
    
         
            +
            		end
         
     | 
| 
      
 91 
     | 
    
         
            +
             
     | 
| 
      
 92 
     | 
    
         
            +
            		private
         
     | 
| 
      
 93 
     | 
    
         
            +
             
     | 
| 
      
 94 
     | 
    
         
            +
            			# file action wrapper
         
     | 
| 
      
 95 
     | 
    
         
            +
            			def fileAction(action)
         
     | 
| 
      
 96 
     | 
    
         
            +
            				action.call
         
     | 
| 
      
 97 
     | 
    
         
            +
            				true
         
     | 
| 
      
 98 
     | 
    
         
            +
            			rescue Exception => err
         
     | 
| 
      
 99 
     | 
    
         
            +
            				puts err.message
         
     | 
| 
      
 100 
     | 
    
         
            +
            				false
         
     | 
| 
      
 101 
     | 
    
         
            +
            			end
         
     | 
| 
      
 102 
     | 
    
         
            +
             
     | 
| 
      
 103 
     | 
    
         
            +
            			# removes text from file based on regex
         
     | 
| 
      
 104 
     | 
    
         
            +
            			def removeFromFile(file, regex)
         
     | 
| 
      
 105 
     | 
    
         
            +
            				# create tempfile
         
     | 
| 
      
 106 
     | 
    
         
            +
            				tmp = Tempfile.new "foo"
         
     | 
| 
      
 107 
     | 
    
         
            +
             
     | 
| 
      
 108 
     | 
    
         
            +
            				# Read file
         
     | 
| 
      
 109 
     | 
    
         
            +
            				confFile = File.read(file)
         
     | 
| 
      
 110 
     | 
    
         
            +
            				confFile.gsub!(regex, '').chomp!
         
     | 
| 
      
 111 
     | 
    
         
            +
             
     | 
| 
      
 112 
     | 
    
         
            +
            				tmp.write confFile
         
     | 
| 
      
 113 
     | 
    
         
            +
            				tmp.close
         
     | 
| 
      
 114 
     | 
    
         
            +
             
     | 
| 
      
 115 
     | 
    
         
            +
            				FileUtils.mv(tmp.path, file)
         
     | 
| 
      
 116 
     | 
    
         
            +
            				true
         
     | 
| 
      
 117 
     | 
    
         
            +
            			rescue Exception => e
         
     | 
| 
      
 118 
     | 
    
         
            +
            				puts e.message
         
     | 
| 
      
 119 
     | 
    
         
            +
            				false
         
     | 
| 
      
 120 
     | 
    
         
            +
            			end
         
     | 
| 
      
 121 
     | 
    
         
            +
             
     | 
| 
      
 122 
     | 
    
         
            +
            			# returns a hash with the ruby and gemset information
         
     | 
| 
      
 123 
     | 
    
         
            +
            			# @return [Hash]
         
     | 
| 
      
 124 
     | 
    
         
            +
            			def rvmInfo
         
     | 
| 
      
 125 
     | 
    
         
            +
            				rvm = {}
         
     | 
| 
      
 126 
     | 
    
         
            +
            				rvmArray = `rvm-prompt`.chomp.split('@')
         
     | 
| 
      
 127 
     | 
    
         
            +
            				rvm[:ruby] = rvmArray[0].split('-')[1]
         
     | 
| 
      
 128 
     | 
    
         
            +
            				rvm[:gemset] = rvmArray[1]
         
     | 
| 
      
 129 
     | 
    
         
            +
            				rvm
         
     | 
| 
      
 130 
     | 
    
         
            +
            			end
         
     | 
| 
      
 131 
     | 
    
         
            +
            	end
         
     | 
| 
      
 132 
     | 
    
         
            +
             
     | 
| 
      
 133 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,49 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module RvmPow
         
     | 
| 
      
 2 
     | 
    
         
            +
            	POW_PATH = File.expand_path("~/.pow")
         
     | 
| 
      
 3 
     | 
    
         
            +
              RAKE_APP_DIRECTORY = File.expand_path('.')
         
     | 
| 
      
 4 
     | 
    
         
            +
              POW_ENV_FILE = "#{RAKE_APP_DIRECTORY}/.powenv"
         
     | 
| 
      
 5 
     | 
    
         
            +
              RESTART_FILE = "#{RAKE_APP_DIRECTORY}/tmp/restart.txt"
         
     | 
| 
      
 6 
     | 
    
         
            +
              APP_NAME = RAKE_APP_DIRECTORY.split('/').last
         
     | 
| 
      
 7 
     | 
    
         
            +
              POW_LINK = "#{POW_PATH}/#{APP_NAME}"
         
     | 
| 
      
 8 
     | 
    
         
            +
              GITIGNORE_FILE = "#{RAKE_APP_DIRECTORY}/.gitignore"
         
     | 
| 
      
 9 
     | 
    
         
            +
              GITIGNORE_ENTRY = "\n# rvmpow\n.powenv"
         
     | 
| 
      
 10 
     | 
    
         
            +
              GEMFILE = "#{RAKE_APP_DIRECTORY}/Gemfile"
         
     | 
| 
      
 11 
     | 
    
         
            +
              RVM_BINARY = "#{File.expand_path('~/')}/.rvm/bin/rvm"
         
     | 
| 
      
 12 
     | 
    
         
            +
              CONFIG_RU = "#{RvmPow::RAKE_APP_DIRECTORY}/config.ru"
         
     | 
| 
      
 13 
     | 
    
         
            +
              GEMFILE_MATCHER = /.#\srvmpow.ruby\s'\d(\.\d)+'.#ruby-gemset=\S+/m
         
     | 
| 
      
 14 
     | 
    
         
            +
              GITIGNORE_MATCHER = /.#\srvmpow.\.powenv/m
         
     | 
| 
      
 15 
     | 
    
         
            +
              ADD_POWENV = "Add .powenv file"
         
     | 
| 
      
 16 
     | 
    
         
            +
              REMOVE_POWENV = "Remove .powenv file"
         
     | 
| 
      
 17 
     | 
    
         
            +
              ADD_LINK = "Add app link in ~/.pow"
         
     | 
| 
      
 18 
     | 
    
         
            +
              REMOVE_LINK = "Remove app link from ~/.pow"
         
     | 
| 
      
 19 
     | 
    
         
            +
              TOUCH_RESTART = "Touch restart.txt file in ./tmp/"
         
     | 
| 
      
 20 
     | 
    
         
            +
              REMOVE_RESTART = "Remove restart.txt file from ./tmp/"
         
     | 
| 
      
 21 
     | 
    
         
            +
              ADD_GITIGNORE = "Add '.powenv' to ./.gitignore"
         
     | 
| 
      
 22 
     | 
    
         
            +
              REMOVE_GITIGNORE = "Remove .powenv from ./.gitignore"
         
     | 
| 
      
 23 
     | 
    
         
            +
              ADD_GEMFILE = "Add rvm ruby and gemset information to ./Gemfile"
         
     | 
| 
      
 24 
     | 
    
         
            +
              REMOVE_GEMFILE = "Remove rvm and gemset information from ./Gemfile"
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
            	POWENV = <<-EOF
         
     | 
| 
      
 27 
     | 
    
         
            +
            # detect `$rvm_path`
         
     | 
| 
      
 28 
     | 
    
         
            +
            if [ -z "${rvm_path:-}" ] && [ -x "${HOME:-}/.rvm/bin/rvm" ]
         
     | 
| 
      
 29 
     | 
    
         
            +
            then rvm_path="${HOME:-}/.rvm"
         
     | 
| 
      
 30 
     | 
    
         
            +
            fi
         
     | 
| 
      
 31 
     | 
    
         
            +
            if [ -z "${rvm_path:-}" ] && [ -x "/usr/local/rvm/bin/rvm" ]
         
     | 
| 
      
 32 
     | 
    
         
            +
            then rvm_path="/usr/local/rvm"
         
     | 
| 
      
 33 
     | 
    
         
            +
            fi
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
            # load environment of current project ruby
         
     | 
| 
      
 36 
     | 
    
         
            +
            if
         
     | 
| 
      
 37 
     | 
    
         
            +
              [ -n "${rvm_path:-}" ] &&
         
     | 
| 
      
 38 
     | 
    
         
            +
              [ -x "${rvm_path:-}/bin/rvm" ] &&
         
     | 
| 
      
 39 
     | 
    
         
            +
              rvm_project_environment=`"${rvm_path:-}/bin/rvm" . do rvm env --path 2>/dev/null` &&
         
     | 
| 
      
 40 
     | 
    
         
            +
              [ -n "${rvm_project_environment:-}" ] &&
         
     | 
| 
      
 41 
     | 
    
         
            +
              [ -s "${rvm_project_environment:-}" ]
         
     | 
| 
      
 42 
     | 
    
         
            +
            then
         
     | 
| 
      
 43 
     | 
    
         
            +
              echo "RVM loading: ${rvm_project_environment:-}"
         
     | 
| 
      
 44 
     | 
    
         
            +
              \. "${rvm_project_environment:-}"
         
     | 
| 
      
 45 
     | 
    
         
            +
            else
         
     | 
| 
      
 46 
     | 
    
         
            +
              echo "RVM project not found at: $PWD"
         
     | 
| 
      
 47 
     | 
    
         
            +
            fi
         
     | 
| 
      
 48 
     | 
    
         
            +
            	EOF
         
     | 
| 
      
 49 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,32 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # constants loaded in rvmpow.rb
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module Shared
         
     | 
| 
      
 4 
     | 
    
         
            +
            	private
         
     | 
| 
      
 5 
     | 
    
         
            +
            		# @return [Boolean]
         
     | 
| 
      
 6 
     | 
    
         
            +
            		# 	true if config.ru exists
         
     | 
| 
      
 7 
     | 
    
         
            +
            		def rakeApp?
         
     | 
| 
      
 8 
     | 
    
         
            +
            			File.exists?(RvmPow::CONFIG_RU)
         
     | 
| 
      
 9 
     | 
    
         
            +
            		end
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            		# return [Boolean]
         
     | 
| 
      
 12 
     | 
    
         
            +
            		# 	true if the rvm binary exists
         
     | 
| 
      
 13 
     | 
    
         
            +
            		def rvm?
         
     | 
| 
      
 14 
     | 
    
         
            +
            			File.exists?(RvmPow::RVM_BINARY)
         
     | 
| 
      
 15 
     | 
    
         
            +
            		end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            		# return [Boolean]
         
     | 
| 
      
 18 
     | 
    
         
            +
            		# 	true if Rack app and rvm binary exists
         
     | 
| 
      
 19 
     | 
    
         
            +
            		def rakeAppAndRvm
         
     | 
| 
      
 20 
     | 
    
         
            +
            			(rakeApp? && rvm?)
         
     | 
| 
      
 21 
     | 
    
         
            +
            		end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
            		# Executes given proc if Rack app and rvm binary exists
         
     | 
| 
      
 24 
     | 
    
         
            +
            		def exec_cmd
         
     | 
| 
      
 25 
     | 
    
         
            +
            			if ! rakeAppAndRvm
         
     | 
| 
      
 26 
     | 
    
         
            +
            				error "The current directory does not seem to be the root of a rake app or rvm is not installed. Nothing to do!"
         
     | 
| 
      
 27 
     | 
    
         
            +
            				exit 0
         
     | 
| 
      
 28 
     | 
    
         
            +
            			else
         
     | 
| 
      
 29 
     | 
    
         
            +
            				yield
         
     | 
| 
      
 30 
     | 
    
         
            +
            			end
         
     | 
| 
      
 31 
     | 
    
         
            +
            		end
         
     | 
| 
      
 32 
     | 
    
         
            +
            end
         
     | 
    
        data/rvmpow.gemspec
    ADDED
    
    | 
         @@ -0,0 +1,27 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # coding: utf-8
         
     | 
| 
      
 2 
     | 
    
         
            +
            lib = File.expand_path('../lib', __FILE__)
         
     | 
| 
      
 3 
     | 
    
         
            +
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'rvmpow/version'
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            Gem::Specification.new do |spec|
         
     | 
| 
      
 7 
     | 
    
         
            +
              spec.name          = "rvmpow"
         
     | 
| 
      
 8 
     | 
    
         
            +
              spec.version       = RvmPow::VERSION
         
     | 
| 
      
 9 
     | 
    
         
            +
              spec.authors       = ["Olivier Robert"]
         
     | 
| 
      
 10 
     | 
    
         
            +
              spec.email         = ["robby57@gmail.com"]
         
     | 
| 
      
 11 
     | 
    
         
            +
              spec.summary       = ["Sets up pow (http://pow.cx/) for your rake app"]
         
     | 
| 
      
 12 
     | 
    
         
            +
              spec.description   = ["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 
     | 
    
         
            +
            "]
         
     | 
| 
      
 14 
     | 
    
         
            +
              spec.homepage      = "https://github.com/olibob/rvmpow"
         
     | 
| 
      
 15 
     | 
    
         
            +
              spec.license       = "MIT"
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
              spec.files         = `git ls-files -z`.split("\x0")
         
     | 
| 
      
 18 
     | 
    
         
            +
              spec.executables   = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
         
     | 
| 
      
 19 
     | 
    
         
            +
              spec.test_files    = spec.files.grep(%r{^(test|spec|features)/})
         
     | 
| 
      
 20 
     | 
    
         
            +
              spec.require_paths = ["lib"]
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
              spec.add_dependency "thor", "~> 0.19.1"
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
              spec.add_development_dependency "bundler", "~> 1.5"
         
     | 
| 
      
 25 
     | 
    
         
            +
              spec.add_development_dependency "rake"
         
     | 
| 
      
 26 
     | 
    
         
            +
              spec.add_development_dependency "rspec", "~> 2.14.1"
         
     | 
| 
      
 27 
     | 
    
         
            +
            end
         
     | 
    
        data/spec/spec_helper.rb
    ADDED
    
    | 
         @@ -0,0 +1,17 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # This file was generated by the `rspec --init` command. Conventionally, all
         
     | 
| 
      
 2 
     | 
    
         
            +
            # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
         
     | 
| 
      
 3 
     | 
    
         
            +
            # Require this file using `require "spec_helper"` to ensure that it is only
         
     | 
| 
      
 4 
     | 
    
         
            +
            # loaded once.
         
     | 
| 
      
 5 
     | 
    
         
            +
            #
         
     | 
| 
      
 6 
     | 
    
         
            +
            # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
         
     | 
| 
      
 7 
     | 
    
         
            +
            RSpec.configure do |config|
         
     | 
| 
      
 8 
     | 
    
         
            +
              config.treat_symbols_as_metadata_keys_with_true_values = true
         
     | 
| 
      
 9 
     | 
    
         
            +
              config.run_all_when_everything_filtered = true
         
     | 
| 
      
 10 
     | 
    
         
            +
              config.filter_run :focus
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
              # Run specs in random order to surface order dependencies. If you find an
         
     | 
| 
      
 13 
     | 
    
         
            +
              # order dependency and want to debug it, you can fix the order by providing
         
     | 
| 
      
 14 
     | 
    
         
            +
              # the seed, which is printed after each run.
         
     | 
| 
      
 15 
     | 
    
         
            +
              #     --seed 1234
         
     | 
| 
      
 16 
     | 
    
         
            +
              config.order = 'random'
         
     | 
| 
      
 17 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,122 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: rvmpow
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.1
         
     | 
| 
      
 5 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 6 
     | 
    
         
            +
            authors:
         
     | 
| 
      
 7 
     | 
    
         
            +
            - Olivier Robert
         
     | 
| 
      
 8 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 9 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 10 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2014-05-04 00:00:00.000000000 Z
         
     | 
| 
      
 12 
     | 
    
         
            +
            dependencies:
         
     | 
| 
      
 13 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 14 
     | 
    
         
            +
              name: thor
         
     | 
| 
      
 15 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 16 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 17 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 18 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 19 
     | 
    
         
            +
                    version: 0.19.1
         
     | 
| 
      
 20 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 21 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 22 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 23 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 24 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 25 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 26 
     | 
    
         
            +
                    version: 0.19.1
         
     | 
| 
      
 27 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 28 
     | 
    
         
            +
              name: bundler
         
     | 
| 
      
 29 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 30 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 31 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 32 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 33 
     | 
    
         
            +
                    version: '1.5'
         
     | 
| 
      
 34 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 35 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 36 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 37 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 38 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 39 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 40 
     | 
    
         
            +
                    version: '1.5'
         
     | 
| 
      
 41 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 42 
     | 
    
         
            +
              name: rake
         
     | 
| 
      
 43 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 44 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 45 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 46 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 47 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 48 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 49 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 50 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 51 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 52 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 53 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 54 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 55 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 56 
     | 
    
         
            +
              name: rspec
         
     | 
| 
      
 57 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 58 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 59 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 60 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 61 
     | 
    
         
            +
                    version: 2.14.1
         
     | 
| 
      
 62 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 63 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 64 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 65 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 66 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 67 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 68 
     | 
    
         
            +
                    version: 2.14.1
         
     | 
| 
      
 69 
     | 
    
         
            +
            description: '["Pow (http://pow.cx) needs to know what ruby and gemset is being used.
         
     | 
| 
      
 70 
     | 
    
         
            +
              rvm users can provide this information manually (http://rvm.io/integration/pow)
         
     | 
| 
      
 71 
     | 
    
         
            +
              or install `rvmpow` and it''ll handle it for you, including adding the new configuration
         
     | 
| 
      
 72 
     | 
    
         
            +
              file to .gitignore and linking the new app for immediate browsing.\n"]'
         
     | 
| 
      
 73 
     | 
    
         
            +
            email:
         
     | 
| 
      
 74 
     | 
    
         
            +
            - robby57@gmail.com
         
     | 
| 
      
 75 
     | 
    
         
            +
            executables:
         
     | 
| 
      
 76 
     | 
    
         
            +
            - rvmpow
         
     | 
| 
      
 77 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 78 
     | 
    
         
            +
            extra_rdoc_files: []
         
     | 
| 
      
 79 
     | 
    
         
            +
            files:
         
     | 
| 
      
 80 
     | 
    
         
            +
            - ".gitignore"
         
     | 
| 
      
 81 
     | 
    
         
            +
            - ".rspec"
         
     | 
| 
      
 82 
     | 
    
         
            +
            - ".ruby-gemset"
         
     | 
| 
      
 83 
     | 
    
         
            +
            - ".ruby-version"
         
     | 
| 
      
 84 
     | 
    
         
            +
            - Gemfile
         
     | 
| 
      
 85 
     | 
    
         
            +
            - LICENSE.txt
         
     | 
| 
      
 86 
     | 
    
         
            +
            - README.md
         
     | 
| 
      
 87 
     | 
    
         
            +
            - Rakefile
         
     | 
| 
      
 88 
     | 
    
         
            +
            - bin/rvmpow
         
     | 
| 
      
 89 
     | 
    
         
            +
            - lib/rvmpow.rb
         
     | 
| 
      
 90 
     | 
    
         
            +
            - lib/rvmpow/constants.rb
         
     | 
| 
      
 91 
     | 
    
         
            +
            - lib/rvmpow/shared_private_methods.rb
         
     | 
| 
      
 92 
     | 
    
         
            +
            - lib/rvmpow/version.rb
         
     | 
| 
      
 93 
     | 
    
         
            +
            - rvmpow.gemspec
         
     | 
| 
      
 94 
     | 
    
         
            +
            - spec/lib/rvmpow_spec.rb
         
     | 
| 
      
 95 
     | 
    
         
            +
            - spec/spec_helper.rb
         
     | 
| 
      
 96 
     | 
    
         
            +
            homepage: https://github.com/olibob/rvmpow
         
     | 
| 
      
 97 
     | 
    
         
            +
            licenses:
         
     | 
| 
      
 98 
     | 
    
         
            +
            - MIT
         
     | 
| 
      
 99 
     | 
    
         
            +
            metadata: {}
         
     | 
| 
      
 100 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 101 
     | 
    
         
            +
            rdoc_options: []
         
     | 
| 
      
 102 
     | 
    
         
            +
            require_paths:
         
     | 
| 
      
 103 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 104 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 105 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 106 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 107 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 108 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 109 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 110 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 111 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 112 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 113 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 114 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 115 
     | 
    
         
            +
            rubyforge_project: 
         
     | 
| 
      
 116 
     | 
    
         
            +
            rubygems_version: 2.2.2
         
     | 
| 
      
 117 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 118 
     | 
    
         
            +
            specification_version: 4
         
     | 
| 
      
 119 
     | 
    
         
            +
            summary: '["Sets up pow (http://pow.cx/) for your rake app"]'
         
     | 
| 
      
 120 
     | 
    
         
            +
            test_files:
         
     | 
| 
      
 121 
     | 
    
         
            +
            - spec/lib/rvmpow_spec.rb
         
     | 
| 
      
 122 
     | 
    
         
            +
            - spec/spec_helper.rb
         
     |