scoped_search 2.5.0 → 2.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +8 -3
- data/{vendor → app}/assets/images/spinner.gif +0 -0
- data/{vendor → app}/assets/javascripts/scoped_search.js +0 -0
- data/{vendor → app}/assets/stylesheets/scoped_search.scss +5 -1
- data/lib/scoped_search.rb +1 -4
- data/lib/scoped_search/version.rb +3 -0
- data/scoped_search.gemspec +22 -23
- metadata +17 -11
- data/tasks/github-gem.rake +0 -371
data/Rakefile
CHANGED
@@ -1,4 +1,9 @@
|
|
1
|
-
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rspec/core/rake_task"
|
2
3
|
|
3
|
-
|
4
|
-
task
|
4
|
+
RSpec::Core::RakeTask.new(:spec) do |task|
|
5
|
+
task.pattern = "./spec/**/*_spec.rb"
|
6
|
+
task.rspec_opts = ['--color']
|
7
|
+
end
|
8
|
+
|
9
|
+
task :default => :spec
|
File without changes
|
File without changes
|
@@ -1,3 +1,7 @@
|
|
1
|
+
/*
|
2
|
+
*= require jquery.ui.autocomplete
|
3
|
+
*/
|
4
|
+
|
1
5
|
// Opacity
|
2
6
|
@mixin opacity($opacity) {
|
3
7
|
opacity: $opacity / 100;
|
@@ -28,7 +32,7 @@
|
|
28
32
|
}
|
29
33
|
}
|
30
34
|
.ui-autocomplete-loading {
|
31
|
-
background: white url('/
|
35
|
+
background: white url('/assets/spinner.gif') 98% 50% no-repeat;
|
32
36
|
}
|
33
37
|
.ui-autocomplete-completed {
|
34
38
|
color: #aaa;
|
data/lib/scoped_search.rb
CHANGED
@@ -12,10 +12,6 @@ require 'active_record'
|
|
12
12
|
# previous scoped_search versions (1.x).
|
13
13
|
module ScopedSearch
|
14
14
|
|
15
|
-
# The current scoped_search version. Do not change thisvalue by hand,
|
16
|
-
# because it will be updated automatically by the gem release script.
|
17
|
-
VERSION = "2.5.0"
|
18
|
-
|
19
15
|
# The ClassMethods module will be included into the ActiveRecord::Base class
|
20
16
|
# to add the <tt>ActiveRecord::Base.scoped_search</tt> method and the
|
21
17
|
# <tt>ActiveRecord::Base.search_for</tt> named scope.
|
@@ -84,6 +80,7 @@ module ScopedSearch
|
|
84
80
|
end
|
85
81
|
|
86
82
|
# Load all lib files
|
83
|
+
require "scoped_search/version"
|
87
84
|
require 'scoped_search/definition'
|
88
85
|
require 'scoped_search/query_language'
|
89
86
|
require 'scoped_search/query_builder'
|
data/scoped_search.gemspec
CHANGED
@@ -1,13 +1,16 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
# automatically by the gem release script.
|
6
|
-
s.version = "2.5.0"
|
7
|
-
s.date = "2013-03-29"
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'scoped_search/version'
|
8
5
|
|
9
|
-
|
10
|
-
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "scoped_search"
|
8
|
+
gem.version = ScopedSearch::VERSION
|
9
|
+
gem.authors = ['Amos Benari', 'Willem van Bergen', 'Wes Hays']
|
10
|
+
gem.email = ['abenari@redhat.com', 'willem@railsdoctors.com', 'weshays@gbdev.com']
|
11
|
+
gem.homepage = "https://github.com/wvanbergen/scoped_search/wiki"
|
12
|
+
gem.summary = %q{Easily search you ActiveRecord models with a simple query language using a named scope}
|
13
|
+
gem.description = <<-EOS
|
11
14
|
Scoped search makes it easy to search your ActiveRecord-based models.
|
12
15
|
|
13
16
|
It will create a named scope :search_for that can be called with a query string. It will build an SQL query using
|
@@ -19,20 +22,16 @@ Gem::Specification.new do |s|
|
|
19
22
|
suitable to quickly add basic search functionality to your application with little hassle. On the other hand,
|
20
23
|
it may not be the best choice if it is going to be used on very large datasets or by a large user base.
|
21
24
|
EOS
|
25
|
+
|
26
|
+
gem.files = `git ls-files`.split($/)
|
27
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
28
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
29
|
+
gem.require_paths = ["lib"]
|
22
30
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
s.add_runtime_dependency('activerecord', '>= 2.1.0')
|
28
|
-
s.add_development_dependency('rspec', '~> 2.0')
|
29
|
-
s.add_development_dependency('rake')
|
30
|
-
|
31
|
-
s.rdoc_options << '--title' << s.name << '--main' << 'README.rdoc' << '--line-numbers' << '--inline-source'
|
32
|
-
s.extra_rdoc_files = ['README.rdoc']
|
31
|
+
gem.add_runtime_dependency('activerecord', '>= 2.1.0')
|
32
|
+
gem.add_development_dependency('rspec', '~> 2.0')
|
33
|
+
gem.add_development_dependency('rake')
|
33
34
|
|
34
|
-
|
35
|
-
|
36
|
-
s.files = %w(.gitignore .infinity_test .travis.yml Gemfile Gemfile.activerecord2 Gemfile.activerecord3 Gemfile.activerecord4 LICENSE README.rdoc Rakefile init.rb lib/scoped_search.rb lib/scoped_search/auto_complete_builder.rb lib/scoped_search/definition.rb lib/scoped_search/engine.rb lib/scoped_search/query_builder.rb lib/scoped_search/query_language.rb lib/scoped_search/query_language/ast.rb lib/scoped_search/query_language/parser.rb lib/scoped_search/query_language/tokenizer.rb lib/scoped_search/rails_helper.rb scoped_search.gemspec spec/database.jruby.yml spec/database.ruby.yml spec/integration/api_spec.rb spec/integration/auto_complete_spec.rb spec/integration/key_value_querying_spec.rb spec/integration/ordinal_querying_spec.rb spec/integration/profile_querying_spec.rb spec/integration/relation_querying_spec.rb spec/integration/set_query_spec.rb spec/integration/string_querying_spec.rb spec/lib/database.rb spec/lib/matchers.rb spec/lib/mocks.rb spec/spec_helper.rb spec/unit/ast_spec.rb spec/unit/auto_complete_builder_spec.rb spec/unit/definition_spec.rb spec/unit/parser_spec.rb spec/unit/query_builder_spec.rb spec/unit/tokenizer_spec.rb tasks/github-gem.rake vendor/assets/images/spinner.gif vendor/assets/javascripts/scoped_search.js vendor/assets/stylesheets/scoped_search.scss)
|
37
|
-
s.test_files = %w(spec/integration/api_spec.rb spec/integration/auto_complete_spec.rb spec/integration/key_value_querying_spec.rb spec/integration/ordinal_querying_spec.rb spec/integration/profile_querying_spec.rb spec/integration/relation_querying_spec.rb spec/integration/set_query_spec.rb spec/integration/string_querying_spec.rb spec/unit/ast_spec.rb spec/unit/auto_complete_builder_spec.rb spec/unit/definition_spec.rb spec/unit/parser_spec.rb spec/unit/query_builder_spec.rb spec/unit/tokenizer_spec.rb)
|
35
|
+
gem.rdoc_options << '--title' << gem.name << '--main' << 'README.rdoc' << '--line-numbers' << '--inline-source'
|
36
|
+
gem.extra_rdoc_files = ['README.rdoc']
|
38
37
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scoped_search
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.5.
|
4
|
+
version: 2.5.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2013-
|
14
|
+
date: 2013-04-02 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activerecord
|
@@ -91,6 +91,9 @@ files:
|
|
91
91
|
- LICENSE
|
92
92
|
- README.rdoc
|
93
93
|
- Rakefile
|
94
|
+
- app/assets/images/spinner.gif
|
95
|
+
- app/assets/javascripts/scoped_search.js
|
96
|
+
- app/assets/stylesheets/scoped_search.scss
|
94
97
|
- init.rb
|
95
98
|
- lib/scoped_search.rb
|
96
99
|
- lib/scoped_search/auto_complete_builder.rb
|
@@ -102,6 +105,7 @@ files:
|
|
102
105
|
- lib/scoped_search/query_language/parser.rb
|
103
106
|
- lib/scoped_search/query_language/tokenizer.rb
|
104
107
|
- lib/scoped_search/rails_helper.rb
|
108
|
+
- lib/scoped_search/version.rb
|
105
109
|
- scoped_search.gemspec
|
106
110
|
- spec/database.jruby.yml
|
107
111
|
- spec/database.ruby.yml
|
@@ -123,11 +127,7 @@ files:
|
|
123
127
|
- spec/unit/parser_spec.rb
|
124
128
|
- spec/unit/query_builder_spec.rb
|
125
129
|
- spec/unit/tokenizer_spec.rb
|
126
|
-
|
127
|
-
- vendor/assets/images/spinner.gif
|
128
|
-
- vendor/assets/javascripts/scoped_search.js
|
129
|
-
- vendor/assets/stylesheets/scoped_search.scss
|
130
|
-
homepage: http://github.com/wvanbergen/scoped_search/wiki
|
130
|
+
homepage: https://github.com/wvanbergen/scoped_search/wiki
|
131
131
|
licenses: []
|
132
132
|
post_install_message:
|
133
133
|
rdoc_options:
|
@@ -147,7 +147,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
147
147
|
version: '0'
|
148
148
|
segments:
|
149
149
|
- 0
|
150
|
-
hash:
|
150
|
+
hash: -3142613325770757127
|
151
151
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
152
|
none: false
|
153
153
|
requirements:
|
@@ -156,15 +156,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
156
|
version: '0'
|
157
157
|
segments:
|
158
158
|
- 0
|
159
|
-
hash:
|
159
|
+
hash: -3142613325770757127
|
160
160
|
requirements: []
|
161
161
|
rubyforge_project:
|
162
|
-
rubygems_version: 1.8.
|
162
|
+
rubygems_version: 1.8.25
|
163
163
|
signing_key:
|
164
164
|
specification_version: 3
|
165
165
|
summary: Easily search you ActiveRecord models with a simple query language using
|
166
|
-
a named scope
|
166
|
+
a named scope
|
167
167
|
test_files:
|
168
|
+
- spec/database.jruby.yml
|
169
|
+
- spec/database.ruby.yml
|
168
170
|
- spec/integration/api_spec.rb
|
169
171
|
- spec/integration/auto_complete_spec.rb
|
170
172
|
- spec/integration/key_value_querying_spec.rb
|
@@ -173,6 +175,10 @@ test_files:
|
|
173
175
|
- spec/integration/relation_querying_spec.rb
|
174
176
|
- spec/integration/set_query_spec.rb
|
175
177
|
- spec/integration/string_querying_spec.rb
|
178
|
+
- spec/lib/database.rb
|
179
|
+
- spec/lib/matchers.rb
|
180
|
+
- spec/lib/mocks.rb
|
181
|
+
- spec/spec_helper.rb
|
176
182
|
- spec/unit/ast_spec.rb
|
177
183
|
- spec/unit/auto_complete_builder_spec.rb
|
178
184
|
- spec/unit/definition_spec.rb
|
data/tasks/github-gem.rake
DELETED
@@ -1,371 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'rake'
|
3
|
-
require 'rake/tasklib'
|
4
|
-
require 'date'
|
5
|
-
require 'set'
|
6
|
-
|
7
|
-
module GithubGem
|
8
|
-
|
9
|
-
# Detects the gemspc file of this project using heuristics.
|
10
|
-
def self.detect_gemspec_file
|
11
|
-
FileList['*.gemspec'].first
|
12
|
-
end
|
13
|
-
|
14
|
-
# Detects the main include file of this project using heuristics
|
15
|
-
def self.detect_main_include
|
16
|
-
if File.exist?(File.expand_path("../lib/#{File.basename(detect_gemspec_file, '.gemspec').gsub(/-/, '/')}.rb", detect_gemspec_file))
|
17
|
-
"lib/#{File.basename(detect_gemspec_file, '.gemspec').gsub(/-/, '/')}.rb"
|
18
|
-
elsif FileList['lib/*.rb'].length == 1
|
19
|
-
FileList['lib/*.rb'].first
|
20
|
-
else
|
21
|
-
nil
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
class RakeTasks
|
26
|
-
|
27
|
-
include Rake::DSL if Rake.const_defined?('DSL')
|
28
|
-
|
29
|
-
attr_reader :gemspec, :modified_files
|
30
|
-
attr_accessor :gemspec_file, :task_namespace, :main_include, :root_dir, :spec_pattern, :test_pattern, :remote, :remote_branch, :local_branch
|
31
|
-
|
32
|
-
# Initializes the settings, yields itself for configuration
|
33
|
-
# and defines the rake tasks based on the gemspec file.
|
34
|
-
def initialize(task_namespace = :gem)
|
35
|
-
@gemspec_file = GithubGem.detect_gemspec_file
|
36
|
-
@task_namespace = task_namespace
|
37
|
-
@main_include = GithubGem.detect_main_include
|
38
|
-
@modified_files = Set.new
|
39
|
-
@root_dir = Dir.pwd
|
40
|
-
@test_pattern = 'test/**/*_test.rb'
|
41
|
-
@spec_pattern = 'spec/**/*_spec.rb'
|
42
|
-
@local_branch = 'master'
|
43
|
-
@remote = 'origin'
|
44
|
-
@remote_branch = 'master'
|
45
|
-
|
46
|
-
yield(self) if block_given?
|
47
|
-
|
48
|
-
load_gemspec!
|
49
|
-
define_tasks!
|
50
|
-
end
|
51
|
-
|
52
|
-
protected
|
53
|
-
|
54
|
-
def git
|
55
|
-
@git ||= ENV['GIT'] || 'git'
|
56
|
-
end
|
57
|
-
|
58
|
-
# Define Unit test tasks
|
59
|
-
def define_test_tasks!
|
60
|
-
require 'rake/testtask'
|
61
|
-
|
62
|
-
namespace(:test) do
|
63
|
-
Rake::TestTask.new(:basic) do |t|
|
64
|
-
t.pattern = test_pattern
|
65
|
-
t.verbose = true
|
66
|
-
t.libs << 'test'
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
desc "Run all unit tests for #{gemspec.name}"
|
71
|
-
task(:test => ['test:basic'])
|
72
|
-
end
|
73
|
-
|
74
|
-
# Defines RSpec tasks
|
75
|
-
def define_rspec_tasks!
|
76
|
-
require 'rspec/core/rake_task'
|
77
|
-
|
78
|
-
namespace(:spec) do
|
79
|
-
desc "Verify all RSpec examples for #{gemspec.name}"
|
80
|
-
RSpec::Core::RakeTask.new(:basic) do |t|
|
81
|
-
t.pattern = spec_pattern
|
82
|
-
end
|
83
|
-
|
84
|
-
desc "Verify all RSpec examples for #{gemspec.name} and output specdoc"
|
85
|
-
RSpec::Core::RakeTask.new(:specdoc) do |t|
|
86
|
-
t.pattern = spec_pattern
|
87
|
-
t.rspec_opts = ['--format', 'documentation', '--color']
|
88
|
-
end
|
89
|
-
|
90
|
-
desc "Run RCov on specs for #{gemspec.name}"
|
91
|
-
RSpec::Core::RakeTask.new(:rcov) do |t|
|
92
|
-
t.pattern = spec_pattern
|
93
|
-
t.rcov = true
|
94
|
-
t.rcov_opts = ['--exclude', '"spec/*,gems/*"', '--rails']
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
desc "Verify all RSpec examples for #{gemspec.name} and output specdoc"
|
99
|
-
task(:spec => ['spec:specdoc'])
|
100
|
-
end
|
101
|
-
|
102
|
-
# Defines the rake tasks
|
103
|
-
def define_tasks!
|
104
|
-
|
105
|
-
define_test_tasks! if has_tests?
|
106
|
-
define_rspec_tasks! if has_specs?
|
107
|
-
|
108
|
-
namespace(@task_namespace) do
|
109
|
-
desc "Updates the filelist in the gemspec file"
|
110
|
-
task(:manifest) { manifest_task }
|
111
|
-
|
112
|
-
desc "Builds the .gem package"
|
113
|
-
task(:build => :manifest) { build_task }
|
114
|
-
|
115
|
-
desc "Sets the version of the gem in the gemspec"
|
116
|
-
task(:set_version => [:check_version, :check_current_branch]) { version_task }
|
117
|
-
task(:check_version => :fetch_origin) { check_version_task }
|
118
|
-
|
119
|
-
task(:fetch_origin) { fetch_origin_task }
|
120
|
-
task(:check_current_branch) { check_current_branch_task }
|
121
|
-
task(:check_clean_status) { check_clean_status_task }
|
122
|
-
task(:check_not_diverged => :fetch_origin) { check_not_diverged_task }
|
123
|
-
|
124
|
-
checks = [:check_current_branch, :check_clean_status, :check_not_diverged, :check_version]
|
125
|
-
checks.unshift('spec:basic') if has_specs? && !skip_tests?
|
126
|
-
checks.unshift('test:basic') if has_tests? && !skip_tests?
|
127
|
-
# checks.push << [:check_rubyforge] if gemspec.rubyforge_project
|
128
|
-
|
129
|
-
desc "Perform all checks that would occur before a release"
|
130
|
-
task(:release_checks => checks)
|
131
|
-
|
132
|
-
release_tasks = [:release_checks, :set_version, :build, :github_release, :gemcutter_release]
|
133
|
-
# release_tasks << [:rubyforge_release] if gemspec.rubyforge_project
|
134
|
-
|
135
|
-
desc "Release a new version of the gem using the VERSION environment variable"
|
136
|
-
task(:release => release_tasks) { release_task }
|
137
|
-
|
138
|
-
namespace(:release) do
|
139
|
-
desc "Release the next version of the gem, by incrementing the last version segment by 1"
|
140
|
-
task(:next => [:next_version] + release_tasks) { release_task }
|
141
|
-
|
142
|
-
desc "Release the next version of the gem, using a patch increment (0.0.1)"
|
143
|
-
task(:patch => [:next_patch_version] + release_tasks) { release_task }
|
144
|
-
|
145
|
-
desc "Release the next version of the gem, using a minor increment (0.1.0)"
|
146
|
-
task(:minor => [:next_minor_version] + release_tasks) { release_task }
|
147
|
-
|
148
|
-
desc "Release the next version of the gem, using a major increment (1.0.0)"
|
149
|
-
task(:major => [:next_major_version] + release_tasks) { release_task }
|
150
|
-
end
|
151
|
-
|
152
|
-
# task(:check_rubyforge) { check_rubyforge_task }
|
153
|
-
# task(:rubyforge_release) { rubyforge_release_task }
|
154
|
-
task(:gemcutter_release) { gemcutter_release_task }
|
155
|
-
task(:github_release => [:commit_modified_files, :tag_version]) { github_release_task }
|
156
|
-
task(:tag_version) { tag_version_task }
|
157
|
-
task(:commit_modified_files) { commit_modified_files_task }
|
158
|
-
|
159
|
-
task(:next_version) { next_version_task }
|
160
|
-
task(:next_patch_version) { next_version_task(:patch) }
|
161
|
-
task(:next_minor_version) { next_version_task(:minor) }
|
162
|
-
task(:next_major_version) { next_version_task(:major) }
|
163
|
-
|
164
|
-
desc "Updates the gem release tasks with the latest version on Github"
|
165
|
-
task(:update_tasks) { update_tasks_task }
|
166
|
-
end
|
167
|
-
end
|
168
|
-
|
169
|
-
# Updates the files list and test_files list in the gemspec file using the list of files
|
170
|
-
# in the repository and the spec/test file pattern.
|
171
|
-
def manifest_task
|
172
|
-
# Load all the gem's files using "git ls-files"
|
173
|
-
repository_files = `#{git} ls-files`.split("\n")
|
174
|
-
test_files = Dir[test_pattern] + Dir[spec_pattern]
|
175
|
-
|
176
|
-
update_gemspec(:files, repository_files)
|
177
|
-
update_gemspec(:test_files, repository_files & test_files)
|
178
|
-
end
|
179
|
-
|
180
|
-
# Builds the gem
|
181
|
-
def build_task
|
182
|
-
sh "gem build -q #{gemspec_file}"
|
183
|
-
Dir.mkdir('pkg') unless File.exist?('pkg')
|
184
|
-
sh "mv #{gemspec.name}-#{gemspec.version}.gem pkg/#{gemspec.name}-#{gemspec.version}.gem"
|
185
|
-
end
|
186
|
-
|
187
|
-
def newest_version
|
188
|
-
`#{git} tag`.split("\n").map { |tag| tag.split('-').last }.compact.map { |v| Gem::Version.new(v) }.max || Gem::Version.new('0.0.0')
|
189
|
-
end
|
190
|
-
|
191
|
-
def next_version(increment = nil)
|
192
|
-
next_version = newest_version.segments
|
193
|
-
increment_index = case increment
|
194
|
-
when :micro then 3
|
195
|
-
when :patch then 2
|
196
|
-
when :minor then 1
|
197
|
-
when :major then 0
|
198
|
-
else next_version.length - 1
|
199
|
-
end
|
200
|
-
|
201
|
-
next_version[increment_index] ||= 0
|
202
|
-
next_version[increment_index] = next_version[increment_index].succ
|
203
|
-
((increment_index + 1)...next_version.length).each { |i| next_version[i] = 0 }
|
204
|
-
|
205
|
-
Gem::Version.new(next_version.join('.'))
|
206
|
-
end
|
207
|
-
|
208
|
-
def next_version_task(increment = nil)
|
209
|
-
ENV['VERSION'] = next_version(increment).version
|
210
|
-
puts "Releasing version #{ENV['VERSION']}..."
|
211
|
-
end
|
212
|
-
|
213
|
-
# Updates the version number in the gemspec file, the VERSION constant in the main
|
214
|
-
# include file and the contents of the VERSION file.
|
215
|
-
def version_task
|
216
|
-
update_gemspec(:version, ENV['VERSION']) if ENV['VERSION']
|
217
|
-
update_gemspec(:date, Date.today)
|
218
|
-
|
219
|
-
update_version_file(gemspec.version)
|
220
|
-
update_version_constant(gemspec.version)
|
221
|
-
end
|
222
|
-
|
223
|
-
def check_version_task
|
224
|
-
raise "#{ENV['VERSION']} is not a valid version number!" if ENV['VERSION'] && !Gem::Version.correct?(ENV['VERSION'])
|
225
|
-
proposed_version = Gem::Version.new((ENV['VERSION'] || gemspec.version).dup)
|
226
|
-
raise "This version (#{proposed_version}) is not higher than the highest tagged version (#{newest_version})" if newest_version >= proposed_version
|
227
|
-
end
|
228
|
-
|
229
|
-
# Checks whether the current branch is not diverged from the remote branch
|
230
|
-
def check_not_diverged_task
|
231
|
-
raise "The current branch is diverged from the remote branch!" if `#{git} rev-list HEAD..#{remote}/#{remote_branch}`.split("\n").any?
|
232
|
-
end
|
233
|
-
|
234
|
-
# Checks whether the repository status ic clean
|
235
|
-
def check_clean_status_task
|
236
|
-
raise "The current working copy contains modifications" if `#{git} ls-files -m`.split("\n").any?
|
237
|
-
end
|
238
|
-
|
239
|
-
# Checks whether the current branch is correct
|
240
|
-
def check_current_branch_task
|
241
|
-
raise "Currently not on #{local_branch} branch!" unless `#{git} branch`.split("\n").detect { |b| /^\* / =~ b } == "* #{local_branch}"
|
242
|
-
end
|
243
|
-
|
244
|
-
# Fetches the latest updates from Github
|
245
|
-
def fetch_origin_task
|
246
|
-
sh git, 'fetch', remote
|
247
|
-
end
|
248
|
-
|
249
|
-
# Commits every file that has been changed by the release task.
|
250
|
-
def commit_modified_files_task
|
251
|
-
really_modified = `#{git} ls-files -m #{modified_files.entries.join(' ')}`.split("\n")
|
252
|
-
if really_modified.any?
|
253
|
-
really_modified.each { |file| sh git, 'add', file }
|
254
|
-
sh git, 'commit', '-m', "Released #{gemspec.name} gem version #{gemspec.version}."
|
255
|
-
end
|
256
|
-
end
|
257
|
-
|
258
|
-
# Adds a tag for the released version
|
259
|
-
def tag_version_task
|
260
|
-
sh git, 'tag', '-a', "#{gemspec.name}-#{gemspec.version}", '-m', "Released #{gemspec.name} gem version #{gemspec.version}."
|
261
|
-
end
|
262
|
-
|
263
|
-
# Pushes the changes and tag to github
|
264
|
-
def github_release_task
|
265
|
-
sh git, 'push', '--tags', remote, remote_branch
|
266
|
-
end
|
267
|
-
|
268
|
-
def gemcutter_release_task
|
269
|
-
sh "gem", 'push', "pkg/#{gemspec.name}-#{gemspec.version}.gem"
|
270
|
-
end
|
271
|
-
|
272
|
-
# Gem release task.
|
273
|
-
# All work is done by the task's dependencies, so just display a release completed message.
|
274
|
-
def release_task
|
275
|
-
puts
|
276
|
-
puts "Release successful."
|
277
|
-
end
|
278
|
-
|
279
|
-
private
|
280
|
-
|
281
|
-
def skip_tests?
|
282
|
-
!!ENV['SKIP_TESTS']
|
283
|
-
end
|
284
|
-
|
285
|
-
# Checks whether this project has any RSpec files
|
286
|
-
def has_specs?
|
287
|
-
FileList[spec_pattern].any?
|
288
|
-
end
|
289
|
-
|
290
|
-
# Checks whether this project has any unit test files
|
291
|
-
def has_tests?
|
292
|
-
FileList[test_pattern].any?
|
293
|
-
end
|
294
|
-
|
295
|
-
# Loads the gemspec file
|
296
|
-
def load_gemspec!
|
297
|
-
@gemspec = eval(File.read(@gemspec_file))
|
298
|
-
end
|
299
|
-
|
300
|
-
# Updates the VERSION file with the new version
|
301
|
-
def update_version_file(version)
|
302
|
-
if File.exists?('VERSION')
|
303
|
-
File.open('VERSION', 'w') { |f| f << version.to_s }
|
304
|
-
modified_files << 'VERSION'
|
305
|
-
end
|
306
|
-
end
|
307
|
-
|
308
|
-
# Updates the VERSION constant in the main include file if it exists
|
309
|
-
def update_version_constant(version)
|
310
|
-
if main_include && File.exist?(main_include)
|
311
|
-
file_contents = File.read(main_include)
|
312
|
-
if file_contents.sub!(/^(\s+VERSION\s*=\s*)[^\s].*$/) { $1 + version.to_s.inspect }
|
313
|
-
File.open(main_include, 'w') { |f| f << file_contents }
|
314
|
-
modified_files << main_include
|
315
|
-
end
|
316
|
-
end
|
317
|
-
end
|
318
|
-
|
319
|
-
# Updates an attribute of the gemspec file.
|
320
|
-
# This function will open the file, and search/replace the attribute using a regular expression.
|
321
|
-
def update_gemspec(attribute, new_value, literal = false)
|
322
|
-
|
323
|
-
unless literal
|
324
|
-
new_value = case new_value
|
325
|
-
when Array then "%w(#{new_value.join(' ')})"
|
326
|
-
when Hash, String then new_value.inspect
|
327
|
-
when Date then new_value.strftime('%Y-%m-%d').inspect
|
328
|
-
else raise "Cannot write value #{new_value.inspect} to gemspec file!"
|
329
|
-
end
|
330
|
-
end
|
331
|
-
|
332
|
-
spec = File.read(gemspec_file)
|
333
|
-
regexp = Regexp.new('^(\s+\w+\.' + Regexp.quote(attribute.to_s) + '\s*=\s*)[^\s].*$')
|
334
|
-
if spec.sub!(regexp) { $1 + new_value }
|
335
|
-
File.open(gemspec_file, 'w') { |f| f << spec }
|
336
|
-
modified_files << gemspec_file
|
337
|
-
|
338
|
-
# Reload the gemspec so the changes are incorporated
|
339
|
-
load_gemspec!
|
340
|
-
|
341
|
-
# Also mark the Gemfile.lock file as changed because of the new version.
|
342
|
-
modified_files << 'Gemfile.lock' if File.exist?(File.join(root_dir, 'Gemfile.lock'))
|
343
|
-
end
|
344
|
-
end
|
345
|
-
|
346
|
-
# Updates the tasks file using the latest file found on Github
|
347
|
-
def update_tasks_task
|
348
|
-
require 'net/https'
|
349
|
-
require 'uri'
|
350
|
-
|
351
|
-
uri = URI.parse('https://raw.github.com/wvanbergen/github-gem/master/tasks/github-gem.rake')
|
352
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
353
|
-
http.use_ssl = true
|
354
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
355
|
-
response = http.request(Net::HTTP::Get.new(uri.path))
|
356
|
-
|
357
|
-
if Net::HTTPSuccess === response
|
358
|
-
open(__FILE__, "w") { |file| file.write(response.body) }
|
359
|
-
relative_file = File.expand_path(__FILE__).sub(%r[^#{@root_dir}/], '')
|
360
|
-
if `#{git} ls-files -m #{relative_file}`.split("\n").any?
|
361
|
-
sh git, 'add', relative_file
|
362
|
-
sh git, 'commit', '-m', "Updated to latest gem release management tasks."
|
363
|
-
else
|
364
|
-
puts "Release managament tasks already are at the latest version."
|
365
|
-
end
|
366
|
-
else
|
367
|
-
raise "Download failed with HTTP status #{response.code}!"
|
368
|
-
end
|
369
|
-
end
|
370
|
-
end
|
371
|
-
end
|