shart 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ .env
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in shart.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Brad Gessler
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,41 @@
1
+ # Shart
2
+
3
+ Shart is designed to deploy [Middleman](http://middlemanapp.com/) websites, or sites built with other static site builders, to cloud storage providers, like Amazon S3 and [more](http://fog.io/0.8.1/storage/).
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'shart'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install shart
18
+
19
+ ## Usage
20
+
21
+ Create a `Shartfile` in the root of your project.
22
+
23
+ ```ruby
24
+ # A middleman Shartfile
25
+ source './build'
26
+ target 'your-aws-bucket-name', {
27
+ provider: 'AWS',
28
+ aws_secret_access_key: 'your AWS credentials',
29
+ aws_access_key_id: 'your AWS credentials'
30
+ }
31
+ ```
32
+
33
+ Now run `shart` from your project root and BOOM! Your website will be deployed. If you're using Middleman, don't forget to run build first.
34
+
35
+ ## Contributing
36
+
37
+ 1. Fork it
38
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
39
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
40
+ 4. Push to the branch (`git push origin my-new-feature`)
41
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/shart ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
4
+
5
+ require 'shart'
6
+
7
+ Shart::DSL.shartfile('Shartfile')
8
+
9
+ # target = Shart::Target.new 'tech.polleverywhere.com', {
10
+ # :provider => 'AWS',
11
+ # :aws_secret_access_key => ENV['AWS_SECRET_ACCESS_KEY'],
12
+ # :aws_access_key_id => ENV['AWS_ACCESS_KEY_ID']
13
+ # }
14
+
15
+ # source = Shart::Source.new('/Users/bradgessler/projects/polleverywhere/tech-blog/build')
16
+
17
+ # target.sync source
@@ -0,0 +1,3 @@
1
+ module Shart
2
+ VERSION = "3.0.0"
3
+ end
data/lib/shart.rb ADDED
@@ -0,0 +1,90 @@
1
+ require "shart/version"
2
+ require 'fog'
3
+ require 'pathname'
4
+
5
+ module Shart
6
+ # The Target is where the content will be published.
7
+ class Target
8
+ attr_reader :directory_name
9
+
10
+ def initialize(directory_name, opts={})
11
+ @directory_name = directory_name
12
+ @storage = Fog::Storage.new(opts)
13
+ end
14
+
15
+ def files
16
+ directory.files
17
+ end
18
+
19
+ def directory
20
+ @directory ||= @storage.directories.get(@directory_name)
21
+ end
22
+
23
+ def sync(source)
24
+ Sync.new(source, self).sync
25
+ end
26
+ end
27
+
28
+ # The Source represents where the content is coming from.
29
+ class Source
30
+ attr_reader :root
31
+
32
+ def initialize(path)
33
+ @root = Pathname.new(path)
34
+ end
35
+
36
+ def files(&block)
37
+ Dir.glob(@root + '**/*').reject{ |p| File.directory?(p) }.inject Hash.new do |hash, source_path|
38
+ hash[source_path] = Pathname.new(source_path).relative_path_from(@root).to_s # Give us the 'key' path that we'll publish to in the target.
39
+ hash
40
+ end
41
+ end
42
+
43
+ def sync(target)
44
+ Sync.new(self, target).sync
45
+ end
46
+ end
47
+
48
+ # Process info a Shartfile
49
+ class DSL
50
+ def target(directory_name, opts={})
51
+ @target = Target.new(directory_name, opts)
52
+ end
53
+
54
+ def source(path)
55
+ @source = Source.new(path)
56
+ end
57
+
58
+ def sync
59
+ Sync.new(@source, @target)
60
+ end
61
+
62
+ def self.shartfile(filename)
63
+ sync = new.tap { |dsl| dsl.instance_eval(File.read(filename), filename) }.sync
64
+ puts "Sharting from #{sync.source.root.to_s.inspect} to #{sync.target.directory_name.inspect}"
65
+ sync.run do |path, key, file|
66
+ puts " #{key.inspect}"
67
+ end
68
+ end
69
+ end
70
+
71
+ # Sync deals with the specifics of getting each file from the source to the target.
72
+ class Sync
73
+ attr_reader :source, :target
74
+
75
+ def initialize(source, target)
76
+ @source, @target = source, target
77
+ end
78
+
79
+ def run(&block)
80
+ @source.files.each do |path, key|
81
+ block.call path, key, @target.files.create({
82
+ :key => key,
83
+ :body => File.open(path),
84
+ :public => true,
85
+ :cache_control => 0 # Disable cache on S3 so that future sharts are visible if folks web browsers.
86
+ })
87
+ end
88
+ end
89
+ end
90
+ end
data/shart.gemspec ADDED
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'shart/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "shart"
8
+ gem.version = Shart::VERSION
9
+ gem.authors = ["Brad Gessler"]
10
+ gem.email = ["brad@bradgessler.com"]
11
+ gem.description = %q{Deploys static website to cloud storage providers.}
12
+ gem.summary = %q{Shart makes it easy to deploy static websites to cloud storage providers. Works great with Middleman, Jekyll, or Dreamweaver websites.}
13
+ gem.homepage = "http://github.com/polleverywhere/shart"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_dependency "fog"
21
+ end
@@ -0,0 +1,6 @@
1
+ source '/Users/bradgessler/projects/polleverywhere/tech-blog/build'
2
+ target 'tech.polleverywhere.com', {
3
+ provider: 'AWS',
4
+ aws_secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
5
+ aws_access_key_id: ENV['AWS_ACCESS_KEY_ID']
6
+ }
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: shart
3
+ version: !ruby/object:Gem::Version
4
+ version: 3.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Brad Gessler
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-12-11 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: fog
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ description: Deploys static website to cloud storage providers.
31
+ email:
32
+ - brad@bradgessler.com
33
+ executables:
34
+ - shart
35
+ extensions: []
36
+ extra_rdoc_files: []
37
+ files:
38
+ - .gitignore
39
+ - Gemfile
40
+ - LICENSE.txt
41
+ - README.md
42
+ - Rakefile
43
+ - bin/shart
44
+ - lib/shart.rb
45
+ - lib/shart/version.rb
46
+ - shart.gemspec
47
+ - spec/fixtures/Shartfile
48
+ homepage: http://github.com/polleverywhere/shart
49
+ licenses: []
50
+ post_install_message:
51
+ rdoc_options: []
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ! '>='
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ requirements: []
67
+ rubyforge_project:
68
+ rubygems_version: 1.8.24
69
+ signing_key:
70
+ specification_version: 3
71
+ summary: Shart makes it easy to deploy static websites to cloud storage providers.
72
+ Works great with Middleman, Jekyll, or Dreamweaver websites.
73
+ test_files:
74
+ - spec/fixtures/Shartfile