microstatic 0.5.0 → 0.5.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ae9e8c819afc46577034785b6ddd5d5a92630c3f
4
+ data.tar.gz: 500fff96e94b01479e8f0940ef2cbe6aded8a332
5
+ SHA512:
6
+ metadata.gz: cc991b82b2aa63a200e9e228294c5849f49dd78e884fed0ab212a7027db8ff342db17061ed8c411dde22eb4e1c6b8c492e229ae57cbd6e4684ed8d87a8500dcf
7
+ data.tar.gz: db96cf7cacc0bfb239491e7580d2707e78cba806b52eb0af7b5d1cb392f06653fd65cbeb69fed14df08ced646ba6d01423ee3c075fe9cfe1f05183e7d6012dbf
data/.gitignore CHANGED
@@ -16,4 +16,6 @@ test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
18
 
19
+ /vendor/bundle
20
+
19
21
  /.creds
data/README.md CHANGED
@@ -1,11 +1,26 @@
1
1
  # Microstatic
2
2
 
3
- The microstatic gem turns generating your static site and deploying it to S3 into a one-liner.
3
+ The microstatic gem turns generating your static site and deploying it to S3 into a one-liner. There's [a blog post](http://blog.thepete.net/blog/2014/01/17/microstatic-radically-simple-static-microsites/) with more details on the what and the why.
4
+
5
+ Microstatic does two things. Firstly it provides a command-line tool that makes it ridiculously simple to create a new microsite. Secondly it provides a rake task that makes it ridiculously simple to push new content to the microsite.
6
+
7
+ ## Creating a new microsite
8
+
9
+ `microstatic setup` and you’re done. This will create a new S3 bucket to hold your microsite, and then add a Route 53 entry to wire that S3 bucket up to a subdomain.
10
+
11
+ ## Deploying content to your microsite
12
+
13
+ `rake deploy` and you’re done. Microstatic ships with a rake task that will sync your local contents with the S3 bucket hosting your site.
14
+
15
+ ## Demo time!
16
+
17
+ <iframe src="//player.vimeo.com/video/84530116" width="500" height="375" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe> <p><a href="http://vimeo.com/84530116">Microstatic: setup a static subdomain microsite in < 30 seconds</a> from <a href="http://vimeo.com/user5163505">Pete Hodgson</a> on <a href="https://vimeo.com">Vimeo</a>.</p>
18
+
19
+
4
20
 
5
21
  ## Credits
6
22
 
7
23
  The s3 deployment code was originally written by [Giles Alexander](http://twitter.com/gga)
8
24
 
9
25
  ## TODO
10
- - specify MICROSTATIC_SITE_NAME and cloud creds using dot file
11
- -
26
+ * specify MICROSTATIC_SITE_NAME and cloud creds using dot file
data/lib/microstatic.rb CHANGED
@@ -3,6 +3,7 @@ require "microstatic/version"
3
3
  require 'microstatic/config'
4
4
  require 'microstatic/uses_fog'
5
5
 
6
+ require "microstatic/uploader"
6
7
  require "microstatic/s3_deployer"
7
8
  require "microstatic/s3_bucket_creator"
8
9
  require "microstatic/route53_dns"
@@ -12,8 +12,8 @@ class S3DeployTask < ::Rake::TaskLib
12
12
  end
13
13
 
14
14
  @name = opts.fetch( :name ) { :s3deploy }
15
- @aws_access_key_id = opts.fetch( :aws_access_key_id ) { ENV.fetch('AWS_ACCESS_KEY_ID') }
16
- @aws_secret_access_key = opts.fetch( :aws_secret_access_key ) { ENV.fetch('AWS_SECRET_ACCESS_KEY') }
15
+ @aws_access_key_id = opts.fetch( :aws_access_key_id ) { ENV.fetch('AWS_ACCESS_KEY_ID',false) }
16
+ @aws_secret_access_key = opts.fetch( :aws_secret_access_key ) { ENV.fetch('AWS_SECRET_ACCESS_KEY',false) }
17
17
  @bucket_name = opts.fetch( :bucket_name, false )
18
18
  @source_dir = opts.fetch( :source_dir, false )
19
19
  @exclude = opts.fetch( :exclude, false )
@@ -24,18 +24,19 @@ class S3DeployTask < ::Rake::TaskLib
24
24
 
25
25
  raise 'must specify bucket_name' unless bucket_name
26
26
  raise 'must specify source_dir' unless source_dir
27
- raise 'must specify aws_access_key_id' unless aws_access_key_id
28
- raise 'must specify aws_secret_access_key' unless aws_secret_access_key
29
-
30
- aws_creds = {
31
- :access_key_id => aws_access_key_id,
32
- :secret_access_key => aws_secret_access_key
33
- }
34
27
 
35
28
  desc "deploy to the '#{bucket_name}' S3 bucket" unless ::Rake.application.last_comment
36
29
  task name do
37
- deployer = Microstatic::S3Deployer.new( source_dir, bucket_name, aws_creds )
38
- deployer.file_list.exclude(@exclude) if @exclude
30
+
31
+ raise 'must specify aws_access_key_id' unless aws_access_key_id
32
+ raise 'must specify aws_secret_access_key' unless aws_secret_access_key
33
+ aws_creds = {
34
+ :access_key_id => aws_access_key_id,
35
+ :secret_access_key => aws_secret_access_key
36
+ }
37
+
38
+ deployer = Microstatic::S3Deployer.build( source_dir, bucket_name, aws_creds )
39
+ deployer.exclude_files(@exclude) if @exclude
39
40
  deployer.upload
40
41
  end
41
42
  end
@@ -3,64 +3,29 @@ require 'pathname'
3
3
  require 'rake/file_list'
4
4
 
5
5
  module Microstatic
6
-
7
- # The following is based on code generously
8
- # shared by Giles Alexander (@gga)
9
6
  class S3Deployer
10
- include UsesFog
11
-
12
- attr_reader :file_list # TODO: don't expose this directly
13
7
 
14
- def initialize( local_dir, bucket, aws_creds )
15
- check_and_store_aws_creds(aws_creds)
8
+ def self.build( local_dir, bucket, aws_creds )
9
+ uploader = Uploader.new( local_dir, bucket, aws_creds )
10
+ new( local_dir, uploader )
11
+ end
16
12
 
13
+ def initialize( local_dir, uploader )
17
14
  @local_dir = Pathname.new(local_dir)
18
15
  @file_list = ::Rake::FileList.new( (@local_dir+"**/*").to_s )
19
- @bucket = bucket
16
+ @uploader = uploader
17
+ end
18
+
19
+ def exclude_files(*args)
20
+ @file_list.exclude(*args)
20
21
  end
21
22
 
22
23
  def upload
23
24
  @file_list.each do |entry|
24
25
  entry = Pathname.new(entry)
25
- upload_file(entry) unless entry.directory?
26
+ @uploader.upsert_filepath(entry) unless entry.directory?
26
27
  end
27
28
  end
28
29
 
29
- def upload_file( file )
30
- s3_key = file.relative_path_from(@local_dir).to_s
31
-
32
- begin
33
- s3_object = connection.head_object(@bucket,s3_key)
34
- rescue Excon::Errors::NotFound
35
- s3_object = false
36
- end
37
-
38
- if !s3_object
39
- log_action('CREATE', s3_key)
40
- put_file( s3_key, file )
41
- else
42
- s3_md5 = s3_object.headers['ETag'].sub(/"(.*)"/,'\1')
43
- local_md5 = Digest::MD5.hexdigest( file.read )
44
-
45
- if( s3_md5 == local_md5 )
46
- log_action('NO CHANGE', s3_key)
47
- else
48
- log_action('UPDATE', s3_key)
49
- put_file( s3_key, file )
50
- end
51
- end
52
- end
53
-
54
- private
55
-
56
- def put_file( s3_key, file )
57
- connection.put_object( @bucket, s3_key, file.open, 'x-amz-acl' => 'public-read', 'x-amz-storage-class' => 'REDUCED_REDUNDANCY' )
58
- end
59
-
60
- def log_action(action,file)
61
- message = action.to_s.rjust(10) + " " + file
62
- puts message
63
- end
64
30
  end
65
-
66
31
  end
@@ -0,0 +1,64 @@
1
+ require 'pathname'
2
+
3
+ module Microstatic
4
+
5
+ class Uploader
6
+ include UsesFog
7
+
8
+ def initialize( base_dir, bucket, aws_creds )
9
+ check_and_store_aws_creds(aws_creds)
10
+ @bucket = bucket
11
+ @base_dir = Pathname.new(base_dir)
12
+ end
13
+
14
+ def upsert_filepath( filepath )
15
+ pathname = Pathname.new(filepath)
16
+ s3_key = relative_path_for(pathname)
17
+
18
+ begin
19
+ s3_object = connection.head_object(@bucket,s3_key)
20
+ rescue Excon::Errors::NotFound
21
+ s3_object = false
22
+ end
23
+
24
+ if s3_object
25
+ update_object_if_changed(s3_key, pathname,s3_object)
26
+ else
27
+ create_object(s3_key, pathname)
28
+ end
29
+ end
30
+
31
+ private
32
+
33
+ def create_object(s3_key, pathname)
34
+ log_action('CREATE', s3_key)
35
+ put_file( s3_key, pathname )
36
+ end
37
+
38
+ def update_object_if_changed(s3_key, pathname,s3_object)
39
+ s3_md5 = s3_object.headers['ETag'].sub(/"(.*)"/,'\1')
40
+ local_md5 = Digest::MD5.hexdigest( pathname.read )
41
+
42
+ if( s3_md5 == local_md5 )
43
+ log_action('NO CHANGE', s3_key)
44
+ else
45
+ log_action('UPDATE', s3_key)
46
+ put_file( s3_key, pathname )
47
+ end
48
+ end
49
+
50
+ def relative_path_for(pathname)
51
+ pathname.relative_path_from(@base_dir).to_s
52
+ end
53
+
54
+ def put_file( s3_key, file )
55
+ connection.put_object( @bucket, s3_key, file.open, 'x-amz-acl' => 'public-read', 'x-amz-storage-class' => 'REDUCED_REDUNDANCY' )
56
+ end
57
+
58
+ def log_action(action,file)
59
+ message = action.to_s.rjust(10) + " " + file
60
+ puts message
61
+ end
62
+ end
63
+
64
+ end
@@ -1,3 +1,3 @@
1
1
  module Microstatic
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  end
File without changes
@@ -19,8 +19,8 @@ describe 'uploading to a test bucket' do
19
19
  end
20
20
 
21
21
  it 'succeeds' do
22
- deployer = S3Deployer.new( test_dir, test_bucket, aws_creds )
23
- deployer.file_list.exclude(%r|ignored/|)
22
+ deployer = S3Deployer.build( test_dir, test_bucket, aws_creds )
23
+ deployer.exclude_files(%r|ignored/|)
24
24
  deployer.upload
25
25
  end
26
26
 
metadata CHANGED
@@ -1,126 +1,111 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: microstatic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
5
- prerelease:
4
+ version: 0.5.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Pete Hodgson
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-08-24 00:00:00.000000000 Z
11
+ date: 2015-02-23 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: fog
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '1'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: '1'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: thor
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0.15'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0.15'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rainbow
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
47
  version: '2.0'
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - ">="
60
53
  - !ruby/object:Gem::Version
61
54
  version: '2.0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rake
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - ">="
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :runtime
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - ">="
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: bundler
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - ">="
84
74
  - !ruby/object:Gem::Version
85
75
  version: '0'
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - ">="
92
81
  - !ruby/object:Gem::Version
93
82
  version: '0'
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: rspec
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
- - - ~>
87
+ - - "~>"
100
88
  - !ruby/object:Gem::Version
101
89
  version: 2.13.0
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
- - - ~>
94
+ - - "~>"
108
95
  - !ruby/object:Gem::Version
109
96
  version: 2.13.0
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: pry-nav
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
- - - ~>
101
+ - - "~>"
116
102
  - !ruby/object:Gem::Version
117
103
  version: 0.2.3
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
- - - ~>
108
+ - - "~>"
124
109
  - !ruby/object:Gem::Version
125
110
  version: 0.2.3
126
111
  description: The microstatic gem turns generating your static site and deploying it
@@ -132,9 +117,7 @@ executables:
132
117
  extensions: []
133
118
  extra_rdoc_files: []
134
119
  files:
135
- - .gitignore
136
- - .ruby-gemset
137
- - .ruby-version
120
+ - ".gitignore"
138
121
  - Gemfile
139
122
  - LICENSE
140
123
  - README.md
@@ -147,6 +130,7 @@ files:
147
130
  - lib/microstatic/route53_dns.rb
148
131
  - lib/microstatic/s3_bucket_creator.rb
149
132
  - lib/microstatic/s3_deployer.rb
133
+ - lib/microstatic/uploader.rb
150
134
  - lib/microstatic/uses_fog.rb
151
135
  - lib/microstatic/version.rb
152
136
  - microstatic.gemspec
@@ -155,38 +139,32 @@ files:
155
139
  - spec/integration/fixtures/subdir/foo.txt
156
140
  - spec/integration/fixtures/subdir/ignored/ignored-file.txt
157
141
  - spec/integration/fixtures/subdir/subsubdir/deep.txt
142
+ - spec/integration/fixtures/symlink.txt
158
143
  - spec/integration/spec_helper.rb
159
144
  - spec/integration/upload_to_test_bucket_spec.rb
160
145
  - templates/Rakefile.erb
161
146
  homepage: https://github.com/moredip/microstatic
162
147
  licenses: []
148
+ metadata: {}
163
149
  post_install_message:
164
150
  rdoc_options: []
165
151
  require_paths:
166
152
  - lib
167
153
  required_ruby_version: !ruby/object:Gem::Requirement
168
- none: false
169
154
  requirements:
170
- - - ! '>='
155
+ - - ">="
171
156
  - !ruby/object:Gem::Version
172
157
  version: '0'
173
- segments:
174
- - 0
175
- hash: -1270358842069851857
176
158
  required_rubygems_version: !ruby/object:Gem::Requirement
177
- none: false
178
159
  requirements:
179
- - - ! '>='
160
+ - - ">="
180
161
  - !ruby/object:Gem::Version
181
162
  version: '0'
182
- segments:
183
- - 0
184
- hash: -1270358842069851857
185
163
  requirements: []
186
164
  rubyforge_project:
187
- rubygems_version: 1.8.25
165
+ rubygems_version: 2.4.4
188
166
  signing_key:
189
- specification_version: 3
167
+ specification_version: 4
190
168
  summary: Generate static sites from git and deploy them to an S3 bucket.
191
169
  test_files:
192
170
  - spec/integration/fixtures/example_file.txt
@@ -194,5 +172,6 @@ test_files:
194
172
  - spec/integration/fixtures/subdir/foo.txt
195
173
  - spec/integration/fixtures/subdir/ignored/ignored-file.txt
196
174
  - spec/integration/fixtures/subdir/subsubdir/deep.txt
175
+ - spec/integration/fixtures/symlink.txt
197
176
  - spec/integration/spec_helper.rb
198
177
  - spec/integration/upload_to_test_bucket_spec.rb
data/.ruby-gemset DELETED
@@ -1 +0,0 @@
1
- microstatic
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- default