every_day_irb 1.6.1 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: d213edb00033e0945f696b6b22820889a55edb55
4
- data.tar.gz: f3cc5ff284fee3d19a725a47c99cc9f72cbd423d
2
+ SHA256:
3
+ metadata.gz: 63b54ae5658ab766b9b11309684504b8fa40ed1ba8514d20c7794c90cb73275f
4
+ data.tar.gz: 2f9f355a588e94980e8e7186e5f9ad789b1ddc3ca7ff1f8fba3ef9759c521e95
5
5
  SHA512:
6
- metadata.gz: ddbc9d0eff3e565f736651a7389d8d082b6b19f58841a8a41d538eb7813320640324dcb4a8e79664f7a9e161503cd7d2ce09707c91afaa3dd7ea3f7806308c21
7
- data.tar.gz: 7d2d5e644edfa86bef52abb304e3f07217afa5aecb9327cf069c28632bb5480feeadc2b2b0b69011608ec2ff37a8011d1039df29726a4a61eb846c25067996d6
6
+ metadata.gz: f379ad16388abc35a36015bc6ee219ce67b1d8725728378e992c4a519aae1a960bef10aa21b0f4fd07a0525111f989802b299c5a98d898968c7f795a24238558
7
+ data.tar.gz: e23d016a3c95d27830522ffdd6248fa05ac746fadbb0940231bc53f9c2e06257c93b185cf246fb3094bd4eccbade1a2ecac43cb16705a5d537ca580b2bae3391
@@ -0,0 +1,2 @@
1
+ Gemfile.lock
2
+ /pkg
@@ -0,0 +1,18 @@
1
+ sudo: false
2
+ language: ruby
3
+
4
+ rvm:
5
+ - 2.6
6
+ - 2.5
7
+ - 2.4
8
+ - 2.3
9
+ - ruby-head
10
+ - jruby-9.2.6.0
11
+ - truffleruby
12
+
13
+ matrix:
14
+ allow_failures:
15
+ - rvm: ruby-head
16
+ - rvm: truffleruby
17
+ - rvm: 2.3
18
+ # fast_finish: true
@@ -0,0 +1,17 @@
1
+ ## CHANGELOG
2
+
3
+ ### 2.1.1
4
+
5
+ - Loosen Ruby dependency to allow Ruby 3.0
6
+
7
+ ### 2.1.0
8
+
9
+ - Separate every_day_irb into its own git repository
10
+ - No code changes
11
+
12
+ ### 2.0.0
13
+
14
+ - Separate every_day_irb's release cycle from irbtool release cycle
15
+ - Move cd enhancements into cd microgem on which every_day_irb depends
16
+ - You must extend EveryDayIrb explicitly, does not happen on require, anymore
17
+ - Add rr for require_relative
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at opensource@janlelis.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem "rspec", "~> 3.2"
6
+ gem "rake"
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010-2014 Jan Lelis
1
+ Copyright (c) 2010-2020 Jan Lelis
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -0,0 +1,38 @@
1
+ # Every day… IRB [![[version]](https://badge.fury.io/rb/every_day_irb.svg)](https://badge.fury.io/rb/every_day_irb) [![[travis]](https://travis-ci.org/janlelis/every_day_irb.svg)](https://travis-ci.org/janlelis/every_day_irb)
2
+
3
+ Provides utility methods useful in IRB, like a `rq` method for requiring libraries, or `ls` for showing the list of files of the current directory. Part of [Irbtools](https://irb.tools).
4
+
5
+ ## Setup
6
+
7
+ Add to your `Gemfile`:
8
+
9
+ ```ruby
10
+ gem "every_day_irb"
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ Execute this:
16
+
17
+ ```ruby
18
+ extend EveryDayIrb
19
+ ```
20
+
21
+ to get the following methods:
22
+
23
+ - ls(path = '.')
24
+ - cd(path = nil)
25
+ - cat(path)
26
+ - rq(lib)
27
+ - rr(lib)
28
+ - ld(lib)
29
+ - rerequire(lib)
30
+ - clear
31
+ - reset!
32
+ - session_history(number_of_lines = nil)
33
+
34
+ More info at the [Irbtools README](https://github.com/janlelis/irbtools#irbtools-methods) and in the [specs](https://github.com/janlelis/every_day_irb/blob/master/spec/every_day_irb_spec.rb).
35
+
36
+ ## MIT License
37
+
38
+ Copyright (C) 2010-2020 Jan Lelis <https://janlelis.com>. Released under the MIT license.
@@ -0,0 +1,41 @@
1
+ # # #
2
+ # Get gemspec info
3
+
4
+ gemspec_file = Dir["*.gemspec"].first
5
+ gemspec = eval File.read(gemspec_file), binding, gemspec_file
6
+ info = "#{gemspec.name} | #{gemspec.version} | " \
7
+ "#{gemspec.runtime_dependencies.size} dependencies | " \
8
+ "#{gemspec.files.size} files"
9
+
10
+ # # #
11
+ # Gem build and install task
12
+
13
+ desc info
14
+ task :gem do
15
+ puts info + "\n\n"
16
+ print " "; sh "gem build #{gemspec_file}"
17
+ FileUtils.mkdir_p "pkg"
18
+ FileUtils.mv "#{gemspec.name}-#{gemspec.version}.gem", "pkg"
19
+ puts; sh %{gem install --no-document pkg/#{gemspec.name}-#{gemspec.version}.gem}
20
+ end
21
+
22
+ # # #
23
+ # Start an IRB session with the gem loaded
24
+
25
+ desc "#{gemspec.name} | IRB"
26
+ task :irb do
27
+ sh "irb -I ./lib -r #{gemspec.name.gsub '-','/'}"
28
+ end
29
+
30
+ # # #
31
+ # Run specs
32
+
33
+ require "rspec/core/rake_task"
34
+
35
+ RSpec::Core::RakeTask.new(:spec) do |t|
36
+ t.rspec_opts = '--backtrace --color'
37
+ end
38
+
39
+ task default: :spec
40
+
41
+
@@ -1,18 +1,22 @@
1
1
  # -*- encoding: utf-8 -*-
2
- require File.dirname(__FILE__) + '/lib/irbtools/configure'
3
2
 
4
- Gem::Specification.new do |s|
5
- s.name = 'every_day_irb'
6
- s.version = Irbtools::VERSION
3
+ require File.dirname(__FILE__) + "/lib/every_day_irb/version"
7
4
 
8
- s.authors = ["Jan Lelis"]
9
- s.summary = 'every_day_irb defines helper methods that simplify life in irb.'
10
- s.description = 'every_day_irb defines helper methods that simplify life in irb.: ls, cat, rq, rrq, ld, session_history, reset!, clear, ...'
11
- s.email = 'mail@janlelis.de'
12
- s.extra_rdoc_files = %w[LICENSE]
13
- s.files = Dir.glob(%w[lib/every_day_irb.rb every_day_irb.gemspec])
14
- s.homepage = 'http://github.com/janlelis/irbtools'
15
- s.required_ruby_version = '>= 1.8.7'
16
- s.license = 'MIT'
17
- s.add_development_dependency %q<rspec>
5
+ Gem::Specification.new do |gem|
6
+ gem.name = "every_day_irb"
7
+ gem.version = EveryDayIrb::VERSION
8
+ gem.summary = "EveryDayIrb simplifies daily life in IRB."
9
+ gem.description = "EveryDayIrb simplifies daily life in IRB with commands like: ls, cat, rq, rrq, ld, reset!, ..."
10
+ gem.authors = ["Jan Lelis"]
11
+ gem.email = ["hi@ruby.consulting"]
12
+ gem.homepage = "https://irb.tools"
13
+ gem.license = "MIT"
14
+
15
+ gem.files = Dir["{**/}{.*,*}"].select{ |path| File.file?(path) && path !~ /^pkg/ }
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.required_ruby_version = ">= 2.0", "< 4.0"
21
+ gem.add_dependency 'cd', '~> 1.0'
18
22
  end
@@ -1,16 +1,20 @@
1
- # every_day_irb defines some helper methods that might be useful in every-day irb usage
1
+ require_relative 'every_day_irb/version'
2
2
 
3
- module EveryDayIrb
4
- VERSION = "1.6.1"
3
+ require 'cd'
5
4
 
5
+ module EveryDayIrb
6
6
  extend self
7
7
  private
8
8
 
9
9
  # shows the contents of your current directory (more such commands available by FileUtils)
10
- def ls(path='.')
11
- Dir[ File.join( path, '*' )].map{|filename| File.basename filename }
10
+ def ls(path = '.')
11
+ Cd.cd.ls(path)
12
+ end
13
+
14
+ # patch cd so that it also shows the current directory and got some extras
15
+ def cd(path = nil)
16
+ Cd.cd(path)
12
17
  end
13
- alias dir ls
14
18
 
15
19
  # read file contents (also see ray for ruby source files ;) )
16
20
  def cat(path)
@@ -22,6 +26,11 @@ module EveryDayIrb
22
26
  require lib.to_s
23
27
  end
24
28
 
29
+ # same for require relative
30
+ def rr(lib)
31
+ require_relative lib.to_s
32
+ end
33
+
25
34
  # load shortcut, not suited for non-rb
26
35
  def ld(lib)
27
36
  load lib.to_s + '.rb'
@@ -40,11 +49,16 @@ module EveryDayIrb
40
49
  end
41
50
  alias rrq rerequire
42
51
 
52
+ # just clear the screen
53
+ def clear
54
+ system 'clear'
55
+ end
56
+
43
57
  # restart irb
44
58
  def reset!
45
59
  # remember history...
46
- reset_irb = proc{ exec$0 }
47
- if defined?(Ripl) && Ripl.respond_to?(:started?) && Ripl.started?
60
+ reset_irb = proc{ exec $0 }
61
+ if defined?(Ripl) && Ripl.started?
48
62
  Ripl.shell.write_history if Ripl.shell.respond_to? :write_history
49
63
  reset_irb.call
50
64
  else
@@ -53,15 +67,10 @@ module EveryDayIrb
53
67
  end
54
68
  end
55
69
 
56
- # just clear the screen
57
- def clear
58
- system 'clear'
59
- end
60
-
61
- # returns the last lines, needed for some copy_ methods
70
+ # returns the last lines
62
71
  def session_history(number_of_lines = nil)
63
72
  if !number_of_lines
64
- if defined?(Ripl) && Ripl.respond_to?(:started?) && Ripl.started?
73
+ if defined?(Ripl) && Ripl.started?
65
74
  number_of_lines = Ripl.shell.line
66
75
  else
67
76
  number_of_lines = context.instance_variable_get(:@line_no)
@@ -70,7 +79,3 @@ module EveryDayIrb
70
79
  Readline::HISTORY.entries[-number_of_lines...-1]*"\n"
71
80
  end
72
81
  end
73
-
74
- include EveryDayIrb
75
-
76
- # J-_-L
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EveryDayIrb
4
+ VERSION = "2.1.1"
5
+ end
@@ -0,0 +1,126 @@
1
+ require_relative '../lib/every_day_irb'
2
+
3
+ require 'fileutils'
4
+
5
+ describe EveryDayIrb do
6
+ include EveryDayIrb
7
+
8
+ let(:filename){ __FILE__ }
9
+ let(:filename_without_rb){ filename.sub(/\.rb$/, '') }
10
+ let(:path){ File.dirname(filename) + '/..' }
11
+
12
+ describe '#ls' do
13
+ it 'returns an array' do
14
+ expect( ls ).to be_a Array
15
+ end
16
+
17
+ context '[no args]' do
18
+ it 'calls Dir["./*"] to get the list of all files in the current dir' do
19
+ res = Dir['./*']
20
+ expect( Dir ).to receive(:[]).with('./*').and_return(res)
21
+
22
+ ls
23
+ end
24
+ end
25
+
26
+ context 'one arg' do
27
+ it 'calls Dir["#{path}/*"] to get the list of all files of the given path' do
28
+ res = Dir["#{path}/*"]
29
+ expect( Dir ).to receive(:[]).with("#{path}/*").and_return(res)
30
+
31
+ ls(path)
32
+ end
33
+ end
34
+ end
35
+
36
+ describe "#cd" do
37
+ it 'returns an array' do
38
+ expect( ls ).to be_a Array
39
+ end
40
+
41
+ it 'requests FileUtils to change the directory' do
42
+ expect( FileUtils::Verbose ).to receive(:cd).with("/")
43
+
44
+ cd "/"
45
+ end
46
+ end
47
+
48
+ describe '#cat' do
49
+ it 'returns a String' do
50
+ expect( cat(filename) ).to be_a String
51
+ end
52
+
53
+ it 'calls File.read(path)' do
54
+ expect( File ).to receive(:read).with(filename)
55
+
56
+ cat(filename)
57
+ end
58
+ end
59
+
60
+ describe '#rq' do
61
+ it 'calls require with the arg' do
62
+ expect( self ).to receive(:require).with('rbconfig')
63
+
64
+ rq 'rbconfig'
65
+ end
66
+
67
+ it 'calls to_s on the arg' do
68
+ expect( self ).to receive(:require).with('rbconfig')
69
+
70
+ rq:rbconfig
71
+ end
72
+ end
73
+
74
+ describe '#rr' do
75
+ it 'calls require_re with the arg' do
76
+ expect( self ).to receive(:require_relative).with('something').and_return(nil)
77
+
78
+ rr 'something'
79
+ end
80
+
81
+ it 'calls to_s on the arg' do
82
+ expect( self ).to receive(:require_relative).with('something').and_return(nil)
83
+
84
+ rr:something
85
+ end
86
+ end
87
+
88
+ describe '#ld' do
89
+ it 'calls load with the arg, but appends ".rb"' do
90
+ expect( self ).to receive(:load).with(filename)
91
+
92
+ ld filename_without_rb
93
+ end
94
+
95
+ it 'calls to_s on the arg' do
96
+ expect( self ).to receive(:load).with(filename)
97
+
98
+ ld filename_without_rb.to_sym
99
+ end
100
+ end
101
+
102
+ describe '#rerequire' do
103
+ it 'requires a library a second time' do
104
+ first_time = require 'abbrev'
105
+ second_time = rerequire 'abbrev'
106
+
107
+ expect( second_time ).to be true
108
+ end
109
+ end
110
+
111
+ describe '#clear' do
112
+ it "calls the system's clear command" do
113
+ expect( self ).to receive(:system).with('clear')
114
+
115
+ clear
116
+ end
117
+ end
118
+
119
+ describe '#reset!' do
120
+ pending
121
+ end
122
+
123
+ describe '#session_history' do
124
+ pending
125
+ end
126
+ end
metadata CHANGED
@@ -1,41 +1,51 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: every_day_irb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.1
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Lelis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-16 00:00:00.000000000 Z
11
+ date: 2020-12-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rspec
14
+ name: cd
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :development
19
+ version: '1.0'
20
+ type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
27
- description: 'every_day_irb defines helper methods that simplify life in irb.: ls,
28
- cat, rq, rrq, ld, session_history, reset!, clear, ...'
29
- email: mail@janlelis.de
26
+ version: '1.0'
27
+ description: 'EveryDayIrb simplifies daily life in IRB with commands like: ls, cat,
28
+ rq, rrq, ld, reset!, ...'
29
+ email:
30
+ - hi@ruby.consulting
30
31
  executables: []
31
32
  extensions: []
32
- extra_rdoc_files:
33
- - LICENSE
33
+ extra_rdoc_files: []
34
34
  files:
35
- - LICENSE
35
+ - ".gitignore"
36
+ - ".travis.yml"
37
+ - CHANGELOG.md
38
+ - CODE_OF_CONDUCT.md
39
+ - Gemfile
40
+ - Gemfile.lock
41
+ - MIT-LICENSE.txt
42
+ - README.md
43
+ - Rakefile
36
44
  - every_day_irb.gemspec
37
45
  - lib/every_day_irb.rb
38
- homepage: http://github.com/janlelis/irbtools
46
+ - lib/every_day_irb/version.rb
47
+ - spec/every_day_irb_spec.rb
48
+ homepage: https://irb.tools
39
49
  licenses:
40
50
  - MIT
41
51
  metadata: {}
@@ -47,16 +57,19 @@ required_ruby_version: !ruby/object:Gem::Requirement
47
57
  requirements:
48
58
  - - ">="
49
59
  - !ruby/object:Gem::Version
50
- version: 1.8.7
60
+ version: '2.0'
61
+ - - "<"
62
+ - !ruby/object:Gem::Version
63
+ version: '4.0'
51
64
  required_rubygems_version: !ruby/object:Gem::Requirement
52
65
  requirements:
53
66
  - - ">="
54
67
  - !ruby/object:Gem::Version
55
68
  version: '0'
56
69
  requirements: []
57
- rubyforge_project:
58
- rubygems_version: 2.2.1
70
+ rubygems_version: 3.1.2
59
71
  signing_key:
60
72
  specification_version: 4
61
- summary: every_day_irb defines helper methods that simplify life in irb.
62
- test_files: []
73
+ summary: EveryDayIrb simplifies daily life in IRB.
74
+ test_files:
75
+ - spec/every_day_irb_spec.rb