Merge pull request #357 from warpc/263-refactoring
[Refs #263] Big lib code cleanup * Upgrade gems; * Upgrade FactoryGirl syntax; * Move code out from vendor/plugins, redo plugins structure; * Fix all deprecations; * Great refactor for lib and initializers folders; * Add magic encodings; * Fix some specs.
This commit is contained in:
commit
5aca4a0ea9
13
Gemfile
13
Gemfile
|
@ -22,8 +22,9 @@ gem 'jbuilder'
|
||||||
|
|
||||||
# gem 'rugged', '~> 0.16.0'
|
# gem 'rugged', '~> 0.16.0'
|
||||||
gem 'grack', :git => 'git://github.com/rdblue/grack.git', :require => 'git_http'
|
gem 'grack', :git => 'git://github.com/rdblue/grack.git', :require => 'git_http'
|
||||||
gem "grit", :git => 'git://github.com/chipiga/grit.git' #, :path => '~/Sites/code/grit'
|
gem "grit", :git => 'git://github.com/warpc/grit.git' #, :path => '~/Sites/code/grit'
|
||||||
gem 'charlock_holmes', '~> 0.6.8' #, :git => 'git://github.com/brianmario/charlock_holmes.git', :branch => 'bundle-icu'
|
gem 'charlock_holmes', '~> 0.6.8' #, :git => 'git://github.com/brianmario/charlock_holmes.git', :branch => 'bundle-icu'
|
||||||
|
gem 'diff-display', '~> 0.0.1'
|
||||||
|
|
||||||
# Wiki
|
# Wiki
|
||||||
gem "gollum", "1.3.1"
|
gem "gollum", "1.3.1"
|
||||||
|
@ -34,7 +35,7 @@ gem 'rdiscount'
|
||||||
gem 'RedCloth'
|
gem 'RedCloth'
|
||||||
gem 'wikicloth'
|
gem 'wikicloth'
|
||||||
|
|
||||||
gem 'unicorn', '~> 4.2.0', :platforms => [:mri, :rbx]
|
gem 'unicorn', '~> 4.2.1', :platforms => [:mri, :rbx]
|
||||||
gem 'trinidad', '~> 1.0.2', :platforms => :jruby
|
gem 'trinidad', '~> 1.0.2', :platforms => :jruby
|
||||||
gem 'newrelic_rpm', '~> 3.3.2', :platforms => [:mri, :rbx]
|
gem 'newrelic_rpm', '~> 3.3.2', :platforms => [:mri, :rbx]
|
||||||
gem 'whenever', '~> 0.7.3', :require => false
|
gem 'whenever', '~> 0.7.3', :require => false
|
||||||
|
@ -49,8 +50,8 @@ group :assets do
|
||||||
gem 'sass-rails', '~> 3.2.5'
|
gem 'sass-rails', '~> 3.2.5'
|
||||||
gem 'coffee-rails', '~> 3.2.2'
|
gem 'coffee-rails', '~> 3.2.2'
|
||||||
gem 'compass-rails', '~> 1.0.1'
|
gem 'compass-rails', '~> 1.0.1'
|
||||||
gem 'uglifier', '~> 1.2.1'
|
gem 'uglifier', '~> 1.2.4'
|
||||||
gem 'therubyracer', '~> 0.9.10', :platforms => [:mri, :rbx]
|
gem 'therubyracer', '~> 0.10.0', :platforms => [:mri, :rbx]
|
||||||
gem 'therubyrhino', '~> 1.73.1', :platforms => :jruby
|
gem 'therubyrhino', '~> 1.73.1', :platforms => :jruby
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -72,8 +73,8 @@ group :development do
|
||||||
end
|
end
|
||||||
|
|
||||||
group :test do
|
group :test do
|
||||||
gem 'rspec-rails', '~> 2.8.1'
|
gem 'rspec-rails', '~> 2.9.0', :group => 'development'
|
||||||
gem 'factory_girl_rails', '~> 1.7.0'
|
gem 'factory_girl_rails', '~> 3.0.0'
|
||||||
gem 'rr', '~> 1.0.4'
|
gem 'rr', '~> 1.0.4'
|
||||||
gem 'shoulda'
|
gem 'shoulda'
|
||||||
end
|
end
|
||||||
|
|
76
Gemfile.lock
76
Gemfile.lock
|
@ -1,12 +1,3 @@
|
||||||
GIT
|
|
||||||
remote: git://github.com/chipiga/grit.git
|
|
||||||
revision: 696b0967cb7e6bac044569d898e5acef431d4f97
|
|
||||||
specs:
|
|
||||||
grit (2.4.1)
|
|
||||||
diff-lcs (~> 1.1)
|
|
||||||
mime-types (~> 1.15)
|
|
||||||
posix-spawn (~> 0.3.6)
|
|
||||||
|
|
||||||
GIT
|
GIT
|
||||||
remote: git://github.com/chipiga/redhillonrails_core.git
|
remote: git://github.com/chipiga/redhillonrails_core.git
|
||||||
revision: 5f58167c41882890c223168b0a5521d99e8d92aa
|
revision: 5f58167c41882890c223168b0a5521d99e8d92aa
|
||||||
|
@ -21,6 +12,15 @@ GIT
|
||||||
specs:
|
specs:
|
||||||
grack (0.2.0)
|
grack (0.2.0)
|
||||||
|
|
||||||
|
GIT
|
||||||
|
remote: git://github.com/warpc/grit.git
|
||||||
|
revision: 696b0967cb7e6bac044569d898e5acef431d4f97
|
||||||
|
specs:
|
||||||
|
grit (2.4.1)
|
||||||
|
diff-lcs (~> 1.1)
|
||||||
|
mime-types (~> 1.15)
|
||||||
|
posix-spawn (~> 0.3.6)
|
||||||
|
|
||||||
GEM
|
GEM
|
||||||
remote: http://rubygems.org/
|
remote: http://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
|
@ -108,6 +108,7 @@ GEM
|
||||||
orm_adapter (~> 0.0.3)
|
orm_adapter (~> 0.0.3)
|
||||||
railties (~> 3.1)
|
railties (~> 3.1)
|
||||||
warden (~> 1.1.1)
|
warden (~> 1.1.1)
|
||||||
|
diff-display (0.0.1)
|
||||||
diff-lcs (1.1.3)
|
diff-lcs (1.1.3)
|
||||||
erubis (2.7.0)
|
erubis (2.7.0)
|
||||||
eventmachine (0.12.10)
|
eventmachine (0.12.10)
|
||||||
|
@ -115,10 +116,10 @@ GEM
|
||||||
execjs (1.3.0)
|
execjs (1.3.0)
|
||||||
multi_json (~> 1.0)
|
multi_json (~> 1.0)
|
||||||
expression_parser (0.9.0)
|
expression_parser (0.9.0)
|
||||||
factory_girl (2.6.4)
|
factory_girl (3.0.0)
|
||||||
activesupport (>= 2.3.9)
|
activesupport (>= 3.0.0)
|
||||||
factory_girl_rails (1.7.0)
|
factory_girl_rails (3.0.0)
|
||||||
factory_girl (~> 2.6.0)
|
factory_girl (~> 3.0.0)
|
||||||
railties (>= 3.0.0)
|
railties (>= 3.0.0)
|
||||||
fssm (0.2.8.1)
|
fssm (0.2.8.1)
|
||||||
github-markup (0.7.1)
|
github-markup (0.7.1)
|
||||||
|
@ -150,15 +151,15 @@ GEM
|
||||||
railties (>= 3.2.0, < 5.0)
|
railties (>= 3.2.0, < 5.0)
|
||||||
thor (~> 0.14)
|
thor (~> 0.14)
|
||||||
jruby-rack (1.1.4)
|
jruby-rack (1.1.4)
|
||||||
json (1.6.5)
|
json (1.6.6)
|
||||||
json (1.6.5-java)
|
json (1.6.6-java)
|
||||||
kgio (2.7.3)
|
kgio (2.7.4)
|
||||||
libv8 (3.3.10.4)
|
libv8 (3.3.10.4)
|
||||||
mail (2.4.4)
|
mail (2.4.4)
|
||||||
i18n (>= 0.4.0)
|
i18n (>= 0.4.0)
|
||||||
mime-types (~> 1.16)
|
mime-types (~> 1.16)
|
||||||
treetop (~> 1.4.8)
|
treetop (~> 1.4.8)
|
||||||
mailcatcher (0.5.5)
|
mailcatcher (0.5.6)
|
||||||
activesupport (~> 3.0)
|
activesupport (~> 3.0)
|
||||||
eventmachine (~> 0.12)
|
eventmachine (~> 0.12)
|
||||||
haml (~> 3.1)
|
haml (~> 3.1)
|
||||||
|
@ -170,7 +171,7 @@ GEM
|
||||||
meta-tags (1.2.6)
|
meta-tags (1.2.6)
|
||||||
actionpack
|
actionpack
|
||||||
mime-types (1.18)
|
mime-types (1.18)
|
||||||
multi_json (1.1.0)
|
multi_json (1.2.0)
|
||||||
mustache (0.99.4)
|
mustache (0.99.4)
|
||||||
net-scp (1.0.4)
|
net-scp (1.0.4)
|
||||||
net-ssh (>= 1.99.1)
|
net-ssh (>= 1.99.1)
|
||||||
|
@ -188,7 +189,7 @@ GEM
|
||||||
omniauth-openid (1.0.1)
|
omniauth-openid (1.0.1)
|
||||||
omniauth (~> 1.0)
|
omniauth (~> 1.0)
|
||||||
rack-openid (~> 1.3.1)
|
rack-openid (~> 1.3.1)
|
||||||
orm_adapter (0.0.6)
|
orm_adapter (0.0.7)
|
||||||
paperclip (2.7.0)
|
paperclip (2.7.0)
|
||||||
activerecord (>= 2.3.0)
|
activerecord (>= 2.3.0)
|
||||||
activesupport (>= 2.3.2)
|
activesupport (>= 2.3.2)
|
||||||
|
@ -235,19 +236,19 @@ GEM
|
||||||
json (~> 1.4)
|
json (~> 1.4)
|
||||||
redcarpet (1.17.2)
|
redcarpet (1.17.2)
|
||||||
rr (1.0.4)
|
rr (1.0.4)
|
||||||
rspec (2.8.0)
|
rspec (2.9.0)
|
||||||
rspec-core (~> 2.8.0)
|
rspec-core (~> 2.9.0)
|
||||||
rspec-expectations (~> 2.8.0)
|
rspec-expectations (~> 2.9.0)
|
||||||
rspec-mocks (~> 2.8.0)
|
rspec-mocks (~> 2.9.0)
|
||||||
rspec-core (2.8.0)
|
rspec-core (2.9.0)
|
||||||
rspec-expectations (2.8.0)
|
rspec-expectations (2.9.0)
|
||||||
diff-lcs (~> 1.1.2)
|
diff-lcs (~> 1.1.3)
|
||||||
rspec-mocks (2.8.0)
|
rspec-mocks (2.9.0)
|
||||||
rspec-rails (2.8.1)
|
rspec-rails (2.9.0)
|
||||||
actionpack (>= 3.0)
|
actionpack (>= 3.0)
|
||||||
activesupport (>= 3.0)
|
activesupport (>= 3.0)
|
||||||
railties (>= 3.0)
|
railties (>= 3.0)
|
||||||
rspec (~> 2.8.0)
|
rspec (~> 2.9.0)
|
||||||
ruby-openid (2.1.8)
|
ruby-openid (2.1.8)
|
||||||
russian (0.6.0)
|
russian (0.6.0)
|
||||||
i18n (>= 0.5.0)
|
i18n (>= 0.5.0)
|
||||||
|
@ -278,7 +279,7 @@ GEM
|
||||||
tilt (~> 1.1, != 1.3.0)
|
tilt (~> 1.1, != 1.3.0)
|
||||||
sqlite3 (1.3.5)
|
sqlite3 (1.3.5)
|
||||||
state_machine (1.1.2)
|
state_machine (1.1.2)
|
||||||
therubyracer (0.9.10)
|
therubyracer (0.10.0)
|
||||||
libv8 (~> 3.3.10)
|
libv8 (~> 3.3.10)
|
||||||
therubyrhino (1.73.1)
|
therubyrhino (1.73.1)
|
||||||
thin (1.3.1)
|
thin (1.3.1)
|
||||||
|
@ -295,10 +296,10 @@ GEM
|
||||||
trinidad_jars (>= 0.3.0)
|
trinidad_jars (>= 0.3.0)
|
||||||
trinidad_jars (1.0.2)
|
trinidad_jars (1.0.2)
|
||||||
tzinfo (0.3.32)
|
tzinfo (0.3.32)
|
||||||
uglifier (1.2.3)
|
uglifier (1.2.4)
|
||||||
execjs (>= 0.3.0)
|
execjs (>= 0.3.0)
|
||||||
multi_json (>= 1.0.2)
|
multi_json (>= 1.0.2)
|
||||||
unicorn (4.2.0)
|
unicorn (4.2.1)
|
||||||
kgio (~> 2.6)
|
kgio (~> 2.6)
|
||||||
rack
|
rack
|
||||||
raindrops (~> 0.7)
|
raindrops (~> 0.7)
|
||||||
|
@ -332,7 +333,8 @@ DEPENDENCIES
|
||||||
daemons (= 1.1.6)
|
daemons (= 1.1.6)
|
||||||
delayed_job_active_record (~> 0.3.2)
|
delayed_job_active_record (~> 0.3.2)
|
||||||
devise (~> 2.0.4)
|
devise (~> 2.0.4)
|
||||||
factory_girl_rails (~> 1.7.0)
|
diff-display (~> 0.0.1)
|
||||||
|
factory_girl_rails (~> 3.0.0)
|
||||||
gollum (= 1.3.1)
|
gollum (= 1.3.1)
|
||||||
grack!
|
grack!
|
||||||
grit!
|
grit!
|
||||||
|
@ -355,16 +357,16 @@ DEPENDENCIES
|
||||||
redcarpet (= 1.17.2)
|
redcarpet (= 1.17.2)
|
||||||
redhillonrails_core!
|
redhillonrails_core!
|
||||||
rr (~> 1.0.4)
|
rr (~> 1.0.4)
|
||||||
rspec-rails (~> 2.8.1)
|
rspec-rails (~> 2.9.0)
|
||||||
russian (~> 0.6.0)
|
russian (~> 0.6.0)
|
||||||
sass-rails (~> 3.2.5)
|
sass-rails (~> 3.2.5)
|
||||||
shotgun
|
shotgun
|
||||||
shoulda
|
shoulda
|
||||||
therubyracer (~> 0.9.10)
|
therubyracer (~> 0.10.0)
|
||||||
therubyrhino (~> 1.73.1)
|
therubyrhino (~> 1.73.1)
|
||||||
trinidad (~> 1.0.2)
|
trinidad (~> 1.0.2)
|
||||||
uglifier (~> 1.2.1)
|
uglifier (~> 1.2.4)
|
||||||
unicorn (~> 4.2.0)
|
unicorn (~> 4.2.1)
|
||||||
whenever (~> 0.7.3)
|
whenever (~> 0.7.3)
|
||||||
wikicloth
|
wikicloth
|
||||||
will_paginate (~> 3.0.3)
|
will_paginate (~> 3.0.3)
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
# -*- encoding : utf-8 -*-
|
|
||||||
Rails.application.config.generators do |g|
|
|
||||||
g.test_framework = :rspec
|
|
||||||
end
|
|
|
@ -5,5 +5,14 @@
|
||||||
# Mime::Type.register "text/richtext", :rtf
|
# Mime::Type.register "text/richtext", :rtf
|
||||||
# Mime::Type.register_alias "text/html", :iphone
|
# Mime::Type.register_alias "text/html", :iphone
|
||||||
|
|
||||||
Mime::Type.register "text/plain", :diff
|
Mime::Type.register "text/plain", 'diff'
|
||||||
Mime::Type.register "text/plain", :patch
|
Mime::Type.register "text/plain", 'patch'
|
||||||
|
|
||||||
|
# add rpm spec as mime type for *.spec files
|
||||||
|
[["text/x-python", ['py'], '8bit'],
|
||||||
|
["text/x-rpm-spec", ['spec'], '8bit'],
|
||||||
|
["text/x-csrc", ['h', 'c'], '8bit'],
|
||||||
|
["text/x-c++src", ['cpp'], '8bit']
|
||||||
|
].each do |type|
|
||||||
|
MIME::Types.add MIME::Type.from_array(type)
|
||||||
|
end
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
# -*- encoding : utf-8 -*-
|
|
||||||
require './lib/rosa_presenter/rosa_presenter'
|
|
|
@ -1,35 +1,12 @@
|
||||||
# -*- encoding : utf-8 -*-
|
# -*- encoding : utf-8 -*-
|
||||||
APP_CONFIG = YAML.load_file("#{Rails.root}/config/application.yml")[Rails.env]
|
APP_CONFIG = YAML.load_file("#{Rails.root}/config/application.yml")[Rails.env]
|
||||||
|
|
||||||
|
Dir[Rails.root.join("lib/ext/**/*.rb")].each {|f| require f}
|
||||||
require 'modules'
|
require 'modules'
|
||||||
|
require 'plugins'
|
||||||
|
|
||||||
# Setup Smart HTTP GRack
|
# Setup Smart HTTP GRack
|
||||||
require 'grack'
|
|
||||||
config = {:project_root => File.join(APP_CONFIG['root_path'], 'git_projects'), :git_path => 'git', :upload_pack => true, :receive_pack => true}
|
config = {:project_root => File.join(APP_CONFIG['root_path'], 'git_projects'), :git_path => 'git', :upload_pack => true, :receive_pack => true}
|
||||||
# Rosa::Application.config.middleware.insert_before 0, ::Grack::Handler, config
|
# Rosa::Application.config.middleware.insert_before 0, ::Grack::Handler, config
|
||||||
Rosa::Application.config.middleware.insert_after ::Rails::Rack::Logger, ::Grack::Handler, config
|
Rosa::Application.config.middleware.insert_after ::Rails::Rack::Logger, ::Grack::Handler, config
|
||||||
Rosa::Application.config.middleware.insert_before ::Grack::Handler, ::Grack::Auth
|
Rosa::Application.config.middleware.insert_before ::Grack::Handler, ::Grack::Auth
|
||||||
|
|
||||||
Grit::Git.git_timeout = 60
|
|
||||||
# Grit.debug = true
|
|
||||||
GAP_REPO_PATH = '/tmp/gap_repo.git'
|
|
||||||
unless File.directory? GAP_REPO_PATH
|
|
||||||
Grit::Repo.init_bare(GAP_REPO_PATH)
|
|
||||||
# FileUtils.chmod "a-w", GAP_REPO_PATH
|
|
||||||
end
|
|
||||||
|
|
||||||
Dir[Rails.root.join("lib/ext/**/*.rb")].each {|f| require f}
|
|
||||||
|
|
||||||
# add rpm spec as mime type for *.spec files
|
|
||||||
types = [
|
|
||||||
["text/x-python", ['py'], '8bit'],
|
|
||||||
["text/x-rpm-spec", ['spec'], '8bit'],
|
|
||||||
["text/x-csrc", ['h', 'c'], '8bit'],
|
|
||||||
["text/x-c++src", ['cpp'], '8bit']
|
|
||||||
]
|
|
||||||
types.each do |type|
|
|
||||||
MIME::Types.add MIME::Type.from_array(type)
|
|
||||||
end
|
|
||||||
|
|
||||||
# load datatables plugin
|
|
||||||
require Rails.root.join("lib/rails_datatables")
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
# -*- encoding : utf-8 -*-
|
||||||
class AddConfirmableToUsers < ActiveRecord::Migration
|
class AddConfirmableToUsers < ActiveRecord::Migration
|
||||||
def self.up
|
def self.up
|
||||||
add_column :users, :confirmation_token, :string
|
add_column :users, :confirmation_token, :string
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
# -*- encoding : utf-8 -*-
|
||||||
class ConfirmAllRegisteredUsers < ActiveRecord::Migration
|
class ConfirmAllRegisteredUsers < ActiveRecord::Migration
|
||||||
def up
|
def up
|
||||||
User.all.each { |user| user.confirm! }
|
User.all.each { |user| user.confirm! }
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
# -*- encoding : utf-8 -*-
|
||||||
class RemoveAutoBuildList < ActiveRecord::Migration
|
class RemoveAutoBuildList < ActiveRecord::Migration
|
||||||
def self.up
|
def self.up
|
||||||
drop_table :auto_build_lists
|
drop_table :auto_build_lists
|
||||||
|
@ -13,4 +14,4 @@ class RemoveAutoBuildList < ActiveRecord::Migration
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
# -*- encoding : utf-8 -*-
|
||||||
class DeleteCategories < ActiveRecord::Migration
|
class DeleteCategories < ActiveRecord::Migration
|
||||||
def self.up
|
def self.up
|
||||||
remove_column :projects, :category_id
|
remove_column :projects, :category_id
|
||||||
|
@ -14,4 +15,4 @@ class DeleteCategories < ActiveRecord::Migration
|
||||||
end
|
end
|
||||||
add_column :projects, :category_id, :integer
|
add_column :projects, :category_id, :integer
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
10
db/schema.rb
10
db/schema.rb
|
@ -1,4 +1,4 @@
|
||||||
# encoding: UTF-8
|
# -*- encoding : utf-8 -*-
|
||||||
# This file is auto-generated from the current state of the database. Instead
|
# This file is auto-generated from the current state of the database. Instead
|
||||||
# of editing this file, please use the migrations feature of Active Record to
|
# of editing this file, please use the migrations feature of Active Record to
|
||||||
# incrementally modify your database, and then regenerate this schema definition.
|
# incrementally modify your database, and then regenerate this schema definition.
|
||||||
|
@ -17,8 +17,8 @@ ActiveRecord::Schema.define(:version => 20120329182602) do
|
||||||
t.integer "user_id", :null => false
|
t.integer "user_id", :null => false
|
||||||
t.string "kind"
|
t.string "kind"
|
||||||
t.text "data"
|
t.text "data"
|
||||||
t.datetime "created_at"
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at", :null => false
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "arches", :force => true do |t|
|
create_table "arches", :force => true do |t|
|
||||||
|
@ -351,16 +351,16 @@ ActiveRecord::Schema.define(:version => 20120329182602) do
|
||||||
t.string "name"
|
t.string "name"
|
||||||
t.string "email", :default => "", :null => false
|
t.string "email", :default => "", :null => false
|
||||||
t.string "encrypted_password", :limit => 128, :default => "", :null => false
|
t.string "encrypted_password", :limit => 128, :default => "", :null => false
|
||||||
t.string "password_salt", :default => "", :null => false
|
|
||||||
t.string "reset_password_token"
|
t.string "reset_password_token"
|
||||||
t.datetime "remember_created_at"
|
t.datetime "remember_created_at"
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
|
t.text "ssh_key"
|
||||||
t.string "uname"
|
t.string "uname"
|
||||||
t.string "role"
|
t.string "role"
|
||||||
t.string "language", :default => "en"
|
t.string "language", :default => "en"
|
||||||
t.integer "own_projects_count", :default => 0, :null => false
|
|
||||||
t.datetime "reset_password_sent_at"
|
t.datetime "reset_password_sent_at"
|
||||||
|
t.integer "own_projects_count", :default => 0, :null => false
|
||||||
t.text "professional_experience"
|
t.text "professional_experience"
|
||||||
t.string "site"
|
t.string "site"
|
||||||
t.string "company"
|
t.string "company"
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
# -*- encoding : utf-8 -*-
|
# -*- encoding : utf-8 -*-
|
||||||
# # -*- encoding : utf-8 -*-
|
|
||||||
module Gollum
|
module Gollum
|
||||||
class Wiki
|
class Wiki
|
||||||
# Public: Applies a reverse diff for a given page. If only 1 SHA is given,
|
# Public: Applies a reverse diff for a given page. If only 1 SHA is given,
|
|
@ -1,6 +1,4 @@
|
||||||
# -*- encoding : utf-8 -*-
|
# -*- encoding : utf-8 -*-
|
||||||
# -*- ruby encoding: utf-8 -*-
|
|
||||||
|
|
||||||
module Grit
|
module Grit
|
||||||
class Blob
|
class Blob
|
||||||
|
|
||||||
|
@ -48,3 +46,11 @@ module Grit
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Grit::Git.git_timeout = 60
|
||||||
|
# Grit.debug = true
|
||||||
|
GAP_REPO_PATH = '/tmp/gap_repo.git'
|
||||||
|
unless File.directory? GAP_REPO_PATH
|
||||||
|
Grit::Repo.init_bare(GAP_REPO_PATH)
|
||||||
|
# FileUtils.chmod "a-w", GAP_REPO_PATH
|
||||||
|
end
|
|
@ -6,7 +6,5 @@ module Modules
|
||||||
|
|
||||||
module Models
|
module Models
|
||||||
extend ActiveSupport::Autoload
|
extend ActiveSupport::Autoload
|
||||||
|
|
||||||
autoload :Owner
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,9 +8,6 @@ module Modules
|
||||||
after_create lambda { relations.create :object_id => owner.id, :object_type => owner.class.to_s, :role => 'admin' }
|
after_create lambda { relations.create :object_id => owner.id, :object_type => owner.class.to_s, :role => 'admin' }
|
||||||
end
|
end
|
||||||
|
|
||||||
module InstanceMethods
|
|
||||||
end
|
|
||||||
|
|
||||||
module ClassMethods
|
module ClassMethods
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,30 +8,28 @@ module Modules
|
||||||
after_create :create_personal_repository
|
after_create :create_personal_repository
|
||||||
end
|
end
|
||||||
|
|
||||||
module InstanceMethods
|
def create_personal_repository
|
||||||
def create_personal_repository
|
pl = platforms.build
|
||||||
pl = platforms.build
|
pl.owner = self
|
||||||
pl.owner = self
|
pl.name = "#{self.uname}_personal"
|
||||||
pl.name = "#{self.uname}_personal"
|
pl.description = "#{self.uname}_personal"
|
||||||
pl.description = "#{self.uname}_personal"
|
pl.platform_type = 'personal'
|
||||||
pl.platform_type = 'personal'
|
pl.distrib_type = APP_CONFIG['distr_types'].first
|
||||||
pl.distrib_type = APP_CONFIG['distr_types'].first
|
pl.visibility = 'open'
|
||||||
pl.visibility = 'open'
|
pl.save!
|
||||||
pl.save!
|
|
||||||
|
|
||||||
rep = pl.repositories.build
|
rep = pl.repositories.build
|
||||||
rep.name = 'main'
|
rep.name = 'main'
|
||||||
rep.description = 'main'
|
rep.description = 'main'
|
||||||
rep.save!
|
rep.save!
|
||||||
end
|
end
|
||||||
|
|
||||||
def personal_platform
|
def personal_platform
|
||||||
platforms.personal.first
|
platforms.personal.first
|
||||||
end
|
end
|
||||||
|
|
||||||
def personal_repository
|
def personal_repository
|
||||||
personal_platform.repositories.first
|
personal_platform.repositories.first
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
module ClassMethods
|
module ClassMethods
|
||||||
|
|
|
@ -18,9 +18,6 @@ module Modules
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
module InstanceMethods
|
|
||||||
end
|
|
||||||
|
|
||||||
module ClassMethods
|
module ClassMethods
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
# -*- encoding : utf-8 -*-
|
||||||
|
Dir[File.join(File.dirname(__FILE__), 'plugins', '*.rb')].each do |f|
|
||||||
|
$:.unshift File.dirname(f)
|
||||||
|
require f
|
||||||
|
end
|
|
@ -1,3 +1,4 @@
|
||||||
# -*- encoding : utf-8 -*-
|
# -*- encoding : utf-8 -*-
|
||||||
require Rails.root.join('lib/rails_datatables/rails_datatables')
|
require_relative 'rails_datatables/rails_datatables'
|
||||||
|
|
||||||
ActionView::Base.send :include, RailsDatatables
|
ActionView::Base.send :include, RailsDatatables
|
|
@ -17,4 +17,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@ -135,4 +135,4 @@ There is a more functionality offered by DataTables than this plugin currently p
|
||||||
|
|
||||||
### Credits
|
### Credits
|
||||||
|
|
||||||
Copyright (c) 2009 [Phronos](http://phronos.com), released under the MIT license
|
Copyright (c) 2009 [Phronos](http://phronos.com), released under the MIT license
|
|
@ -0,0 +1,17 @@
|
||||||
|
# -*- encoding : utf-8 -*-
|
||||||
|
module RelatedModels
|
||||||
|
extend ActiveSupport::Autoload
|
||||||
|
|
||||||
|
autoload :ClassMethods
|
||||||
|
autoload :BelongsToHelpers
|
||||||
|
autoload :PolymorphicHelpers
|
||||||
|
autoload :UrlHelpers
|
||||||
|
autoload :Base
|
||||||
|
end
|
||||||
|
|
||||||
|
class ActionController::Base
|
||||||
|
#include ClassMethods
|
||||||
|
def self.is_related_controller!
|
||||||
|
RelatedModels::Base.is_child!(self)
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,11 @@
|
||||||
|
# -*- encoding : utf-8 -*-
|
||||||
|
module RosaPresenter
|
||||||
|
extend ActiveSupport::Autoload
|
||||||
|
|
||||||
|
autoload :Activation
|
||||||
|
autoload :Base
|
||||||
|
|
||||||
|
VERSION = "0.0.1"
|
||||||
|
end
|
||||||
|
|
||||||
|
ActionController::Base.send(:include, RosaPresenter::Activation)
|
|
@ -13,5 +13,3 @@ module RosaPresenter
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
ActionController::Base.send(:include, RosaPresenter::Activation)
|
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
# -*- encoding : utf-8 -*-
|
|
||||||
require File.dirname(__FILE__) + "/lib/activation"
|
|
||||||
require File.dirname(__FILE__) + "/lib/base"
|
|
||||||
|
|
||||||
module RosaPresenter
|
|
||||||
VERSION = "0.0.1"
|
|
||||||
end
|
|
|
@ -68,7 +68,7 @@ describe BuildListsController do
|
||||||
|
|
||||||
context 'crud' do
|
context 'crud' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
platform = Factory(:platform_with_repos)
|
platform = FactoryGirl.create(:platform_with_repos)
|
||||||
@create_params = {
|
@create_params = {
|
||||||
:build_list => {
|
:build_list => {
|
||||||
:project_version => 'latest_master',
|
:project_version => 'latest_master',
|
||||||
|
@ -76,7 +76,7 @@ describe BuildListsController do
|
||||||
:update_type => 'security',
|
:update_type => 'security',
|
||||||
:include_repos => [platform.repositories.first.id]
|
:include_repos => [platform.repositories.first.id]
|
||||||
},
|
},
|
||||||
:arches => [Factory(:arch).id],
|
:arches => [FactoryGirl.create(:arch).id],
|
||||||
:bpls => [platform.id]
|
:bpls => [platform.id]
|
||||||
}
|
}
|
||||||
any_instance_of(Project, :versions => ['v1.0', 'v2.0'])
|
any_instance_of(Project, :versions => ['v1.0', 'v2.0'])
|
||||||
|
@ -91,24 +91,24 @@ describe BuildListsController do
|
||||||
|
|
||||||
context 'for user' do
|
context 'for user' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@build_list = Factory(:build_list_core)
|
@build_list = FactoryGirl.create(:build_list_core)
|
||||||
@project = @build_list.project
|
@project = @build_list.project
|
||||||
@owner_user = @project.owner
|
@owner_user = @project.owner
|
||||||
@member_user = Factory(:user)
|
@member_user = FactoryGirl.create(:user)
|
||||||
rel = @project.relations.build(:role => 'reader')
|
rel = @project.relations.build(:role => 'reader')
|
||||||
rel.object = @member_user
|
rel.object = @member_user
|
||||||
rel.save
|
rel.save
|
||||||
@user = Factory(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
set_session_for(@user)
|
set_session_for(@user)
|
||||||
@show_params = {:project_id => @project.id, :id => @build_list.id}
|
@show_params = {:project_id => @project.id, :id => @build_list.id}
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'for all build lists' do
|
context 'for all build lists' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@build_list1 = Factory(:build_list_core)
|
@build_list1 = FactoryGirl.create(:build_list_core)
|
||||||
@build_list2 = Factory(:build_list_core, :project => Factory(:project, :visibility => 'hidden'))
|
@build_list2 = FactoryGirl.create(:build_list_core, :project => FactoryGirl.create(:project, :visibility => 'hidden'))
|
||||||
@build_list3 = Factory(:build_list_core, :project => Factory(:project, :owner => @user, :visibility => 'hidden'))
|
@build_list3 = FactoryGirl.create(:build_list_core, :project => FactoryGirl.create(:project, :owner => @user, :visibility => 'hidden'))
|
||||||
@build_list4 = Factory(:build_list_core, :project => Factory(:project, :visibility => 'hidden'))
|
@build_list4 = FactoryGirl.create(:build_list_core, :project => FactoryGirl.create(:project, :visibility => 'hidden'))
|
||||||
@build_list4.project.relations.create :role => 'reader', :object_id => @user.id, :object_type => 'User'
|
@build_list4.project.relations.create :role => 'reader', :object_id => @user.id, :object_type => 'User'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -168,21 +168,21 @@ describe BuildListsController do
|
||||||
|
|
||||||
context 'for group' do
|
context 'for group' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@owner_group = Factory(:group)
|
@owner_group = FactoryGirl.create(:group)
|
||||||
@owner_user = Factory(:user)
|
@owner_user = FactoryGirl.create(:user)
|
||||||
@owner_group.objects.create :role => 'reader', :object_id => @owner_user.id, :object_type => 'User'
|
@owner_group.objects.create :role => 'reader', :object_id => @owner_user.id, :object_type => 'User'
|
||||||
@member_group = Factory(:group)
|
@member_group = FactoryGirl.create(:group)
|
||||||
@member_user = Factory(:user)
|
@member_user = FactoryGirl.create(:user)
|
||||||
@member_group.objects.create :role => 'reader', :object_id => @member_user.id, :object_type => 'User'
|
@member_group.objects.create :role => 'reader', :object_id => @member_user.id, :object_type => 'User'
|
||||||
|
|
||||||
@group = Factory(:group)
|
@group = FactoryGirl.create(:group)
|
||||||
@user = Factory(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
@group.objects.create :role => 'reader', :object_id => @user.id, :object_type => 'User'
|
@group.objects.create :role => 'reader', :object_id => @user.id, :object_type => 'User'
|
||||||
|
|
||||||
@project = Factory(:project, :owner => @owner_group)
|
@project = FactoryGirl.create(:project, :owner => @owner_group)
|
||||||
@project.relations.create :role => 'reader', :object_id => @member_group.id, :object_type => 'Group'
|
@project.relations.create :role => 'reader', :object_id => @member_group.id, :object_type => 'Group'
|
||||||
|
|
||||||
@build_list = Factory(:build_list_core, :project => @project)
|
@build_list = FactoryGirl.create(:build_list_core, :project => @project)
|
||||||
|
|
||||||
set_session_for(@user)
|
set_session_for(@user)
|
||||||
@show_params = {:project_id => @project.id, :id => @build_list.id}
|
@show_params = {:project_id => @project.id, :id => @build_list.id}
|
||||||
|
@ -190,10 +190,10 @@ describe BuildListsController do
|
||||||
|
|
||||||
context 'for all build lists' do
|
context 'for all build lists' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@build_list1 = Factory(:build_list_core)
|
@build_list1 = FactoryGirl.create(:build_list_core)
|
||||||
@build_list2 = Factory(:build_list_core, :project => Factory(:project, :visibility => 'hidden'))
|
@build_list2 = FactoryGirl.create(:build_list_core, :project => FactoryGirl.create(:project, :visibility => 'hidden'))
|
||||||
@build_list3 = Factory(:build_list_core, :project => Factory(:project, :owner => @group, :visibility => 'hidden'))
|
@build_list3 = FactoryGirl.create(:build_list_core, :project => FactoryGirl.create(:project, :owner => @group, :visibility => 'hidden'))
|
||||||
@build_list4 = Factory(:build_list_core, :project => Factory(:project, :visibility => 'hidden'))
|
@build_list4 = FactoryGirl.create(:build_list_core, :project => FactoryGirl.create(:project, :visibility => 'hidden'))
|
||||||
@build_list4.project.relations.create :role => 'reader', :object_id => @group.id, :object_type => 'Group'
|
@build_list4.project.relations.create :role => 'reader', :object_id => @group.id, :object_type => 'Group'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -253,7 +253,7 @@ describe BuildListsController do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'for admin' do
|
context 'for admin' do
|
||||||
before(:each) { set_session_for Factory(:admin) }
|
before(:each) { set_session_for FactoryGirl.create(:admin) }
|
||||||
|
|
||||||
it "should be able to perform index action without exception" do
|
it "should be able to perform index action without exception" do
|
||||||
any_instance_of(XMLRPC::Client) do |xml_rpc|
|
any_instance_of(XMLRPC::Client) do |xml_rpc|
|
||||||
|
@ -271,12 +271,12 @@ describe BuildListsController do
|
||||||
context 'filter' do
|
context 'filter' do
|
||||||
|
|
||||||
before(:each) do
|
before(:each) do
|
||||||
set_session_for Factory(:admin)
|
set_session_for FactoryGirl.create(:admin)
|
||||||
|
|
||||||
@build_list1 = Factory(:build_list_core)
|
@build_list1 = FactoryGirl.create(:build_list_core)
|
||||||
@build_list2 = Factory(:build_list_core)
|
@build_list2 = FactoryGirl.create(:build_list_core)
|
||||||
@build_list3 = Factory(:build_list_core)
|
@build_list3 = FactoryGirl.create(:build_list_core)
|
||||||
@build_list4 = Factory(:build_list_core, :created_at => (Time.now - 1.day),
|
@build_list4 = FactoryGirl.create(:build_list_core, :created_at => (Time.now - 1.day),
|
||||||
:project => @build_list3.project, :pl => @build_list3.pl,
|
:project => @build_list3.project, :pl => @build_list3.pl,
|
||||||
:arch => @build_list3.arch)
|
:arch => @build_list3.arch)
|
||||||
end
|
end
|
||||||
|
@ -310,7 +310,7 @@ describe BuildListsController do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'callbacks' do
|
context 'callbacks' do
|
||||||
let(:build_list) { Factory(:build_list_core) }
|
let(:build_list) { FactoryGirl.create(:build_list_core) }
|
||||||
|
|
||||||
describe 'publish_build' do
|
describe 'publish_build' do
|
||||||
before { test_git_commit(build_list.project); build_list.update_attribute :commit_hash, build_list.project.git_repository.commits('master').last.id }
|
before { test_git_commit(build_list.project); build_list.update_attribute :commit_hash, build_list.project.git_repository.commits('master').last.id }
|
||||||
|
|
|
@ -38,8 +38,8 @@ end
|
||||||
describe CollaboratorsController do
|
describe CollaboratorsController do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
stub_rsync_methods
|
stub_rsync_methods
|
||||||
@project = Factory(:project)
|
@project = FactoryGirl.create(:project)
|
||||||
@another_user = Factory(:user)
|
@another_user = FactoryGirl.create(:user)
|
||||||
@update_params = {:user => {@another_user.id => :reader}}
|
@update_params = {:user => {@another_user.id => :reader}}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ describe CollaboratorsController do
|
||||||
|
|
||||||
context 'for global admin' do
|
context 'for global admin' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@admin = Factory(:admin)
|
@admin = FactoryGirl.create(:admin)
|
||||||
set_session_for(@admin)
|
set_session_for(@admin)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -66,10 +66,10 @@ describe CollaboratorsController do
|
||||||
|
|
||||||
context 'for admin user' do
|
context 'for admin user' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = Factory(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
@user.relations
|
@user.relations
|
||||||
set_session_for(@user)
|
set_session_for(@user)
|
||||||
@group = Factory(:group)
|
@group = FactoryGirl.create(:group)
|
||||||
@project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin')
|
@project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ describe CollaboratorsController do
|
||||||
|
|
||||||
context 'for owner user' do
|
context 'for owner user' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = Factory(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
set_session_for(@user)
|
set_session_for(@user)
|
||||||
@project.update_attribute(:owner, @user)
|
@project.update_attribute(:owner, @user)
|
||||||
@project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin')
|
@project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin')
|
||||||
|
@ -102,7 +102,7 @@ describe CollaboratorsController do
|
||||||
|
|
||||||
context 'for reader user' do
|
context 'for reader user' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = Factory(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
set_session_for(@user)
|
set_session_for(@user)
|
||||||
@project.update_attribute(:owner, @user)
|
@project.update_attribute(:owner, @user)
|
||||||
@project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'reader')
|
@project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'reader')
|
||||||
|
@ -113,7 +113,7 @@ describe CollaboratorsController do
|
||||||
|
|
||||||
context 'for writer user' do
|
context 'for writer user' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = Factory(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
set_session_for(@user)
|
set_session_for(@user)
|
||||||
@project.update_attribute(:owner, @user)
|
@project.update_attribute(:owner, @user)
|
||||||
@project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'writer')
|
@project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'writer')
|
||||||
|
|
|
@ -79,7 +79,7 @@ end
|
||||||
describe CommentsController do
|
describe CommentsController do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
stub_rsync_methods
|
stub_rsync_methods
|
||||||
@project = Factory(:project)
|
@project = FactoryGirl.create(:project)
|
||||||
%x(cp -Rf #{Rails.root}/spec/tests.git/* #{@project.git_repository.path}) # maybe FIXME ?
|
%x(cp -Rf #{Rails.root}/spec/tests.git/* #{@project.git_repository.path}) # maybe FIXME ?
|
||||||
@commit = @project.git_repository.commits.first
|
@commit = @project.git_repository.commits.first
|
||||||
|
|
||||||
|
@ -87,8 +87,8 @@ describe CommentsController do
|
||||||
@update_params = {:comment => {:body => 'updated'}, :project_id => @project.id, :commit_id => @commit.id}
|
@update_params = {:comment => {:body => 'updated'}, :project_id => @project.id, :commit_id => @commit.id}
|
||||||
|
|
||||||
any_instance_of(Project, :versions => ['v1.0', 'v2.0'])
|
any_instance_of(Project, :versions => ['v1.0', 'v2.0'])
|
||||||
@stranger_comment = create_comment Factory(:user)
|
@stranger_comment = create_comment FactoryGirl.create(:user)
|
||||||
@user = Factory(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
@own_comment = create_comment @user
|
@own_comment = create_comment @user
|
||||||
set_session_for(@user)
|
set_session_for(@user)
|
||||||
end
|
end
|
||||||
|
|
|
@ -74,18 +74,18 @@ describe CommentsController do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
stub_rsync_methods
|
stub_rsync_methods
|
||||||
|
|
||||||
@project = Factory(:project)
|
@project = FactoryGirl.create(:project)
|
||||||
@issue = Factory(:issue, :project_id => @project.id, :creator => Factory(:user))
|
@issue = FactoryGirl.create(:issue, :project_id => @project.id, :creator => FactoryGirl.create(:user))
|
||||||
@comment = Factory(:comment, :commentable => @issue, :project_id => @project.id)
|
@comment = FactoryGirl.create(:comment, :commentable => @issue, :project_id => @project.id)
|
||||||
|
|
||||||
@create_params = {:comment => {:body => 'I am a comment!'}, :project_id => @project.id, :issue_id => @issue.serial_id}
|
@create_params = {:comment => {:body => 'I am a comment!'}, :project_id => @project.id, :issue_id => @issue.serial_id}
|
||||||
@update_params = {:comment => {:body => 'updated'}, :project_id => @project.id, :issue_id => @issue.serial_id}
|
@update_params = {:comment => {:body => 'updated'}, :project_id => @project.id, :issue_id => @issue.serial_id}
|
||||||
|
|
||||||
any_instance_of(Project, :versions => ['v1.0', 'v2.0'])
|
any_instance_of(Project, :versions => ['v1.0', 'v2.0'])
|
||||||
|
|
||||||
@user = Factory(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
set_session_for(@user)
|
set_session_for(@user)
|
||||||
@own_comment = Factory(:comment, :commentable => @issue, :user => @user, :project_id => @project.id)
|
@own_comment = FactoryGirl.create(:comment, :commentable => @issue, :user => @user, :project_id => @project.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'for project admin user' do
|
context 'for project admin user' do
|
||||||
|
|
|
@ -70,8 +70,8 @@ end
|
||||||
describe GroupsController do
|
describe GroupsController do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
stub_rsync_methods
|
stub_rsync_methods
|
||||||
@group = Factory(:group)
|
@group = FactoryGirl.create(:group)
|
||||||
@another_user = Factory(:user)
|
@another_user = FactoryGirl.create(:user)
|
||||||
@create_params = {:group => {:description => 'grp1', :uname => 'un_grp1'}}
|
@create_params = {:group => {:description => 'grp1', :uname => 'un_grp1'}}
|
||||||
@update_params = {:group => {:description => 'grp2'}}
|
@update_params = {:group => {:description => 'grp2'}}
|
||||||
end
|
end
|
||||||
|
@ -95,7 +95,7 @@ describe GroupsController do
|
||||||
|
|
||||||
context 'for global admin' do
|
context 'for global admin' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@admin = Factory(:admin)
|
@admin = FactoryGirl.create(:admin)
|
||||||
set_session_for(@admin)
|
set_session_for(@admin)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ describe GroupsController do
|
||||||
|
|
||||||
context 'for group admin' do
|
context 'for group admin' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = Factory(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
set_session_for(@user)
|
set_session_for(@user)
|
||||||
@group.objects.create(:object_type => 'User', :object_id => @user.id, :role => 'admin')
|
@group.objects.create(:object_type => 'User', :object_id => @user.id, :role => 'admin')
|
||||||
end
|
end
|
||||||
|
@ -127,7 +127,7 @@ describe GroupsController do
|
||||||
|
|
||||||
context 'for group owner' do
|
context 'for group owner' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = Factory(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
set_session_for(@user)
|
set_session_for(@user)
|
||||||
@group.update_attribute(:owner, @user)
|
@group.update_attribute(:owner, @user)
|
||||||
@group.objects.create(:object_type => 'User', :object_id => @user.id, :role => 'admin')
|
@group.objects.create(:object_type => 'User', :object_id => @user.id, :role => 'admin')
|
||||||
|
@ -139,7 +139,7 @@ describe GroupsController do
|
||||||
|
|
||||||
context 'for group reader and writer user' do
|
context 'for group reader and writer user' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = Factory(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
set_session_for(@user)
|
set_session_for(@user)
|
||||||
@group.objects.create(:object_type => 'User', :object_id => @user.id, :role => 'reader')
|
@group.objects.create(:object_type => 'User', :object_id => @user.id, :role => 'reader')
|
||||||
end
|
end
|
||||||
|
|
|
@ -75,12 +75,12 @@ describe IssuesController do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
stub_rsync_methods
|
stub_rsync_methods
|
||||||
|
|
||||||
@project = Factory(:project)
|
@project = FactoryGirl.create(:project)
|
||||||
@issue_user = Factory(:user)
|
@issue_user = FactoryGirl.create(:user)
|
||||||
|
|
||||||
any_instance_of(Project, :versions => ['v1.0', 'v2.0'])
|
any_instance_of(Project, :versions => ['v1.0', 'v2.0'])
|
||||||
|
|
||||||
@issue = Factory(:issue, :project_id => @project.id, :user_id => @issue_user.id)
|
@issue = FactoryGirl.create(:issue, :project_id => @project.id, :user_id => @issue_user.id)
|
||||||
@create_params = {
|
@create_params = {
|
||||||
:project_id => @project.id,
|
:project_id => @project.id,
|
||||||
:issue => {
|
:issue => {
|
||||||
|
@ -98,13 +98,13 @@ describe IssuesController do
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@project_with_turned_off_issues = Factory(:project, :has_issues => false)
|
@project_with_turned_off_issues = FactoryGirl.create(:project, :has_issues => false)
|
||||||
@turned_of_issue = Factory(:issue, :project_id => @project_with_turned_off_issues.id, :user_id => @issue_user.id)
|
@turned_of_issue = FactoryGirl.create(:issue, :project_id => @project_with_turned_off_issues.id, :user_id => @issue_user.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'for global admin user' do
|
context 'for global admin user' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@admin = Factory(:admin)
|
@admin = FactoryGirl.create(:admin)
|
||||||
set_session_for(@admin)
|
set_session_for(@admin)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ describe IssuesController do
|
||||||
|
|
||||||
context 'for project admin user' do
|
context 'for project admin user' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = Factory(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
set_session_for(@user)
|
set_session_for(@user)
|
||||||
@project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin')
|
@project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin')
|
||||||
end
|
end
|
||||||
|
@ -127,7 +127,7 @@ describe IssuesController do
|
||||||
|
|
||||||
context 'for project owner user' do
|
context 'for project owner user' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = Factory(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
set_session_for(@user)
|
set_session_for(@user)
|
||||||
@project.update_attribute(:owner, @user)
|
@project.update_attribute(:owner, @user)
|
||||||
@project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin')
|
@project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin')
|
||||||
|
@ -142,7 +142,7 @@ describe IssuesController do
|
||||||
|
|
||||||
context 'for project reader user' do
|
context 'for project reader user' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = Factory(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
set_session_for(@user)
|
set_session_for(@user)
|
||||||
@project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'reader')
|
@project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'reader')
|
||||||
end
|
end
|
||||||
|
@ -164,7 +164,7 @@ describe IssuesController do
|
||||||
|
|
||||||
context 'for project writer user' do
|
context 'for project writer user' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = Factory(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
set_session_for(@user)
|
set_session_for(@user)
|
||||||
@project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'writer')
|
@project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'writer')
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,10 +4,10 @@ require 'spec_helper'
|
||||||
describe MembersController do
|
describe MembersController do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
stub_rsync_methods
|
stub_rsync_methods
|
||||||
@group = Factory(:group)
|
@group = FactoryGirl.create(:group)
|
||||||
@user = @group.owner
|
@user = @group.owner
|
||||||
set_session_for @user
|
set_session_for @user
|
||||||
@another_user = Factory(:user)
|
@another_user = FactoryGirl.create(:user)
|
||||||
@add_params = {:group_id => @group.id, :user_id => @another_user.uname}
|
@add_params = {:group_id => @group.id, :user_id => @another_user.uname}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -48,10 +48,10 @@ describe PersonalRepositoriesController do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
stub_rsync_methods
|
stub_rsync_methods
|
||||||
|
|
||||||
@repository = Factory(:personal_repository)
|
@repository = FactoryGirl.create(:personal_repository)
|
||||||
@platform = Factory(:platform)
|
@platform = FactoryGirl.create(:platform)
|
||||||
@project = Factory(:project)
|
@project = FactoryGirl.create(:project)
|
||||||
@another_user = Factory(:user)
|
@another_user = FactoryGirl.create(:user)
|
||||||
@create_params = {:repository => {:name => 'pro', :description => 'pro2'}, :platform_id => @platform.id}
|
@create_params = {:repository => {:name => 'pro', :description => 'pro2'}, :platform_id => @platform.id}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ describe PersonalRepositoriesController do
|
||||||
|
|
||||||
context 'for global admin' do
|
context 'for global admin' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@admin = Factory(:admin)
|
@admin = FactoryGirl.create(:admin)
|
||||||
@project.update_attribute(:owner, @admin)
|
@project.update_attribute(:owner, @admin)
|
||||||
set_session_for(@admin)
|
set_session_for(@admin)
|
||||||
end
|
end
|
||||||
|
@ -78,7 +78,7 @@ describe PersonalRepositoriesController do
|
||||||
|
|
||||||
pending 'for anyone except admin' do
|
pending 'for anyone except admin' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = Factory(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
set_session_for(@user)
|
set_session_for(@user)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ describe PersonalRepositoriesController do
|
||||||
|
|
||||||
context 'for owner user' do
|
context 'for owner user' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = Factory(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
|
|
||||||
@project.update_attribute(:owner, @user)
|
@project.update_attribute(:owner, @user)
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ describe PersonalRepositoriesController do
|
||||||
|
|
||||||
context 'for reader user' do
|
context 'for reader user' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = Factory(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
@repository.platform.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'reader')
|
@repository.platform.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'reader')
|
||||||
set_session_for(@user)
|
set_session_for(@user)
|
||||||
end
|
end
|
||||||
|
|
|
@ -37,9 +37,9 @@ describe PlatformsController do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
stub_rsync_methods
|
stub_rsync_methods
|
||||||
|
|
||||||
@platform = Factory(:platform)
|
@platform = FactoryGirl.create(:platform)
|
||||||
@personal_platform = Factory(:platform, :platform_type => 'personal')
|
@personal_platform = FactoryGirl.create(:platform, :platform_type => 'personal')
|
||||||
@user = Factory(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
@create_params = {:platform => {
|
@create_params = {:platform => {
|
||||||
:name => 'pl1',
|
:name => 'pl1',
|
||||||
:description => 'pl1',
|
:description => 'pl1',
|
||||||
|
@ -67,8 +67,8 @@ describe PlatformsController do
|
||||||
|
|
||||||
context 'for global admin' do
|
context 'for global admin' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@admin = Factory(:admin)
|
@admin = FactoryGirl.create(:admin)
|
||||||
@user = Factory(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
set_session_for(@admin)
|
set_session_for(@admin)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ describe PlatformsController do
|
||||||
|
|
||||||
context 'for owner user' do
|
context 'for owner user' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = Factory(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
set_session_for(@user)
|
set_session_for(@user)
|
||||||
@platform.update_attribute(:owner, @user)
|
@platform.update_attribute(:owner, @user)
|
||||||
@platform.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin')
|
@platform.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin')
|
||||||
|
@ -126,7 +126,7 @@ describe PlatformsController do
|
||||||
|
|
||||||
context 'for reader user' do
|
context 'for reader user' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = Factory(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
set_session_for(@user)
|
set_session_for(@user)
|
||||||
@platform.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'reader')
|
@platform.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'reader')
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,7 +11,7 @@ describe ProductBuildListsController do
|
||||||
{:product_id => product.id, :platform_id => product.platform_id}
|
{:product_id => product.id, :platform_id => product.platform_id}
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:product) { Factory(:product) }
|
let(:product) { FactoryGirl.create(:product) }
|
||||||
|
|
||||||
context 'for guest' do
|
context 'for guest' do
|
||||||
it 'should not be able to perform create action' do
|
it 'should not be able to perform create action' do
|
||||||
|
@ -21,7 +21,7 @@ describe ProductBuildListsController do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'for user' do
|
context 'for user' do
|
||||||
before(:each) { set_session_for Factory(:user) }
|
before(:each) { set_session_for FactoryGirl.create(:user) }
|
||||||
|
|
||||||
it 'should not be able to perform create action' do
|
it 'should not be able to perform create action' do
|
||||||
post :create, valid_attributes
|
post :create, valid_attributes
|
||||||
|
@ -30,7 +30,7 @@ describe ProductBuildListsController do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'for admin' do
|
context 'for admin' do
|
||||||
before(:each) { set_session_for Factory(:admin) }
|
before(:each) { set_session_for FactoryGirl.create(:admin) }
|
||||||
|
|
||||||
it "creates a new ProductBuildList" do
|
it "creates a new ProductBuildList" do
|
||||||
expect {
|
expect {
|
||||||
|
@ -46,7 +46,7 @@ describe ProductBuildListsController do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'callbacks' do
|
context 'callbacks' do
|
||||||
let(:product_build_list) { Factory(:product_build_list) }
|
let(:product_build_list) { FactoryGirl.create(:product_build_list) }
|
||||||
|
|
||||||
def do_get
|
def do_get
|
||||||
get :status_build, :id => product_build_list.id, :status => ProductBuildList::BUILD_FAILED
|
get :status_build, :id => product_build_list.id, :status => ProductBuildList::BUILD_FAILED
|
||||||
|
|
|
@ -5,9 +5,9 @@ describe ProductsController do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
stub_rsync_methods
|
stub_rsync_methods
|
||||||
|
|
||||||
@another_user = Factory(:user)
|
@another_user = FactoryGirl.create(:user)
|
||||||
@platform = Factory(:platform)
|
@platform = FactoryGirl.create(:platform)
|
||||||
@product = Factory(:product, :platform => @platform)
|
@product = FactoryGirl.create(:product, :platform => @platform)
|
||||||
@create_params = {:product => {:name => 'pro'}, :platform_id => @platform.id}
|
@create_params = {:product => {:name => 'pro'}, :platform_id => @platform.id}
|
||||||
@update_params = {:product => {:name => 'pro2'}, :platform_id => @platform.id}
|
@update_params = {:product => {:name => 'pro2'}, :platform_id => @platform.id}
|
||||||
end
|
end
|
||||||
|
@ -30,7 +30,7 @@ describe ProductsController do
|
||||||
|
|
||||||
context 'for global admin' do
|
context 'for global admin' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@admin = Factory(:admin)
|
@admin = FactoryGirl.create(:admin)
|
||||||
set_session_for(@admin)
|
set_session_for(@admin)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ describe ProductsController do
|
||||||
|
|
||||||
context 'for admin relation user' do
|
context 'for admin relation user' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = Factory(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
set_session_for(@user)
|
set_session_for(@user)
|
||||||
@platform.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin')
|
@platform.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin')
|
||||||
end
|
end
|
||||||
|
@ -91,7 +91,7 @@ describe ProductsController do
|
||||||
|
|
||||||
context 'for no relation user' do
|
context 'for no relation user' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = Factory(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
set_session_for(@user)
|
set_session_for(@user)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,8 @@ describe ProjectsController do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
stub_rsync_methods
|
stub_rsync_methods
|
||||||
|
|
||||||
@project = Factory(:project)
|
@project = FactoryGirl.create(:project)
|
||||||
@another_user = Factory(:user)
|
@another_user = FactoryGirl.create(:user)
|
||||||
@create_params = {:project => {:name => 'pro'}}
|
@create_params = {:project => {:name => 'pro'}}
|
||||||
@update_params = {:project => {:name => 'pro2'}}
|
@update_params = {:project => {:name => 'pro2'}}
|
||||||
end
|
end
|
||||||
|
@ -25,7 +25,7 @@ describe ProjectsController do
|
||||||
|
|
||||||
context 'for admin' do
|
context 'for admin' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@admin = Factory(:admin)
|
@admin = FactoryGirl.create(:admin)
|
||||||
set_session_for(@admin)
|
set_session_for(@admin)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ describe ProjectsController do
|
||||||
|
|
||||||
context 'for owner user' do
|
context 'for owner user' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = Factory(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
set_session_for(@user)
|
set_session_for(@user)
|
||||||
@project.update_attribute(:owner, @user)
|
@project.update_attribute(:owner, @user)
|
||||||
@project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin')
|
@project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin')
|
||||||
|
@ -70,7 +70,7 @@ describe ProjectsController do
|
||||||
|
|
||||||
context 'for reader user' do
|
context 'for reader user' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = Factory(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
set_session_for(@user)
|
set_session_for(@user)
|
||||||
@project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'reader')
|
@project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'reader')
|
||||||
end
|
end
|
||||||
|
@ -80,7 +80,7 @@ describe ProjectsController do
|
||||||
|
|
||||||
context 'for writer user' do
|
context 'for writer user' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = Factory(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
set_session_for(@user)
|
set_session_for(@user)
|
||||||
@project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'writer')
|
@project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'writer')
|
||||||
end
|
end
|
||||||
|
@ -91,9 +91,9 @@ describe ProjectsController do
|
||||||
context 'search projects' do
|
context 'search projects' do
|
||||||
|
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@admin = Factory(:admin)
|
@admin = FactoryGirl.create(:admin)
|
||||||
@project1 = Factory(:project, :name => 'perl-debug')
|
@project1 = FactoryGirl.create(:project, :name => 'perl-debug')
|
||||||
@project2 = Factory(:project, :name => 'perl')
|
@project2 = FactoryGirl.create(:project, :name => 'perl')
|
||||||
set_session_for(@admin)
|
set_session_for(@admin)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,11 +5,11 @@ describe RepositoriesController do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
stub_rsync_methods
|
stub_rsync_methods
|
||||||
|
|
||||||
@repository = Factory(:repository)
|
@repository = FactoryGirl.create(:repository)
|
||||||
@personal_repository = Factory(:personal_repository)
|
@personal_repository = FactoryGirl.create(:personal_repository)
|
||||||
@platform = Factory(:platform)
|
@platform = FactoryGirl.create(:platform)
|
||||||
@project = Factory(:project)
|
@project = FactoryGirl.create(:project)
|
||||||
@another_user = Factory(:user)
|
@another_user = FactoryGirl.create(:user)
|
||||||
@create_params = {:repository => {:name => 'pro', :description => 'pro2'}, :platform_id => @platform.id}
|
@create_params = {:repository => {:name => 'pro', :description => 'pro2'}, :platform_id => @platform.id}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ describe RepositoriesController do
|
||||||
|
|
||||||
context 'for admin' do
|
context 'for admin' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@admin = Factory(:admin)
|
@admin = FactoryGirl.create(:admin)
|
||||||
set_session_for(@admin)
|
set_session_for(@admin)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ describe RepositoriesController do
|
||||||
|
|
||||||
context 'for anyone except admin' do
|
context 'for anyone except admin' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = Factory(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
set_session_for(@user)
|
set_session_for(@user)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ describe RepositoriesController do
|
||||||
|
|
||||||
context 'for owner user' do
|
context 'for owner user' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = Factory(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
set_session_for(@user)
|
set_session_for(@user)
|
||||||
@repository.platform.update_attribute(:owner, @user)
|
@repository.platform.update_attribute(:owner, @user)
|
||||||
@repository.platform.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin')
|
@repository.platform.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin')
|
||||||
|
@ -88,7 +88,7 @@ describe RepositoriesController do
|
||||||
|
|
||||||
context 'for reader user' do
|
context 'for reader user' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = Factory(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
set_session_for(@user)
|
set_session_for(@user)
|
||||||
@repository.platform.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'reader')
|
@repository.platform.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'reader')
|
||||||
end
|
end
|
||||||
|
|
|
@ -51,8 +51,8 @@ describe SubscribesController do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
stub_rsync_methods
|
stub_rsync_methods
|
||||||
|
|
||||||
@project = Factory(:project)
|
@project = FactoryGirl.create(:project)
|
||||||
@issue = Factory(:issue, :project_id => @project.id)
|
@issue = FactoryGirl.create(:issue, :project_id => @project.id)
|
||||||
|
|
||||||
@create_params = {:issue_id => @issue.serial_id, :project_id => @project.id}
|
@create_params = {:issue_id => @issue.serial_id, :project_id => @project.id}
|
||||||
@destroy_params = {:issue_id => @issue.serial_id, :project_id => @project.id}
|
@destroy_params = {:issue_id => @issue.serial_id, :project_id => @project.id}
|
||||||
|
@ -64,7 +64,7 @@ describe SubscribesController do
|
||||||
|
|
||||||
context 'for global admin user' do
|
context 'for global admin user' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = Factory(:admin)
|
@user = FactoryGirl.create(:admin)
|
||||||
set_session_for(@user)
|
set_session_for(@user)
|
||||||
@project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin')
|
@project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin')
|
||||||
@destroy_params = @destroy_params.merge({:id => @user.id})
|
@destroy_params = @destroy_params.merge({:id => @user.id})
|
||||||
|
@ -87,7 +87,7 @@ describe SubscribesController do
|
||||||
|
|
||||||
context 'for simple user' do
|
context 'for simple user' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = Factory(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
set_session_for(@user)
|
set_session_for(@user)
|
||||||
@destroy_params = @destroy_params.merge({:id => @user.id})
|
@destroy_params = @destroy_params.merge({:id => @user.id})
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,11 +5,11 @@ describe UsersController do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
stub_rsync_methods
|
stub_rsync_methods
|
||||||
|
|
||||||
@simple_user = Factory(:user)
|
@simple_user = FactoryGirl.create(:user)
|
||||||
@other_user = Factory(:user)
|
@other_user = FactoryGirl.create(:user)
|
||||||
@admin = Factory(:admin)
|
@admin = FactoryGirl.create(:admin)
|
||||||
%w[user1 user2 user3].each do |uname|
|
%w[user1 user2 user3].each do |uname|
|
||||||
Factory(:user, :uname => uname, :email => "#{ uname }@nonexistanceserver.com")
|
FactoryGirl.create(:user, :uname => uname, :email => "#{ uname }@nonexistanceserver.com")
|
||||||
end
|
end
|
||||||
@update_params = {:email => 'new_email@test.com'}
|
@update_params = {:email => 'new_email@test.com'}
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,30 +1,32 @@
|
||||||
# -*- encoding : utf-8 -*-
|
# -*- encoding : utf-8 -*-
|
||||||
Factory.sequence :integer do |n|
|
FactoryGirl.define do
|
||||||
n
|
sequence :integer do |n|
|
||||||
end
|
n
|
||||||
|
end
|
||||||
|
|
||||||
Factory.sequence :string do |n|
|
sequence :string do |n|
|
||||||
"Lorem ipsum #{n}"
|
"Lorem ipsum #{n}"
|
||||||
end
|
end
|
||||||
|
|
||||||
Factory.sequence :uname do |n|
|
sequence :uname do |n|
|
||||||
"test#{n}"
|
"test#{n}"
|
||||||
end
|
end
|
||||||
|
|
||||||
Factory.sequence :unixname do |n|
|
sequence :unixname do |n|
|
||||||
"test_unixname#{n}"
|
"test_unixname#{n}"
|
||||||
end
|
end
|
||||||
|
|
||||||
Factory.sequence :email do |n|
|
sequence :email do |n|
|
||||||
"email#{n}@example.com"
|
"email#{n}@example.com"
|
||||||
end
|
end
|
||||||
|
|
||||||
Factory.sequence :text do |n|
|
sequence :text do |n|
|
||||||
"#{n}. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
|
"#{n}. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
|
||||||
end
|
end
|
||||||
|
|
||||||
Factory.sequence :text_file do |n|
|
sequence :text_file do |n|
|
||||||
stringio = StringIO.new("this is file content #{n}")
|
stringio = StringIO.new("this is file content #{n}")
|
||||||
stringio.instance_eval("def original_filename; 'stringio#{n}.txt'; end ")
|
stringio.instance_eval("def original_filename; 'stringio#{n}.txt'; end ")
|
||||||
stringio
|
stringio
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
# -*- encoding : utf-8 -*-
|
# -*- encoding : utf-8 -*-
|
||||||
Factory.define(:arch) do |p|
|
FactoryGirl.define do
|
||||||
p.name { Factory.next(:string) }
|
factory :arch do
|
||||||
|
name { FactoryGirl.generate(:string) }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,17 +1,19 @@
|
||||||
# -*- encoding : utf-8 -*-
|
# -*- encoding : utf-8 -*-
|
||||||
Factory.define(:build_list) do |p|
|
FactoryGirl.define do
|
||||||
p.association :user
|
factory :build_list do
|
||||||
p.association :project
|
association :user
|
||||||
p.association :pl, :factory => :platform_with_repos
|
association :project
|
||||||
p.association :arch
|
association :pl, :factory => :platform_with_repos
|
||||||
p.bpl {|bl| bl.pl}
|
association :arch
|
||||||
p.project_version "1.0"
|
bpl {|bl| bl.pl}
|
||||||
p.build_requires true
|
project_version "1.0"
|
||||||
p.update_type 'security'
|
build_requires true
|
||||||
p.include_repos {|bl| bl.pl.repositories.map(&:id)}
|
update_type 'security'
|
||||||
p.commit_hash '1234567890abcdef1234567890abcdef12345678'
|
include_repos {|bl| bl.pl.repositories.map(&:id)}
|
||||||
end
|
commit_hash '1234567890abcdef1234567890abcdef12345678'
|
||||||
|
end
|
||||||
|
|
||||||
Factory.define(:build_list_core, :parent => :build_list) do |p|
|
factory :build_list_core, :parent => :build_list do
|
||||||
p.bs_id { Factory.next(:integer) }
|
bs_id { FactoryGirl.generate(:integer) }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
# -*- encoding : utf-8 -*-
|
# -*- encoding : utf-8 -*-
|
||||||
Factory.define(:comment) do |p|
|
FactoryGirl.define do
|
||||||
p.body { Factory.next(:string) }
|
factory :comment do
|
||||||
p.association :user, :factory => :user
|
body { FactoryGirl.generate(:string) }
|
||||||
p.association :commentable, :factory => :issue
|
association :user, :factory => :user
|
||||||
|
association :commentable, :factory => :issue
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
# -*- encoding : utf-8 -*-
|
# -*- encoding : utf-8 -*-
|
||||||
Factory.define(:group) do |g|
|
FactoryGirl.define do
|
||||||
g.uname { Factory.next(:uname) }
|
factory :group do
|
||||||
g.description 'Description'
|
uname { FactoryGirl.generate(:uname) }
|
||||||
g.association :owner, :factory => :user
|
description 'Description'
|
||||||
|
association :owner, :factory => :user
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
# -*- encoding : utf-8 -*-
|
# -*- encoding : utf-8 -*-
|
||||||
Factory.define(:issue) do |p|
|
FactoryGirl.define do
|
||||||
p.title { Factory.next(:string) }
|
factory :issue do
|
||||||
p.body { Factory.next(:string) }
|
title { FactoryGirl.generate(:string) }
|
||||||
p.association :project, :factory => :project
|
body { FactoryGirl.generate(:string) }
|
||||||
p.association :user, :factory => :user
|
association :project, :factory => :project
|
||||||
p.association :creator, :factory => :user
|
association :user, :factory => :user
|
||||||
p.status "open"
|
association :creator, :factory => :user
|
||||||
|
status "open"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
# -*- encoding : utf-8 -*-
|
# -*- encoding : utf-8 -*-
|
||||||
Factory.define(:platform) do |p|
|
FactoryGirl.define do
|
||||||
p.description { Factory.next(:string) }
|
factory :platform do
|
||||||
p.name { Factory.next(:unixname) }
|
description { FactoryGirl.generate(:string) }
|
||||||
p.platform_type 'main'
|
name { FactoryGirl.generate(:unixname) }
|
||||||
p.distrib_type APP_CONFIG['distr_types'].first
|
platform_type 'main'
|
||||||
p.association :owner, :factory => :user
|
distrib_type APP_CONFIG['distr_types'].first
|
||||||
end
|
association :owner, :factory => :user
|
||||||
|
end
|
||||||
|
|
||||||
Factory.define(:platform_with_repos, :parent => :platform) do |p|
|
factory :platform_with_repos, :parent => :platform do
|
||||||
p.repositories {|r| [r.association(:repository)]}
|
repositories {|r| [r.association(:repository)]}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
# -*- encoding : utf-8 -*-
|
# -*- encoding : utf-8 -*-
|
||||||
Factory.define(:private_user) do |p|
|
FactoryGirl.define do
|
||||||
p.login { Factory.next(:string) }
|
factory :private_user do
|
||||||
p.password { Factory.next(:string) }
|
login { FactoryGirl.generate(:string) }
|
||||||
p.association :platform, :factory => :platform
|
password { FactoryGirl.generate(:string) }
|
||||||
p.association :user, :factory => :user
|
association :platform, :factory => :platform
|
||||||
|
association :user, :factory => :user
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
# -*- encoding : utf-8 -*-
|
# -*- encoding : utf-8 -*-
|
||||||
Factory.define(:product_build_list) do |p|
|
FactoryGirl.define do
|
||||||
p.association :product, :factory => :product
|
factory :product_build_list do
|
||||||
|
association :product, :factory => :product
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# -*- encoding : utf-8 -*-
|
# -*- encoding : utf-8 -*-
|
||||||
Factory.define(:product) do |p|
|
FactoryGirl.define do
|
||||||
p.name { Factory.next(:string) }
|
factory :product do
|
||||||
p.association :platform, :factory => :platform
|
name { FactoryGirl.generate(:string) }
|
||||||
|
association :platform, :factory => :platform
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
# -*- encoding : utf-8 -*-
|
# -*- encoding : utf-8 -*-
|
||||||
Factory.define(:project) do |p|
|
FactoryGirl.define do
|
||||||
p.description { Factory.next(:string) }
|
factory :project do
|
||||||
p.name { Factory.next(:unixname) }
|
description { FactoryGirl.generate(:string) }
|
||||||
p.association :owner, :factory => :user
|
name { FactoryGirl.generate(:unixname) }
|
||||||
|
association :owner, :factory => :user
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
FactoryGirl.define do
|
FactoryGirl.define do
|
||||||
factory :register_request do
|
factory :register_request do
|
||||||
name "MyString"
|
name "MyString"
|
||||||
email { Factory.next(:email) }
|
email { FactoryGirl.generate(:email) }
|
||||||
token "MyString"
|
token "MyString"
|
||||||
interest "MyString"
|
interest "MyString"
|
||||||
more "MyText"
|
more "MyText"
|
||||||
|
|
|
@ -1,14 +1,16 @@
|
||||||
# -*- encoding : utf-8 -*-
|
# -*- encoding : utf-8 -*-
|
||||||
Factory.define(:repository) do |p|
|
FactoryGirl.define do
|
||||||
p.description { Factory.next(:string) }
|
factory :repository do
|
||||||
p.name { Factory.next(:unixname) }
|
description { FactoryGirl.generate(:string) }
|
||||||
p.association :platform, :factory => :platform
|
name { FactoryGirl.generate(:unixname) }
|
||||||
end
|
association :platform, :factory => :platform
|
||||||
|
end
|
||||||
|
|
||||||
Factory.define(:personal_repository, :parent => :repository) do |p|
|
factory :personal_repository, :parent => :repository do
|
||||||
p.after_create {|r|
|
after_create {|r|
|
||||||
r.platform.platform_type = 'personal'
|
r.platform.platform_type = 'personal'
|
||||||
r.platform.visibility = 'hidden'
|
r.platform.visibility = 'hidden'
|
||||||
r.platform.save!
|
r.platform.save!
|
||||||
}
|
}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# -*- encoding : utf-8 -*-
|
# -*- encoding : utf-8 -*-
|
||||||
Factory.define(:subscribe) do |p|
|
FactoryGirl.define do
|
||||||
p.association :subscribeable, :factory => :issue
|
factory :subscribe do
|
||||||
p.association :user, :factory => :user
|
association :subscribeable, :factory => :issue
|
||||||
|
association :user, :factory => :user
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,17 +1,15 @@
|
||||||
# -*- encoding : utf-8 -*-
|
# -*- encoding : utf-8 -*-
|
||||||
Factory.define(:user) do |u|
|
FactoryGirl.define do
|
||||||
u.email { Factory.next(:email) }
|
factory :user do
|
||||||
u.name { Factory.next(:string) }
|
email { FactoryGirl.generate(:email) }
|
||||||
u.uname { Factory.next(:uname) }
|
name { FactoryGirl.generate(:string) }
|
||||||
u.password '123456'
|
uname { FactoryGirl.generate(:uname) }
|
||||||
u.password_confirmation { |user| user.password }
|
password '123456'
|
||||||
end
|
password_confirmation {|u| u.password}
|
||||||
|
confirmed_at { Time.current }
|
||||||
|
end
|
||||||
|
|
||||||
Factory.define(:admin, :class => 'User') do |u|
|
factory :admin, :parent => :user do
|
||||||
u.email { Factory.next(:email) }
|
role 'admin'
|
||||||
u.name { Factory.next(:string) }
|
end
|
||||||
u.uname { Factory.next(:uname) }
|
|
||||||
u.password '123456'
|
|
||||||
u.password_confirmation { |user| user.password }
|
|
||||||
u.role 'admin'
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,12 +8,12 @@ describe UserMailer do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
stub_rsync_methods
|
stub_rsync_methods
|
||||||
|
|
||||||
@project = Factory(:project)
|
@project = FactoryGirl.create(:project)
|
||||||
@issue_user = Factory(:user)
|
@issue_user = FactoryGirl.create(:user)
|
||||||
|
|
||||||
any_instance_of(Project, :versions => ['v1.0', 'v2.0'])
|
any_instance_of(Project, :versions => ['v1.0', 'v2.0'])
|
||||||
|
|
||||||
@issue = Factory(:issue, :project_id => @project.id, :user_id => @issue_user.id, :creator => @issue_user)
|
@issue = FactoryGirl.create(:issue, :project_id => @project.id, :user_id => @issue_user.id, :creator => @issue_user)
|
||||||
@email = UserMailer.new_issue_notification(@issue, @issue_user).deliver
|
@email = UserMailer.new_issue_notification(@issue, @issue_user).deliver
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -46,13 +46,13 @@ describe UserMailer do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
stub_rsync_methods
|
stub_rsync_methods
|
||||||
|
|
||||||
@project = Factory(:project)
|
@project = FactoryGirl.create(:project)
|
||||||
@issue_user = Factory(:user)
|
@issue_user = FactoryGirl.create(:user)
|
||||||
@user = Factory(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
|
|
||||||
any_instance_of(Project, :versions => ['v1.0', 'v2.0'])
|
any_instance_of(Project, :versions => ['v1.0', 'v2.0'])
|
||||||
|
|
||||||
@issue = Factory(:issue, :project_id => @project.id, :user_id => @issue_user.id, :creator => @issue_user)
|
@issue = FactoryGirl.create(:issue, :project_id => @project.id, :user_id => @issue_user.id, :creator => @issue_user)
|
||||||
@email = UserMailer.issue_assign_notification(@issue, @user).deliver
|
@email = UserMailer.issue_assign_notification(@issue, @user).deliver
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -82,14 +82,14 @@ describe UserMailer do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
stub_rsync_methods
|
stub_rsync_methods
|
||||||
|
|
||||||
@project = Factory(:project)
|
@project = FactoryGirl.create(:project)
|
||||||
@issue_user = Factory(:user)
|
@issue_user = FactoryGirl.create(:user)
|
||||||
@user = Factory(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
|
|
||||||
any_instance_of(Project, :versions => ['v1.0', 'v2.0'])
|
any_instance_of(Project, :versions => ['v1.0', 'v2.0'])
|
||||||
|
|
||||||
@issue = Factory(:issue, :project_id => @project.id, :user_id => @issue_user.id, :creator => @issue_user)
|
@issue = FactoryGirl.create(:issue, :project_id => @project.id, :user_id => @issue_user.id, :creator => @issue_user)
|
||||||
@comment = Factory(:comment, :commentable => @issue, :user_id => @user.id, :project => @project)
|
@comment = FactoryGirl.create(:comment, :commentable => @issue, :user_id => @user.id, :project => @project)
|
||||||
@email = UserMailer.new_comment_notification(@comment, @issue_user).deliver
|
@email = UserMailer.new_comment_notification(@comment, @issue_user).deliver
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -3,12 +3,12 @@ require 'spec_helper'
|
||||||
require "cancan/matchers"
|
require "cancan/matchers"
|
||||||
|
|
||||||
def admin_create
|
def admin_create
|
||||||
@admin = Factory(:admin)
|
@admin = FactoryGirl.create(:admin)
|
||||||
@ability = Ability.new(@admin)
|
@ability = Ability.new(@admin)
|
||||||
end
|
end
|
||||||
|
|
||||||
def user_create
|
def user_create
|
||||||
@user = Factory(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
@ability = Ability.new(@user)
|
@ability = Ability.new(@user)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -18,11 +18,11 @@ end
|
||||||
|
|
||||||
describe CanCan do
|
describe CanCan do
|
||||||
|
|
||||||
let(:personal_platform) { Factory(:platform, :platform_type => 'personal') }
|
let(:personal_platform) { FactoryGirl.create(:platform, :platform_type => 'personal') }
|
||||||
let(:personal_repository) { Factory(:personal_repository) }
|
let(:personal_repository) { FactoryGirl.create(:personal_repository) }
|
||||||
let(:open_platform) { Factory(:platform, :visibility => 'open') }
|
let(:open_platform) { FactoryGirl.create(:platform, :visibility => 'open') }
|
||||||
let(:hidden_platform) { Factory(:platform, :visibility => 'hidden') }
|
let(:hidden_platform) { FactoryGirl.create(:platform, :visibility => 'hidden') }
|
||||||
let(:register_request) { Factory(:register_request) }
|
let(:register_request) { FactoryGirl.create(:register_request) }
|
||||||
|
|
||||||
before(:each) do
|
before(:each) do
|
||||||
stub_rsync_methods
|
stub_rsync_methods
|
||||||
|
@ -118,7 +118,7 @@ describe CanCan do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "shoud be able to read open projects" do
|
it "shoud be able to read open projects" do
|
||||||
@project = Factory(:project, :visibility => 'open')
|
@project = FactoryGirl.create(:project, :visibility => 'open')
|
||||||
@ability.should be_able_to(:read, @project)
|
@ability.should be_able_to(:read, @project)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ describe CanCan do
|
||||||
|
|
||||||
context "private users relations" do
|
context "private users relations" do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@private_user = Factory(:private_user)
|
@private_user = FactoryGirl.create(:private_user)
|
||||||
@private_user.platform.update_attribute(:owner, @user)
|
@private_user.platform.update_attribute(:owner, @user)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -145,8 +145,8 @@ describe CanCan do
|
||||||
|
|
||||||
context 'as project collaborator' do
|
context 'as project collaborator' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@project = Factory(:project)
|
@project = FactoryGirl.create(:project)
|
||||||
@issue = Factory(:issue, :project_id => @project.id)
|
@issue = FactoryGirl.create(:issue, :project_id => @project.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with read rights' do
|
context 'with read rights' do
|
||||||
|
@ -180,7 +180,7 @@ describe CanCan do
|
||||||
|
|
||||||
[:new, :create].each do |action|
|
[:new, :create].each do |action|
|
||||||
it "should be able to #{action} build_list" do
|
it "should be able to #{action} build_list" do
|
||||||
@build_list = Factory(:build_list, :project => @project)
|
@build_list = FactoryGirl.create(:build_list, :project => @project)
|
||||||
@ability.should be_able_to(action, @build_list)
|
@ability.should be_able_to(action, @build_list)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -199,7 +199,7 @@ describe CanCan do
|
||||||
|
|
||||||
[:new, :create].each do |action|
|
[:new, :create].each do |action|
|
||||||
it "should be able to #{action} build_list" do
|
it "should be able to #{action} build_list" do
|
||||||
@build_list = Factory(:build_list, :project => @project)
|
@build_list = FactoryGirl.create(:build_list, :project => @project)
|
||||||
@ability.should be_able_to(action, @build_list)
|
@ability.should be_able_to(action, @build_list)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -229,7 +229,7 @@ describe CanCan do
|
||||||
|
|
||||||
[:new, :create].each do |action|
|
[:new, :create].each do |action|
|
||||||
it "should be able to #{action} build_list" do
|
it "should be able to #{action} build_list" do
|
||||||
@build_list = Factory(:build_list, :project => @project)
|
@build_list = FactoryGirl.create(:build_list, :project => @project)
|
||||||
@ability.should be_able_to(action, @build_list)
|
@ability.should be_able_to(action, @build_list)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -245,7 +245,7 @@ describe CanCan do
|
||||||
|
|
||||||
context 'platform relations' do
|
context 'platform relations' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@platform = Factory(:platform)
|
@platform = FactoryGirl.create(:platform)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with owner rights' do
|
context 'with owner rights' do
|
||||||
|
@ -273,7 +273,7 @@ describe CanCan do
|
||||||
|
|
||||||
context 'repository relations' do
|
context 'repository relations' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@repository = Factory(:repository)
|
@repository = FactoryGirl.create(:repository)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with owner rights' do
|
context 'with owner rights' do
|
||||||
|
@ -301,9 +301,9 @@ describe CanCan do
|
||||||
|
|
||||||
context 'build list relations' do
|
context 'build list relations' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@project = Factory(:project)
|
@project = FactoryGirl.create(:project)
|
||||||
@project.relations.create!(:object_id => @user.id, :object_type => 'User', :role => 'writer')
|
@project.relations.create!(:object_id => @user.id, :object_type => 'User', :role => 'writer')
|
||||||
@build_list = Factory(:build_list, :project => @project)
|
@build_list = FactoryGirl.create(:build_list, :project => @project)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be able to publish build list with SUCCESS status' do
|
it 'should be able to publish build list with SUCCESS status' do
|
||||||
|
|
|
@ -11,7 +11,7 @@ end
|
||||||
def set_comments_data_for_commit
|
def set_comments_data_for_commit
|
||||||
@ability = Ability.new(@user)
|
@ability = Ability.new(@user)
|
||||||
|
|
||||||
@project = Factory(:project, :owner => @user)
|
@project = FactoryGirl.create(:project, :owner => @user)
|
||||||
%x(cp -Rf #{Rails.root}/spec/tests.git/* #{@project.git_repository.path}) # maybe FIXME ?
|
%x(cp -Rf #{Rails.root}/spec/tests.git/* #{@project.git_repository.path}) # maybe FIXME ?
|
||||||
@commit = @project.git_repository.commits.first
|
@commit = @project.git_repository.commits.first
|
||||||
|
|
||||||
|
@ -28,8 +28,8 @@ describe Comment do
|
||||||
before { stub_rsync_methods }
|
before { stub_rsync_methods }
|
||||||
context 'for global admin user' do
|
context 'for global admin user' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = Factory(:admin)
|
@user = FactoryGirl.create(:admin)
|
||||||
@stranger = Factory(:user)
|
@stranger = FactoryGirl.create(:user)
|
||||||
|
|
||||||
set_comments_data_for_commit
|
set_comments_data_for_commit
|
||||||
end
|
end
|
||||||
|
@ -57,11 +57,11 @@ describe Comment do
|
||||||
|
|
||||||
context 'for project admin user' do
|
context 'for project admin user' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = Factory(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
@stranger = Factory(:user)
|
@stranger = FactoryGirl.create(:user)
|
||||||
|
|
||||||
set_comments_data_for_commit
|
set_comments_data_for_commit
|
||||||
@admin = Factory(:user)
|
@admin = FactoryGirl.create(:user)
|
||||||
@ability = Ability.new(@admin)
|
@ability = Ability.new(@admin)
|
||||||
@project.relations.create!(:object_type => 'User', :object_id => @admin.id, :role => 'admin')
|
@project.relations.create!(:object_type => 'User', :object_id => @admin.id, :role => 'admin')
|
||||||
ActionMailer::Base.deliveries = []
|
ActionMailer::Base.deliveries = []
|
||||||
|
@ -147,8 +147,8 @@ describe Comment do
|
||||||
|
|
||||||
context 'for project owner user' do
|
context 'for project owner user' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = Factory(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
@stranger = Factory(:user)
|
@stranger = FactoryGirl.create(:user)
|
||||||
set_comments_data_for_commit
|
set_comments_data_for_commit
|
||||||
@project.update_attribute(:owner, @user)
|
@project.update_attribute(:owner, @user)
|
||||||
ActionMailer::Base.deliveries = []
|
ActionMailer::Base.deliveries = []
|
||||||
|
@ -244,9 +244,9 @@ describe Comment do
|
||||||
|
|
||||||
context 'for simple user' do
|
context 'for simple user' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = Factory(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
@simple = Factory(:user)
|
@simple = FactoryGirl.create(:user)
|
||||||
@stranger = Factory(:user)
|
@stranger = FactoryGirl.create(:user)
|
||||||
set_comments_data_for_commit
|
set_comments_data_for_commit
|
||||||
@comment = create_comment(@simple)
|
@comment = create_comment(@simple)
|
||||||
@ability = Ability.new(@simple)
|
@ability = Ability.new(@simple)
|
||||||
|
|
|
@ -5,11 +5,11 @@ require "cancan/matchers"
|
||||||
def set_commentable_data
|
def set_commentable_data
|
||||||
@ability = Ability.new(@user)
|
@ability = Ability.new(@user)
|
||||||
|
|
||||||
@project = Factory(:project)
|
@project = FactoryGirl.create(:project)
|
||||||
@issue = Factory(:issue, :project_id => @project.id, :creator => @user)
|
@issue = FactoryGirl.create(:issue, :project_id => @project.id, :creator => @user)
|
||||||
|
|
||||||
@comment = Factory(:comment, :commentable => @issue, :user => @user, :project => @project)
|
@comment = FactoryGirl.create(:comment, :commentable => @issue, :user => @user, :project => @project)
|
||||||
@stranger_comment = Factory(:comment, :commentable => @issue, :user => @stranger, :project => @project)
|
@stranger_comment = FactoryGirl.create(:comment, :commentable => @issue, :user => @stranger, :project => @project)
|
||||||
|
|
||||||
any_instance_of(Project, :versions => ['v1.0', 'v2.0'])
|
any_instance_of(Project, :versions => ['v1.0', 'v2.0'])
|
||||||
end
|
end
|
||||||
|
@ -18,8 +18,8 @@ describe Comment do
|
||||||
before { stub_rsync_methods }
|
before { stub_rsync_methods }
|
||||||
context 'for global admin user' do
|
context 'for global admin user' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = Factory(:admin)
|
@user = FactoryGirl.create(:admin)
|
||||||
@stranger = Factory(:user)
|
@stranger = FactoryGirl.create(:user)
|
||||||
|
|
||||||
set_commentable_data
|
set_commentable_data
|
||||||
end
|
end
|
||||||
|
@ -51,8 +51,8 @@ describe Comment do
|
||||||
|
|
||||||
context 'for project admin user' do
|
context 'for project admin user' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = Factory(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
@stranger = Factory(:user)
|
@stranger = FactoryGirl.create(:user)
|
||||||
|
|
||||||
set_commentable_data
|
set_commentable_data
|
||||||
|
|
||||||
|
@ -79,8 +79,8 @@ describe Comment do
|
||||||
|
|
||||||
context 'for project owner user' do
|
context 'for project owner user' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = Factory(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
@stranger = Factory(:user)
|
@stranger = FactoryGirl.create(:user)
|
||||||
|
|
||||||
set_commentable_data
|
set_commentable_data
|
||||||
|
|
||||||
|
@ -107,8 +107,8 @@ describe Comment do
|
||||||
|
|
||||||
context 'for simple user' do
|
context 'for simple user' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = Factory(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
@stranger = Factory(:user)
|
@stranger = FactoryGirl.create(:user)
|
||||||
|
|
||||||
set_commentable_data
|
set_commentable_data
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,7 +5,7 @@ require "cancan/matchers"
|
||||||
describe Group do
|
describe Group do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
stub_rsync_methods
|
stub_rsync_methods
|
||||||
@group = Factory(:group)
|
@group = FactoryGirl.create(:group)
|
||||||
@ability = Ability.new(User.new)
|
@ability = Ability.new(User.new)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ describe Group do
|
||||||
|
|
||||||
context 'for global admin' do
|
context 'for global admin' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@admin = Factory(:admin)
|
@admin = FactoryGirl.create(:admin)
|
||||||
@ability = Ability.new(@admin)
|
@ability = Ability.new(@admin)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -32,8 +32,8 @@ describe Group do
|
||||||
|
|
||||||
context 'for group admin' do
|
context 'for group admin' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = Factory(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
@another_user = Factory(:user)
|
@another_user = FactoryGirl.create(:user)
|
||||||
@group.objects.create(:object_type => 'User', :object_id => @user.id, :role => 'admin')
|
@group.objects.create(:object_type => 'User', :object_id => @user.id, :role => 'admin')
|
||||||
@ability = Ability.new(@user)
|
@ability = Ability.new(@user)
|
||||||
end
|
end
|
||||||
|
@ -61,7 +61,7 @@ describe Group do
|
||||||
|
|
||||||
context 'for group owner' do
|
context 'for group owner' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = Factory(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
@group.update_attribute(:owner, @user)
|
@group.update_attribute(:owner, @user)
|
||||||
@group.objects.create(:object_type => 'User', :object_id => @user.id, :role => 'admin')
|
@group.objects.create(:object_type => 'User', :object_id => @user.id, :role => 'admin')
|
||||||
@ability = Ability.new(@user)
|
@ability = Ability.new(@user)
|
||||||
|
@ -76,7 +76,7 @@ describe Group do
|
||||||
|
|
||||||
context 'for group reader and writer user' do
|
context 'for group reader and writer user' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = Factory(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
@group.objects.create(:object_type => 'User', :object_id => @user.id, :role => 'reader')
|
@group.objects.create(:object_type => 'User', :object_id => @user.id, :role => 'reader')
|
||||||
@ability = Ability.new(@user)
|
@ability = Ability.new(@user)
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,7 +10,7 @@ describe Platform do
|
||||||
|
|
||||||
context 'released' do
|
context 'released' do
|
||||||
it 'should add suffix to name when released' do
|
it 'should add suffix to name when released' do
|
||||||
@platform = Factory(:platform)
|
@platform = FactoryGirl.create(:platform)
|
||||||
old_name = @platform.name
|
old_name = @platform.name
|
||||||
|
|
||||||
@platform.released = true
|
@platform.released = true
|
||||||
|
@ -20,7 +20,7 @@ describe Platform do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should not add suffix to name when not released' do
|
it 'should not add suffix to name when not released' do
|
||||||
@platform = Factory(:platform, :name => 'name')
|
@platform = FactoryGirl.create(:platform, :name => 'name')
|
||||||
@platform.name.should == 'name'
|
@platform.name.should == 'name'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,10 +4,10 @@ require 'spec_helper'
|
||||||
describe ProjectToRepository do
|
describe ProjectToRepository do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
stub_rsync_methods
|
stub_rsync_methods
|
||||||
@platform = Factory(:platform)
|
@platform = FactoryGirl.create(:platform)
|
||||||
@first_repo = Factory(:repository, :platform_id => @platform.id)
|
@first_repo = FactoryGirl.create(:repository, :platform_id => @platform.id)
|
||||||
@second_repo = Factory(:repository, :platform_id => @platform.id)
|
@second_repo = FactoryGirl.create(:repository, :platform_id => @platform.id)
|
||||||
@project = Factory(:project)
|
@project = FactoryGirl.create(:project)
|
||||||
@first_repo.projects << @project
|
@first_repo.projects << @project
|
||||||
@first_repo.save
|
@first_repo.save
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,7 +6,7 @@ describe Repository do
|
||||||
context 'when create with same owner that platform' do
|
context 'when create with same owner that platform' do
|
||||||
before (:each) do
|
before (:each) do
|
||||||
stub_rsync_methods
|
stub_rsync_methods
|
||||||
@platform = Factory(:platform)
|
@platform = FactoryGirl.create(:platform)
|
||||||
@params = {:name => 'tst_platform', :description => 'test platform'}
|
@params = {:name => 'tst_platform', :description => 'test platform'}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,8 @@ require "cancan/matchers"
|
||||||
def set_testable_data
|
def set_testable_data
|
||||||
@ability = Ability.new(@user)
|
@ability = Ability.new(@user)
|
||||||
|
|
||||||
@project = Factory(:project)
|
@project = FactoryGirl.create(:project)
|
||||||
@issue = Factory(:issue, :project_id => @project.id)
|
@issue = FactoryGirl.create(:issue, :project_id => @project.id)
|
||||||
|
|
||||||
any_instance_of(Project, :versions => ['v1.0', 'v2.0'])
|
any_instance_of(Project, :versions => ['v1.0', 'v2.0'])
|
||||||
end
|
end
|
||||||
|
@ -15,8 +15,8 @@ describe Subscribe do
|
||||||
before { stub_rsync_methods }
|
before { stub_rsync_methods }
|
||||||
context 'for global admin user' do
|
context 'for global admin user' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = Factory(:admin)
|
@user = FactoryGirl.create(:admin)
|
||||||
@stranger = Factory(:user)
|
@stranger = FactoryGirl.create(:user)
|
||||||
|
|
||||||
set_testable_data
|
set_testable_data
|
||||||
end
|
end
|
||||||
|
@ -27,8 +27,8 @@ describe Subscribe do
|
||||||
|
|
||||||
context 'destroy' do
|
context 'destroy' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@subscribe = Factory(:subscribe, :subscribeable => @issue, :user => @user)
|
@subscribe = FactoryGirl.create(:subscribe, :subscribeable => @issue, :user => @user)
|
||||||
@stranger_subscribe = Factory(:subscribe, :subscribeable => @issue, :user => @stranger)
|
@stranger_subscribe = FactoryGirl.create(:subscribe, :subscribeable => @issue, :user => @stranger)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'own subscribe' do
|
context 'own subscribe' do
|
||||||
|
@ -47,8 +47,8 @@ describe Subscribe do
|
||||||
|
|
||||||
context 'for simple user' do
|
context 'for simple user' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = Factory(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
@stranger = Factory(:user)
|
@stranger = FactoryGirl.create(:user)
|
||||||
|
|
||||||
set_testable_data
|
set_testable_data
|
||||||
end
|
end
|
||||||
|
@ -59,8 +59,8 @@ describe Subscribe do
|
||||||
|
|
||||||
context 'destroy' do
|
context 'destroy' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@subscribe = Factory(:subscribe, :subscribeable => @issue, :user => @user)
|
@subscribe = FactoryGirl.create(:subscribe, :subscribeable => @issue, :user => @user)
|
||||||
@stranger_subscribe = Factory(:subscribe, :subscribeable => @issue, :user => @stranger)
|
@stranger_subscribe = FactoryGirl.create(:subscribe, :subscribeable => @issue, :user => @stranger)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'own subscribe' do
|
context 'own subscribe' do
|
||||||
|
|
|
@ -28,7 +28,7 @@ RSpec.configure do |config|
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_session_for(user=nil)
|
def set_session_for(user=nil)
|
||||||
current_user = user.is_a?(Symbol) ? Factory.create(user) : user
|
current_user = user.is_a?(Symbol) ? FactoryGirl.create(user) : user
|
||||||
@request.env["devise.mapping"] = :user
|
@request.env["devise.mapping"] = :user
|
||||||
sign_in current_user
|
sign_in current_user
|
||||||
end
|
end
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
.DS_Store
|
|
|
@ -1,4 +0,0 @@
|
||||||
== 0.0.1 2008-01-28
|
|
||||||
|
|
||||||
* 1 major enhancement:
|
|
||||||
* Initial release
|
|
|
@ -1,21 +0,0 @@
|
||||||
Copyright (c) 2008 Johan Sørensen
|
|
||||||
Copyright (c) 2003 Marcel Molina Jr.
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
a copy of this software and associated documentation files (the
|
|
||||||
"Software"), to deal in the Software without restriction, including
|
|
||||||
without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
distribute, sublicense, and/or sell copies of the Software, and to
|
|
||||||
permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be
|
|
||||||
included in all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
||||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
||||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
@ -1,26 +0,0 @@
|
||||||
History.txt
|
|
||||||
License.txt
|
|
||||||
Manifest.txt
|
|
||||||
README.txt
|
|
||||||
Rakefile
|
|
||||||
config/hoe.rb
|
|
||||||
config/requirements.rb
|
|
||||||
lib/diff-display.rb
|
|
||||||
lib/diff-display/version.rb
|
|
||||||
log/debug.log
|
|
||||||
script/destroy
|
|
||||||
script/generate
|
|
||||||
script/txt2html
|
|
||||||
setup.rb
|
|
||||||
spec/diff-display_spec.rb
|
|
||||||
spec/spec.opts
|
|
||||||
spec/spec_helper.rb
|
|
||||||
tasks/deployment.rake
|
|
||||||
tasks/environment.rake
|
|
||||||
tasks/rspec.rake
|
|
||||||
tasks/website.rake
|
|
||||||
website/index.html
|
|
||||||
website/index.txt
|
|
||||||
website/javascripts/rounded_corners_lite.inc.js
|
|
||||||
website/stylesheets/screen.css
|
|
||||||
website/template.rhtml
|
|
|
@ -1,58 +0,0 @@
|
||||||
Diff::Display
|
|
||||||
=============
|
|
||||||
|
|
||||||
Diff::Display::Unified renders unified diffs into various forms. The output is
|
|
||||||
based on a callback object that's passed into the renderer
|
|
||||||
|
|
||||||
Rewrite of an (unreleased) library by Marcel Molina Jr., who wrote this it
|
|
||||||
probably back in 2004 or so.
|
|
||||||
|
|
||||||
Usage
|
|
||||||
======
|
|
||||||
|
|
||||||
irb(main):001:0> require 'diff-display'
|
|
||||||
=> true
|
|
||||||
irb(main):002:0> diff = <<EOS
|
|
||||||
irb(main):003:0" diff --git a/History.txt b/History.txt
|
|
||||||
irb(main):004:0" index 0ed7358..622c384 100644
|
|
||||||
irb(main):005:0" --- a/History.txt
|
|
||||||
irb(main):006:0" +++ b/History.txt
|
|
||||||
irb(main):007:0" @@ -1,4 +1,5 @@
|
|
||||||
irb(main):008:0" == 0.0.1 2008-01-28
|
|
||||||
irb(main):009:0"
|
|
||||||
irb(main):010:0" -* 1 major enhancement:
|
|
||||||
irb(main):011:0" - * Initial release
|
|
||||||
irb(main):012:0" +* 2 major enhancements:
|
|
||||||
irb(main):013:0" + * The Initial release
|
|
||||||
irb(main):014:0" + * stuff added
|
|
||||||
irb(main):015:0" EOS
|
|
||||||
...
|
|
||||||
irb(main):016:0> diff_display = Diff::Display::Unified.new(diff)
|
|
||||||
=> #<Diff::Display::Unified:0x331c9c @data=...
|
|
||||||
# Be boring and render it back out as a diff
|
|
||||||
irb(main):017:0> puts diff_display.render(Diff::Renderer::Diff.new)
|
|
||||||
diff --git a/History.txt b/History.txt
|
|
||||||
index 0ed7358..622c384 100644
|
|
||||||
--- a/History.txt
|
|
||||||
+++ b/History.txt
|
|
||||||
@@ -1,4 +1,5 @@
|
|
||||||
== 0.0.1 2008-01-28
|
|
||||||
|
|
||||||
-* 1 major enhancement:
|
|
||||||
- * Initial release
|
|
||||||
+* 2 major enhancements:
|
|
||||||
+ * The Initial release
|
|
||||||
+ * stuff added
|
|
||||||
|
|
||||||
See Diff::Renderer::Base for what methods your callback needs to implement
|
|
||||||
|
|
||||||
Git Repository
|
|
||||||
===============
|
|
||||||
|
|
||||||
http://gitorious.org/projects/diff-display/
|
|
||||||
|
|
||||||
|
|
||||||
License
|
|
||||||
======
|
|
||||||
|
|
||||||
Please see License.txt
|
|
|
@ -1,10 +0,0 @@
|
||||||
# encoding: utf-8
|
|
||||||
|
|
||||||
require 'rubygems'
|
|
||||||
require 'hoe'
|
|
||||||
require './lib/diff-display.rb'
|
|
||||||
|
|
||||||
Hoe.new('diff-display', Diff::Display::VERSION::STRING) do |p|
|
|
||||||
p.rubyforge_name = 'hoe_testx'
|
|
||||||
p.developer('Johan Sørensen', 'johan@johansorensen.com')
|
|
||||||
end
|
|
|
@ -1,15 +0,0 @@
|
||||||
# -*- encoding : utf-8 -*-
|
|
||||||
$:.unshift File.dirname(__FILE__)
|
|
||||||
|
|
||||||
module Diff
|
|
||||||
module Display
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
require "diff/display/version"
|
|
||||||
# require "diff/display/data_structure"
|
|
||||||
require "diff/display/unified"
|
|
||||||
require "diff/display/unified/generator"
|
|
||||||
|
|
||||||
require "diff/renderer/base"
|
|
||||||
require "diff/renderer/diff"
|
|
|
@ -1,20 +0,0 @@
|
||||||
# -*- encoding : utf-8 -*-
|
|
||||||
module Diff
|
|
||||||
module Display
|
|
||||||
class Unified
|
|
||||||
def initialize(udiff)
|
|
||||||
@data = Diff::Display::Unified::Generator.run(udiff)
|
|
||||||
end
|
|
||||||
attr_reader :data
|
|
||||||
|
|
||||||
def stats
|
|
||||||
@stats ||= data.stats
|
|
||||||
end
|
|
||||||
|
|
||||||
def render(renderer, out="")
|
|
||||||
out << renderer.render(data)
|
|
||||||
out
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,405 +0,0 @@
|
||||||
# -*- encoding : utf-8 -*-
|
|
||||||
module Diff::Display
|
|
||||||
# Processes the diff and generates a Data object which contains the
|
|
||||||
# resulting data structure.
|
|
||||||
#
|
|
||||||
# The +run+ class method is fed a diff and returns a Data object. It will
|
|
||||||
# accept as its argument a String, an Array or a File object (or anything
|
|
||||||
# that responds to #each):
|
|
||||||
#
|
|
||||||
# Diff::Display::Unified::Generator.run(diff)
|
|
||||||
#
|
|
||||||
class Data < Array
|
|
||||||
def initialize
|
|
||||||
super
|
|
||||||
@stats = {:additions => 0, :deletions => 0}
|
|
||||||
end
|
|
||||||
|
|
||||||
def stats
|
|
||||||
each do |block|
|
|
||||||
block.each do |line|
|
|
||||||
case line
|
|
||||||
when Diff::Display::AddLine
|
|
||||||
@stats[:additions] += 1
|
|
||||||
when Diff::Display::RemLine
|
|
||||||
@stats[:deletions] += 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@stats
|
|
||||||
end
|
|
||||||
|
|
||||||
def to_diff
|
|
||||||
diff = ""
|
|
||||||
each do |block|
|
|
||||||
block.each do |line|
|
|
||||||
line_str = line.expand_inline_changes_with(nil, nil)
|
|
||||||
case line
|
|
||||||
when HeaderLine
|
|
||||||
diff << "#{line_str}\n"
|
|
||||||
when UnModLine
|
|
||||||
diff << " #{line_str}\n"
|
|
||||||
when SepLine
|
|
||||||
diff << "\n"
|
|
||||||
when AddLine
|
|
||||||
diff << "+#{line_str}\n"
|
|
||||||
when RemLine
|
|
||||||
diff << "-#{line_str}\n"
|
|
||||||
when NonewlineLine
|
|
||||||
diff << line_str
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
diff.chomp
|
|
||||||
end
|
|
||||||
|
|
||||||
def debug
|
|
||||||
demodularize = Proc.new {|obj| obj.class.name[/\w+$/]}
|
|
||||||
each do |diff_block|
|
|
||||||
print "-" * 40, ' ', demodularize.call(diff_block)
|
|
||||||
puts
|
|
||||||
puts diff_block.map {|line|
|
|
||||||
# "%5d" % line.old_number +
|
|
||||||
"%8s" % "[#{line.old_number || '.'} #{line.new_number || '.'}]" +
|
|
||||||
" [#{demodularize.call(line)}#{'(i)' if line.inline_changes?}]" +
|
|
||||||
line
|
|
||||||
}.join("\n")
|
|
||||||
puts "-" * 40, ' '
|
|
||||||
end
|
|
||||||
nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
class Line < String
|
|
||||||
class << self
|
|
||||||
def add(line, line_number, inline = false, offsets = [])
|
|
||||||
AddLine.new(line, line_number, inline, offsets)
|
|
||||||
end
|
|
||||||
|
|
||||||
def rem(line, line_number, inline = false, offsets = [])
|
|
||||||
RemLine.new(line, line_number, inline, offsets)
|
|
||||||
end
|
|
||||||
|
|
||||||
def unmod(line, old_number, new_number)
|
|
||||||
UnModLine.new(line, old_number, new_number)
|
|
||||||
end
|
|
||||||
|
|
||||||
def nonewline(line)
|
|
||||||
NonewlineLine.new(line)
|
|
||||||
end
|
|
||||||
|
|
||||||
def header(line)
|
|
||||||
HeaderLine.new(line)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def initialize(line, old_number = nil, new_number = nil)
|
|
||||||
super(line)
|
|
||||||
@old_number, @new_number = old_number, new_number
|
|
||||||
@inline = false
|
|
||||||
end
|
|
||||||
attr_reader :old_number, :new_number
|
|
||||||
|
|
||||||
def identifier
|
|
||||||
self.class.name[/\w+$/].gsub(/Line$/, "").downcase.to_sym
|
|
||||||
end
|
|
||||||
|
|
||||||
def inline_changes?
|
|
||||||
# Is set in the AddLine+RemLine subclasses
|
|
||||||
@inline
|
|
||||||
end
|
|
||||||
|
|
||||||
# returns the prefix, middle and postfix parts of a line with inline changes
|
|
||||||
def segments
|
|
||||||
return self.dup unless inline_changes?
|
|
||||||
prefix, changed = self.dup.split('\\0')
|
|
||||||
changed, postfix = changed.split('\\1')
|
|
||||||
[prefix, changed, postfix]
|
|
||||||
end
|
|
||||||
|
|
||||||
# Expand any inline changes with +prefix+ and +postfix+
|
|
||||||
def expand_inline_changes_with(prefix, postfix)
|
|
||||||
return self.dup unless inline_changes?
|
|
||||||
str = self.dup
|
|
||||||
str.sub!('\\0', prefix.to_s)
|
|
||||||
str.sub!('\\1', postfix.to_s)
|
|
||||||
str
|
|
||||||
end
|
|
||||||
|
|
||||||
def inspect
|
|
||||||
%Q{#<#{self.class.name} [#{old_number.inspect}-#{new_number.inspect}] "#{self}">}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
class AddLine < Line
|
|
||||||
def initialize(line, line_number, inline = false, offsets = [])
|
|
||||||
super(line, nil, line_number)
|
|
||||||
@inline = inline
|
|
||||||
@offsets = offsets
|
|
||||||
end
|
|
||||||
attr_reader :offsets
|
|
||||||
end
|
|
||||||
|
|
||||||
class RemLine < Line
|
|
||||||
def initialize(line, line_number, inline = false, offsets = [])
|
|
||||||
super(line, line_number, nil)
|
|
||||||
@inline = inline
|
|
||||||
@offsets = offsets
|
|
||||||
end
|
|
||||||
attr_reader :offsets
|
|
||||||
end
|
|
||||||
|
|
||||||
class NonewlineLine < Line
|
|
||||||
def initialize(line = '\\ No newline at end of file')
|
|
||||||
super(line)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
class UnModLine < Line
|
|
||||||
def initialize(line, old_number, new_number)
|
|
||||||
super(line, old_number, new_number)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
class SepLine < Line
|
|
||||||
def initialize(line = '...')
|
|
||||||
super(line)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
class HeaderLine < Line
|
|
||||||
def initialize(line)
|
|
||||||
super(line)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# This class is an array which contains Line objects. Just like Line
|
|
||||||
# classes, several Block classes inherit from Block. If all the lines
|
|
||||||
# in the block are added lines then it is an AddBlock. If all lines
|
|
||||||
# in the block are removed lines then it is a RemBlock. If the lines
|
|
||||||
# in the block are all unmodified then it is an UnMod block. If the
|
|
||||||
# lines in the block are a mixture of added and removed lines then
|
|
||||||
# it is a ModBlock. There are no blocks that contain a mixture of
|
|
||||||
# modified and unmodified lines.
|
|
||||||
class Block < Array
|
|
||||||
class << self
|
|
||||||
def add; AddBlock.new end
|
|
||||||
def rem; RemBlock.new end
|
|
||||||
def mod; ModBlock.new end
|
|
||||||
def unmod; UnModBlock.new end
|
|
||||||
def header; HeaderBlock.new end
|
|
||||||
def nonewline; NonewlineBlock.new end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
#:stopdoc:#
|
|
||||||
class AddBlock < Block; end
|
|
||||||
class RemBlock < Block; end
|
|
||||||
class ModBlock < Block; end
|
|
||||||
class UnModBlock < Block; end
|
|
||||||
class SepBlock < Block; end
|
|
||||||
class HeaderBlock < Block; end
|
|
||||||
class NonewlineBlock < Block; end
|
|
||||||
#:startdoc:#
|
|
||||||
|
|
||||||
|
|
||||||
class Unified::Generator
|
|
||||||
|
|
||||||
# Extracts the line number info for a given diff section
|
|
||||||
LINE_NUM_RE = /^@@ [+-]([0-9]+)(?:,([0-9]+))? [+-]([0-9]+)(?:,([0-9]+))? @@/
|
|
||||||
LINE_TYPES = {'+' => :add, '-' => :rem, ' ' => :unmod, '\\' => :nonewline}
|
|
||||||
|
|
||||||
# Runs the generator on a diff and returns a Data object
|
|
||||||
def self.run(udiff)
|
|
||||||
raise ArgumentError, "Object must be enumerable" unless udiff.respond_to?(:each_line)
|
|
||||||
generator = new
|
|
||||||
udiff.each_line do |line|
|
|
||||||
begin
|
|
||||||
generator.process(line.chomp)
|
|
||||||
rescue ArgumentError => e
|
|
||||||
e.message =~ /^invalid byte sequence/ ? next : raise(e)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
generator.finish
|
|
||||||
generator.data
|
|
||||||
end
|
|
||||||
|
|
||||||
def initialize
|
|
||||||
@buffer = []
|
|
||||||
@line_type = nil
|
|
||||||
@prev_line_type = nil
|
|
||||||
@offset = [0, 0]
|
|
||||||
@data = Data.new
|
|
||||||
self
|
|
||||||
end
|
|
||||||
|
|
||||||
# Finishes up with the generation and returns the Data object (could
|
|
||||||
# probably use a better name...maybe just #data?)
|
|
||||||
def data
|
|
||||||
@data
|
|
||||||
end
|
|
||||||
|
|
||||||
# This method is called once the generator is done with the unified
|
|
||||||
# diff. It is a finalizer of sorts. By the time it is called all data
|
|
||||||
# has been collected and processed.
|
|
||||||
def finish
|
|
||||||
# certain things could be set now that processing is done
|
|
||||||
#identify_block
|
|
||||||
end
|
|
||||||
|
|
||||||
def process(line)
|
|
||||||
if is_header_line?(line)
|
|
||||||
push Block.header
|
|
||||||
current_block << Line.header(line)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if line =~ LINE_NUM_RE
|
|
||||||
push Block.header
|
|
||||||
current_block << Line.header(line)
|
|
||||||
add_separator unless @offset[0].zero?
|
|
||||||
@line_type = nil
|
|
||||||
@offset = Array.new(2) { $3.to_i - 1 }
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
@line_type, line = LINE_TYPES[car(line)], cdr(line)
|
|
||||||
|
|
||||||
if @line_type == :add && @prev_line_type == :rem
|
|
||||||
@offset[0] -= 1
|
|
||||||
@buffer.push current_block.pop
|
|
||||||
@buffer.push line
|
|
||||||
process_block(:mod, false)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if LINE_TYPES.values.include?(@line_type)
|
|
||||||
@buffer.push(line.to_s)
|
|
||||||
process_block(@line_type, true)
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
protected
|
|
||||||
def is_header_line?(line)
|
|
||||||
return true if ['+++ ', '--- '].include?(line[0,4])
|
|
||||||
return true if line =~ /^(new|delete) file mode [0-9]+$/
|
|
||||||
return true if line =~ /^diff \-\-git/
|
|
||||||
return true if line =~ /^index \w+\.\.\w+( [0-9]+)?$/i
|
|
||||||
false
|
|
||||||
end
|
|
||||||
|
|
||||||
def process_block(diff_line_type, isnew = false)
|
|
||||||
@data.pop unless isnew
|
|
||||||
push Block.send(diff_line_type)
|
|
||||||
|
|
||||||
current_line = @buffer.pop
|
|
||||||
return unless current_line
|
|
||||||
|
|
||||||
# \\ No newline at end of file
|
|
||||||
if diff_line_type == :nonewline
|
|
||||||
current_block << Line.nonewline('\\ No newline at end of file')
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if isnew
|
|
||||||
process_line(current_line, diff_line_type)
|
|
||||||
else
|
|
||||||
process_lines_with_differences(@buffer.shift, current_line)
|
|
||||||
raise "buffer exceeded #{@buffer.inspect}" unless @buffer.empty?
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def process_line(line, type, inline = false)
|
|
||||||
case type
|
|
||||||
when :add
|
|
||||||
@offset[1] += 1
|
|
||||||
current_block << Line.send(type, line, @offset[1], inline, @offset.dup)
|
|
||||||
when :rem
|
|
||||||
@offset[0] += 1
|
|
||||||
current_block << Line.send(type, line, @offset[0], inline, @offset.dup)
|
|
||||||
# when :rmod
|
|
||||||
# @offset[0] += 1
|
|
||||||
# @offset[1] += 1 # TODO: is that really correct?
|
|
||||||
# current_block << Line.send(@prev_line_type, line, @offset[0])
|
|
||||||
when :unmod
|
|
||||||
@offset[0] += 1
|
|
||||||
@offset[1] += 1
|
|
||||||
current_block << Line.send(type, line, *@offset)
|
|
||||||
end
|
|
||||||
@prev_line_type = type
|
|
||||||
end
|
|
||||||
|
|
||||||
# TODO Needs a better name...it does process a line (two in fact) but
|
|
||||||
# its primary function is to add a Rem and an Add pair which
|
|
||||||
# potentially have inline changes
|
|
||||||
def process_lines_with_differences(oldline, newline)
|
|
||||||
start, ending = get_change_extent(oldline, newline)
|
|
||||||
|
|
||||||
if start.zero? && ending.zero?
|
|
||||||
process_line(oldline, :rem, false) # -
|
|
||||||
process_line(newline, :add, false) # +
|
|
||||||
else
|
|
||||||
# -
|
|
||||||
line = inline_diff(oldline, start, ending)
|
|
||||||
process_line(line, :rem, true)
|
|
||||||
# +
|
|
||||||
line = inline_diff(newline, start, ending)
|
|
||||||
process_line(line, :add, true)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Inserts string formating characters around the section of a string
|
|
||||||
# that differs internally from another line so that the Line class
|
|
||||||
# can insert the desired formating
|
|
||||||
def inline_diff(line, start, ending)
|
|
||||||
if start != 0 || ending != 0
|
|
||||||
last = ending + line.length
|
|
||||||
str = line[0...start] + '\0' + line[start...last] + '\1' + line[last...line.length]
|
|
||||||
end
|
|
||||||
str || line
|
|
||||||
end
|
|
||||||
|
|
||||||
def add_separator
|
|
||||||
push SepBlock.new
|
|
||||||
current_block << SepLine.new
|
|
||||||
end
|
|
||||||
|
|
||||||
def car(line)
|
|
||||||
line[0,1]
|
|
||||||
end
|
|
||||||
|
|
||||||
def cdr(line)
|
|
||||||
line[1..-1]
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns the current Block object
|
|
||||||
def current_block
|
|
||||||
@data.last
|
|
||||||
end
|
|
||||||
|
|
||||||
# Adds a Line object onto the current Block object
|
|
||||||
def push(line)
|
|
||||||
@data.push line
|
|
||||||
end
|
|
||||||
|
|
||||||
# Determines the extent of differences between two string. Returns
|
|
||||||
# an array containing the offset at which changes start, and then
|
|
||||||
# negative offset at which the chnages end. If the two strings have
|
|
||||||
# neither a common prefix nor a common suffic, [0, 0] is returned.
|
|
||||||
def get_change_extent(str1, str2)
|
|
||||||
start = 0
|
|
||||||
limit = [str1.size, str2.size].sort.first
|
|
||||||
while start < limit and str1[start, 1] == str2[start, 1]
|
|
||||||
start += 1
|
|
||||||
end
|
|
||||||
ending = -1
|
|
||||||
limit -= start
|
|
||||||
while -ending <= limit and str1[ending, 1] == str2[ending, 1]
|
|
||||||
ending -= 1
|
|
||||||
end
|
|
||||||
|
|
||||||
return [start, ending + 1]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,12 +0,0 @@
|
||||||
# -*- encoding : utf-8 -*-
|
|
||||||
module Diff
|
|
||||||
module Display #:nodoc:
|
|
||||||
module VERSION #:nodoc:
|
|
||||||
MAJOR = 0
|
|
||||||
MINOR = 0
|
|
||||||
TINY = 1
|
|
||||||
|
|
||||||
STRING = [MAJOR, MINOR, TINY].join('.')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,93 +0,0 @@
|
||||||
# -*- encoding : utf-8 -*-
|
|
||||||
module Diff
|
|
||||||
module Renderer
|
|
||||||
class Base
|
|
||||||
def render(data)
|
|
||||||
result = []
|
|
||||||
data.each do |block|
|
|
||||||
result << send("before_" + classify(block), block)
|
|
||||||
result << block.map { |line| send(classify(line), line) }
|
|
||||||
result << send("after_" + classify(block), block)
|
|
||||||
end
|
|
||||||
result.compact.join(new_line)
|
|
||||||
end
|
|
||||||
|
|
||||||
def before_headerblock(block)
|
|
||||||
end
|
|
||||||
|
|
||||||
def before_unmodblock(block)
|
|
||||||
end
|
|
||||||
|
|
||||||
def before_modblock(block)
|
|
||||||
end
|
|
||||||
|
|
||||||
def before_remblock(block)
|
|
||||||
end
|
|
||||||
|
|
||||||
def before_addblock(block)
|
|
||||||
end
|
|
||||||
|
|
||||||
def before_sepblock(block)
|
|
||||||
end
|
|
||||||
|
|
||||||
def before_nonewlineblock(block)
|
|
||||||
end
|
|
||||||
|
|
||||||
def headerline(line)
|
|
||||||
line
|
|
||||||
end
|
|
||||||
|
|
||||||
def unmodline(line)
|
|
||||||
line
|
|
||||||
end
|
|
||||||
|
|
||||||
def remline(line)
|
|
||||||
line
|
|
||||||
end
|
|
||||||
|
|
||||||
def addline(line)
|
|
||||||
line
|
|
||||||
end
|
|
||||||
|
|
||||||
def sepline(line)
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def nonewlineline(line)
|
|
||||||
line
|
|
||||||
end
|
|
||||||
|
|
||||||
def after_headerblock(block)
|
|
||||||
end
|
|
||||||
|
|
||||||
def after_unmodblock(block)
|
|
||||||
end
|
|
||||||
|
|
||||||
def after_modblock(block)
|
|
||||||
end
|
|
||||||
|
|
||||||
def after_remblock(block)
|
|
||||||
"</div>"
|
|
||||||
end
|
|
||||||
|
|
||||||
def after_addblock(block)
|
|
||||||
"</div>"
|
|
||||||
end
|
|
||||||
|
|
||||||
def after_sepblock(block)
|
|
||||||
end
|
|
||||||
|
|
||||||
def after_nonewlineblock(block)
|
|
||||||
end
|
|
||||||
|
|
||||||
def new_line
|
|
||||||
""
|
|
||||||
end
|
|
||||||
|
|
||||||
protected
|
|
||||||
def classify(object)
|
|
||||||
object.class.name[/\w+$/].downcase
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,94 +0,0 @@
|
||||||
# -*- encoding : utf-8 -*-
|
|
||||||
module Diff
|
|
||||||
module Renderer
|
|
||||||
class Diff < Base
|
|
||||||
def before_addblock(block)
|
|
||||||
%q{<tbody class="add"><tr>}
|
|
||||||
end
|
|
||||||
|
|
||||||
def before_remblock(block)
|
|
||||||
%Q{<tbody class="rem"><tr>}
|
|
||||||
end
|
|
||||||
|
|
||||||
def before_modblock(block)
|
|
||||||
%Q{<tbody class="mod"><tr>}
|
|
||||||
end
|
|
||||||
|
|
||||||
def before_unmodblock(block)
|
|
||||||
%Q{<tbody class="unmod"><tr>}
|
|
||||||
end
|
|
||||||
|
|
||||||
def before_sepblock(block)
|
|
||||||
%Q{<tbody class="sep"><tr>}
|
|
||||||
end
|
|
||||||
|
|
||||||
# After blocks
|
|
||||||
def after_addblock(block)
|
|
||||||
"</tbody>"
|
|
||||||
end
|
|
||||||
|
|
||||||
def after_remblock(block)
|
|
||||||
"</tbody>"
|
|
||||||
end
|
|
||||||
|
|
||||||
def after_modblock(block)
|
|
||||||
"</tbody>"
|
|
||||||
end
|
|
||||||
|
|
||||||
def after_unmodblock(block)
|
|
||||||
"</tbody>"
|
|
||||||
end
|
|
||||||
|
|
||||||
def after_sepblock(block)
|
|
||||||
"</tbody>"
|
|
||||||
end
|
|
||||||
|
|
||||||
# Before lines
|
|
||||||
def addline(line)
|
|
||||||
# adds go on the right
|
|
||||||
%Q{<th class="line-numbers">#{line.old_number}</th>} +
|
|
||||||
%Q{<td class="code ins"></td>} +
|
|
||||||
%Q{<th class="line-numbers">#{line.new_number}</th>} +
|
|
||||||
%Q{<td class="code ins"><ins>#{line}</ins></td></tr>}
|
|
||||||
end
|
|
||||||
|
|
||||||
def remline(line)
|
|
||||||
# rems go on the left (hide the right side)
|
|
||||||
%Q{<th class="line-numbers">#{line.old_number}</th>} +
|
|
||||||
%Q{<td class="code del"><del>#{line}</del></td>} +
|
|
||||||
%Q{<th class="line-numbers">#{line.new_number}</th>} +
|
|
||||||
%Q{<td class="code del hidden"><del>#{line}</del></td></tr>}
|
|
||||||
end
|
|
||||||
|
|
||||||
def modline(line)
|
|
||||||
# TODO: figure how we best display these
|
|
||||||
# %Q{<th class="line-numbers">#{line.old_number}</th>} +
|
|
||||||
# %Q{<td class="code changed mod">#{render_line(line)}</td>} +
|
|
||||||
# %Q{<th class="line-numbers">#{line.new_number}</th>} +
|
|
||||||
# %Q{<td class="code changed mod">#{render_line(line)}</td></tr>}
|
|
||||||
end
|
|
||||||
|
|
||||||
def unmodline(line)
|
|
||||||
# unmods goes on both sides
|
|
||||||
%Q{<th class="line-numbers">#{line.old_number}</th>} +
|
|
||||||
%Q{<td class="code unchanged unmod">#{line}</td>} +
|
|
||||||
%Q{<th class="line-numbers">#{line.new_number}</th>} +
|
|
||||||
%Q{<td class="code unchanged unmod">#{line}</td></tr>}
|
|
||||||
end
|
|
||||||
|
|
||||||
def sepline(line)
|
|
||||||
%Q{<th class="line-numbers line-num-cut">…</th>} +
|
|
||||||
%Q{<td class="code cut-line"></td>} +
|
|
||||||
%Q{<th class="line-numbers line-num-cut">…</th>} +
|
|
||||||
%Q{<td class="code cut-line"></td></tr>}
|
|
||||||
end
|
|
||||||
|
|
||||||
def nonewlineline(line)
|
|
||||||
%Q{<th class="line-numbers line-num-cut">…</th>} +
|
|
||||||
%Q{<td class="code mod"></td>} +
|
|
||||||
%Q{<th class="line-numbers line-num-cut">…</th>} +
|
|
||||||
%Q{<td class="code mod">#{line}</td></tr>}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,34 +0,0 @@
|
||||||
desc 'Release the website and new gem version'
|
|
||||||
task :deploy => [:check_version, :website, :release] do
|
|
||||||
puts "Remember to create SVN tag:"
|
|
||||||
puts "svn copy svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/trunk " +
|
|
||||||
"svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/tags/REL-#{VERS} "
|
|
||||||
puts "Suggested comment:"
|
|
||||||
puts "Tagging release #{CHANGES}"
|
|
||||||
end
|
|
||||||
|
|
||||||
desc 'Runs tasks website_generate and install_gem as a local deployment of the gem'
|
|
||||||
task :local_deploy => [:website_generate, :install_gem]
|
|
||||||
|
|
||||||
task :check_version do
|
|
||||||
unless ENV['VERSION']
|
|
||||||
puts 'Must pass a VERSION=x.y.z release version'
|
|
||||||
exit
|
|
||||||
end
|
|
||||||
unless ENV['VERSION'] == VERS
|
|
||||||
puts "Please update your version.rb to match the release version, currently #{VERS}"
|
|
||||||
exit
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
desc 'Install the package as a gem, without generating documentation(ri/rdoc)'
|
|
||||||
task :install_gem_no_doc => [:clean, :package] do
|
|
||||||
sh "#{'sudo ' unless Hoe::WINDOZE }gem install pkg/*.gem --no-rdoc --no-ri"
|
|
||||||
end
|
|
||||||
|
|
||||||
namespace :manifest do
|
|
||||||
desc 'Recreate Manifest.txt to include ALL files'
|
|
||||||
task :refresh do
|
|
||||||
`rake check_manifest | patch -p0 > Manifest.txt`
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,7 +0,0 @@
|
||||||
task :ruby_env do
|
|
||||||
RUBY_APP = if RUBY_PLATFORM =~ /java/
|
|
||||||
"jruby"
|
|
||||||
else
|
|
||||||
"ruby"
|
|
||||||
end unless defined? RUBY_APP
|
|
||||||
end
|
|
|
@ -1,17 +0,0 @@
|
||||||
desc 'Generate website files'
|
|
||||||
task :website_generate => :ruby_env do
|
|
||||||
(Dir['website/**/*.txt'] - Dir['website/version*.txt']).each do |txt|
|
|
||||||
sh %{ #{RUBY_APP} script/txt2html #{txt} > #{txt.gsub(/txt$/,'html')} }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
desc 'Upload website files to rubyforge'
|
|
||||||
task :website_upload do
|
|
||||||
host = "#{rubyforge_username}@rubyforge.org"
|
|
||||||
remote_dir = "/var/www/gforge-projects/#{PATH}/"
|
|
||||||
local_dir = 'website'
|
|
||||||
sh %{rsync -aCv #{local_dir}/ #{host}:#{remote_dir}}
|
|
||||||
end
|
|
||||||
|
|
||||||
desc 'Generate and upload website files'
|
|
||||||
task :website => [:website_generate, :website_upload, :publish_docs]
|
|
|
@ -1,14 +0,0 @@
|
||||||
#!/usr/bin/env ruby
|
|
||||||
APP_ROOT = File.join(File.dirname(__FILE__), '..')
|
|
||||||
|
|
||||||
begin
|
|
||||||
require 'rubigen'
|
|
||||||
rescue LoadError
|
|
||||||
require 'rubygems'
|
|
||||||
require 'rubigen'
|
|
||||||
end
|
|
||||||
require 'rubigen/scripts/destroy'
|
|
||||||
|
|
||||||
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
|
||||||
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
|
||||||
RubiGen::Scripts::Destroy.new.run(ARGV)
|
|
|
@ -1,14 +0,0 @@
|
||||||
#!/usr/bin/env ruby
|
|
||||||
APP_ROOT = File.join(File.dirname(__FILE__), '..')
|
|
||||||
|
|
||||||
begin
|
|
||||||
require 'rubigen'
|
|
||||||
rescue LoadError
|
|
||||||
require 'rubygems'
|
|
||||||
require 'rubigen'
|
|
||||||
end
|
|
||||||
require 'rubigen/scripts/generate'
|
|
||||||
|
|
||||||
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
|
||||||
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
|
||||||
RubiGen::Scripts::Generate.new.run(ARGV)
|
|
|
@ -1,74 +0,0 @@
|
||||||
#!/usr/bin/env ruby
|
|
||||||
|
|
||||||
require 'rubygems'
|
|
||||||
begin
|
|
||||||
require 'newgem'
|
|
||||||
rescue LoadError
|
|
||||||
puts "\n\nGenerating the website requires the newgem RubyGem"
|
|
||||||
puts "Install: gem install newgem\n\n"
|
|
||||||
exit(1)
|
|
||||||
end
|
|
||||||
require 'redcloth'
|
|
||||||
require 'syntax/convertors/html'
|
|
||||||
require 'erb'
|
|
||||||
require File.dirname(__FILE__) + '/../lib/diff-display/version.rb'
|
|
||||||
|
|
||||||
version = Diff-display::VERSION::STRING
|
|
||||||
download = 'http://rubyforge.org/projects/diff-display'
|
|
||||||
|
|
||||||
class Fixnum
|
|
||||||
def ordinal
|
|
||||||
# teens
|
|
||||||
return 'th' if (10..19).include?(self % 100)
|
|
||||||
# others
|
|
||||||
case self % 10
|
|
||||||
when 1: return 'st'
|
|
||||||
when 2: return 'nd'
|
|
||||||
when 3: return 'rd'
|
|
||||||
else return 'th'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
class Time
|
|
||||||
def pretty
|
|
||||||
return "#{mday}#{mday.ordinal} #{strftime('%B')} #{year}"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def convert_syntax(syntax, source)
|
|
||||||
return Syntax::Convertors::HTML.for_syntax(syntax).convert(source).gsub(%r!^<pre>|</pre>$!,'')
|
|
||||||
end
|
|
||||||
|
|
||||||
if ARGV.length >= 1
|
|
||||||
src, template = ARGV
|
|
||||||
template ||= File.join(File.dirname(__FILE__), '/../website/template.rhtml')
|
|
||||||
|
|
||||||
else
|
|
||||||
puts("Usage: #{File.split($0).last} source.txt [template.rhtml] > output.html")
|
|
||||||
exit!
|
|
||||||
end
|
|
||||||
|
|
||||||
template = ERB.new(File.open(template).read)
|
|
||||||
|
|
||||||
title = nil
|
|
||||||
body = nil
|
|
||||||
File.open(src) do |fsrc|
|
|
||||||
title_text = fsrc.readline
|
|
||||||
body_text = fsrc.read
|
|
||||||
syntax_items = []
|
|
||||||
body_text.gsub!(%r!<(pre|code)[^>]*?syntax=['"]([^'"]+)[^>]*>(.*?)</\1>!m){
|
|
||||||
ident = syntax_items.length
|
|
||||||
element, syntax, source = $1, $2, $3
|
|
||||||
syntax_items << "<#{element} class='syntax'>#{convert_syntax(syntax, source)}</#{element}>"
|
|
||||||
"syntax-temp-#{ident}"
|
|
||||||
}
|
|
||||||
title = RedCloth.new(title_text).to_html.gsub(%r!<.*?>!,'').strip
|
|
||||||
body = RedCloth.new(body_text).to_html
|
|
||||||
body.gsub!(%r!(?:<pre><code>)?syntax-temp-(\d+)(?:</code></pre>)?!){ syntax_items[$1.to_i] }
|
|
||||||
end
|
|
||||||
stat = File.stat(src)
|
|
||||||
created = stat.ctime
|
|
||||||
modified = stat.mtime
|
|
||||||
|
|
||||||
$stdout << template.result(binding)
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,590 +0,0 @@
|
||||||
--- unified.rb (revision 620)
|
|
||||||
+++ unified.rb (revision 644)
|
|
||||||
@@ -1,298 +1,390 @@
|
|
||||||
module Diff
|
|
||||||
module Display
|
|
||||||
module Unified
|
|
||||||
-
|
|
||||||
- LINE_RE = /@@ [+-]([0-9]+),([0-9]+) [+-]([0-9]+),([0-9]+) @@/
|
|
||||||
- TABWIDTH = 4
|
|
||||||
- SPACE = ' ' #' '
|
|
||||||
- # By defaul don't wrap inline diffs in anything
|
|
||||||
- INLINE_REM_OPEN = "\e[4;33m"
|
|
||||||
- INLINE_REM_CLOSE = "\e[m"
|
|
||||||
- INLINE_ADD_OPEN = "\e[4;35m"
|
|
||||||
- INLINE_ADD_CLOSE = "\e[m"
|
|
||||||
- ESCAPE_HTML = false
|
|
||||||
-
|
|
||||||
class Line < String
|
|
||||||
- attr_reader :add_lineno, :rem_lineno
|
|
||||||
- def initialize(line, type, add_lineno, rem_lineno = add_lineno)
|
|
||||||
+ def initialize(line, line_number)
|
|
||||||
super(line)
|
|
||||||
- @type = type
|
|
||||||
- @add_lineno = add_lineno
|
|
||||||
- @rem_lineno = rem_lineno
|
|
||||||
+ @line_number = line_number
|
|
||||||
+ self
|
|
||||||
end
|
|
||||||
|
|
||||||
+ def contains_inline_change?
|
|
||||||
+ @inline
|
|
||||||
+ end
|
|
||||||
+
|
|
||||||
def number
|
|
||||||
- add_lineno ? add_lineno : rem_lineno
|
|
||||||
+ @line_number
|
|
||||||
end
|
|
||||||
|
|
||||||
- def type
|
|
||||||
- @type
|
|
||||||
+ def decorate(&block)
|
|
||||||
+ yield self
|
|
||||||
end
|
|
||||||
|
|
||||||
- class << self
|
|
||||||
- def add(line, add_lineno)
|
|
||||||
- AddLine.new(line, add_lineno)
|
|
||||||
+ def inline_add_open; '' end
|
|
||||||
+ def inline_add_close; '' end
|
|
||||||
+ def inline_rem_open; '' end
|
|
||||||
+ def inline_rem_close; '' end
|
|
||||||
+
|
|
||||||
+ protected
|
|
||||||
+
|
|
||||||
+ def escape
|
|
||||||
+ self
|
|
||||||
end
|
|
||||||
|
|
||||||
- def rem(line, rem_lineno)
|
|
||||||
- RemLine.new(line, rem_lineno)
|
|
||||||
+ def expand
|
|
||||||
+ escape.gsub("\t", ' ' * tabwidth).gsub(/ ( +)|^ /) do |match|
|
|
||||||
+ (space + ' ') * (match.size / 2) +
|
|
||||||
+ space * (match.size % 2)
|
|
||||||
+ end
|
|
||||||
end
|
|
||||||
|
|
||||||
- def unmod(line, lineno)
|
|
||||||
- UnModLine.new(line, lineno)
|
|
||||||
+ def tabwidth
|
|
||||||
+ 4
|
|
||||||
end
|
|
||||||
|
|
||||||
- def mod(line, lineno)
|
|
||||||
- ModLine.new(line, lineno)
|
|
||||||
+
|
|
||||||
+ def space
|
|
||||||
+ ' '
|
|
||||||
end
|
|
||||||
+
|
|
||||||
+ class << self
|
|
||||||
+ def add(line, line_number, inline = false)
|
|
||||||
+ AddLine.new(line, line_number, inline)
|
|
||||||
+ end
|
|
||||||
+
|
|
||||||
+ def rem(line, line_number, inline = false)
|
|
||||||
+ RemLine.new(line, line_number, inline)
|
|
||||||
+ end
|
|
||||||
+
|
|
||||||
+ def unmod(line, line_number)
|
|
||||||
+ UnModLine.new(line, line_number)
|
|
||||||
+ end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
class AddLine < Line
|
|
||||||
- def initialize(line, add_lineno)
|
|
||||||
- super(line, 'add', add_lineno, nil)
|
|
||||||
+ def initialize(line, line_number, inline = false)
|
|
||||||
+ line = inline ? line % [inline_add_open, inline_add_close] : line
|
|
||||||
+ super(line, line_number)
|
|
||||||
+ @inline = inline
|
|
||||||
+ self
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
class RemLine < Line
|
|
||||||
- def initialize(line, rem_lineno)
|
|
||||||
- super(line, 'rem', nil, rem_lineno)
|
|
||||||
+ def initialize(line, line_number, inline = false)
|
|
||||||
+ line = inline ? line % [inline_rem_open, inline_rem_close] : line
|
|
||||||
+ super(line, line_number)
|
|
||||||
+ @inline = inline
|
|
||||||
+ self
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
class UnModLine < Line
|
|
||||||
- def initialize(line, lineno)
|
|
||||||
- super(line, 'unmod', lineno)
|
|
||||||
+ def initialize(line, line_number)
|
|
||||||
+ super(line, line_number)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
- class ModLine < Line
|
|
||||||
- def initialize(line, lineno)
|
|
||||||
- super(line, 'mod', lineno)
|
|
||||||
+ class SepLine < Line
|
|
||||||
+ def initialize(line = '...')
|
|
||||||
+ super(line, nil)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
+ # This class is an array which contains Line objects. Just like Line
|
|
||||||
+ # classes, several Block classes inherit from Block. If all the lines
|
|
||||||
+ # in the block are added lines then it is an AddBlock. If all lines
|
|
||||||
+ # in the block are removed lines then it is a RemBlock. If the lines
|
|
||||||
+ # in the block are all unmodified then it is an UnMod block. If the
|
|
||||||
+ # lines in the block are a mixture of added and removed lines then
|
|
||||||
+ # it is a ModBlock. There are no blocks that contain a mixture of
|
|
||||||
+ # modified and unmodified lines.
|
|
||||||
class Block < Array
|
|
||||||
- def initialize(type)
|
|
||||||
- super(0)
|
|
||||||
- @type = type
|
|
||||||
+ def initialize
|
|
||||||
+ super
|
|
||||||
+ @line_types = []
|
|
||||||
end
|
|
||||||
|
|
||||||
def <<(line_object)
|
|
||||||
super(line_object)
|
|
||||||
- (@line_types ||= []).push(line_object.type)
|
|
||||||
- @line_types.uniq!
|
|
||||||
+ line_class = line_object.class.name[/\w+$/]
|
|
||||||
+ @line_types.push(line_class) unless @line_types.include?(line_class)
|
|
||||||
self
|
|
||||||
end
|
|
||||||
|
|
||||||
+ def decorate(&block)
|
|
||||||
+ yield self
|
|
||||||
+ end
|
|
||||||
+
|
|
||||||
def line_types
|
|
||||||
@line_types
|
|
||||||
end
|
|
||||||
|
|
||||||
- def type
|
|
||||||
- @type
|
|
||||||
+ class << self
|
|
||||||
+ def add; AddBlock.new end
|
|
||||||
+ def rem; RemBlock.new end
|
|
||||||
+ def mod; ModBlock.new end
|
|
||||||
+ def unmod; UnModBlock.new end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
- class Generator < Array
|
|
||||||
+ class AddBlock < Block; end
|
|
||||||
+ class RemBlock < Block; end
|
|
||||||
+ class ModBlock < Block; end
|
|
||||||
+ class UnModBlock < Block; end
|
|
||||||
+ class SepBlock < Block; end
|
|
||||||
|
|
||||||
+ # This data object contains the generated diff data structure. It is an
|
|
||||||
+ # array of Block objects which are themselves arrays of Line objects. The
|
|
||||||
+ # Generator class returns a Data instance object after it is done
|
|
||||||
+ # processing the diff.
|
|
||||||
+ class Data < Array
|
|
||||||
+ def initialize
|
|
||||||
+ super
|
|
||||||
+ end
|
|
||||||
+
|
|
||||||
+ def debug
|
|
||||||
+ demodularize = Proc.new {|obj| obj.class.name[/\w+$/]}
|
|
||||||
+ each do |diff_block|
|
|
||||||
+ print "*" * 40, ' ', demodularize.call(diff_block)
|
|
||||||
+ puts
|
|
||||||
+ puts diff_block.map {|line|
|
|
||||||
+ "%5d" % line.number +
|
|
||||||
+ " [#{demodularize.call(line)}]" +
|
|
||||||
+ line
|
|
||||||
+ }.join("\n")
|
|
||||||
+ puts "*" * 40, ' '
|
|
||||||
+ end
|
|
||||||
+ end
|
|
||||||
+
|
|
||||||
+ end
|
|
||||||
+
|
|
||||||
+ # Processes the diff and generates a Data object which contains the
|
|
||||||
+ # resulting data structure.
|
|
||||||
+ class Generator
|
|
||||||
+
|
|
||||||
+ # Extracts the line number info for a given diff section
|
|
||||||
+ LINE_NUM_RE = /@@ [+-]([0-9]+),([0-9]+) [+-]([0-9]+),([0-9]+) @@/
|
|
||||||
+ LINE_TYPES = {'+' => :add, '-' => :rem, ' ' => :unmod}
|
|
||||||
+
|
|
||||||
class << self
|
|
||||||
- def run(udiff, options = {})
|
|
||||||
- generator = new(options)
|
|
||||||
- udiff.split("\n").each {|line| generator.build(line) }
|
|
||||||
- generator.close
|
|
||||||
- generator
|
|
||||||
+
|
|
||||||
+ # Runs the generator on a diff and returns a Data object without
|
|
||||||
+ # instantiating a Generator object
|
|
||||||
+ def run(udiff)
|
|
||||||
+ raise ArgumentError, "Object must be enumerable" unless udiff.respond_to?(:each)
|
|
||||||
+ generator = new
|
|
||||||
+ udiff.each {|line| generator.process(line.chomp)}
|
|
||||||
+ generator.render
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
- def initialize(options = {})
|
|
||||||
- super(0)
|
|
||||||
- default_options = {:inline_add_open => INLINE_ADD_OPEN,
|
|
||||||
- :inline_add_close => INLINE_ADD_CLOSE,
|
|
||||||
- :inline_rem_open => INLINE_REM_OPEN,
|
|
||||||
- :inline_rem_close => INLINE_REM_CLOSE,
|
|
||||||
- :escape_html => ESCAPE_HTML,
|
|
||||||
- :tabwidth => TABWIDTH,
|
|
||||||
- :space => SPACE}
|
|
||||||
-
|
|
||||||
- @options = default_options.merge(options)
|
|
||||||
- @block = []
|
|
||||||
- @ttype = nil
|
|
||||||
- @p_block = []
|
|
||||||
- @p_type = nil
|
|
||||||
- @changeno = -1
|
|
||||||
- @blockno = 0
|
|
||||||
+ def initialize
|
|
||||||
+ @buffer = []
|
|
||||||
+ @prev_buffer = []
|
|
||||||
+ @line_type = nil
|
|
||||||
+ @prev_line_type = nil
|
|
||||||
@offset_base = 0
|
|
||||||
@offset_changed = 0
|
|
||||||
+ @data = Diff::Display::Unified::Data.new
|
|
||||||
+ self
|
|
||||||
end
|
|
||||||
|
|
||||||
- def current_block
|
|
||||||
- last
|
|
||||||
+ # Operates on a single line from the diff and passes along the
|
|
||||||
+ # collected data to the appropriate method for further processing. The
|
|
||||||
+ # cycle of processing is in general:
|
|
||||||
+ #
|
|
||||||
+ # process --> identify_block --> process_block --> process_line
|
|
||||||
+ #
|
|
||||||
+ def process(line)
|
|
||||||
+ return if ['++', '--'].include?(line[0,2])
|
|
||||||
+
|
|
||||||
+ if match = LINE_NUM_RE.match(line)
|
|
||||||
+ identify_block
|
|
||||||
+ push SepBlock.new and current_block << SepLine.new unless @offset_changed.zero?
|
|
||||||
+ @line_type = nil
|
|
||||||
+ @offset_base = match[1].to_i - 1
|
|
||||||
+ @offset_changed = match[3].to_i - 1
|
|
||||||
+ return
|
|
||||||
+ end
|
|
||||||
+
|
|
||||||
+ new_line_type, line = LINE_TYPES[car(line)], cdr(line)
|
|
||||||
+
|
|
||||||
+ # Add line to the buffer if it's the same diff line type
|
|
||||||
+ # as the previous line
|
|
||||||
+ #
|
|
||||||
+ # e.g.
|
|
||||||
+ #
|
|
||||||
+ # + This is a new line
|
|
||||||
+ # + As is this one
|
|
||||||
+ # + And yet another one...
|
|
||||||
+ #
|
|
||||||
+ if new_line_type.eql?(@line_type)
|
|
||||||
+ @buffer.push(line)
|
|
||||||
+ else
|
|
||||||
+ # Side by side inline diff
|
|
||||||
+ #
|
|
||||||
+ # e.g.
|
|
||||||
+ #
|
|
||||||
+ # - This line just had to go
|
|
||||||
+ # + This line is on the way in
|
|
||||||
+ #
|
|
||||||
+ if new_line_type.eql?(LINE_TYPES['+']) and @line_type.eql?(LINE_TYPES['-'])
|
|
||||||
+ @prev_buffer = @buffer
|
|
||||||
+ @prev_line_type = @line_type
|
|
||||||
+ else
|
|
||||||
+ identify_block
|
|
||||||
+ end
|
|
||||||
+ @buffer = [line]
|
|
||||||
+ @line_type = new_line_type
|
|
||||||
+ end
|
|
||||||
end
|
|
||||||
|
|
||||||
+ # Finishes up with the generation and returns the Data object (could
|
|
||||||
+ # probably use a better name...maybe just #data?)
|
|
||||||
def render
|
|
||||||
close
|
|
||||||
- self
|
|
||||||
+ @data
|
|
||||||
end
|
|
||||||
-
|
|
||||||
- def escape(text)
|
|
||||||
- return '' unless text
|
|
||||||
- return text unless @options[:escape_html]
|
|
||||||
- text.gsub('&', '&').
|
|
||||||
- gsub('<', '<' ).
|
|
||||||
- gsub('>', '>' ).
|
|
||||||
- gsub('"', '"')
|
|
||||||
- end
|
|
||||||
|
|
||||||
- def expand(text)
|
|
||||||
- escape(text).gsub(/ ( +)|^ /) do |match|
|
|
||||||
- (@options[:space] + ' ') * (match.size / 2) +
|
|
||||||
- @options[:space] * (match.size % 2)
|
|
||||||
- end
|
|
||||||
- end
|
|
||||||
+ protected
|
|
||||||
|
|
||||||
- def inline_diff(line, start, ending, change)
|
|
||||||
- expand(line[0, start]) +
|
|
||||||
- change +
|
|
||||||
- expand(line[ending, ending.abs])
|
|
||||||
- end
|
|
||||||
+ def identify_block
|
|
||||||
+ if @prev_line_type.eql?(LINE_TYPES['-']) and @line_type.eql?(LINE_TYPES['+'])
|
|
||||||
+ process_block(:mod, {:old => @prev_buffer, :new => @buffer})
|
|
||||||
+ else
|
|
||||||
+ if LINE_TYPES.values.include?(@line_type)
|
|
||||||
+ process_block(@line_type, {:new => @buffer})
|
|
||||||
+ end
|
|
||||||
+ end
|
|
||||||
|
|
||||||
- def write_line(oldline, newline)
|
|
||||||
- start, ending = get_change_extent(oldline, newline)
|
|
||||||
- change = ''
|
|
||||||
- if oldline.size > start - ending
|
|
||||||
- change = @options[:inline_rem_open] +
|
|
||||||
- expand(oldline[start...ending]) +
|
|
||||||
- @options[:inline_rem_close]
|
|
||||||
+ @prev_line_type = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
- line = inline_diff(oldline, start, ending, change)
|
|
||||||
- current_block << Line.rem(line, @offset_base)
|
|
||||||
+ def process_block(diff_line_type, blocks = {:old => nil, :new => nil})
|
|
||||||
+ push Block.send(diff_line_type)
|
|
||||||
+ old, new = blocks[:old], blocks[:new]
|
|
||||||
|
|
||||||
- change = ''
|
|
||||||
- if newline.size > start - ending
|
|
||||||
- change = @options[:inline_add_open] +
|
|
||||||
- expand(newline[start...ending]) +
|
|
||||||
- @options[:inline_add_close]
|
|
||||||
+ # Mod block
|
|
||||||
+ if diff_line_type.eql?(:mod) and old.size & new.size == 1
|
|
||||||
+ process_line(old.first, new.first)
|
|
||||||
+ return
|
|
||||||
+ end
|
|
||||||
+
|
|
||||||
+ if old and not old.empty?
|
|
||||||
+ old.each do |line|
|
|
||||||
+ @offset_base += 1
|
|
||||||
+ current_block << Line.send(@prev_line_type, line, @offset_base)
|
|
||||||
+ end
|
|
||||||
+ end
|
|
||||||
+
|
|
||||||
+ if new and not new.empty?
|
|
||||||
+ new.each do |line|
|
|
||||||
+ @offset_changed += 1
|
|
||||||
+ current_block << Line.send(@line_type, line, @offset_changed)
|
|
||||||
+ end
|
|
||||||
+ end
|
|
||||||
end
|
|
||||||
|
|
||||||
- line = inline_diff(newline, start, ending, change)
|
|
||||||
- current_block << Line.add(line, @offset_changed)
|
|
||||||
- end
|
|
||||||
+ # TODO Needs a better name...it does process a line (two in fact) but
|
|
||||||
+ # its primary function is to add a Rem and an Add pair which
|
|
||||||
+ # potentially have inline changes
|
|
||||||
+ def process_line(oldline, newline)
|
|
||||||
+ start, ending = get_change_extent(oldline, newline)
|
|
||||||
|
|
||||||
- def write_block(dtype, old = nil, new = nil)
|
|
||||||
- push Block.new(dtype)
|
|
||||||
+ # -
|
|
||||||
+ line = inline_diff(oldline, start, ending)
|
|
||||||
+ current_block << Line.rem(line, @offset_base += 1, true)
|
|
||||||
|
|
||||||
- if dtype == 'mod' and old.size == 1 and new.size == 1
|
|
||||||
- write_line(old.first, new.first)
|
|
||||||
- return
|
|
||||||
+ # +
|
|
||||||
+ line = inline_diff(newline, start, ending)
|
|
||||||
+ current_block << Line.add(line, @offset_changed += 1, true)
|
|
||||||
end
|
|
||||||
|
|
||||||
- if old and not old.empty?
|
|
||||||
- old.each do |e|
|
|
||||||
- current_block << Line.send(dtype, expand(e), @offset_base)
|
|
||||||
- @offset_base += 1
|
|
||||||
- end
|
|
||||||
+ # Inserts string formating characters around the section of a string
|
|
||||||
+ # that differs internally from another line so that the Line class
|
|
||||||
+ # can insert the desired formating
|
|
||||||
+ def inline_diff(line, start, ending)
|
|
||||||
+ line[0, start] +
|
|
||||||
+ '%s' + extract_change(line, start, ending) + '%s' +
|
|
||||||
+ line[ending, ending.abs]
|
|
||||||
end
|
|
||||||
|
|
||||||
- if new and not new.empty?
|
|
||||||
- new.each do |e|
|
|
||||||
- current_block << Line.send(dtype, expand(e), @offset_changed)
|
|
||||||
- @offset_changed += 1
|
|
||||||
- end
|
|
||||||
+ def extract_change(line, start, ending)
|
|
||||||
+ line.size > (start - ending) ? line[start...ending] : ''
|
|
||||||
end
|
|
||||||
- end
|
|
||||||
|
|
||||||
- def print_block
|
|
||||||
- if @p_type.eql?('-') and @ttype.eql?('+')
|
|
||||||
- write_block('mod', @p_block, @block)
|
|
||||||
- else
|
|
||||||
- case @ttype
|
|
||||||
- when '+'
|
|
||||||
- write_block('add', @block)
|
|
||||||
- when '-'
|
|
||||||
- write_block('rem', @block)
|
|
||||||
- when ' '
|
|
||||||
- write_block('unmod', @block)
|
|
||||||
- end
|
|
||||||
+ def car(line)
|
|
||||||
+ line[0,1]
|
|
||||||
end
|
|
||||||
|
|
||||||
- @block = @p_block = []
|
|
||||||
- @p_type = ' '
|
|
||||||
- @blockno += 1
|
|
||||||
- end
|
|
||||||
+ def cdr(line)
|
|
||||||
+ line[1..-1]
|
|
||||||
+ end
|
|
||||||
|
|
||||||
- def build(text)
|
|
||||||
- # TODO Names of the files and their versions go here perhaps
|
|
||||||
+ # Returns the current Block object
|
|
||||||
+ def current_block
|
|
||||||
+ @data.last
|
|
||||||
+ end
|
|
||||||
|
|
||||||
- return if ['++', '--'].include?(text[0,2])
|
|
||||||
+ # Adds a Line object onto the current Block object
|
|
||||||
+ def push(line)
|
|
||||||
+ @data.push line
|
|
||||||
+ end
|
|
||||||
|
|
||||||
- if match = LINE_RE.match(text)
|
|
||||||
- print_block
|
|
||||||
- @changeno += 1
|
|
||||||
- @blockno = 0
|
|
||||||
- @offset_base = match[1].to_i - 1
|
|
||||||
- @offset_changed = match[3].to_i - 1
|
|
||||||
- return
|
|
||||||
+ # This method is called once the generator is done with the unified
|
|
||||||
+ # diff. It is a finalizer of sorts. By the time it is called all data
|
|
||||||
+ # has been collected and processed.
|
|
||||||
+ def close
|
|
||||||
+ # certain things could be set now that processing is done
|
|
||||||
+ identify_block
|
|
||||||
end
|
|
||||||
|
|
||||||
- # Set ttype to first character of line
|
|
||||||
- ttype = text[0, 1]
|
|
||||||
- text = text[1..-1]
|
|
||||||
- text = text.gsub("\t", ' ' * @options[:tabwidth]) if text
|
|
||||||
- # If it's the same type of mod as the last line push this line onto the
|
|
||||||
- # block stack
|
|
||||||
- if ttype.eql?(@ttype)
|
|
||||||
- @block.push(text)
|
|
||||||
- else
|
|
||||||
- # If we have a side by side subtraction/addition
|
|
||||||
- if ttype == '+' and @ttype == '-'
|
|
||||||
- @p_block = @block
|
|
||||||
- @p_type = @ttype
|
|
||||||
- else
|
|
||||||
- print_block
|
|
||||||
+ # Determines the extent of differences between two string. Returns
|
|
||||||
+ # an array containing the offset at which changes start, and then
|
|
||||||
+ # negative offset at which the chnages end. If the two strings have
|
|
||||||
+ # neither a common prefix nor a common suffic, [0, 0] is returned.
|
|
||||||
+ def get_change_extent(str1, str2)
|
|
||||||
+ start = 0
|
|
||||||
+ limit = [str1.size, str2.size].sort.first
|
|
||||||
+ while start < limit and str1[start, 1] == str2[start, 1]
|
|
||||||
+ start += 1
|
|
||||||
end
|
|
||||||
- @block = [text]
|
|
||||||
- @ttype = ttype
|
|
||||||
+ ending = -1
|
|
||||||
+ limit -= start
|
|
||||||
+ while -ending <= limit and str1[ending, 1] == str2[ending, 1]
|
|
||||||
+ ending -= 1
|
|
||||||
+ end
|
|
||||||
+
|
|
||||||
+ return [start, ending + 1]
|
|
||||||
end
|
|
||||||
- end
|
|
||||||
+ end
|
|
||||||
|
|
||||||
- def debug
|
|
||||||
- each do |diff_block|
|
|
||||||
- print "*" * (40 - diff_block.type.size / 2), ' ', diff_block.type
|
|
||||||
- puts
|
|
||||||
- puts diff_block.map {|line| "#{line.number}" << line << " [#{line.type}]"}.join("\n")
|
|
||||||
- print "Line types:"
|
|
||||||
- puts diff_block.line_types.join(", ")
|
|
||||||
- puts
|
|
||||||
- end
|
|
||||||
+ # Mostly a convinience class at this point that just overwrites various
|
|
||||||
+ # customization methods
|
|
||||||
+ class HTMLGenerator < Generator
|
|
||||||
+
|
|
||||||
+ # This and the space method now don't work/make sense now that those
|
|
||||||
+ # methods are part of the Line class and there certainly won't be an
|
|
||||||
+ # HTMLLine class
|
|
||||||
+ def escape(text)
|
|
||||||
+ text.gsub('&', '&').
|
|
||||||
+ gsub('<', '<' ).
|
|
||||||
+ gsub('>', '>' ).
|
|
||||||
+ gsub('"', '"')
|
|
||||||
end
|
|
||||||
|
|
||||||
- def close
|
|
||||||
- # certain things could be set now that processing is done
|
|
||||||
- print_block
|
|
||||||
+ def space
|
|
||||||
+ ' '
|
|
||||||
end
|
|
||||||
|
|
||||||
- # Determines the extent of differences between two string. Returns
|
|
||||||
- # an array containing the offset at which changes start, and then
|
|
||||||
- # negative offset at which the chnages end. If the two strings have
|
|
||||||
- # neither a common prefix nor a common suffic, [0, 0] is returned.
|
|
||||||
- def get_change_extent(str1, str2)
|
|
||||||
- start = 0
|
|
||||||
- limit = [str1.size, str2.size].sort.first
|
|
||||||
- while start < limit and str1[start, 1] == str2[start, 1]
|
|
||||||
- start += 1
|
|
||||||
- end
|
|
||||||
- ending = -1
|
|
||||||
- limit -= start
|
|
||||||
- while -ending <= limit and str1[ending, 1] == str2[ending, 1]
|
|
||||||
- ending -= 1
|
|
||||||
- end
|
|
||||||
+ end
|
|
||||||
|
|
||||||
- return [start, ending + 1]
|
|
||||||
- end
|
|
||||||
+ # See doc string for HTMLGenerator
|
|
||||||
+ class ASCIIGenerator < Generator
|
|
||||||
end
|
|
||||||
+
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
-
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue