reup 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/.gitignore +1 -0
 - data/bin/reup +31 -0
 - data/lib/reup.rb +0 -31
 - data/lib/reup/env.yaml +24 -0
 - data/lib/reup/helpers.rb +76 -9
 - data/lib/reup/version.rb +1 -1
 - metadata +4 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: ae75d7a51da4c495b7844adecbb13e65175f3882
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 2d2286946aaba47137cd3ff2d57166b4a70017e7
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 955516642a57dfd4cb3d190f5773e74c08a1e289255e343163d92c427904692416f1fa73401f601d9640cec7622bde536a1b0304525234c8262913a4a8735fa7
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 1f3f0f31e269886bf329e9111790221c1958aaafddb2660d8432efddf365388df3b5dc42918c5ab6e6d6971968d578ffd843a3dc954a77e740033187fc516636
         
     | 
    
        data/.gitignore
    CHANGED
    
    
    
        data/bin/reup
    ADDED
    
    | 
         @@ -0,0 +1,31 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            #!/usr/bin/ruby
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require "slop"
         
     | 
| 
      
 4 
     | 
    
         
            +
            require "cocaine"
         
     | 
| 
      
 5 
     | 
    
         
            +
            require "byebug"
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            require_relative "../lib/reup/version"
         
     | 
| 
      
 8 
     | 
    
         
            +
            require_relative "../lib/reup/helpers"
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            include Reup::Helpers
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            options = Slop.parse do |option|
         
     | 
| 
      
 13 
     | 
    
         
            +
              option.bool   "-r", "--resetdb", "resets the database"
         
     | 
| 
      
 14 
     | 
    
         
            +
              option.string "-b", "--branch",  "checkout branch"
         
     | 
| 
      
 15 
     | 
    
         
            +
              option.on     "-v", "--version", "print the version" do
         
     | 
| 
      
 16 
     | 
    
         
            +
                puts Reup::VERSION
         
     | 
| 
      
 17 
     | 
    
         
            +
                exit
         
     | 
| 
      
 18 
     | 
    
         
            +
              end
         
     | 
| 
      
 19 
     | 
    
         
            +
            end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
            wasChange = detect_change_to(watch_files) do
         
     | 
| 
      
 22 
     | 
    
         
            +
              run "git checkout #{options[:branch]}", quiet: true if options.branch?
         
     | 
| 
      
 23 
     | 
    
         
            +
              run "git pull"
         
     | 
| 
      
 24 
     | 
    
         
            +
            end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
            install if wasChange
         
     | 
| 
      
 27 
     | 
    
         
            +
            reset_db if options.resetdb?
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
            serve
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
    
        data/lib/reup.rb
    CHANGED
    
    | 
         @@ -1,31 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require "slop"
         
     | 
| 
       2 
     | 
    
         
            -
            require "cocaine"
         
     | 
| 
       3 
     | 
    
         
            -
            require "byebug"
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
            require_relative "reup/version"
         
     | 
| 
       6 
     | 
    
         
            -
            require_relative "reup/helpers"
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
            include Reup::Helpers
         
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
            options = Slop.parse do |option|
         
     | 
| 
       11 
     | 
    
         
            -
              option.bool   "-r", "--resetdb", "resets the database"
         
     | 
| 
       12 
     | 
    
         
            -
              option.string "-b", "--branch",  "checkout branch"
         
     | 
| 
       13 
     | 
    
         
            -
              option.on     "-v", "--version", "print the version" do
         
     | 
| 
       14 
     | 
    
         
            -
                puts Reup::VERSION
         
     | 
| 
       15 
     | 
    
         
            -
                exit
         
     | 
| 
       16 
     | 
    
         
            -
              end
         
     | 
| 
       17 
     | 
    
         
            -
            end
         
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
            run "git checkout #{options[:branch]}", quiet: true if options.branch?
         
     | 
| 
       20 
     | 
    
         
            -
            run "git pull"
         
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
            case env
         
     | 
| 
       23 
     | 
    
         
            -
            when :rails
         
     | 
| 
       24 
     | 
    
         
            -
              run "bundle"
         
     | 
| 
       25 
     | 
    
         
            -
              run "rake db:migrate:reset" if options.resetdb?
         
     | 
| 
       26 
     | 
    
         
            -
            when :ember
         
     | 
| 
       27 
     | 
    
         
            -
              run "npm install"
         
     | 
| 
       28 
     | 
    
         
            -
            end
         
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
            serve
         
     | 
| 
       31 
     | 
    
         
            -
             
     | 
    
        data/lib/reup/env.yaml
    ADDED
    
    | 
         @@ -0,0 +1,24 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- 
         
     | 
| 
      
 2 
     | 
    
         
            +
            ember: 
         
     | 
| 
      
 3 
     | 
    
         
            +
              indicator_files: 
         
     | 
| 
      
 4 
     | 
    
         
            +
                - ember-cli-build.js
         
     | 
| 
      
 5 
     | 
    
         
            +
              serve:
         
     | 
| 
      
 6 
     | 
    
         
            +
                command: "ember server"
         
     | 
| 
      
 7 
     | 
    
         
            +
              install: 
         
     | 
| 
      
 8 
     | 
    
         
            +
                command: "npm install"
         
     | 
| 
      
 9 
     | 
    
         
            +
                only_if_changed: 
         
     | 
| 
      
 10 
     | 
    
         
            +
                  - bower.json
         
     | 
| 
      
 11 
     | 
    
         
            +
                  - package.json
         
     | 
| 
      
 12 
     | 
    
         
            +
                  - ember-cli-build.js
         
     | 
| 
      
 13 
     | 
    
         
            +
            rails: 
         
     | 
| 
      
 14 
     | 
    
         
            +
              indicator_files: 
         
     | 
| 
      
 15 
     | 
    
         
            +
                - Gemfile
         
     | 
| 
      
 16 
     | 
    
         
            +
              serve:
         
     | 
| 
      
 17 
     | 
    
         
            +
                command: "bundle exec foreman start"
         
     | 
| 
      
 18 
     | 
    
         
            +
              install: 
         
     | 
| 
      
 19 
     | 
    
         
            +
                command: bundle
         
     | 
| 
      
 20 
     | 
    
         
            +
                only_if_changed: 
         
     | 
| 
      
 21 
     | 
    
         
            +
                  - Gemfile
         
     | 
| 
      
 22 
     | 
    
         
            +
              db:
         
     | 
| 
      
 23 
     | 
    
         
            +
                reset_command: "bundle exec rake db:migrate:reset"
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
    
        data/lib/reup/helpers.rb
    CHANGED
    
    | 
         @@ -1,6 +1,16 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require "yaml"
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       1 
3 
     | 
    
         
             
            module Reup
         
     | 
| 
       2 
4 
     | 
    
         
             
              module Helpers
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
                ENV_FILE = File.expand_path "../env.yaml", __FILE__
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                ###########################################################################
         
     | 
| 
      
 9 
     | 
    
         
            +
                # Executable helpers
         
     | 
| 
      
 10 
     | 
    
         
            +
                ###########################################################################
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
       3 
12 
     | 
    
         
             
                def run(command, quiet: false, print_command: true, replace_process: false)
         
     | 
| 
      
 13 
     | 
    
         
            +
                  return unless command
         
     | 
| 
       4 
14 
     | 
    
         
             
                  puts command if print_command
         
     | 
| 
       5 
15 
     | 
    
         
             
                  command += " &>/dev/null" if quiet
         
     | 
| 
       6 
16 
     | 
    
         | 
| 
         @@ -15,29 +25,86 @@ module Reup 
     | 
|
| 
       15 
25 
     | 
    
         
             
                  cmd = Cocaine::CommandLine.new(command)
         
     | 
| 
       16 
26 
     | 
    
         
             
                  result = cmd.run
         
     | 
| 
       17 
27 
     | 
    
         
             
                  puts result unless quiet
         
     | 
| 
      
 28 
     | 
    
         
            +
                  result
         
     | 
| 
       18 
29 
     | 
    
         
             
                end
         
     | 
| 
       19 
30 
     | 
    
         | 
| 
       20 
31 
     | 
    
         
             
                def kernel_run(command)
         
     | 
| 
       21 
32 
     | 
    
         
             
                  Kernel.exec command
         
     | 
| 
       22 
33 
     | 
    
         
             
                end
         
     | 
| 
       23 
34 
     | 
    
         | 
| 
       24 
     | 
    
         
            -
                def  
     | 
| 
       25 
     | 
    
         
            -
                   
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
      
 35 
     | 
    
         
            +
                def detect_change_to(files, &block)
         
     | 
| 
      
 36 
     | 
    
         
            +
                  before = files.map { |f| last_modified(f) }
         
     | 
| 
      
 37 
     | 
    
         
            +
                  yield
         
     | 
| 
      
 38 
     | 
    
         
            +
                  after  = files.map { |f| last_modified(f) }
         
     | 
| 
      
 39 
     | 
    
         
            +
                  before != after # Not equal means there was a change
         
     | 
| 
      
 40 
     | 
    
         
            +
                end
         
     | 
| 
       30 
41 
     | 
    
         | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
      
 42 
     | 
    
         
            +
                ###########################################################################
         
     | 
| 
      
 43 
     | 
    
         
            +
                # Environment helpers
         
     | 
| 
      
 44 
     | 
    
         
            +
                ###########################################################################
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
                def last_modified(file)
         
     | 
| 
      
 47 
     | 
    
         
            +
                  File.mtime file
         
     | 
| 
      
 48 
     | 
    
         
            +
                end
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
                def env_file
         
     | 
| 
      
 51 
     | 
    
         
            +
                  @env_file ||= YAML.load_file ENV_FILE
         
     | 
| 
      
 52 
     | 
    
         
            +
                end
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
                def watch_files
         
     | 
| 
      
 55 
     | 
    
         
            +
                  @watch_files ||= Array(env_file[env]["install"]["only_if_changed"])
         
     | 
| 
      
 56 
     | 
    
         
            +
                end
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
                def install_command
         
     | 
| 
      
 59 
     | 
    
         
            +
                  @install_command ||= env_file[env]["install"]["command"]
         
     | 
| 
      
 60 
     | 
    
         
            +
                end
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
                def serve_command
         
     | 
| 
      
 63 
     | 
    
         
            +
                  @serve_command ||= env_file[env]["serve"]["command"]
         
     | 
| 
      
 64 
     | 
    
         
            +
                end
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
                def reset_db_command
         
     | 
| 
      
 67 
     | 
    
         
            +
                  @reset_db_command ||= (
         
     | 
| 
      
 68 
     | 
    
         
            +
                    db_section = env_file[env]["db"]
         
     | 
| 
      
 69 
     | 
    
         
            +
                    if db_section
         
     | 
| 
      
 70 
     | 
    
         
            +
                      db_section["reset_command"]
         
     | 
| 
      
 71 
     | 
    
         
            +
                    else
         
     | 
| 
      
 72 
     | 
    
         
            +
                      nil
         
     | 
| 
      
 73 
     | 
    
         
            +
                    end
         
     | 
| 
      
 74 
     | 
    
         
            +
                  )
         
     | 
| 
       32 
75 
     | 
    
         
             
                end
         
     | 
| 
       33 
76 
     | 
    
         | 
| 
       34 
77 
     | 
    
         
             
                def env
         
     | 
| 
       35 
78 
     | 
    
         
             
                  @env ||= (
         
     | 
| 
       36 
     | 
    
         
            -
                     
     | 
| 
       37 
     | 
    
         
            -
                    env =  
     | 
| 
      
 79 
     | 
    
         
            +
                    possible_envs = env_file.keys
         
     | 
| 
      
 80 
     | 
    
         
            +
                    env = nil
         
     | 
| 
      
 81 
     | 
    
         
            +
                    possible_envs.each do |possible|
         
     | 
| 
      
 82 
     | 
    
         
            +
                      indicator_files = Array(env_file[possible]["indicator_files"])
         
     | 
| 
      
 83 
     | 
    
         
            +
                      if indicator_files.any? { |f| File.exist? f }
         
     | 
| 
      
 84 
     | 
    
         
            +
                        env = possible
         
     | 
| 
      
 85 
     | 
    
         
            +
                        break
         
     | 
| 
      
 86 
     | 
    
         
            +
                      end
         
     | 
| 
      
 87 
     | 
    
         
            +
                    end
         
     | 
| 
      
 88 
     | 
    
         
            +
                    raise "You don't appear to be in a supported environment" unless env
         
     | 
| 
       38 
89 
     | 
    
         
             
                    env
         
     | 
| 
       39 
90 
     | 
    
         
             
                  )
         
     | 
| 
       40 
91 
     | 
    
         
             
                end
         
     | 
| 
       41 
92 
     | 
    
         | 
| 
      
 93 
     | 
    
         
            +
                ###########################################################################
         
     | 
| 
      
 94 
     | 
    
         
            +
                # API methods
         
     | 
| 
      
 95 
     | 
    
         
            +
                ###########################################################################
         
     | 
| 
      
 96 
     | 
    
         
            +
             
     | 
| 
      
 97 
     | 
    
         
            +
                def install(args = {})
         
     | 
| 
      
 98 
     | 
    
         
            +
                  run install_command, args
         
     | 
| 
      
 99 
     | 
    
         
            +
                end
         
     | 
| 
      
 100 
     | 
    
         
            +
             
     | 
| 
      
 101 
     | 
    
         
            +
                def reset_db(args = {})
         
     | 
| 
      
 102 
     | 
    
         
            +
                  run reset_db_command, args
         
     | 
| 
      
 103 
     | 
    
         
            +
                end
         
     | 
| 
      
 104 
     | 
    
         
            +
             
     | 
| 
      
 105 
     | 
    
         
            +
                def serve
         
     | 
| 
      
 106 
     | 
    
         
            +
                  run(serve_command, replace_process: true)
         
     | 
| 
      
 107 
     | 
    
         
            +
                end
         
     | 
| 
      
 108 
     | 
    
         
            +
             
     | 
| 
       42 
109 
     | 
    
         
             
              end
         
     | 
| 
       43 
110 
     | 
    
         
             
            end
         
     | 
    
        data/lib/reup/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: reup
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.2.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Justin Toniazzo
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: exe
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2015-09- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2015-09-09 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: cocaine
         
     | 
| 
         @@ -109,8 +109,10 @@ files: 
     | 
|
| 
       109 
109 
     | 
    
         
             
            - README.md
         
     | 
| 
       110 
110 
     | 
    
         
             
            - Rakefile
         
     | 
| 
       111 
111 
     | 
    
         
             
            - bin/console
         
     | 
| 
      
 112 
     | 
    
         
            +
            - bin/reup
         
     | 
| 
       112 
113 
     | 
    
         
             
            - bin/setup
         
     | 
| 
       113 
114 
     | 
    
         
             
            - lib/reup.rb
         
     | 
| 
      
 115 
     | 
    
         
            +
            - lib/reup/env.yaml
         
     | 
| 
       114 
116 
     | 
    
         
             
            - lib/reup/helpers.rb
         
     | 
| 
       115 
117 
     | 
    
         
             
            - lib/reup/version.rb
         
     | 
| 
       116 
118 
     | 
    
         
             
            - reup.gemspec
         
     |