Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce number of requires #92

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require 'rubygems'
require 'rake'
require 'date'
require File.expand_path('../lib/papertrail/version', __FILE__)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lib/ should be in the path when this is run so "papertrail/version" should be all that's necessary to require.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope. Doesn't work 😢


#############################################################################
#
Expand All @@ -16,11 +17,6 @@ def module_name
name.split('-').first
end

def version
line = File.read("lib/#{name}.rb")[/^\s*VERSION\s*=\s*.*/]
line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
end

def date
Date.today.to_s
end
Expand All @@ -34,7 +30,7 @@ def gemspec_file
end

def gem_file
"#{name}-#{version}.gem"
"#{name}-#{Papertrail::VERSION}.gem"
end

def replace_header(head, header_name)
Expand Down Expand Up @@ -75,17 +71,17 @@ end
#
#############################################################################

desc "Create tag v#{version} and build and push #{gem_file} to Rubygems"
desc "Create tag v#{Papertrail::VERSION} and build and push #{gem_file} to Rubygems"
task :release => :build do
unless `git branch` =~ /^\* master$/
puts "You must be on the master branch to release!"
exit!
end
sh "git commit --allow-empty -a -m 'Release #{version}'"
sh "git tag v#{version}"
sh "git commit --allow-empty -a -m 'Release #{Papertrail::VERSION}'"
sh "git tag v#{Papertrail::VERSION}"
sh "git push origin master"
sh "git push origin v#{version}"
sh "gem push pkg/#{name}-#{version}.gem"
sh "git push origin v#{Papertrail::VERSION}"
sh "gem push pkg/#{name}-#{Papertrail::VERSION}.gem"
end

desc "Build #{gem_file} into the pkg directory"
Expand All @@ -103,7 +99,7 @@ task :gemspec => :validate do

# replace name version and date
replace_header(head, :name)
replace_header(head, :version)
replace_header(head, Papertrail::VERSION)
replace_header(head, :date)
#comment this out if your rubyforge_project has a different name
replace_header(head, :rubyforge_project)
Expand Down
1 change: 0 additions & 1 deletion bin/papertrail-add-group
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env ruby
require 'papertrail'
require 'papertrail/cli_add_group'

begin
Expand Down
1 change: 0 additions & 1 deletion bin/papertrail-add-system
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env ruby
require 'papertrail'
require 'papertrail/cli_add_system'

begin
Expand Down
1 change: 0 additions & 1 deletion bin/papertrail-join-group
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env ruby
require 'papertrail'
require 'papertrail/cli_join_group'

begin
Expand Down
1 change: 0 additions & 1 deletion bin/papertrail-leave-group
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env ruby
require 'papertrail'
require 'papertrail/cli_leave_group'

begin
Expand Down
1 change: 0 additions & 1 deletion bin/papertrail-remove-system
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env ruby
require 'papertrail'
require 'papertrail/cli_remove_system'

begin
Expand Down
5 changes: 4 additions & 1 deletion lib/papertrail.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
require 'papertrail/version'
require 'optparse'

module Papertrail
VERSION = '0.10.3'
end

require 'papertrail/connection'
require 'papertrail/cli_helpers'
5 changes: 0 additions & 5 deletions lib/papertrail/cli.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
require 'optparse'
require 'yaml'
require 'chronic'
require 'ansi/core'

require 'papertrail'
require 'papertrail/connection'
require 'papertrail/cli_helpers'

module Papertrail
class Cli
Expand Down
6 changes: 1 addition & 5 deletions lib/papertrail/cli_add_group.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
require 'optparse'
require 'yaml'

require 'papertrail/cli_helpers'
require 'papertrail/connection'
require 'papertrail'

module Papertrail
class CliAddGroup
Expand Down
6 changes: 1 addition & 5 deletions lib/papertrail/cli_add_system.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
require 'optparse'
require 'yaml'

require 'papertrail/cli_helpers'
require 'papertrail/connection'
require 'papertrail'

module Papertrail
class CliAddSystem
Expand Down
2 changes: 2 additions & 0 deletions lib/papertrail/cli_helpers.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'yaml'

module Papertrail
module CliHelpers
def find_configfile
Expand Down
6 changes: 1 addition & 5 deletions lib/papertrail/cli_join_group.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
require 'optparse'
require 'yaml'

require 'papertrail/cli_helpers'
require 'papertrail/connection'
require 'papertrail'

module Papertrail
class CliJoinGroup
Expand Down
6 changes: 1 addition & 5 deletions lib/papertrail/cli_leave_group.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
require 'optparse'
require 'yaml'

require 'papertrail/cli_helpers'
require 'papertrail/connection'
require 'papertrail'

module Papertrail
class CliLeaveGroup
Expand Down
6 changes: 1 addition & 5 deletions lib/papertrail/cli_remove_system.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
require 'optparse'
require 'yaml'

require 'papertrail/cli_helpers'
require 'papertrail/connection'
require 'papertrail'

module Papertrail
class CliRemoveSystem
Expand Down
4 changes: 4 additions & 0 deletions lib/papertrail/version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# frozen_string_literal: true
module Papertrail
VERSION = '0.10.3'
end
1 change: 1 addition & 0 deletions papertrail.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ Gem::Specification.new do |s|
lib/papertrail/okjson.rb
lib/papertrail/search_query.rb
lib/papertrail/search_result.rb
lib/papertrail/version.rb
papertrail.gemspec
test/connection_test.rb
test/http_client_test.rb
Expand Down