motion-dependencies 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/.document +5 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +24 -0
- data/LICENSE +22 -0
- data/README.md +31 -0
- data/Rakefile +19 -0
- data/lib/motion-dependencies/version.rb +5 -0
- data/lib/motion-dependencies.rb +38 -0
- data/motion-dependencies.gemspec +17 -0
- data/spec/motion_spec.rb +20 -0
- data/spec/testfile.txt +3 -0
- metadata +59 -0
data/.document
ADDED
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
motion-dependencies (0.0.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
diff-lcs (1.1.3)
|
10
|
+
rspec (2.10.0)
|
11
|
+
rspec-core (~> 2.10.0)
|
12
|
+
rspec-expectations (~> 2.10.0)
|
13
|
+
rspec-mocks (~> 2.10.0)
|
14
|
+
rspec-core (2.10.1)
|
15
|
+
rspec-expectations (2.10.0)
|
16
|
+
diff-lcs (~> 1.1.3)
|
17
|
+
rspec-mocks (2.10.1)
|
18
|
+
|
19
|
+
PLATFORMS
|
20
|
+
ruby
|
21
|
+
|
22
|
+
DEPENDENCIES
|
23
|
+
motion-dependencies!
|
24
|
+
rspec
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Fred Leitz
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Motion::Dependencies
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
$ gem install motion-dependencies
|
8
|
+
|
9
|
+
Add this line to your application's Rakefile:
|
10
|
+
|
11
|
+
require 'motion-dependencies'
|
12
|
+
Motion::Project::App.setup do |app|
|
13
|
+
app.files = Dir.glob('./app/lib/**/*.rb') | Dir.glob('./app/**/*.rb')
|
14
|
+
app.files_dependencies = Motion::Dependencies.find_dependendcies(app.files)
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
## Usage
|
19
|
+
|
20
|
+
# depends your-mixin.rb
|
21
|
+
class FooViewController < UIViewController
|
22
|
+
include YourMixin
|
23
|
+
end
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
require "bundler/gem_tasks"
|
3
|
+
require 'rspec/core/rake_task'
|
4
|
+
|
5
|
+
desc 'Default: run specs.'
|
6
|
+
task :default => :spec
|
7
|
+
|
8
|
+
desc "Run specs"
|
9
|
+
RSpec::Core::RakeTask.new do |t|
|
10
|
+
t.pattern = "./spec/**/*_spec.rb" # don't need this, it's default.
|
11
|
+
# Put spec opts in a file named .rspec in root
|
12
|
+
end
|
13
|
+
|
14
|
+
desc "Generate code coverage"
|
15
|
+
RSpec::Core::RakeTask.new(:coverage) do |t|
|
16
|
+
t.pattern = "./spec/**/*_spec.rb" # don't need this, it's default.
|
17
|
+
t.rcov = true
|
18
|
+
t.rcov_opts = ['--exclude', 'spec']
|
19
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Motion
|
2
|
+
module Dependencies
|
3
|
+
DEPENDENCY_LINE = "# depends "
|
4
|
+
DEPENDENCY_LINE_LENGTH = DEPENDENCY_LINE.length
|
5
|
+
|
6
|
+
def self.dependency_for_line(line)
|
7
|
+
if line.start_with? DEPENDENCY_LINE
|
8
|
+
return line.slice(DEPENDENCY_LINE_LENGTH, line.length - DEPENDENCY_LINE_LENGTH).strip
|
9
|
+
end
|
10
|
+
nil
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.dependencies_for_file(file)
|
14
|
+
File.open(file).each.map(&lambda {|line| dependency_for_line(line)})
|
15
|
+
.select(&lambda {|x| x })
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.resolve_dependencies files, dependencies
|
19
|
+
files.select do |file|
|
20
|
+
dependencies.select do |dependency|
|
21
|
+
file.include? dependency
|
22
|
+
end.length > 0
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.find_dependencies(files)
|
27
|
+
dependencies = {}
|
28
|
+
files.each do |file|
|
29
|
+
unresolved_dependencies = dependencies_for_file(file)
|
30
|
+
if(unresolved_dependencies.length > 0)
|
31
|
+
dependencies[file] = resolve_dependencies files, unresolved_dependencies
|
32
|
+
end
|
33
|
+
end
|
34
|
+
dependencies
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/motion-dependencies/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Fred Leitz"]
|
6
|
+
gem.email = ["fred.leitz@gmail.com"]
|
7
|
+
gem.description = %q{Rudimentary dependency support for Ruby Motion}
|
8
|
+
gem.summary = %q{Track dependencies for ruby motion with comments}
|
9
|
+
gem.homepage = "https://github.com/fleitz/motion-dependencies"
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "motion-dependencies"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Motion::Dependencies::VERSION
|
17
|
+
end
|
data/spec/motion_spec.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'motion-dependencies'
|
2
|
+
describe "Motion Dependencies" do
|
3
|
+
|
4
|
+
it "should find one dependency per line" do
|
5
|
+
dependency = Motion::Dependencies.dependency_for_line("# depends foo.rb")
|
6
|
+
dependency.should eq( "foo.rb" )
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should find mutliple dependencies in a file" do
|
10
|
+
dependencies = Motion::Dependencies.dependencies_for_file( File.expand_path File.join "spec" ,"testfile.txt")
|
11
|
+
dependencies.length.should eq( 2 )
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should resolve dependencies from partial matches" do
|
15
|
+
bar = "foo/bar.rb"
|
16
|
+
resolved = Motion::Dependencies.resolve_dependencies [ bar, "foo/baz.rb"], ["bar.rb"]
|
17
|
+
resolved[0].should eq(bar)
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
data/spec/testfile.txt
ADDED
metadata
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: motion-dependencies
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Fred Leitz
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-06-05 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Rudimentary dependency support for Ruby Motion
|
15
|
+
email:
|
16
|
+
- fred.leitz@gmail.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- .document
|
22
|
+
- .gitignore
|
23
|
+
- Gemfile
|
24
|
+
- Gemfile.lock
|
25
|
+
- LICENSE
|
26
|
+
- README.md
|
27
|
+
- Rakefile
|
28
|
+
- lib/motion-dependencies.rb
|
29
|
+
- lib/motion-dependencies/version.rb
|
30
|
+
- motion-dependencies.gemspec
|
31
|
+
- spec/motion_spec.rb
|
32
|
+
- spec/testfile.txt
|
33
|
+
homepage: https://github.com/fleitz/motion-dependencies
|
34
|
+
licenses: []
|
35
|
+
post_install_message:
|
36
|
+
rdoc_options: []
|
37
|
+
require_paths:
|
38
|
+
- lib
|
39
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
46
|
+
none: false
|
47
|
+
requirements:
|
48
|
+
- - ! '>='
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '0'
|
51
|
+
requirements: []
|
52
|
+
rubyforge_project:
|
53
|
+
rubygems_version: 1.8.23
|
54
|
+
signing_key:
|
55
|
+
specification_version: 3
|
56
|
+
summary: Track dependencies for ruby motion with comments
|
57
|
+
test_files:
|
58
|
+
- spec/motion_spec.rb
|
59
|
+
- spec/testfile.txt
|