ec2_name 0.1.0 → 0.1.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.
- data/Gemfile +1 -1
 - data/LICENSE +1 -1
 - data/README.md +2 -2
 - data/Rakefile +1 -27
 - data/ec2_name.gemspec +2 -2
 - data/lib/ec2_name.rb +7 -4
 - metadata +4 -8
 - data/spec/ec2_name_spec.rb +0 -4
 - data/spec/spec_helper.rb +0 -8
 
    
        data/Gemfile
    CHANGED
    
    
    
        data/LICENSE
    CHANGED
    
    | 
         @@ -15,4 +15,4 @@ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 
     | 
|
| 
       15 
15 
     | 
    
         
             
            FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 
         
     | 
| 
       16 
16 
     | 
    
         
             
            COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 
         
     | 
| 
       17 
17 
     | 
    
         
             
            IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 
         
     | 
| 
       18 
     | 
    
         
            -
            CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         
     | 
| 
      
 18 
     | 
    
         
            +
            CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -15,8 +15,8 @@ Set up a ~/.br-cloud.yml that holds the aws credentials.  File should look like 
     | 
|
| 
       15 
15 
     | 
    
         
             
            <pre>
         
     | 
| 
       16 
16 
     | 
    
         
             
            $ cat ~/.br-cloud.yml
         
     | 
| 
       17 
17 
     | 
    
         
             
            --- 
         
     | 
| 
       18 
     | 
    
         
            -
            : 
     | 
| 
       19 
     | 
    
         
            -
            : 
     | 
| 
      
 18 
     | 
    
         
            +
            :aws_access_key_id: XXXX
         
     | 
| 
      
 19 
     | 
    
         
            +
            :aws_secret_access_key: XXXXXXXXXXXXXXXXXXXX
         
     | 
| 
       20 
20 
     | 
    
         
             
            $ 
         
     | 
| 
       21 
21 
     | 
    
         
             
            </pre>
         
     | 
| 
       22 
22 
     | 
    
         | 
    
        data/Rakefile
    CHANGED
    
    | 
         @@ -1,27 +1 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require 'bundler/gem_tasks'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            # DELETE AFTER USING
         
     | 
| 
       4 
     | 
    
         
            -
            desc "Rename project"
         
     | 
| 
       5 
     | 
    
         
            -
            task :rename do
         
     | 
| 
       6 
     | 
    
         
            -
              name = ENV['NAME'] || File.basename(Dir.pwd)
         
     | 
| 
       7 
     | 
    
         
            -
              camelize = lambda do |str|
         
     | 
| 
       8 
     | 
    
         
            -
                str.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
         
     | 
| 
       9 
     | 
    
         
            -
              end
         
     | 
| 
       10 
     | 
    
         
            -
              dir = Dir['**/ec2_name*']
         
     | 
| 
       11 
     | 
    
         
            -
              begin
         
     | 
| 
       12 
     | 
    
         
            -
                from = dir.pop
         
     | 
| 
       13 
     | 
    
         
            -
                if from
         
     | 
| 
       14 
     | 
    
         
            -
                  to = from.split('/')
         
     | 
| 
       15 
     | 
    
         
            -
                  to[-1].gsub!('ec2_name', name)
         
     | 
| 
       16 
     | 
    
         
            -
                  FileUtils.mv(from, to.join('/'))
         
     | 
| 
       17 
     | 
    
         
            -
                end
         
     | 
| 
       18 
     | 
    
         
            -
              end while dir.length > 0
         
     | 
| 
       19 
     | 
    
         
            -
              Dir["**/*"].each do |path|
         
     | 
| 
       20 
     | 
    
         
            -
                if File.file?(path)
         
     | 
| 
       21 
     | 
    
         
            -
                  `sed -i '' 's/ec2_name/#{name}/g' #{path}`
         
     | 
| 
       22 
     | 
    
         
            -
                  `sed -i '' 's/Ec2Name/#{camelize.call(name)}/g' #{path}`
         
     | 
| 
       23 
     | 
    
         
            -
                  no_space = File.read(path).gsub(/\s+\z/, '')
         
     | 
| 
       24 
     | 
    
         
            -
                  File.open(path, 'w') { |f| f.write(no_space) }
         
     | 
| 
       25 
     | 
    
         
            -
                end
         
     | 
| 
       26 
     | 
    
         
            -
              end
         
     | 
| 
       27 
     | 
    
         
            -
            end
         
     | 
| 
      
 1 
     | 
    
         
            +
            require 'bundler/gem_tasks'
         
     | 
    
        data/ec2_name.gemspec
    CHANGED
    
    | 
         @@ -6,7 +6,7 @@ $:.unshift lib unless $:.include?(lib) 
     | 
|
| 
       6 
6 
     | 
    
         | 
| 
       7 
7 
     | 
    
         
             
            Gem::Specification.new do |s|
         
     | 
| 
       8 
8 
     | 
    
         
             
              s.name        = "ec2_name"
         
     | 
| 
       9 
     | 
    
         
            -
              s.version     = '0.1. 
     | 
| 
      
 9 
     | 
    
         
            +
              s.version     = '0.1.1'
         
     | 
| 
       10 
10 
     | 
    
         
             
              s.platform    = Gem::Platform::RUBY
         
     | 
| 
       11 
11 
     | 
    
         
             
              s.authors     = ["Tung Nguyen"]
         
     | 
| 
       12 
12 
     | 
    
         
             
              s.email       = ["tongueroo@gmail.com"]
         
     | 
| 
         @@ -19,7 +19,7 @@ Gem::Specification.new do |s| 
     | 
|
| 
       19 
19 
     | 
    
         
             
              s.require_paths = %w(lib)
         
     | 
| 
       20 
20 
     | 
    
         
             
              s.test_files = `cd #{root} && git ls-files -- {features,test,spec}/*`.split("\n")
         
     | 
| 
       21 
21 
     | 
    
         | 
| 
       22 
     | 
    
         
            -
              s.add_dependency " 
     | 
| 
      
 22 
     | 
    
         
            +
              s.add_dependency "aws"
         
     | 
| 
       23 
23 
     | 
    
         | 
| 
       24 
24 
     | 
    
         
             
              s.add_development_dependency "rspec", "~> 1.0"
         
     | 
| 
       25 
25 
     | 
    
         
             
            end
         
     | 
    
        data/lib/ec2_name.rb
    CHANGED
    
    | 
         @@ -1,6 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            $:.unshift File.dirname(__FILE__)
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            require ' 
     | 
| 
      
 3 
     | 
    
         
            +
            require 'aws'
         
     | 
| 
       4 
4 
     | 
    
         
             
            require 'yaml'
         
     | 
| 
       5 
5 
     | 
    
         | 
| 
       6 
6 
     | 
    
         
             
            class Ec2Name
         
     | 
| 
         @@ -10,12 +10,15 @@ class Ec2Name 
     | 
|
| 
       10 
10 
     | 
    
         
             
                  fail("ERROR: Need to supply a name.  Usage: #{__FILE__} [name]")
         
     | 
| 
       11 
11 
     | 
    
         
             
                end
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
     | 
    
         
            -
                 
     | 
| 
       14 
     | 
    
         
            -
                @ec2 =  
     | 
| 
      
 13 
     | 
    
         
            +
                config = YAML.load(IO.read("#{ENV['HOME']}/.br-cloud.yml"))
         
     | 
| 
      
 14 
     | 
    
         
            +
                @ec2 = Aws::Ec2.new(
         
     | 
| 
      
 15 
     | 
    
         
            +
                  config[:aws_access_key_id],
         
     | 
| 
      
 16 
     | 
    
         
            +
                  config[:aws_secret_access_key]
         
     | 
| 
      
 17 
     | 
    
         
            +
                )
         
     | 
| 
       15 
18 
     | 
    
         | 
| 
       16 
19 
     | 
    
         
             
                instance_id = ENV['INSTANCE_ID'] || `curl -s http://169.254.169.254/latest/meta-data/instance-id`
         
     | 
| 
       17 
20 
     | 
    
         
             
                puts "Creating tag Name #{@name} for instance #{instance_id}"
         
     | 
| 
       18 
     | 
    
         
            -
                @ec2. 
     | 
| 
      
 21 
     | 
    
         
            +
                @ec2.create_tag(instance_id, 'Name', @name)
         
     | 
| 
       19 
22 
     | 
    
         
             
                puts "Created tag Name #{@name} for instance #{instance_id}"
         
     | 
| 
       20 
23 
     | 
    
         
             
              end
         
     | 
| 
       21 
24 
     | 
    
         
             
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: ec2_name
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.1
         
     | 
| 
       5 
5 
     | 
    
         
             
              prerelease: 
         
     | 
| 
       6 
6 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       7 
7 
     | 
    
         
             
            authors:
         
     | 
| 
         @@ -9,10 +9,10 @@ authors: 
     | 
|
| 
       9 
9 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       10 
10 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       11 
11 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       12 
     | 
    
         
            -
            date: 2012-07- 
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2012-07-29 00:00:00.000000000 Z
         
     | 
| 
       13 
13 
     | 
    
         
             
            dependencies:
         
     | 
| 
       14 
14 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       15 
     | 
    
         
            -
              name:  
     | 
| 
      
 15 
     | 
    
         
            +
              name: aws
         
     | 
| 
       16 
16 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       17 
17 
     | 
    
         
             
                none: false
         
     | 
| 
       18 
18 
     | 
    
         
             
                requirements:
         
     | 
| 
         @@ -60,8 +60,6 @@ files: 
     | 
|
| 
       60 
60 
     | 
    
         
             
            - bin/ec2_name
         
     | 
| 
       61 
61 
     | 
    
         
             
            - ec2_name.gemspec
         
     | 
| 
       62 
62 
     | 
    
         
             
            - lib/ec2_name.rb
         
     | 
| 
       63 
     | 
    
         
            -
            - spec/ec2_name_spec.rb
         
     | 
| 
       64 
     | 
    
         
            -
            - spec/spec_helper.rb
         
     | 
| 
       65 
63 
     | 
    
         
             
            homepage: http://github.com/tongueroo/ec2_name
         
     | 
| 
       66 
64 
     | 
    
         
             
            licenses: []
         
     | 
| 
       67 
65 
     | 
    
         
             
            post_install_message: 
         
     | 
| 
         @@ -86,7 +84,5 @@ rubygems_version: 1.8.24 
     | 
|
| 
       86 
84 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       87 
85 
     | 
    
         
             
            specification_version: 3
         
     | 
| 
       88 
86 
     | 
    
         
             
            summary: Quick way to tag the name of the instance so that it shows up on aws console
         
     | 
| 
       89 
     | 
    
         
            -
            test_files:
         
     | 
| 
       90 
     | 
    
         
            -
            - spec/ec2_name_spec.rb
         
     | 
| 
       91 
     | 
    
         
            -
            - spec/spec_helper.rb
         
     | 
| 
      
 87 
     | 
    
         
            +
            test_files: []
         
     | 
| 
       92 
88 
     | 
    
         
             
            has_rdoc: 
         
     | 
    
        data/spec/ec2_name_spec.rb
    DELETED