treefell 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 801d13dd8ee8f4a572d05c6a011896ffa7dbbb0a
4
+ data.tar.gz: 9768f42505d92fafcc19bdb88be5a687a5099934
5
+ SHA512:
6
+ metadata.gz: 0b8a23f86d3adfad3c3dbe5cdfe6570c571ebbd72ab22c6619a6355ed4cdb609e503a7e9c5a9de46ad0be8ae9e9b992cb5ecf3d50a2051516d2cf8cd0646e019
7
+ data.tar.gz: 531c98a230201a4405276500f49241f301fc317599873f38e1d80ff22b410150dfb0006da245f047d0f8b0535e54894039cf01dae6b0dea538e0a00c261413af
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Treefell [![Build Status](https://travis-ci.org/zdennis/treefell.svg?branch=master)](https://travis-ci.org/zdennis/treefell)
2
+
3
+ Treefell is a simple debug-logging library for ruby.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'treefell'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install treefell
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it ( https://github.com/zdennis/treefell/fork )
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,3 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ Dir[File.join(File.dirname(__FILE__), 'lib/tasks/**/*.rake')].each {|f| load f }
@@ -0,0 +1,62 @@
1
+ namespace :bump do
2
+ namespace :version do
3
+ class ProjectVersion
4
+ FILE = File.dirname(__FILE__) + '/../treefell/version.rb'
5
+ PATTERN = /VERSION\s*=\s*"(\d+)\.(\d+)\.(\d+)"/m
6
+
7
+ def initialize(file=FILE, pattern=PATTERN)
8
+ @file = file
9
+ @pattern = pattern
10
+ end
11
+
12
+ def bump(major:nil, minor:nil, patch:nil)
13
+ version = nil
14
+ contents.sub!(@pattern) do
15
+ _major = major.call($1) if major
16
+ _minor = minor.call($2) if minor
17
+ _patch = patch.call($3) if patch
18
+ version = "#{_major}.#{_minor}.#{_patch}"
19
+ results = %|VERSION = "#{version}"|
20
+ end
21
+ File.write(@file, contents)
22
+ system "bundle"
23
+ system "git add #{ProjectVersion::FILE} && git commit -m 'Bumping version to #{version}'"
24
+ system "git tag v#{version}"
25
+ end
26
+
27
+ private
28
+
29
+ def contents
30
+ @contents ||= File.read(@file)
31
+ end
32
+ end
33
+
34
+ desc "Increments the patch number by 1 for the project"
35
+ task :patch do
36
+ ProjectVersion.new.bump(
37
+ major: ->(major){ major },
38
+ minor: ->(minor){ minor },
39
+ patch: ->(patch){ patch.succ }
40
+ )
41
+ end
42
+
43
+ desc "Increments the minor number by 1 for the project"
44
+ task :minor do
45
+ ProjectVersion.new.bump(
46
+ major: ->(major){ major },
47
+ minor: ->(minor){ minor.succ },
48
+ patch: ->(patch){ 0 }
49
+ )
50
+ end
51
+
52
+ desc "Increments the major number by 1 for the project"
53
+ task :major do
54
+ ProjectVersion.new.bump(
55
+ major: ->(major){ major.succ },
56
+ minor: ->(minor){ 0 },
57
+ patch: ->(patch){ 0 }
58
+ )
59
+ end
60
+
61
+ end
62
+ end
@@ -0,0 +1,28 @@
1
+ module Treefell
2
+ class Color
3
+ COLORS = [
4
+ :bright_black,
5
+ :bright_blue,
6
+ :bright_cyan,
7
+ :bright_green,
8
+ :bright_magenta,
9
+ :bright_red,
10
+ :bright_yellow
11
+ ]
12
+
13
+ def self.rotate
14
+ if !@colors_index || @colors_index == COLORS.length - 1
15
+ @colors_index = -1
16
+ end
17
+ new(COLORS[@colors_index+=1])
18
+ end
19
+
20
+ def initialize(color)
21
+ @color = color
22
+ end
23
+
24
+ def colorize(str)
25
+ ::Term::ANSIColor.send(@color, str)
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,29 @@
1
+ require 'treefell/color'
2
+
3
+ module Treefell
4
+ class DebugLogger
5
+ attr_reader :io, :namespace
6
+
7
+ def initialize(namespace: nil, io: $stdout, color: Color.rotate)
8
+ @namespace = namespace
9
+ @io = io
10
+ @color = color
11
+ end
12
+
13
+ def puts(message)
14
+ formatted_namespace = if namespace
15
+ @color.colorize(namespace)
16
+ end
17
+ @io.puts [
18
+ formatted_namespace,
19
+ message
20
+ ].compact.join(' ')
21
+ end
22
+
23
+ def ==(other)
24
+ other.is_a?(DebugLogger) &&
25
+ other.namespace == namespace &&
26
+ other.io == io
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,3 @@
1
+ module Treefell
2
+ VERSION = '0.1.0'
3
+ end
data/lib/treefell.rb ADDED
@@ -0,0 +1,10 @@
1
+ require 'term/ansicolor'
2
+
3
+ require 'treefell/version'
4
+ require 'treefell/debug_logger'
5
+
6
+ module Treefell
7
+ def self.debug(namespace=nil, io: $stdout)
8
+ DebugLogger.new(namespace: namespace, io: io)
9
+ end
10
+ end
data/treefell.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'treefell/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'treefell'
7
+ s.version = Treefell::VERSION
8
+ s.date = Time.now.strftime '%Y-%m-%d'
9
+ s.summary = 'Treefell is a simple debug-logging library for ruby'
10
+ s.description = 'Treefell is a simple debug-logging library for ruby.'
11
+ s.authors = ['Zach Dennis']
12
+ s.email = 'zach.dennis@gmail.com'
13
+ s.homepage = 'https://github.com/zdennis/treefell'
14
+ s.license = 'MIT'
15
+
16
+ exclude_files = %w(.travis.yml .rspec .gitignore Gemfile)
17
+ s.files = (`git ls-files -z`.split("\x0") - exclude_files)
18
+ .reject { |file| file =~ /^spec\// }
19
+ s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
21
+ s.require_paths = ["lib"]
22
+
23
+ s.add_dependency "term-ansicolor", "~> 1.3"
24
+ s.add_development_dependency 'rspec', '~> 3.4.0', '>= 3.4'
25
+ end
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: treefell
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Zach Dennis
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-05-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: term-ansicolor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 3.4.0
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: '3.4'
37
+ type: :development
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: 3.4.0
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '3.4'
47
+ description: Treefell is a simple debug-logging library for ruby.
48
+ email: zach.dennis@gmail.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - README.md
54
+ - Rakefile
55
+ - lib/tasks/gem.rake
56
+ - lib/treefell.rb
57
+ - lib/treefell/color.rb
58
+ - lib/treefell/debug_logger.rb
59
+ - lib/treefell/version.rb
60
+ - treefell.gemspec
61
+ homepage: https://github.com/zdennis/treefell
62
+ licenses:
63
+ - MIT
64
+ metadata: {}
65
+ post_install_message:
66
+ rdoc_options: []
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ requirements: []
80
+ rubyforge_project:
81
+ rubygems_version: 2.4.5.1
82
+ signing_key:
83
+ specification_version: 4
84
+ summary: Treefell is a simple debug-logging library for ruby
85
+ test_files: []
86
+ has_rdoc: