shart 3.1.1 → 4.0.0.alpha2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MzQ4MzIxZGRkNjM3Y2Q0NjRjMDRmMTUzMTZlM2UzYTIyMWNiN2VhZA==
4
+ NGU4MTljMmE0Y2U5OTU3OGZiZGRlOThmYmUwN2Y4YzliYzFkNGQ3MA==
5
5
  data.tar.gz: !binary |-
6
- ZmNlZjgzYzQyNGYwYWIyMmI4YjVhYjJiYWUxMDhlZjA0NTQ4YmFkZA==
6
+ YjI1YWExNWJiMjA1N2ZmOWM2ZWM4ZDg5ZmUyZjg5ODQ4OWYxMTRjZg==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- OTllZjc4NjM0MGFiZjY1MjMyNmE2YTg1YWRlODJhMTY3OGI3ZjNlNTg3MjM0
10
- MDQ0NjcwYmUwMDYwMDI4OGRkM2Q4MzIyNzE2Mjg5YjM1OWIzNDEwNDI3MjMx
11
- ODYyZDFkZGQzOTcyYTE0OTk0ZWZjM2RiNGM2MDE5ZWVhMDQ3ZGQ=
9
+ ZTZiNGMwYTYwYjU1ZGZhYWZmZTZlMjYyOGJjODBiZjI3MGUxZmZmNzJlOTdm
10
+ YmNjZTM5YWQzYmIwOGFiYjUwZTU4YTY4NmNhODJlMGFlYjhhY2Y3NzNhZmIz
11
+ YTg0YjQ3MDAyODZhN2QwNjFkZmVkZDgyYjBjYzVmNDEzYzdkMTc=
12
12
  data.tar.gz: !binary |-
13
- YjQ4OTBlZDAzZjJlMTg0NGM1ZWVmYWNiODBjZGE2M2JiOGIzOWY3NDAwMmUw
14
- NWMxNTJjYWM1MGNmNDI3ZjZjODIxM2RkOGU1ODZiZTM4MWI5MDVhMmZkMmRk
15
- NDBiZDFlYjdhMWUyMTRlMWZjOTY0ZjQ5MjhlYTFhNWNkNTc3MjQ=
13
+ ODU4NjI4MjlmZDY5ZjFmNmQxYjZkNWE2YzhiMWFiNGYyOWQ1MzcyNTVjZmZi
14
+ OWMwMmEyY2QzYzQ5OWU3M2JmYzU2Y2E2NTZmNzg2NjRhNTg5ZWNlNTc3NTkx
15
+ N2RiMjI3ZmIxNDBkMTU2YTliNjIzMjljYzA3NWNmYTc2MTlkN2Q=
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
@@ -7,7 +7,7 @@ require 'pathname'
7
7
  module Shart
8
8
  # The Target is where the content will be published.
9
9
  class Target
10
- attr_reader :directory_name
10
+ attr_reader :directory_name, :storage
11
11
 
12
12
  def initialize(directory_name, opts={})
13
13
  @directory_name = directory_name
@@ -19,7 +19,7 @@ module Shart
19
19
  end
20
20
 
21
21
  def directory
22
- @directory ||= @storage.directories.get(@directory_name)
22
+ @directory ||= storage.directories.get(@directory_name)
23
23
  end
24
24
 
25
25
  def sync(source)
@@ -48,6 +48,34 @@ module Shart
48
48
  end
49
49
  end
50
50
 
51
+ # Register processing rules for objects with an Engine.
52
+ class Engine
53
+ # Add a rule to the engine. Based on Dir.glob patterns from the objects on
54
+ # the file system.
55
+ def rule(pattern, &block)
56
+ rules << [pattern, block]
57
+ end
58
+
59
+ # Process the stinkin rules mang.
60
+ def process(object)
61
+ rules.each { |pattern, rule| object.instance_eval(&rule) if self.class.match(pattern, object.key) }
62
+ end
63
+
64
+ private
65
+ def self.match(pattern, key)
66
+ case pattern
67
+ when String
68
+ File.fnmatch(pattern, key)
69
+ when Regexp
70
+ key =~ pattern
71
+ end
72
+ end
73
+
74
+ def rules
75
+ @rules ||= []
76
+ end
77
+ end
78
+
51
79
  # Process info a Shartfile
52
80
  class DSL
53
81
  def target(directory_name, opts={})
@@ -59,7 +87,11 @@ module Shart
59
87
  end
60
88
 
61
89
  def sync
62
- Sync.new(@source, @target)
90
+ Sync.new(@source, @target, @engine)
91
+ end
92
+
93
+ def path(*paths, &block)
94
+ paths.each { |path| engine.rule path, &block }
63
95
  end
64
96
 
65
97
  def self.shartfile(filename)
@@ -72,14 +104,19 @@ module Shart
72
104
  puts "✗ #{object.public_url}"
73
105
  end
74
106
  end
107
+
108
+ private
109
+ def engine
110
+ @engine ||= Engine.new
111
+ end
75
112
  end
76
113
 
77
114
  # Sync deals with the specifics of getting each file from the source to the target.
78
115
  class Sync
79
- attr_reader :source, :target
116
+ attr_reader :source, :target, :engine
80
117
 
81
- def initialize(source, target)
82
- @source, @target = source, target
118
+ def initialize(source, target, engine = Engine.new)
119
+ @source, @target, @engine = source, target, engine
83
120
  end
84
121
 
85
122
  # Upload files from target to the source.
@@ -89,8 +126,10 @@ module Shart
89
126
  :key => key,
90
127
  :body => file,
91
128
  :public => true,
92
- :cache_control => 'max-age=0' # Disable cache on S3 so that future sharts are visible if folks web browsers.
129
+ :cache_control => 'max-age=0' # Disable cache by default on S3 so that future sharts are visible if folks web browsers.
93
130
  })
131
+ engine.process object
132
+ object.save
94
133
  block.call file, object
95
134
  end
96
135
  end
@@ -1,3 +1,3 @@
1
1
  module Shart
2
- VERSION = "3.1.1"
2
+ VERSION = "4.0.0.alpha2"
3
3
  end
@@ -18,4 +18,5 @@ Gem::Specification.new do |gem|
18
18
  gem.require_paths = ["lib"]
19
19
 
20
20
  gem.add_dependency "fog"
21
+ gem.add_development_dependency "rspec"
21
22
  end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe Shart::Engine do
4
+ let(:engine) { Shart::Engine.new }
5
+
6
+ it "should process rules" do
7
+ s3_object = mock()
8
+ s3_object.stub!(:key)
9
+ s3_object.stub!(:attribute)
10
+ s3_object.should_receive(:key) { 'shart.gemspec' }
11
+ s3_object.should_receive(:attribute).with(:cache_control, 'max-age=100')
12
+
13
+ engine.rule('*.gemspec'){ attribute :cache_control, 'max-age=100' }
14
+ engine.process s3_object
15
+ end
16
+ end
@@ -4,4 +4,8 @@ target ENV['AWS_BUCKET'], {
4
4
  provider: 'AWS',
5
5
  aws_secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
6
6
  aws_access_key_id: ENV['AWS_ACCESS_KEY_ID']
7
+ }
8
+
9
+ path '/javascripts', '/images', '/stylesheets' {
10
+ attributes :cache_control, 'max-age=60'
7
11
  }
@@ -0,0 +1,19 @@
1
+ require 'shart'
2
+
3
+ # This file was generated by the `rspec --init` command. Conventionally, all
4
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
5
+ # Require this file using `require "spec_helper"` to ensure that it is only
6
+ # loaded once.
7
+ #
8
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
9
+ RSpec.configure do |config|
10
+ config.treat_symbols_as_metadata_keys_with_true_values = true
11
+ config.run_all_when_everything_filtered = true
12
+ config.filter_run :focus
13
+
14
+ # Run specs in random order to surface order dependencies. If you find an
15
+ # order dependency and want to debug it, you can fix the order by providing
16
+ # the seed, which is printed after each run.
17
+ # --seed 1234
18
+ config.order = 'random'
19
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shart
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.1
4
+ version: 4.0.0.alpha2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brad Gessler
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ! '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  description: Deploys static websites like Middleman to cloud storage providers like
28
42
  S3.
29
43
  email:
@@ -34,6 +48,7 @@ extensions: []
34
48
  extra_rdoc_files: []
35
49
  files:
36
50
  - .gitignore
51
+ - .rspec
37
52
  - Gemfile
38
53
  - LICENSE.txt
39
54
  - README.md
@@ -42,7 +57,9 @@ files:
42
57
  - lib/shart.rb
43
58
  - lib/shart/version.rb
44
59
  - shart.gemspec
60
+ - spec/engine_spec.rb
45
61
  - spec/fixtures/Shartfile
62
+ - spec/spec_helper.rb
46
63
  homepage: http://github.com/polleverywhere/shart
47
64
  licenses: []
48
65
  metadata: {}
@@ -57,9 +74,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
57
74
  version: '0'
58
75
  required_rubygems_version: !ruby/object:Gem::Requirement
59
76
  requirements:
60
- - - ! '>='
77
+ - - ! '>'
61
78
  - !ruby/object:Gem::Version
62
- version: '0'
79
+ version: 1.3.1
63
80
  requirements: []
64
81
  rubyforge_project:
65
82
  rubygems_version: 2.0.3
@@ -68,5 +85,7 @@ specification_version: 4
68
85
  summary: Shart makes it easy to deploy static websites to cloud storage providers.
69
86
  Works great with Middleman, Jekyll, or Dreamweaver websites.
70
87
  test_files:
88
+ - spec/engine_spec.rb
71
89
  - spec/fixtures/Shartfile
90
+ - spec/spec_helper.rb
72
91
  has_rdoc: