repository-manager 0.2.10 → 0.2.11

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9a5f9e1303f1c190997c2c901c476fa08b2d910c
4
- data.tar.gz: a5c56d387625acf0a20fd17132c5efa9e957229a
3
+ metadata.gz: 3d35c29abb365d39361fec00d32a394c71f10ba9
4
+ data.tar.gz: ac24f4832561d3fba78d2ccaca4943d4ee6ea0ff
5
5
  SHA512:
6
- metadata.gz: 0d73911fbb82113abd58dd547fcf29b8acdc287c590814157b2eae9804848282c7f4753a8921ef9f32a7f70e58134673ae33537bcf3c612cff7a09e67c516799
7
- data.tar.gz: 18c2b1c8ff1197abce0b43ea492764911f5d3c054712ef0c4f666a68ba97fe036cf2d4fc151edabd0e37330f526c036c26c78985e34e017e486fe1d042b02d15
6
+ metadata.gz: 40c08ddefe5acc9d3505fc49b0b8760fb2865894726c3ed17caee69d2a5d0ff55fd3fa631c5f62c63f873bd8facc1f099fd308699abb0b48a6602a308e3fb789
7
+ data.tar.gz: e19065ccb365a6abf4806e27c69d018ed31ad7b87433af64b0fc820ff1c7c12a201ccf3d95fbba3a2eddf1e9556b7d68ee0f1a139b019dc3463ad263483d5777
data/README.md CHANGED
@@ -248,7 +248,23 @@ file.sender # Returns user1
248
248
 
249
249
  ```
250
250
 
251
- WARNING : There is no verification if the user1 has the permission to create a file or folder into this group. You have to check this in your controller ! The fact that user1 is the sender of this folder gives him NO PERMISSION on it !
251
+ WARNING : There is no verification if the user1 has the permission to create a file or folder into this group. You have to check this in your controller ! The fact that user1 is the sender of this folder gives him NO MORE PERMISSION on it !
252
+
253
+ #### Unzip an archive
254
+
255
+ You can send a zipped file in your application and unzip it on it. Repository Manager will automaticaly create the `Repo Items` needed. This is very usefull when you want to send a folder (with sub files and folders), just zip it, send it, and unzip it in the application. You can use the `has_repository` method `unzip_repo_item(repo_item, options)`.
256
+
257
+ ```ruby
258
+ # @user send a ZIP archive and want to unzip it in his own repository.
259
+ repo_file_archive = @user.create_file(the_file_sended)
260
+ @user.unzip_repo_item(repo_file_archive)
261
+ # => Will unzip all the content (files / folders) of the zip archive in his root repository
262
+
263
+ # @group want to unzip this archive in another folder and overwrite the old one.
264
+ # We want to precise that @user is the sender
265
+ @group.unzip_repo_item(repo_file_archive, source_folder: target_folder, overwrite: true, sender: @user)
266
+
267
+ ```
252
268
 
253
269
  #### Overwrite
254
270
 
@@ -265,7 +281,7 @@ You can overwrite a file or a folder. You juste have to pass the `overwrite: tru
265
281
 
266
282
  ```
267
283
 
268
- NOTE : If you overwrite a folder, the old folder will be destroyed ! If you overwrite a file, the existing file will be updated with the new file (better for versionning).
284
+ NOTE : If you overwrite a folder, the old folder will be destroyed ! If you overwrite a file, the existing file will be updated with the new file (better for versioning).
269
285
 
270
286
  ### How can I share a repo_item (file/folder)
271
287
 
@@ -129,7 +129,7 @@ class RepositoryManager::RepoFile < RepositoryManager::RepoItem
129
129
  new_item.sender = sender
130
130
  new_item.owner = owner
131
131
 
132
- tmp_file_path = "#{Rails.root}/tmp/unzip/#{name}"
132
+ tmp_file_path = File.join(Rails.root, 'tmp', 'unzip', name)
133
133
  # Delete the path
134
134
  FileUtils.rm_rf(tmp_file_path)
135
135
  entry.extract(tmp_file_path)
@@ -11,7 +11,7 @@ class RepoFileUploader < CarrierWave::Uploader::Base
11
11
  # include CarrierWave::MiniMagick
12
12
 
13
13
  # Choose what kind of storage to use for this uploader:
14
- storage :file
14
+ storage RepositoryManager.storage
15
15
  # storage :fog
16
16
 
17
17
  # Override the directory where uploaded files will be stored.
@@ -20,6 +20,9 @@ module RepositoryManager
20
20
  mattr_accessor :auto_overwrite_item
21
21
  @@auto_overwrite_item = false
22
22
 
23
+ mattr_accessor :storage
24
+ @@storage = :file
25
+
23
26
  class << self
24
27
  def setup
25
28
  yield self
@@ -41,4 +44,7 @@ module RepositoryManager
41
44
  end
42
45
 
43
46
  require 'repository_manager/engine'
44
- require 'repository_manager/exceptions'
47
+ require 'repository_manager/exceptions'
48
+ if RepositoryManager.has_paper_trail
49
+ require 'paper_trail'
50
+ end
@@ -234,8 +234,6 @@ module RepositoryManager
234
234
  #We do not destroy, we update it !
235
235
 
236
236
  # We update the file
237
- repo_item_with_same_name.file = file
238
-
239
237
  if file.class.name == 'RepositoryManager::RepoFile'
240
238
  repo_item_with_same_name.file = file.file
241
239
  elsif file.class.name == 'File' || file.class.name == 'ActionDispatch::Http::UploadedFile'
@@ -243,6 +241,7 @@ module RepositoryManager
243
241
  else # "ActionController::Parameters"
244
242
  repo_item_with_same_name.assign_attributes(file)
245
243
  end
244
+
246
245
  repo_item_with_same_name.sender = options[:sender]
247
246
  #p "source: updates the file #{repo_item_with_same_name.name}"
248
247
  repo_file = repo_item_with_same_name
@@ -1,3 +1,3 @@
1
1
  module RepositoryManager
2
- VERSION = '0.2.10'
2
+ VERSION = '0.2.11'
3
3
  end
@@ -2,6 +2,7 @@ source "https://rubygems.org"
2
2
 
3
3
  gem 'repository-manager', :path => '../../'
4
4
  gem 'factory_girl'
5
+ gem 'paper_trail'
5
6
 
6
7
  # Bundle edge Rails instead:
7
8
  # gem 'rails', :git => 'git://github.com/rails/rails.git'
@@ -0,0 +1,13 @@
1
+ class CreateVersions < ActiveRecord::Migration
2
+ def change
3
+ create_table :versions do |t|
4
+ t.string :item_type, :null => false
5
+ t.integer :item_id, :null => false
6
+ t.string :event, :null => false
7
+ t.string :whodunnit
8
+ t.text :object
9
+ t.datetime :created_at
10
+ end
11
+ add_index :versions, [:item_type, :item_id]
12
+ end
13
+ end
@@ -0,0 +1 @@
1
+ 2 This is a fixture text (txt) file.
@@ -0,0 +1 @@
1
+ 3 This is a fixture text (txt) file.
@@ -0,0 +1 @@
1
+ 4 This is a fixture text (txt) file.
@@ -398,4 +398,4 @@ describe 'RepoItem' do
398
398
  @user2.copy_repo_item!(@user1_file, source_folder: fold)
399
399
  expect(fold.children.count).to eq(1)
400
400
  end
401
- end
401
+ end
@@ -1,27 +1,74 @@
1
- # Configure Rails Environment
2
- ENV["RAILS_ENV"] = "test"
1
+ require 'rubygems'
2
+ require 'spork'
3
+ #uncomment the following line to use spork with the debugger
4
+ #require 'spork/ext/ruby-debug'
3
5
 
4
- require File.expand_path("../dummy/config/environment.rb", __FILE__)
6
+ Spork.prefork do
7
+ # Loading more in this block will cause your tests to run faster. However,
8
+ # if you change any configuration or code from libraries loaded here, you'll
9
+ # need to restart spork for it take effect.
10
+
11
+ # Configure Rails Environment
12
+ ENV["RAILS_ENV"] = "test"
13
+
14
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
5
15
  #require "rails/spec_help"
6
16
 
7
- Rails.backtrace_cleaner.remove_silencers!
17
+ Rails.backtrace_cleaner.remove_silencers!
8
18
 
9
19
  # Load support files
10
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
20
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
11
21
 
12
22
  # Load Factories
13
- require 'factory_girl'
14
- Dir["#{File.dirname(__FILE__)}/factories/*.rb"].each {|f| require f}
23
+ require 'factory_girl'
24
+ Dir["#{File.dirname(__FILE__)}/factories/*.rb"].each {|f| require f}
15
25
 
16
26
  # Load fixtures from the engine
17
- if ActiveSupport::TestCase.method_defined?(:fixture_path=)
18
- ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
27
+ if ActiveSupport::TestCase.method_defined?(:fixture_path=)
28
+ ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
29
+ end
30
+
31
+ RSpec.configure do |config|
32
+ config.include SpecTestHelper#, :type => :controller
33
+ end
34
+
19
35
  end
20
36
 
21
- RSpec.configure do |config|
22
- config.include SpecTestHelper#, :type => :controller
37
+ Spork.each_run do
38
+ # This code will be run each time you run your specs.
39
+
23
40
  end
24
41
 
42
+ # --- Instructions ---
43
+ # Sort the contents of this file into a Spork.prefork and a Spork.each_run
44
+ # block.
45
+ #
46
+ # The Spork.prefork block is run only once when the spork server is started.
47
+ # You typically want to place most of your (slow) initializer code in here, in
48
+ # particular, require'ing any 3rd-party gems that you don't normally modify
49
+ # during development.
50
+ #
51
+ # The Spork.each_run block is run each time you run your specs. In case you
52
+ # need to load files that tend to change during development, require them here.
53
+ # With Rails, your application modules are loaded automatically, so sometimes
54
+ # this block can remain empty.
55
+ #
56
+ # Note: You can modify files loaded *from* the Spork.each_run block without
57
+ # restarting the spork server. However, this file itself will not be reloaded,
58
+ # so if you change any of the code inside the each_run block, you still need to
59
+ # restart the server. In general, if you have non-trivial code in this file,
60
+ # it's advisable to move it into a separate file so you can easily edit it
61
+ # without restarting spork. (For example, with RSpec, you could move
62
+ # non-trivial code into a file spec/support/my_helper.rb, making sure that the
63
+ # spec/support/* files are require'd from inside the each_run block.)
64
+ #
65
+ # Any code that is left outside the two blocks will be run during preforking
66
+ # *and* during each_run -- that's probably not what you want.
67
+ #
68
+ # These instructions should self-destruct in 10 seconds. If they don't, feel
69
+ # free to delete them.
70
+
71
+
25
72
 
26
73
  #
27
74
  #class ActiveSupport::TestCase
@@ -0,0 +1,29 @@
1
+ #require 'spec_helper'
2
+ #
3
+ #describe 'Versioning' do
4
+ #
5
+ # before do
6
+ # @user1 = FactoryGirl.create(:user)
7
+ # @user1_file = FactoryGirl.build(:rm_repo_file)
8
+ # @user1_file.owner = @user1
9
+ # @user1_file.save
10
+ # @user1_folder = FactoryGirl.build(:rm_repo_folder)
11
+ # @user1_folder.owner = @user1
12
+ # @user1_folder.save
13
+ # @user2 = FactoryGirl.create(:user)
14
+ #
15
+ # end
16
+ #
17
+ # it 'can versioning a file' do
18
+ # #p @user1_file.sender
19
+ # @user1.create_file!(File.open("#{Rails.root}/../fixture/textfile2.txt"), overwrite: true, sender: @user2, filename: 'textfile.txt')
20
+ # #p @user1_file.reload.sender
21
+ #
22
+ # #p @user1_file.reload.versions
23
+ # #p @user1.root_repo_items
24
+ # @user1_folder.name = 'Nouveau nom'
25
+ # @user1_folder.save!
26
+ # #p @user1_folder.reload.versions
27
+ # end
28
+ #
29
+ #end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: repository-manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.10
4
+ version: 0.2.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yves Baumann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-04 00:00:00.000000000 Z
11
+ date: 2015-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -190,6 +190,7 @@ files:
190
190
  - spec/dummy/db/migrate/20131016193834_create_groups.rb
191
191
  - spec/dummy/db/migrate/20131016194207_create_groups_users.rb
192
192
  - spec/dummy/db/migrate/20131018214212_create_repository_manager.rb
193
+ - spec/dummy/db/migrate/20140806000000_create_versions.rb
193
194
  - spec/dummy/doc/controllers_brief.svg
194
195
  - spec/dummy/doc/controllers_complete.svg
195
196
  - spec/dummy/doc/models_brief.svg
@@ -204,6 +205,9 @@ files:
204
205
  - spec/factories/repo_folder.rb
205
206
  - spec/factories/user.rb
206
207
  - spec/fixture/textfile.txt
208
+ - spec/fixture/textfile2.txt
209
+ - spec/fixture/textfile3.txt
210
+ - spec/fixture/textfile4.txt
207
211
  - spec/fixture/unzip.zip
208
212
  - spec/has_repository_spec.rb
209
213
  - spec/models/associations_spec.rb
@@ -213,6 +217,7 @@ files:
213
217
  - spec/spec_helper.rb
214
218
  - spec/support/spec_test_helper.rb
215
219
  - spec/unzip_spec.rb
220
+ - spec/versioning_spec.rb
216
221
  homepage: https://github.com/Texicitys/repository-manager
217
222
  licenses:
218
223
  - MIT
@@ -233,7 +238,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
233
238
  version: '0'
234
239
  requirements: []
235
240
  rubyforge_project:
236
- rubygems_version: 2.4.1
241
+ rubygems_version: 2.4.2
237
242
  signing_key:
238
243
  specification_version: 4
239
244
  summary: Ruby on Rails plugin (gem) for managing repositories ( files / folders /
@@ -270,6 +275,7 @@ test_files:
270
275
  - spec/dummy/db/migrate/20131016193834_create_groups.rb
271
276
  - spec/dummy/db/migrate/20131016194207_create_groups_users.rb
272
277
  - spec/dummy/db/migrate/20131018214212_create_repository_manager.rb
278
+ - spec/dummy/db/migrate/20140806000000_create_versions.rb
273
279
  - spec/dummy/doc/controllers_brief.svg
274
280
  - spec/dummy/doc/controllers_complete.svg
275
281
  - spec/dummy/doc/models_brief.svg
@@ -284,6 +290,9 @@ test_files:
284
290
  - spec/factories/repo_folder.rb
285
291
  - spec/factories/user.rb
286
292
  - spec/fixture/textfile.txt
293
+ - spec/fixture/textfile2.txt
294
+ - spec/fixture/textfile3.txt
295
+ - spec/fixture/textfile4.txt
287
296
  - spec/fixture/unzip.zip
288
297
  - spec/has_repository_spec.rb
289
298
  - spec/models/associations_spec.rb
@@ -293,3 +302,4 @@ test_files:
293
302
  - spec/spec_helper.rb
294
303
  - spec/support/spec_test_helper.rb
295
304
  - spec/unzip_spec.rb
305
+ - spec/versioning_spec.rb