rappa 0.0.7 → 0.0.8

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/README.md CHANGED
@@ -95,6 +95,12 @@ An example would be to have a thin project which uses Rake and has the following
95
95
 
96
96
  (Recommended that you bundle package instead of putting a bundle install in the bootstrap.sh though)
97
97
 
98
+ ### Troubleshooting
99
+
100
+ If you get an error related to zip/zip or rubyzip try adding this into your Gemfile when using the rappa gem directly
101
+
102
+ gem 'rubyzip', '< 1.0.0'
103
+
98
104
  ### Rap file
99
105
 
100
106
  ./rap.yml
@@ -120,12 +126,14 @@ Once you have your rap.yml in the root of your project you must navigate one lev
120
126
 
121
127
  This packages your application. You need a rap.yml in the root of your project and must be executed from one level up from your application e.g.
122
128
 
123
- rappa package -i path/to/your/app -o path/to/destination
129
+ rappa package -i path/to/your/app -o path/to/destination -e 'file1,folder1'
124
130
 
125
131
  The -i is for input directory and the -o is for output directory e.g.
126
132
 
127
133
  rappa package -i ./myapp -o .
128
134
 
135
+ The -e is to specify files and folders to exclude from the package and it's optional
136
+
129
137
  Will produce a myapp.rap in the current directory. The name of the folder of your application is what will be used in the rap archive.
130
138
 
131
139
  ### expand
data/bin/rappa CHANGED
@@ -49,6 +49,38 @@ elsif Settings.rest.include?('expand')
49
49
  exit 1
50
50
  end
51
51
  end
52
+ elsif Settings.rest.include?('standalone_package')
53
+ if Settings[:input_directory].nil?
54
+ puts '[ERROR] You must supply an input directory for package with -i e.g. rappa standalone_package -i /path/to/project'
55
+ exit 1
56
+ elsif Settings[:output_directory].nil?
57
+ puts '[ERROR] You must supply an output directory for package with -o e.g. rappa standalone_package -o /path/to/output/location'
58
+ exit 1
59
+ else
60
+ begin
61
+ Rappa.new(Settings).standalone_package
62
+ puts '[SUCCESS] packaged standalone zip successfully'
63
+ rescue RappaError => e
64
+ puts "[ERROR] Could not continue package because: #{e}"
65
+ exit 1
66
+ end
67
+ end
68
+ elsif Settings.rest.include?('standalone_expand')
69
+ if Settings[:input_archive].nil?
70
+ puts '[ERROR] You must supply an input .zip archive for standalone_expand with -a e.g. rappa standalone_expand -a /path/to/.zip'
71
+ exit 1
72
+ elsif Settings[:output_archive].nil?
73
+ puts '[ERROR] You must supply an output archive directory for standalone_expand with -d e.g. rappa standalone_expand -d /path/to/output/location'
74
+ exit 1
75
+ else
76
+ begin
77
+ Rappa.new(Settings).standalone_expand
78
+ puts '[SUCCESS] expanded standalone zip successfully'
79
+ rescue RappaError => e
80
+ puts "[ERROR] Could not continue expand because: #{e}"
81
+ exit 1
82
+ end
83
+ end
52
84
  elsif Settings.rest.include?('generate')
53
85
  Rappa.new.generate
54
86
  puts '[SUCCESS] generated sample.rap.yml into current directory'
@@ -75,8 +107,8 @@ else
75
107
  info=<<-EOF
76
108
 
77
109
  ---------------------------------------------------------------------------------
78
- Rappa Version: 0.0.7
79
- Released: 17 November 2013
110
+ Rappa Version: 0.0.8
111
+ Released: 19 November 2013
80
112
  ---------------------------------------------------------------------------------
81
113
 
82
114
  Usage:
@@ -114,6 +146,8 @@ Usage:
114
146
 
115
147
  Info:
116
148
 
149
+ To package/expand/deploy a standalone zip archive use standalone_package/standalone_expand/standalone_deploy in place of package,expand and deploy
150
+
117
151
  For more information on how to use rappa please visit:
118
152
  https://github.com/masterthought/rappa
119
153
 
@@ -40,6 +40,12 @@ class PropertyValidator
40
40
  @config[:input_rap]
41
41
  end
42
42
 
43
+ def input_zip
44
+ check_property(@config[:input_zip], :input_zip)
45
+ raise RappaError, "input zip: #{@config[:input_zip]} does not exist" unless @file.exists?(@config[:input_zip])
46
+ @config[:input_zip]
47
+ end
48
+
43
49
  def url
44
50
  check_property(@config[:url], :url)
45
51
  @config[:url]
data/src/rap_validator.rb CHANGED
@@ -22,6 +22,12 @@ class RapValidator
22
22
  raise RappaError, "input archive: #{input_archive} is not a valid .rap archive" unless extension == '.rap'
23
23
  end
24
24
 
25
+ def validate_is_zip_archive(file, input_archive)
26
+ base_name = file.basename(input_archive)
27
+ extension = file.extname(base_name)
28
+ raise RappaError, "input archive: #{input_archive} is not a valid .zip archive" unless extension == '.zip'
29
+ end
30
+
25
31
  private
26
32
 
27
33
  def validate_details
data/src/rappa.rb CHANGED
@@ -11,7 +11,7 @@ class Rappa
11
11
  @config = config
12
12
  @file = file
13
13
  @rest_client = rest_client
14
- @property_validator= property_validator.new(@config,@file)
14
+ @property_validator= property_validator.new(@config, @file)
15
15
  @rap_validator = rap_validator.new(@file)
16
16
  end
17
17
 
@@ -28,7 +28,7 @@ class Rappa
28
28
  def expand
29
29
  input_archive = @property_validator.input_archive
30
30
  output_directory = @property_validator.output_archive
31
- @rap_validator.validate_is_rap_archive(@file,input_archive)
31
+ @rap_validator.validate_is_rap_archive(@file, input_archive)
32
32
  FileUtils.mkdir_p output_directory unless @file.exists?(output_directory)
33
33
  expand_zip
34
34
  end
@@ -37,9 +37,35 @@ class Rappa
37
37
  input_rap = @property_validator.input_rap
38
38
  api_key = @property_validator.api_key
39
39
  url = @property_validator.url
40
+ @rap_validator.validate_is_rap_archive(@file, input_rap)
40
41
  @rest_client.put "#{url}?key=#{ api_key}", :file => @file.new(input_rap)
41
42
  end
42
43
 
44
+ def standalone_package
45
+ input_directory = @property_validator.input_directory
46
+ output_directory = @property_validator.output_directory
47
+ FileUtils.mkdir_p output_directory unless @file.exists?(output_directory)
48
+ name = "#{output_directory}/#{@config[:file_name]}.zip"
49
+ @property_validator.validate_name(name)
50
+ package_zip(input_directory, name)
51
+ end
52
+
53
+ def standalone_expand
54
+ input_archive = @property_validator.input_archive
55
+ output_directory = @property_validator.output_archive
56
+ @rap_validator.validate_is_zip_archive(@file, input_archive)
57
+ FileUtils.mkdir_p output_directory unless @file.exists?(output_directory)
58
+ expand_zip
59
+ end
60
+
61
+ def standalone_deploy
62
+ input_zip = @property_validator.input_zip
63
+ api_key = @property_validator.api_key
64
+ url = @property_validator.url
65
+ @rap_validator.validate_is_zip_archive(@file, input_zip)
66
+ @rest_client.put "#{url}?key=#{ api_key}", :file => @file.new(input_zip)
67
+ end
68
+
43
69
  def generate
44
70
  sample = {:name => 'App Name', :description => 'App Description', :version => '1', :server_type => 'thin', :start_script => 'start.sh', :stop_script => 'stop.sh', :pids => 'tmp/pids', :bootstrap => 'bootstrap.sh', :excludes => %w(file1 folder1)}
45
71
  @file.open('sample.rap.yml', 'w') { |f| f.puts sample.to_yaml }
@@ -67,7 +93,7 @@ class Rappa
67
93
  def package_zip(input_directory, name)
68
94
  Zip::ZipFile.open(name, Zip::ZipFile::CREATE) do |zip_file|
69
95
  glob = Dir[@file.join(input_directory, '**', '**')]
70
- @property_validator.excludes.each{|ex| glob.reject!{|f| f[input_directory + ex]}}
96
+ @property_validator.excludes.each { |ex| glob.reject! { |f| f[input_directory + ex] } }
71
97
  glob.each do |file|
72
98
  zip_file.add(file.sub(input_directory, ''), file)
73
99
  end
@@ -81,5 +107,4 @@ class Rappa
81
107
  end
82
108
 
83
109
 
84
-
85
110
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rappa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-11 00:00:00.000000000 Z
12
+ date: 2013-11-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec