uuml 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +5 -0
- data/Gemfile +4 -0
- data/README.rdoc +9 -0
- data/Rakefile +3 -0
- data/lib/uuml.rb +13 -0
- data/lib/uuml/html.rb +23 -0
- data/lib/uuml/middleware.rb +19 -0
- data/lib/uuml/railtie.rb +8 -0
- data/spec/spec_helper.rb +19 -0
- data/spec/uuml/html_spec.rb +30 -0
- data/spec/uuml/middleware_spec.rb +28 -0
- data/tasks/gem_release_tasks.rb +365 -0
- data/uuml.gemspec +25 -0
- metadata +129 -0
data/Gemfile
ADDED
data/README.rdoc
ADDED
data/Rakefile
ADDED
data/lib/uuml.rb
ADDED
data/lib/uuml/html.rb
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
module Uuml::HTML
|
|
4
|
+
extend self
|
|
5
|
+
|
|
6
|
+
TEXT_TAGS = %w{title p a li h1 h2 h3 h4 h5 h6 div span option}
|
|
7
|
+
|
|
8
|
+
def convert(html)
|
|
9
|
+
replacer = lambda do |node|
|
|
10
|
+
node.content = node.content.
|
|
11
|
+
gsub(/(?<![Qq])ue/, 'ü').
|
|
12
|
+
gsub(/(?<![QqOo])u(?![i])/, 'ü').
|
|
13
|
+
gsub(/(?<![QqOo])U(?![Ii])/, 'Ü')
|
|
14
|
+
end
|
|
15
|
+
condition = TEXT_TAGS.map { |t| "parent::#{t}"}.join(' or ')
|
|
16
|
+
|
|
17
|
+
doc = Nokogiri::HTML(html)
|
|
18
|
+
doc.xpath("//text()[#{condition}]").each(&replacer)
|
|
19
|
+
doc.xpath('//@alt').each(&replacer)
|
|
20
|
+
doc.xpath('//@title').each(&replacer)
|
|
21
|
+
doc.to_s
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
class Uuml::Middleware
|
|
4
|
+
|
|
5
|
+
attr_reader :app
|
|
6
|
+
|
|
7
|
+
def initialize(app)
|
|
8
|
+
@app = app
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def call(env)
|
|
12
|
+
status, headers, response = @app.call(env)
|
|
13
|
+
|
|
14
|
+
if headers['Content-Type'] == 'text/html; charset=utf-8'
|
|
15
|
+
response.body = Uuml::HTML.convert(response.body)
|
|
16
|
+
end
|
|
17
|
+
[status, headers, response]
|
|
18
|
+
end
|
|
19
|
+
end
|
data/lib/uuml/railtie.rb
ADDED
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'bundler/setup'
|
|
3
|
+
|
|
4
|
+
require 'uuml'
|
|
5
|
+
|
|
6
|
+
require 'rspec'
|
|
7
|
+
|
|
8
|
+
class MockResponse
|
|
9
|
+
attr_accessor :body
|
|
10
|
+
def initialize(body); @body = body; end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def mock_response(body)
|
|
14
|
+
MockResponse.new(body)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
RSpec.configure do |config|
|
|
18
|
+
|
|
19
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe Uuml::HTML do
|
|
6
|
+
it "should add umlauts to all the us within textual content" do
|
|
7
|
+
Uuml::HTML.convert('<p>Uber january lunch</p>').should =~ /Über janüary lünch/
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it "should convert ue in a single umlauted u, if not starting with a q" do
|
|
11
|
+
Uuml::HTML.convert('<a>Revenue</a>').should =~ /Revenü/
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it "should not replace que, ou or ui combinations" do
|
|
15
|
+
Uuml::HTML.convert('<li>build your query</li>').should =~ /build your query/
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "should not convert text in tags that are not listed" do
|
|
19
|
+
Uuml::HTML.convert('<script>lunch</script>').should_not =~ /lünch/
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it "should not convert tags" do
|
|
23
|
+
Uuml::HTML.convert('<ul><li>test</li></ul>').should_not =~ /ül/
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "should replace a alt and title text attributes" do
|
|
27
|
+
Uuml::HTML.convert('<img alt="lunch" />').should =~ /lünch/
|
|
28
|
+
Uuml::HTML.convert('<img title="lunch" />').should =~ /lünch/
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe Uuml::Middleware do
|
|
6
|
+
|
|
7
|
+
let(:env) { Hash.new }
|
|
8
|
+
let(:app) { mock('app') }
|
|
9
|
+
subject { Uuml::Middleware.new(app) }
|
|
10
|
+
|
|
11
|
+
it "should replace stuff in UTF8 HTML responses" do
|
|
12
|
+
app.stub(:call).and_return([200, { 'Content-Type' => 'text/html; charset=utf-8' }, mock_response('<li>lunch</li>')])
|
|
13
|
+
status, headers, response = subject.call(env)
|
|
14
|
+
response.body.should =~ /lünch/
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "should not replace stuff in non-UTF8 HTML responses" do
|
|
18
|
+
app.stub(:call).and_return([200, { 'Content-Type' => 'text/html; charset=iso-8859-1' }, mock_response('<li>lunch</li>')])
|
|
19
|
+
status, headers, response = subject.call(env)
|
|
20
|
+
response.body.should_not =~ /lünch/
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "should not replace in JSON responses" do
|
|
24
|
+
app.stub(:call).and_return([200, { 'Content-Type' => 'application/json; charset=utf-8' }, mock_response('{ "lunch": "super" }')])
|
|
25
|
+
status, headers, response = subject.call(env)
|
|
26
|
+
response.body.should_not =~ /lünch/
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,365 @@
|
|
|
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 detect_gemspec_file =~ /^(\.*)\.gemspec$/ && File.exist?("lib/#{$1}.rb")
|
|
17
|
+
"lib/#{$1}.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
|
+
attr_reader :gemspec, :modified_files
|
|
28
|
+
attr_accessor :gemspec_file, :task_namespace, :main_include, :root_dir, :spec_pattern, :test_pattern, :remote, :remote_branch, :local_branch
|
|
29
|
+
|
|
30
|
+
# Initializes the settings, yields itself for configuration
|
|
31
|
+
# and defines the rake tasks based on the gemspec file.
|
|
32
|
+
def initialize(task_namespace = :gem)
|
|
33
|
+
@gemspec_file = GithubGem.detect_gemspec_file
|
|
34
|
+
@task_namespace = task_namespace
|
|
35
|
+
@main_include = GithubGem.detect_main_include
|
|
36
|
+
@modified_files = Set.new
|
|
37
|
+
@root_dir = Dir.pwd
|
|
38
|
+
@test_pattern = 'test/**/*_test.rb'
|
|
39
|
+
@spec_pattern = 'spec/**/*_spec.rb'
|
|
40
|
+
@local_branch = 'master'
|
|
41
|
+
@remote = 'origin'
|
|
42
|
+
@remote_branch = 'master'
|
|
43
|
+
|
|
44
|
+
yield(self) if block_given?
|
|
45
|
+
|
|
46
|
+
load_gemspec!
|
|
47
|
+
define_tasks!
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
protected
|
|
51
|
+
|
|
52
|
+
def git
|
|
53
|
+
@git ||= ENV['GIT'] || 'git'
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Define Unit test tasks
|
|
57
|
+
def define_test_tasks!
|
|
58
|
+
require 'rake/testtask'
|
|
59
|
+
|
|
60
|
+
namespace(:test) do
|
|
61
|
+
Rake::TestTask.new(:basic) do |t|
|
|
62
|
+
t.pattern = test_pattern
|
|
63
|
+
t.verbose = true
|
|
64
|
+
t.libs << 'test'
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
desc "Run all unit tests for #{gemspec.name}"
|
|
69
|
+
task(:test => ['test:basic'])
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# Defines RSpec tasks
|
|
73
|
+
def define_rspec_tasks!
|
|
74
|
+
require 'rspec/core/rake_task'
|
|
75
|
+
|
|
76
|
+
namespace(:spec) do
|
|
77
|
+
desc "Verify all RSpec examples for #{gemspec.name}"
|
|
78
|
+
RSpec::Core::RakeTask.new(:basic) do |t|
|
|
79
|
+
t.pattern = spec_pattern
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
desc "Verify all RSpec examples for #{gemspec.name} and output specdoc"
|
|
83
|
+
RSpec::Core::RakeTask.new(:specdoc) do |t|
|
|
84
|
+
t.pattern = spec_pattern
|
|
85
|
+
t.rspec_opts = ['--format', 'documentation', '--color']
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
desc "Run RCov on specs for #{gemspec.name}"
|
|
89
|
+
RSpec::Core::RakeTask.new(:rcov) do |t|
|
|
90
|
+
t.pattern = spec_pattern
|
|
91
|
+
t.rcov = true
|
|
92
|
+
t.rcov_opts = ['--exclude', '"spec/*,gems/*"', '--rails']
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
desc "Verify all RSpec examples for #{gemspec.name} and output specdoc"
|
|
97
|
+
task(:spec => ['spec:specdoc'])
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# Defines the rake tasks
|
|
101
|
+
def define_tasks!
|
|
102
|
+
|
|
103
|
+
define_test_tasks! if has_tests?
|
|
104
|
+
define_rspec_tasks! if has_specs?
|
|
105
|
+
|
|
106
|
+
namespace(@task_namespace) do
|
|
107
|
+
desc "Updates the filelist in the gemspec file"
|
|
108
|
+
task(:manifest) { manifest_task }
|
|
109
|
+
|
|
110
|
+
desc "Builds the .gem package"
|
|
111
|
+
task(:build => :manifest) { build_task }
|
|
112
|
+
|
|
113
|
+
desc "Sets the version of the gem in the gemspec"
|
|
114
|
+
task(:set_version => [:check_version, :check_current_branch]) { version_task }
|
|
115
|
+
task(:check_version => :fetch_origin) { check_version_task }
|
|
116
|
+
|
|
117
|
+
task(:fetch_origin) { fetch_origin_task }
|
|
118
|
+
task(:check_current_branch) { check_current_branch_task }
|
|
119
|
+
task(:check_clean_status) { check_clean_status_task }
|
|
120
|
+
task(:check_not_diverged => :fetch_origin) { check_not_diverged_task }
|
|
121
|
+
|
|
122
|
+
checks = [:check_current_branch, :check_clean_status, :check_not_diverged, :check_version]
|
|
123
|
+
checks.unshift('spec:basic') if has_specs?
|
|
124
|
+
checks.unshift('test:basic') if has_tests?
|
|
125
|
+
# checks.push << [:check_rubyforge] if gemspec.rubyforge_project
|
|
126
|
+
|
|
127
|
+
desc "Perform all checks that would occur before a release"
|
|
128
|
+
task(:release_checks => checks)
|
|
129
|
+
|
|
130
|
+
release_tasks = [:release_checks, :set_version, :build, :github_release, :gemcutter_release]
|
|
131
|
+
# release_tasks << [:rubyforge_release] if gemspec.rubyforge_project
|
|
132
|
+
|
|
133
|
+
desc "Release a new version of the gem using the VERSION environment variable"
|
|
134
|
+
task(:release => release_tasks) { release_task }
|
|
135
|
+
|
|
136
|
+
namespace(:release) do
|
|
137
|
+
desc "Release the next version of the gem, by incrementing the last version segment by 1"
|
|
138
|
+
task(:next => [:next_version] + release_tasks) { release_task }
|
|
139
|
+
|
|
140
|
+
desc "Release the next version of the gem, using a patch increment (0.0.1)"
|
|
141
|
+
task(:patch => [:next_patch_version] + release_tasks) { release_task }
|
|
142
|
+
|
|
143
|
+
desc "Release the next version of the gem, using a minor increment (0.1.0)"
|
|
144
|
+
task(:minor => [:next_minor_version] + release_tasks) { release_task }
|
|
145
|
+
|
|
146
|
+
desc "Release the next version of the gem, using a major increment (1.0.0)"
|
|
147
|
+
task(:major => [:next_major_version] + release_tasks) { release_task }
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
# task(:check_rubyforge) { check_rubyforge_task }
|
|
151
|
+
# task(:rubyforge_release) { rubyforge_release_task }
|
|
152
|
+
task(:gemcutter_release) { gemcutter_release_task }
|
|
153
|
+
task(:github_release => [:commit_modified_files, :tag_version]) { github_release_task }
|
|
154
|
+
task(:tag_version) { tag_version_task }
|
|
155
|
+
task(:commit_modified_files) { commit_modified_files_task }
|
|
156
|
+
|
|
157
|
+
task(:next_version) { next_version_task }
|
|
158
|
+
task(:next_patch_version) { next_version_task(:patch) }
|
|
159
|
+
task(:next_minor_version) { next_version_task(:minor) }
|
|
160
|
+
task(:next_major_version) { next_version_task(:major) }
|
|
161
|
+
|
|
162
|
+
desc "Updates the gem release tasks with the latest version on Github"
|
|
163
|
+
task(:update_tasks) { update_tasks_task }
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
# Updates the files list and test_files list in the gemspec file using the list of files
|
|
168
|
+
# in the repository and the spec/test file pattern.
|
|
169
|
+
def manifest_task
|
|
170
|
+
# Load all the gem's files using "git ls-files"
|
|
171
|
+
repository_files = `#{git} ls-files`.split("\n")
|
|
172
|
+
test_files = Dir[test_pattern] + Dir[spec_pattern]
|
|
173
|
+
|
|
174
|
+
update_gemspec(:files, repository_files)
|
|
175
|
+
update_gemspec(:test_files, repository_files & test_files)
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
# Builds the gem
|
|
179
|
+
def build_task
|
|
180
|
+
sh "gem build -q #{gemspec_file}"
|
|
181
|
+
Dir.mkdir('pkg') unless File.exist?('pkg')
|
|
182
|
+
sh "mv #{gemspec.name}-#{gemspec.version}.gem pkg/#{gemspec.name}-#{gemspec.version}.gem"
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
def newest_version
|
|
186
|
+
`#{git} tag`.split("\n").map { |tag| tag.split('-').last }.compact.map { |v| Gem::Version.new(v) }.max || Gem::Version.new('0.0.0')
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
def next_version(increment = nil)
|
|
190
|
+
next_version = newest_version.segments
|
|
191
|
+
increment_index = case increment
|
|
192
|
+
when :micro then 3
|
|
193
|
+
when :patch then 2
|
|
194
|
+
when :minor then 1
|
|
195
|
+
when :major then 0
|
|
196
|
+
else next_version.length - 1
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
next_version[increment_index] ||= 0
|
|
200
|
+
next_version[increment_index] = next_version[increment_index].succ
|
|
201
|
+
((increment_index + 1)...next_version.length).each { |i| next_version[i] = 0 }
|
|
202
|
+
|
|
203
|
+
Gem::Version.new(next_version.join('.'))
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
def next_version_task(increment = nil)
|
|
207
|
+
ENV['VERSION'] = next_version(increment).version
|
|
208
|
+
puts "Releasing version #{ENV['VERSION']}..."
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
# Updates the version number in the gemspec file, the VERSION constant in the main
|
|
212
|
+
# include file and the contents of the VERSION file.
|
|
213
|
+
def version_task
|
|
214
|
+
update_gemspec(:version, ENV['VERSION']) if ENV['VERSION']
|
|
215
|
+
update_gemspec(:date, Date.today)
|
|
216
|
+
|
|
217
|
+
update_version_file(gemspec.version)
|
|
218
|
+
update_version_constant(gemspec.version)
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
def check_version_task
|
|
222
|
+
raise "#{ENV['VERSION']} is not a valid version number!" if ENV['VERSION'] && !Gem::Version.correct?(ENV['VERSION'])
|
|
223
|
+
proposed_version = Gem::Version.new((ENV['VERSION'] || gemspec.version).dup)
|
|
224
|
+
raise "This version (#{proposed_version}) is not higher than the highest tagged version (#{newest_version})" if newest_version >= proposed_version
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
# Checks whether the current branch is not diverged from the remote branch
|
|
228
|
+
def check_not_diverged_task
|
|
229
|
+
raise "The current branch is diverged from the remote branch!" if `#{git} rev-list HEAD..#{remote}/#{remote_branch}`.split("\n").any?
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
# Checks whether the repository status ic clean
|
|
233
|
+
def check_clean_status_task
|
|
234
|
+
raise "The current working copy contains modifications" if `#{git} ls-files -m`.split("\n").any?
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
# Checks whether the current branch is correct
|
|
238
|
+
def check_current_branch_task
|
|
239
|
+
raise "Currently not on #{local_branch} branch!" unless `#{git} branch`.split("\n").detect { |b| /^\* / =~ b } == "* #{local_branch}"
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
# Fetches the latest updates from Github
|
|
243
|
+
def fetch_origin_task
|
|
244
|
+
sh git, 'fetch', remote
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
# Commits every file that has been changed by the release task.
|
|
248
|
+
def commit_modified_files_task
|
|
249
|
+
really_modified = `#{git} ls-files -m #{modified_files.entries.join(' ')}`.split("\n")
|
|
250
|
+
if really_modified.any?
|
|
251
|
+
really_modified.each { |file| sh git, 'add', file }
|
|
252
|
+
sh git, 'commit', '-m', "Released #{gemspec.name} gem version #{gemspec.version}."
|
|
253
|
+
end
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
# Adds a tag for the released version
|
|
257
|
+
def tag_version_task
|
|
258
|
+
sh git, 'tag', '-a', "#{gemspec.name}-#{gemspec.version}", '-m', "Released #{gemspec.name} gem version #{gemspec.version}."
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
# Pushes the changes and tag to github
|
|
262
|
+
def github_release_task
|
|
263
|
+
sh git, 'push', '--tags', remote, remote_branch
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
def gemcutter_release_task
|
|
267
|
+
sh "gem", 'push', "pkg/#{gemspec.name}-#{gemspec.version}.gem"
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
# Gem release task.
|
|
271
|
+
# All work is done by the task's dependencies, so just display a release completed message.
|
|
272
|
+
def release_task
|
|
273
|
+
puts
|
|
274
|
+
puts "Release successful."
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
private
|
|
278
|
+
|
|
279
|
+
# Checks whether this project has any RSpec files
|
|
280
|
+
def has_specs?
|
|
281
|
+
FileList[spec_pattern].any?
|
|
282
|
+
end
|
|
283
|
+
|
|
284
|
+
# Checks whether this project has any unit test files
|
|
285
|
+
def has_tests?
|
|
286
|
+
FileList[test_pattern].any?
|
|
287
|
+
end
|
|
288
|
+
|
|
289
|
+
# Loads the gemspec file
|
|
290
|
+
def load_gemspec!
|
|
291
|
+
@gemspec = eval(File.read(@gemspec_file))
|
|
292
|
+
end
|
|
293
|
+
|
|
294
|
+
# Updates the VERSION file with the new version
|
|
295
|
+
def update_version_file(version)
|
|
296
|
+
if File.exists?('VERSION')
|
|
297
|
+
File.open('VERSION', 'w') { |f| f << version.to_s }
|
|
298
|
+
modified_files << 'VERSION'
|
|
299
|
+
end
|
|
300
|
+
end
|
|
301
|
+
|
|
302
|
+
# Updates the VERSION constant in the main include file if it exists
|
|
303
|
+
def update_version_constant(version)
|
|
304
|
+
if main_include && File.exist?(main_include)
|
|
305
|
+
file_contents = File.read(main_include)
|
|
306
|
+
if file_contents.sub!(/^(\s+VERSION\s*=\s*)[^\s].*$/) { $1 + version.to_s.inspect }
|
|
307
|
+
File.open(main_include, 'w') { |f| f << file_contents }
|
|
308
|
+
modified_files << main_include
|
|
309
|
+
end
|
|
310
|
+
end
|
|
311
|
+
end
|
|
312
|
+
|
|
313
|
+
# Updates an attribute of the gemspec file.
|
|
314
|
+
# This function will open the file, and search/replace the attribute using a regular expression.
|
|
315
|
+
def update_gemspec(attribute, new_value, literal = false)
|
|
316
|
+
|
|
317
|
+
unless literal
|
|
318
|
+
new_value = case new_value
|
|
319
|
+
when Array then "%w(#{new_value.join(' ')})"
|
|
320
|
+
when Hash, String then new_value.inspect
|
|
321
|
+
when Date then new_value.strftime('%Y-%m-%d').inspect
|
|
322
|
+
else raise "Cannot write value #{new_value.inspect} to gemspec file!"
|
|
323
|
+
end
|
|
324
|
+
end
|
|
325
|
+
|
|
326
|
+
spec = File.read(gemspec_file)
|
|
327
|
+
regexp = Regexp.new('^(\s+\w+\.' + Regexp.quote(attribute.to_s) + '\s*=\s*)[^\s].*$')
|
|
328
|
+
if spec.sub!(regexp) { $1 + new_value }
|
|
329
|
+
File.open(gemspec_file, 'w') { |f| f << spec }
|
|
330
|
+
modified_files << gemspec_file
|
|
331
|
+
|
|
332
|
+
# Reload the gemspec so the changes are incorporated
|
|
333
|
+
load_gemspec!
|
|
334
|
+
|
|
335
|
+
# Also mark the Gemfile.lock file as changed because of the new version.
|
|
336
|
+
modified_files << 'Gemfile.lock' if File.exist?(File.join(root_dir, 'Gemfile.lock'))
|
|
337
|
+
end
|
|
338
|
+
end
|
|
339
|
+
|
|
340
|
+
# Updates the tasks file using the latest file found on Github
|
|
341
|
+
def update_tasks_task
|
|
342
|
+
require 'net/https'
|
|
343
|
+
require 'uri'
|
|
344
|
+
|
|
345
|
+
uri = URI.parse('https://github.com/wvanbergen/github-gem/raw/master/tasks/github-gem.rake')
|
|
346
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
|
347
|
+
http.use_ssl = true
|
|
348
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
|
349
|
+
response = http.request(Net::HTTP::Get.new(uri.path))
|
|
350
|
+
|
|
351
|
+
if Net::HTTPSuccess === response
|
|
352
|
+
open(__FILE__, "w") { |file| file.write(response.body) }
|
|
353
|
+
relative_file = File.expand_path(__FILE__).sub(%r[^#{@root_dir}/], '')
|
|
354
|
+
if `#{git} ls-files -m #{relative_file}`.split("\n").any?
|
|
355
|
+
sh git, 'add', relative_file
|
|
356
|
+
sh git, 'commit', '-m', "Updated to latest gem release management tasks."
|
|
357
|
+
else
|
|
358
|
+
puts "Release managament tasks already are at the latest version."
|
|
359
|
+
end
|
|
360
|
+
else
|
|
361
|
+
raise "Download failed with HTTP status #{response.code}!"
|
|
362
|
+
end
|
|
363
|
+
end
|
|
364
|
+
end
|
|
365
|
+
end
|
data/uuml.gemspec
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
|
3
|
+
|
|
4
|
+
Gem::Specification.new do |s|
|
|
5
|
+
s.name = "uuml"
|
|
6
|
+
s.version = "0.0.1"
|
|
7
|
+
s.platform = Gem::Platform::RUBY
|
|
8
|
+
s.authors = ["Willem van Bergen"]
|
|
9
|
+
s.email = ["willem@railsdoctors.com"]
|
|
10
|
+
s.homepage = "https://github.com/wvanbergen/uuml"
|
|
11
|
+
s.summary = %q{Instant Germanification of your web app}
|
|
12
|
+
s.description = %q{Use this rack middleware to add umlauts to your u's where appropriate.}
|
|
13
|
+
|
|
14
|
+
s.rubyforge_project = "uuml"
|
|
15
|
+
|
|
16
|
+
s.add_runtime_dependency('rack')
|
|
17
|
+
s.add_runtime_dependency('nokogiri')
|
|
18
|
+
|
|
19
|
+
s.add_development_dependency('rake')
|
|
20
|
+
s.add_development_dependency('rspec', '~> 2')
|
|
21
|
+
|
|
22
|
+
s.files = %w(.gitignore Gemfile README.rdoc Rakefile lib/uuml.rb lib/uuml/html.rb lib/uuml/middleware.rb lib/uuml/railtie.rb spec/spec_helper.rb spec/uuml/html_spec.rb spec/uuml/middleware_spec.rb tasks/gem_release_tasks.rb uuml.gemspec)
|
|
23
|
+
s.test_files = %w(spec/uuml/html_spec.rb spec/uuml/middleware_spec.rb)
|
|
24
|
+
s.require_paths = ["lib"]
|
|
25
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: uuml
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
prerelease: false
|
|
5
|
+
segments:
|
|
6
|
+
- 0
|
|
7
|
+
- 0
|
|
8
|
+
- 1
|
|
9
|
+
version: 0.0.1
|
|
10
|
+
platform: ruby
|
|
11
|
+
authors:
|
|
12
|
+
- Willem van Bergen
|
|
13
|
+
autorequire:
|
|
14
|
+
bindir: bin
|
|
15
|
+
cert_chain: []
|
|
16
|
+
|
|
17
|
+
date: 2011-03-06 00:00:00 -05:00
|
|
18
|
+
default_executable:
|
|
19
|
+
dependencies:
|
|
20
|
+
- !ruby/object:Gem::Dependency
|
|
21
|
+
name: rack
|
|
22
|
+
prerelease: false
|
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
|
24
|
+
none: false
|
|
25
|
+
requirements:
|
|
26
|
+
- - ">="
|
|
27
|
+
- !ruby/object:Gem::Version
|
|
28
|
+
segments:
|
|
29
|
+
- 0
|
|
30
|
+
version: "0"
|
|
31
|
+
type: :runtime
|
|
32
|
+
version_requirements: *id001
|
|
33
|
+
- !ruby/object:Gem::Dependency
|
|
34
|
+
name: nokogiri
|
|
35
|
+
prerelease: false
|
|
36
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
|
37
|
+
none: false
|
|
38
|
+
requirements:
|
|
39
|
+
- - ">="
|
|
40
|
+
- !ruby/object:Gem::Version
|
|
41
|
+
segments:
|
|
42
|
+
- 0
|
|
43
|
+
version: "0"
|
|
44
|
+
type: :runtime
|
|
45
|
+
version_requirements: *id002
|
|
46
|
+
- !ruby/object:Gem::Dependency
|
|
47
|
+
name: rake
|
|
48
|
+
prerelease: false
|
|
49
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
|
50
|
+
none: false
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
segments:
|
|
55
|
+
- 0
|
|
56
|
+
version: "0"
|
|
57
|
+
type: :development
|
|
58
|
+
version_requirements: *id003
|
|
59
|
+
- !ruby/object:Gem::Dependency
|
|
60
|
+
name: rspec
|
|
61
|
+
prerelease: false
|
|
62
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
|
63
|
+
none: false
|
|
64
|
+
requirements:
|
|
65
|
+
- - ~>
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
segments:
|
|
68
|
+
- 2
|
|
69
|
+
version: "2"
|
|
70
|
+
type: :development
|
|
71
|
+
version_requirements: *id004
|
|
72
|
+
description: Use this rack middleware to add umlauts to your u's where appropriate.
|
|
73
|
+
email:
|
|
74
|
+
- willem@railsdoctors.com
|
|
75
|
+
executables: []
|
|
76
|
+
|
|
77
|
+
extensions: []
|
|
78
|
+
|
|
79
|
+
extra_rdoc_files: []
|
|
80
|
+
|
|
81
|
+
files:
|
|
82
|
+
- .gitignore
|
|
83
|
+
- Gemfile
|
|
84
|
+
- README.rdoc
|
|
85
|
+
- Rakefile
|
|
86
|
+
- lib/uuml.rb
|
|
87
|
+
- lib/uuml/html.rb
|
|
88
|
+
- lib/uuml/middleware.rb
|
|
89
|
+
- lib/uuml/railtie.rb
|
|
90
|
+
- spec/spec_helper.rb
|
|
91
|
+
- spec/uuml/html_spec.rb
|
|
92
|
+
- spec/uuml/middleware_spec.rb
|
|
93
|
+
- tasks/gem_release_tasks.rb
|
|
94
|
+
- uuml.gemspec
|
|
95
|
+
has_rdoc: true
|
|
96
|
+
homepage: https://github.com/wvanbergen/uuml
|
|
97
|
+
licenses: []
|
|
98
|
+
|
|
99
|
+
post_install_message:
|
|
100
|
+
rdoc_options: []
|
|
101
|
+
|
|
102
|
+
require_paths:
|
|
103
|
+
- lib
|
|
104
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
105
|
+
none: false
|
|
106
|
+
requirements:
|
|
107
|
+
- - ">="
|
|
108
|
+
- !ruby/object:Gem::Version
|
|
109
|
+
segments:
|
|
110
|
+
- 0
|
|
111
|
+
version: "0"
|
|
112
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
113
|
+
none: false
|
|
114
|
+
requirements:
|
|
115
|
+
- - ">="
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
segments:
|
|
118
|
+
- 0
|
|
119
|
+
version: "0"
|
|
120
|
+
requirements: []
|
|
121
|
+
|
|
122
|
+
rubyforge_project: uuml
|
|
123
|
+
rubygems_version: 1.3.7
|
|
124
|
+
signing_key:
|
|
125
|
+
specification_version: 3
|
|
126
|
+
summary: Instant Germanification of your web app
|
|
127
|
+
test_files:
|
|
128
|
+
- spec/uuml/html_spec.rb
|
|
129
|
+
- spec/uuml/middleware_spec.rb
|