icy 0.1.0 → 0.3.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4d11ae683e22a9ddf4780af35c0c8fe2f7b41dfe
4
- data.tar.gz: f55086c2ae74d7cb3288084654a2cc0586949832
3
+ metadata.gz: 0f0d51967eda386cb9f13739476c4a0981e0a7a3
4
+ data.tar.gz: 70910a57cb7bec9bd1021d64608e296cd14aa5c1
5
5
  SHA512:
6
- metadata.gz: d21cf0cafa8de80e5010f9ec045e809171c75c44663ef7514cf2c71d397f1cedea85fbdc1c719fe667954bdd20fc851b7c8265df2fea4b05e3348a2bfc23e7ec
7
- data.tar.gz: 946ea347f6787fcb3ea8aa4b6a610d78360d6fac21c70e51f360fd98c449ba5c60a4740af061ce685bc5bd1c75b268765108babdbb5b2d630b858e9fca07f46a
6
+ metadata.gz: badb3136b194dba1e2f146d4c7391aaa5959e414ff44404b54c3f9287b1250b00e88b33e47d4fa8bf8ecb95037894748f999150168a7fd07da8b0155bd7454e4
7
+ data.tar.gz: dc89a33cf0b68ac9c109549fdd8befc10d925898a06eff03db4ee161a882beb86d94227ae01c95776d83b4bd1ad46c199443c6904fdcfc97a3bebbb5ef196310
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/Gemfile CHANGED
@@ -1,4 +1,3 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in icy.gemspec
4
- gemspec
1
+ source 'https://rubygems.org' do
2
+ gemspec
3
+ end
data/README.md CHANGED
@@ -1,9 +1,5 @@
1
1
  # Icy
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/icy`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
6
-
7
3
  ## Installation
8
4
 
9
5
  Add this line to your application's Gemfile:
@@ -22,15 +18,10 @@ Or install it yourself as:
22
18
 
23
19
  ## Usage
24
20
 
25
- TODO: Write usage instructions here
26
-
27
- ## Development
28
-
29
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
-
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
21
+ ```
22
+ Icy.require_tree 'my_dir' # require every ruby file in this directory
23
+ ```
32
24
 
33
25
  ## Contributing
34
26
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/icy.
36
-
27
+ Bug reports and pull requests are welcome on GitHub at https://github.com/austinthecoder/icy.
@@ -21,4 +21,5 @@ Gem::Specification.new do |spec|
21
21
 
22
22
  spec.add_development_dependency "bundler", "~> 1"
23
23
  spec.add_development_dependency "rake", "~> 12"
24
+ spec.add_development_dependency "rspec", "~> 3"
24
25
  end
data/lib/icy.rb CHANGED
@@ -1,5 +1,37 @@
1
- require "icy/version"
1
+ require "pathname"
2
2
 
3
3
  module Icy
4
- # Your code goes here...
4
+ RUBY_EXTNAME = '.rb'
5
+
6
+ def self.require_tree(pathname, exclude: nil)
7
+ pathname = Pathname.new pathname
8
+ pathname_exclusions = Array(exclude).map { |exclude| Pathname.new exclude }
9
+
10
+ working_dir = if pathname.relative? || pathname_exclusions.any?
11
+ calling_filepath = caller[0].split(':')[0]
12
+ Pathname.new(calling_filepath).parent
13
+ end
14
+
15
+ pathname = working_dir.join(pathname) if pathname.relative?
16
+
17
+ pathname_exclusions = pathname_exclusions.map do |pathname_exclusion|
18
+ working_dir.join(pathname_exclusion) if pathname_exclusion.relative?
19
+ end
20
+
21
+ selected_children = pathname.children.reject do |child_pathname|
22
+ pathname_exclusions.any? { |exl| child_pathname == exl }
23
+ end
24
+
25
+ selected_children.each do |child|
26
+ if child.directory?
27
+ require_tree child
28
+ elsif child.extname == RUBY_EXTNAME
29
+ require_relative child
30
+ end
31
+ end
32
+
33
+ true
34
+ end
5
35
  end
36
+
37
+ Icy.require_tree 'icy'
@@ -1,3 +1,3 @@
1
1
  module Icy
2
- VERSION = "0.1.0"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: icy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Austin Schneider
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '12'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3'
41
55
  description:
42
56
  email:
43
57
  - me@austinschneider.com
@@ -46,6 +60,7 @@ extensions: []
46
60
  extra_rdoc_files: []
47
61
  files:
48
62
  - ".gitignore"
63
+ - ".rspec"
49
64
  - Gemfile
50
65
  - README.md
51
66
  - Rakefile