jobmensa_assets 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 15057b5098dc275d50c8b3c9ecc24c520af11709
4
- data.tar.gz: ffbf510953e3f0eeba3a15955c56c9e740eae67b
3
+ metadata.gz: 33dc913cb03fb90f0b53631c53b6153cdd750d0b
4
+ data.tar.gz: c2098fe8f90400e7207235c769c01a841061717f
5
5
  SHA512:
6
- metadata.gz: 7db8acffb9dcc6d9ce53e044395b806fe3ee5a4a47493c34090296fc54ee6ad4c9655b95a84d608e5525b72898a0b67f4a802d8000836940b61cfa525be8c2b3
7
- data.tar.gz: 5ed16fe81bd6297cb1552f526c434707b2f8eb6844556d7aab5ae383598c8ce262f1a20def639df83f4b63e6f2bfd17dc3a31ad562abb40c3607a92de08ad6ce
6
+ metadata.gz: fe1cc74a34fc894d3ee510b9890c74d92d0a163d6527d93afe8cc7084adf72024f9a8e12d08373880d8226d02427c3f1457c9dcea4dbc98ba5e4e2952e521a6b
7
+ data.tar.gz: 44ea14bd68e59a26becba382e260218bfbc0ce771fcee564690bd534a1eef79402e7bc151a13661064c182541c8fe9957586a47a6c37ff748ba5c2e5f111a256
data/Gemfile CHANGED
@@ -8,6 +8,7 @@ gem 'refile', git: 'https://github.com/refile/refile.git', ref: '6a25a2405964e6c
8
8
  gem 'rake'
9
9
  gem 'rspec'
10
10
  gem 'newrelic_rpm', require: false
11
- gem 'puma', require: false
12
11
  gem 'unicorn', require: false
13
- gem 'rollbar', require: false
12
+ gem 'rollbar', require: false
13
+ gem 'sinatra-logentries', require: false
14
+ gem 'logging', require: false
data/Gemfile.lock CHANGED
@@ -47,22 +47,25 @@ GEM
47
47
  i18n (0.7.0)
48
48
  json (1.8.2)
49
49
  kgio (2.9.3)
50
+ le (2.6.2)
51
+ little-plugger (1.1.3)
52
+ logging (2.0.0)
53
+ little-plugger (~> 1.1)
54
+ multi_json (~> 1.10)
50
55
  mime-types (2.4.3)
51
56
  mini_magick (4.2.1)
52
57
  mini_portile (0.6.2)
53
- minitest (5.5.1)
58
+ minitest (5.6.0)
54
59
  multi_json (1.11.0)
55
60
  newrelic_rpm (3.10.0.279)
56
61
  nokogiri (1.6.6.2)
57
62
  mini_portile (~> 0.6.0)
58
- puma (2.11.1)
59
- rack (>= 1.1, < 2.0)
60
63
  rack (1.6.0)
61
64
  rack-protection (1.5.3)
62
65
  rack
63
66
  raindrops (0.13.0)
64
67
  rake (10.4.2)
65
- rollbar (1.4.4)
68
+ rollbar (1.5.0)
66
69
  multi_json (~> 1.3)
67
70
  rspec (3.1.0)
68
71
  rspec-core (~> 3.1.0)
@@ -80,6 +83,8 @@ GEM
80
83
  rack (~> 1.4)
81
84
  rack-protection (~> 1.4)
82
85
  tilt (>= 1.3, < 3)
86
+ sinatra-logentries (0.0.2)
87
+ le (>= 2.1.6)
83
88
  thread_safe (0.3.5)
84
89
  tilt (2.0.1)
85
90
  tzinfo (1.2.2)
@@ -95,10 +100,11 @@ PLATFORMS
95
100
  DEPENDENCIES
96
101
  bundler (~> 1.7)
97
102
  jobmensa_assets!
103
+ logging
98
104
  newrelic_rpm
99
- puma
100
105
  rake
101
106
  refile!
102
107
  rollbar
103
108
  rspec
109
+ sinatra-logentries
104
110
  unicorn
data/config/ey.yml ADDED
@@ -0,0 +1,178 @@
1
+ # Engine Yard Cloud Deploy Options
2
+ #
3
+ ####################################################################
4
+ # IMPORTANT
5
+ # Commit this file into your git repository.
6
+ # These options are loaded on the server during deploy.
7
+ ####################################################################
8
+ #
9
+ # Valid locations:
10
+ # * REPOSITORY_ROOT/config/ey.yml.
11
+ # * REPOSITORY_ROOT/ey.yml
12
+ #
13
+ # Further information available here:
14
+ # https://support.cloud.engineyard.com/entries/20996661-customize-your-deployment-on-engine-yard-cloud
15
+ #
16
+ # For advanced usage, see the source that loads this configuration:
17
+ # https://github.com/engineyard/engineyard-serverside/blob/master/lib/engineyard-serverside/configuration.rb
18
+ #
19
+ defaults:
20
+ # Run migrations during deploy by default.
21
+ #
22
+ # When set to true, runs the migration_command (below) during deploy.
23
+ #
24
+ # This setting can be overridden for individual deployments using
25
+ # the command line options --migrate or --no-migrate.
26
+ #
27
+ migrate: false
28
+
29
+ # Default migration command to run when migrations are enabled.
30
+ #
31
+ #migration_command: rake db:migrate --trace
32
+
33
+ # Enables rails assets precompilation always and halts when the task fails.
34
+ #
35
+ # By default, assets are detected using app/assets and config/application.rb.
36
+ #
37
+ # If you use rails assets and you want Engine Yard to compile your assets
38
+ # during deploy, set this to true. If you want to compile assets locally
39
+ # before deploy, set this to false. Make sure you add `public/assets` to
40
+ # `.gitignore` if you want Engine Yard to precompile your assets.
41
+ #
42
+ # For more control over assets, set precompile_assets: false and
43
+ # run your precompile task in the deploy/before_compile_assets.rb deploy hook.
44
+ #
45
+ precompile_assets: false
46
+
47
+ # Override the assets:precompile rake task. This option will be used instead
48
+ # of assets:precompile in the `rake assets:precompile` command.
49
+ #
50
+ #precompile_assets_task: assets:precompile
51
+
52
+ # Asset strategies affect the way assets are stored on the server.
53
+ #
54
+ # * private
55
+ # Store assets directly in public/assets for each deployment.
56
+ # Previous assets are symlinked for continuity.
57
+ # When assets are reused, they are copied using rsync.
58
+ #
59
+ # * shifting
60
+ # Assets are kept in a shared directory on each server.
61
+ # When new assets are compiled, old assets are shifted to a shared
62
+ # last_assets directory. This has always been the default behavior.
63
+ #
64
+ # * shared
65
+ # Assets are kept in a shared directory on each server.
66
+ # When new assets are compiled, the same directory is used.
67
+ # Assets will accumulate in this mode if a cleaning script is not run.
68
+ # Use this strategy if you want to write your own asset cleaning script.
69
+ #
70
+ # * cleaning
71
+ # Like shared, but a cleaning script is run before each new compile.
72
+ # The script attempts to remove all files not mentioned by the old
73
+ # manifest.yml, before it is replaced by the new manifest (leaving 2
74
+ # deployments worth of assets in the directory)
75
+ #
76
+ # "private" is recommended because it is the least error prone.
77
+ # If you prefer faster compilation, "shared" can be quicker, but will require
78
+ # custom scripting and will cause problems when rollbacks are used.
79
+ # "shifting" is the default behavior.
80
+ #
81
+ #asset_strategy: private
82
+
83
+ # This list of repository relative paths is checked for changes during
84
+ # each deployment (when change detection is not disabled). If `git diff`
85
+ # detects changes since the last deployment, fresh assets will be compiled.
86
+ #
87
+ # This option overrides the default list, so include the following
88
+ # defaults if you need them.
89
+ #
90
+ #asset_dependencies:
91
+ #- app/assets # default
92
+ #- lib/assets # default
93
+ #- vendor/assets # default
94
+ #- Gemfile.lock # default
95
+ #- config/application.rb # default
96
+ #- config/routes.rb # default
97
+ #- config/requirejs.yml # example of a custom asset dependency
98
+
99
+ # When true, precompiles assets even if no changes would be detected by
100
+ # running git diff with the asset_dependencies above.
101
+ #
102
+ # Default is false (always check git diff before asset compilation)
103
+ #
104
+ #precompile_unchanged_assets: false
105
+
106
+ # Choose which servers should compile assets.
107
+ #
108
+ # Default behavior is to exclude util instances.
109
+ # Specify :all to compile on all servers including util servers.
110
+ #
111
+ #asset_roles: :all
112
+
113
+ # Bundle without different bundler groups:
114
+ # Ex: bundle install --without '[bundle_without]'
115
+ #
116
+ # Default is "".
117
+ # Leave blank to remove --without from the bundle install command.
118
+ #
119
+ #bundle_without:
120
+
121
+ # Add extra options to the bundle install command line.
122
+ # Does not override bundle_without, if specified.
123
+ #
124
+ # If the application's gems are vendored in the
125
+ # repository, setting --local can speed up bundle.
126
+ #
127
+ #bundle_options:
128
+
129
+ # Enable maintenance page during migrate action (default)
130
+ # Setting this to false, disables maintenance page during migrations.
131
+ #
132
+ # CAUTION! No-downtime migrations requires careful migration
133
+ # planning. Migrations must be non-destructive. The *previous*
134
+ # deployment might serve pages during a partially migrated state.
135
+ # For example, if you rename a column, all traffic served during
136
+ # that migration will be broken until the new code is deployed.
137
+ #
138
+ #maintenance_on_migrate: true
139
+
140
+ # Enable maintanence page during every deploy.
141
+ # Unicorn and Passenger support no-downtime deploys, so the default
142
+ # for these servers is false. Mongrel and some other servers default
143
+ # to true to avoid downtime during server restarting.
144
+ #
145
+ #maintenance_on_restart:
146
+
147
+ # If true, always run deployments in verbose mode.
148
+ #
149
+ #verbose: false
150
+
151
+ # Hide the warning shown when the Gemfile does not contain a recognized
152
+ # database adapter (mongodb for example)
153
+ #
154
+ # This warning is here to help new customers that accidentally have no adapter.
155
+ # You may safely set this to true if you aren't using a common database.
156
+ #
157
+ #ignore_database_adapter_warning: false
158
+
159
+ # You can add custom keys that will be available in your deploy hooks.
160
+ # Custom keys will be available using config.key or config[:key]
161
+ #
162
+ #your_own_custom_key: custom info
163
+
164
+
165
+ ####################################################################
166
+ # Environment specific options.
167
+ #
168
+ # The options you specify here will only apply to a single environment
169
+ # that exactly matches the environment name key.
170
+ #
171
+ # Environment options will override the default options above.
172
+ #
173
+ environments:
174
+
175
+ # These options will only apply to the EXAMPLE_ENVIRONMENT environment.
176
+ #EXAMPLE_ENVIRONMENT:
177
+ #precompile_unchanged_assets: true
178
+
File without changes
data/config.ru CHANGED
@@ -14,34 +14,47 @@ require 'jobmensa_assets/config'
14
14
  require 'refile/app'
15
15
 
16
16
  # init logger, not needed if inside of a rails app
17
- require 'logger'
18
- Refile.logger = if [:test, :development].include? settings.environment
19
- logger = Logger.new("log/#{settings.environment}.log")
20
- logger.level = Logger::DEBUG
21
- logger
17
+ require 'logging'
18
+ logger = Logging.logger['default_logger']
19
+ logger.add_appenders \
20
+ Logging.appenders.rolling_file "log/#{settings.environment}.log", keep: 5, age: 'daily'
21
+ if [:test, :development].include? settings.environment
22
+ logger.level = :debug
22
23
  else
23
- logger = Logger.new(STDOUT)
24
- logger.level = Logger::INFO
25
- logger
24
+ logger.level = :info
26
25
  end
26
+ Refile.logger = logger
27
+
27
28
 
28
29
  # configure rollbar
29
- require 'rollbar'
30
30
  if rollbar_key = ENV['ROLLBAR_ACCESS_TOKEN']
31
+ require 'rollbar'
31
32
  Rollbar.configure do |config|
32
33
  config.access_token = rollbar_key
33
34
  end
34
35
  end
35
36
 
37
+ # configure logentries
38
+ if logentries_key = ENV['LOGENTRIES_TOKEN']
39
+ require 'sinatra-logentries'
40
+ Sinatra::Logentries.token = logentries_key
41
+ end
42
+
36
43
  # configure newrelic
37
44
  configure :staging, :production do
38
45
  require 'newrelic_rpm'
39
46
  end
40
47
 
41
48
  jobmensa_assets_app = Rack::Builder.new do
49
+ if (authorized_domain = ENV['BLITZ_AUTHORIZED_DOMAIN'])
50
+ map "/#{authorized_domain}" do
51
+ blitz_app = Sinatra.new { get('/') { '42' } }
52
+ blitz_app.run!
53
+ end
54
+ end
42
55
  map '/attachments' do
43
56
  run Refile::App
44
57
  end
45
58
  end
46
59
 
47
- run jobmensa_assets_app
60
+ run jobmensa_assets_app
@@ -3,9 +3,13 @@ require 'degu'
3
3
  module JobmensaAssets
4
4
  enum :AttachmentType do
5
5
  field :content_type
6
-
6
+
7
+ # Path for image if no thumnail is available
8
+ field :default_thumbnail_path
9
+
7
10
  Image(
8
- content_type: ['image/jpeg', 'image/gif', 'image/png']
11
+ content_type: ['image/jpeg', 'image/gif', 'image/png'],
12
+ default_thumbnail_path: ''
9
13
  )
10
14
 
11
15
  Spreadsheet(
@@ -13,11 +17,13 @@ module JobmensaAssets
13
17
  'application/vnd.ms-excel', 'application/excel', # xls
14
18
  'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', # xlsx
15
19
  'application/vnd.oasis.opendocument.spreadsheet' # ods
16
- ]
20
+ ],
21
+ default_thumbnail_path: 'jobmensa/attachment-tables.png'
17
22
  )
18
23
 
19
24
  PDF(
20
- content_type: ['application/pdf']
25
+ content_type: ['application/pdf'],
26
+ default_thumbnail_path: 'jobmensa/attachment-pdf.png'
21
27
  )
22
28
 
23
29
  Document(
@@ -26,7 +32,8 @@ module JobmensaAssets
26
32
  'application/vnd.openxmlformats-officedocument.wordprocessingml.document', # docx
27
33
  'application/vnd.oasis.opendocument.text', # odt
28
34
  'application/rtf', 'application/x-rtf', 'text/rtf', 'text/x-rtf' # rtf
29
- ]
35
+ ],
36
+ default_thumbnail_path: 'jobmensa/attachment-text.png'
30
37
  )
31
38
 
32
39
  def self.content_type(type)
@@ -43,7 +50,13 @@ module JobmensaAssets
43
50
  content_type.each_with_object([]) { |type, memo| memo << MIME::Types[type].flat_map(&:extensions) }.flatten.uniq
44
51
  end
45
52
  end
46
-
53
+
54
+ def self.attachment_type_for(content_type)
55
+ all.select do |attachment_type|
56
+ attachment_type.content_type.include? content_type
57
+ end.first
58
+ end
59
+
47
60
  def self.max_filesize(_type)
48
61
  Refile.cache.max_size
49
62
  end
@@ -1,3 +1,3 @@
1
1
  module JobmensaAssets
2
- VERSION = "0.1.0"
2
+ VERSION = '0.2.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jobmensa_assets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jobmensa dev team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-13 00:00:00.000000000 Z
11
+ date: 2015-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra
@@ -130,9 +130,10 @@ files:
130
130
  - README.md
131
131
  - Rakefile
132
132
  - config.ru
133
+ - config/ey.yml
133
134
  - config/newrelic.yml
134
135
  - config/puma.rb
135
- - config/unicorn.rb
136
+ - config/unicorn_local.rb
136
137
  - jobmensa_assets.gemspec
137
138
  - lib/jobmensa_assets.rb
138
139
  - lib/jobmensa_assets/attachment_type.rb
@@ -173,3 +174,4 @@ summary: Our image resize and delivery app.
173
174
  test_files:
174
175
  - spec/jobmensa_assets_spec.rb
175
176
  - spec/spec_helper.rb
177
+ has_rdoc: