ruby_on_etags 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ pkg/*
2
+ *.gem
3
+ .bundle
4
+ /tmp/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in ruby_on_etags.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,65 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ ruby_on_etags (0.0.1)
5
+ bundler (~> 1.0.0)
6
+ rake (~> 0.8.7)
7
+ watchr (~> 0.7)
8
+
9
+ GEM
10
+ remote: http://rubygems.org/
11
+ specs:
12
+ archive-tar-minitar (0.5.2)
13
+ aruba (0.2.6)
14
+ background_process
15
+ cucumber (~> 0.9.4)
16
+ background_process (1.2)
17
+ builder (2.1.2)
18
+ columnize (0.3.2)
19
+ cucumber (0.9.4)
20
+ builder (~> 2.1.2)
21
+ diff-lcs (~> 1.1.2)
22
+ gherkin (~> 2.2.9)
23
+ json (~> 1.4.6)
24
+ term-ansicolor (~> 1.0.5)
25
+ diff-lcs (1.1.2)
26
+ gherkin (2.2.9)
27
+ json (~> 1.4.6)
28
+ term-ansicolor (~> 1.0.5)
29
+ json (1.4.6)
30
+ linecache19 (0.5.11)
31
+ ruby_core_source (>= 0.1.4)
32
+ rake (0.8.7)
33
+ rspec (2.1.0)
34
+ rspec-core (~> 2.1.0)
35
+ rspec-expectations (~> 2.1.0)
36
+ rspec-mocks (~> 2.1.0)
37
+ rspec-core (2.1.0)
38
+ rspec-expectations (2.1.0)
39
+ diff-lcs (~> 1.1.2)
40
+ rspec-mocks (2.1.0)
41
+ ruby-debug-base19 (0.11.24)
42
+ columnize (>= 0.3.1)
43
+ linecache19 (>= 0.5.11)
44
+ ruby_core_source (>= 0.1.4)
45
+ ruby-debug19 (0.11.6)
46
+ columnize (>= 0.3.1)
47
+ linecache19 (>= 0.5.11)
48
+ ruby-debug-base19 (>= 0.11.19)
49
+ ruby_core_source (0.1.4)
50
+ archive-tar-minitar (>= 0.5.2)
51
+ term-ansicolor (1.0.5)
52
+ watchr (0.7)
53
+
54
+ PLATFORMS
55
+ ruby
56
+
57
+ DEPENDENCIES
58
+ aruba (~> 0.2.6)
59
+ bundler (~> 1.0.0)
60
+ cucumber (~> 0.9.0)
61
+ rake (~> 0.8.7)
62
+ rspec (~> 2.1.0)
63
+ ruby-debug19 (~> 0.11.6)
64
+ ruby_on_etags!
65
+ watchr (~> 0.7)
data/README.rdoc ADDED
@@ -0,0 +1,42 @@
1
+ == Ruby on ETags
2
+
3
+ Ruby on ETags is a set of rake tasks to help a developer keep TAGS file up to
4
+ date.
5
+
6
+ == Installation
7
+
8
+ gem install ruby_on_etags
9
+
10
+ Add the following to Rakefile:
11
+
12
+ require 'ruby_on_etags'
13
+ RubyOnEtags.install_tasks
14
+
15
+ == Usage
16
+
17
+ To build TAGS file which includes definitions of your project modules, all
18
+ dependecies gems and ruby version you use, run the following:
19
+
20
+ rake ruby_on_etags:build
21
+
22
+ This task maintain cache to avoid building tags for static files like gems or
23
+ ruby sources.
24
+
25
+ Also, you can use the following task to build TAGS everytime you change
26
+ something in the project:
27
+
28
+ rake ruby_on_etags:watch
29
+
30
+ == Maintainers
31
+
32
+ * Aleksei Gusev (http://github.com/hron)
33
+
34
+ == Bugs and Feedback
35
+
36
+ If you discover any bugs, please create an issue on GitHub.
37
+
38
+ http://github.com/hron/ruby_on_etags/issues
39
+
40
+ == License
41
+
42
+ MIT License. Copyright 2010 Aleksei Gusev.
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'cucumber'
5
+ require 'cucumber/rake/task'
6
+
7
+ Cucumber::Rake::Task.new(:cucumber) do |t|
8
+ t.cucumber_opts = "features"
9
+ end
10
+
11
+ require 'rspec'
12
+ require 'rspec/core/rake_task'
13
+
14
+ RSpec::Core::RakeTask.new do |t|
15
+ t.skip_bundler = true
16
+ end
@@ -0,0 +1,29 @@
1
+ Feature: Integration with any ruby project
2
+ As a developer I want to able to easy install Ruby On ETags
3
+ To have ability build TAGS with all ruby modules involved in a project
4
+
5
+ Scenario: Installing to use with rake
6
+ Given a standard ruby project directory structure
7
+ When I append to "Rakefile" with:
8
+ """
9
+ require 'ruby_on_etags'
10
+ RubyOnEtags.install_tasks
11
+ """
12
+ And I run "rake -T ruby_on_etags"
13
+ Then the output should contain:
14
+ """
15
+ rake ruby_on_etags:build # Build TAGS for whole project.
16
+ rake ruby_on_etags:watch # Watch for changes in project directory and build TAGS when needed.
17
+ """
18
+
19
+ Scenario: Building TAGS with rake
20
+ Given a standard ruby project directory structure
21
+ And Ruby On ETags is installed
22
+ When I run "rake ruby_on_etags:build"
23
+ Then a file named "TAGS" should exist
24
+ # project sources
25
+ And the file "TAGS" should contain "StandardRubyProject"
26
+ # ruby standard library
27
+ And the file "TAGS" should contain "Array"
28
+ # used gem
29
+ And the file "TAGS" should contain "RubyOnEtags"
@@ -0,0 +1,28 @@
1
+ Given /^a standard ruby project directory structure$/ do
2
+ steps %Q{
3
+ Given a file named "Rakefile" with:
4
+ """
5
+ require 'bundler'
6
+ Bundler.setup
7
+
8
+ """
9
+ And a file named "lib/standard_ruby_project.rb" with:
10
+ """
11
+ module StandardRubyProject
12
+ end
13
+ """
14
+ }
15
+ install_gems <<-G
16
+ gem 'ruby_on_etags', :path => '../..'
17
+ G
18
+ end
19
+
20
+ Given /^Ruby On ETags is installed$/ do
21
+ steps %Q{
22
+ When I append to "Rakefile" with:
23
+ """
24
+ require 'ruby_on_etags'
25
+ RubyOnEtags.install_tasks
26
+ """
27
+ }
28
+ end
@@ -0,0 +1,10 @@
1
+ require 'aruba'
2
+
3
+ ENV['RUBY_ON_ETAGS_CACHE'] = File.join("tmp", "ruby_on_etags_cache")
4
+
5
+ Before do
6
+ FileUtils.rm_rf(ENV['RUBY_ON_ETAGS_CACHE'])
7
+ FileUtils.mkdir_p(ENV['RUBY_ON_ETAGS_CACHE'])
8
+ unset_bundler_env_vars
9
+ @aruba_timeout_seconds = 3
10
+ end
@@ -0,0 +1,3 @@
1
+ module RubyOnEtags
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,106 @@
1
+ require 'tempfile'
2
+ require 'bundler'
3
+
4
+ module RubyOnEtags
5
+
6
+ def install_tasks
7
+ Core.install_tasks
8
+ end
9
+ module_function :install_tasks
10
+
11
+ class Core
12
+
13
+ def self.install_tasks
14
+
15
+ namespace :ruby_on_etags do
16
+
17
+ desc "Build TAGS for whole project. GEMS='some_gem-1.0.0, another_gem-0.2.1'."
18
+ task :build do
19
+ self.new.build_tags
20
+ end
21
+
22
+ desc "Watch for changes in project directory and build TAGS when needed."
23
+ task :watch do
24
+ system "watchr -e 'watch(\"\.rb\") { system \"rake ruby_on_etags:build &>/dev/null\" }'"
25
+ end
26
+
27
+ end
28
+
29
+ end
30
+
31
+ def build_tags
32
+ remove_tags
33
+ tags_files = []
34
+ tags_files << build_tags_for_standard_library
35
+ tags_files += build_tags_for_gems
36
+ tags_files << build_tags_current_dir
37
+ concatenate_tags_files(tags_files)
38
+ end
39
+
40
+ def build_tags_for_gems
41
+ loaded_gems.map do |gem_spec|
42
+ tags_filename = File.join(cache_dir,
43
+ 'gems',
44
+ "#{gem_spec.name}-#{gem_spec.version.version}",
45
+ 'TAGS')
46
+ etags(gem_spec.load_paths.join(' '), tags_filename)
47
+ tags_filename
48
+ end
49
+ end
50
+
51
+ def build_tags_for_standard_library
52
+ File.join(cache_dir, 'rubies', RUBY_VERSION, 'TAGS').tap do |tags_filename|
53
+ dirs = $:.delete_if { |path| path =~ %r|/gems/| }
54
+ etags(dirs.join(' '), tags_filename)
55
+ end
56
+ end
57
+
58
+ def build_tags_current_dir
59
+ tags_file = Tempfile.new('ruby_on_etags-project-TAGS')
60
+ tags_file.close
61
+ etags(".", tags_file.path)
62
+ tags_file.path
63
+ end
64
+
65
+ def concatenate_tags_files(tags_files)
66
+ File.open("TAGS", 'w') do |tags|
67
+ tags_files.each do |tags_filename|
68
+ tags << IO.read(tags_filename)
69
+ end
70
+ end
71
+ end
72
+
73
+ def remove_tags
74
+ FileUtils.rm_f("TAGS")
75
+ end
76
+
77
+ def loaded_gems
78
+ File.exists?("Gemfile") ? Bundler.load.specs : []
79
+ end
80
+
81
+
82
+ private
83
+
84
+ def run(cmd)
85
+ system_with_rvm(cmd)
86
+ end
87
+
88
+ def system_with_rvm(cmd)
89
+ system "$SHELL -c 'cd .; #{cmd}'"
90
+ end
91
+
92
+ def etags(dirs, output)
93
+ if !File.exists?(output) || File.zero?(output)
94
+ FileUtils.mkdir_p(File.dirname(output))
95
+ run "etags -R -o #{output} #{dirs}"
96
+ end
97
+ end
98
+
99
+ def cache_dir
100
+ ENV['RUBY_ON_ETAGS_CACHE'] ||
101
+ File.join(ENV['HOME'], '.ruby_on_tags', 'cache')
102
+ end
103
+
104
+ end
105
+
106
+ end
@@ -0,0 +1,31 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "ruby_on_etags/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "ruby_on_etags"
7
+ s.version = RubyOnEtags::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Aleksei Gusev"]
10
+ s.email = ["aleksei.gusev@gmail.com"]
11
+ s.homepage = "https://github.com/hron/dotfiles"
12
+ s.summary = "Automatic generation of TAGS for all ruby modules a project use."
13
+ s.description = "Ruby on ETags is a set of rake tasks to help a developer keep TAGS file up to
14
+ date."
15
+
16
+ s.rubyforge_project = "ruby_on_etags"
17
+
18
+ s.files = `git ls-files`.split("\n")
19
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
+ s.require_paths = ["lib"]
22
+
23
+ s.add_development_dependency("cucumber", "~>0.9.0")
24
+ s.add_development_dependency("rspec", "~>2.1.0")
25
+ s.add_development_dependency("aruba", "~>0.2.6")
26
+ s.add_development_dependency("ruby-debug19", "~>0.11.6")
27
+
28
+ s.add_dependency("bundler", "~>1.0.0")
29
+ s.add_dependency("watchr", "~>0.7")
30
+ s.add_dependency("rake", "~>0.8.7")
31
+ end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe RubyOnEtags do
4
+
5
+ subject { RubyOnEtags::Core.new }
6
+
7
+ it "should be able to detect paths of used gems with Bundler" do
8
+ unset_bundler_env_vars
9
+ install_gems <<-G
10
+ gem 'mechanize'
11
+ gem 'org-ruby'
12
+ G
13
+
14
+ in_current_dir do
15
+ should have(5).loaded_gems
16
+ end
17
+ end
18
+
19
+ end
@@ -0,0 +1,6 @@
1
+ require 'ruby_on_etags'
2
+ require 'aruba/api'
3
+
4
+ RSpec.configure do |config|
5
+ config.include Aruba::Api
6
+ end
data/tests.watchr ADDED
@@ -0,0 +1,79 @@
1
+ # -*- coding: utf-8 -*-
2
+ if __FILE__ == $0
3
+ puts "Run with: watchr #{__FILE__}. \n\nRequired gems: watchr rev"
4
+ exit 1
5
+ end
6
+
7
+ # --------------------------------------------------
8
+ # Convenience Methods
9
+ # --------------------------------------------------
10
+ def system_with_rvm(cmd)
11
+ system "$SHELL -c 'cd .; #{cmd}'"
12
+ end
13
+
14
+ def run(cmd)
15
+ puts(cmd)
16
+ system_with_rvm(cmd)
17
+ end
18
+
19
+ def run_all_tests
20
+ run "rake SPEC_OPTS=\"--format progress\" spec && rake cucumber CUCUMBER_FORMAT='progress'"
21
+ end
22
+
23
+ def run_single_spec *spec
24
+ spec = spec.join(' ')
25
+ run "rspec --format documentation #{spec}"
26
+ end
27
+
28
+ def run_specs_with_shared_examples(shared_example_filename, spec_path = 'spec')
29
+
30
+ # Returns the names of the shared examples in filename
31
+ def shared_examples(filename)
32
+ lines = File.readlines(filename)
33
+ lines.grep(/shared_examples_for[\s'"]+(.+)['"]\s*[do|\{]/) do |matching_line|
34
+ $1
35
+ end
36
+ end
37
+
38
+ # Returns array with filenames of the specs using shared_example
39
+ def specs_with_shared_example(shared_example, path)
40
+ command = "grep -lrE 'it_should_behave_like .(#{shared_example}).' #{path}"
41
+ `#{command}`.split
42
+ end
43
+
44
+ shared_examples(shared_example_filename).each do |shared_example|
45
+ specs_to_run = specs_with_shared_example(shared_example, spec_path)
46
+ run_single_spec(specs_to_run) unless specs_to_run.empty?
47
+ end
48
+
49
+ end
50
+
51
+ def run_cucumber_scenario scenario_path
52
+ run "rake cucumber CUCUMBER_FORMAT=\"pretty\" FEATURE=#{scenario_path}"
53
+ end
54
+
55
+ # --------------------------------------------------
56
+ # Watchr Rules
57
+ # --------------------------------------------------
58
+ watch( '^spec/spec_helper\.rb' ) { run_all_tests }
59
+ watch( '^spec/shared_behaviors/.*\.rb' ) { |m| run_specs_with_shared_examples(m[0]) }
60
+ watch( '^spec/.*_spec\.rb' ) { |m| run_single_spec(m[0]) }
61
+ watch( '^app/(.*)\.rb' ) { |m| run_single_spec("spec/%s_spec.rb" % m[1]) }
62
+ watch( '^app/views/(.*)\.haml' ) { |m| run_single_spec("spec/views/%s.haml_spec.rb" % m[1]) }
63
+ watch( '^lib/(.*)\.rb' ) { |m| run_single_spec("spec/lib/%s_spec.rb" % m[1] ) }
64
+ watch( '^features/.*\.feature' ) { |m| run_cucumber_scenario(m[0]) }
65
+
66
+
67
+ # --------------------------------------------------
68
+ # Signal Handling
69
+ # --------------------------------------------------
70
+ # Ctrl-C
71
+ Signal.trap('INT') do
72
+ puts "\n\n --- Running all tests ---\n\n"
73
+ run_all_tests
74
+ end
75
+
76
+ # Ctrl-\
77
+ Signal.trap('QUIT') { abort("\n") }
78
+
79
+ puts "Погладь вотчр... ;]"
metadata ADDED
@@ -0,0 +1,183 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruby_on_etags
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - Aleksei Gusev
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-11-28 00:00:00 +02:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: cucumber
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ - 9
31
+ - 0
32
+ version: 0.9.0
33
+ type: :development
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: rspec
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ segments:
44
+ - 2
45
+ - 1
46
+ - 0
47
+ version: 2.1.0
48
+ type: :development
49
+ version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ name: aruba
52
+ prerelease: false
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ~>
57
+ - !ruby/object:Gem::Version
58
+ segments:
59
+ - 0
60
+ - 2
61
+ - 6
62
+ version: 0.2.6
63
+ type: :development
64
+ version_requirements: *id003
65
+ - !ruby/object:Gem::Dependency
66
+ name: ruby-debug19
67
+ prerelease: false
68
+ requirement: &id004 !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ~>
72
+ - !ruby/object:Gem::Version
73
+ segments:
74
+ - 0
75
+ - 11
76
+ - 6
77
+ version: 0.11.6
78
+ type: :development
79
+ version_requirements: *id004
80
+ - !ruby/object:Gem::Dependency
81
+ name: bundler
82
+ prerelease: false
83
+ requirement: &id005 !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ~>
87
+ - !ruby/object:Gem::Version
88
+ segments:
89
+ - 1
90
+ - 0
91
+ - 0
92
+ version: 1.0.0
93
+ type: :runtime
94
+ version_requirements: *id005
95
+ - !ruby/object:Gem::Dependency
96
+ name: watchr
97
+ prerelease: false
98
+ requirement: &id006 !ruby/object:Gem::Requirement
99
+ none: false
100
+ requirements:
101
+ - - ~>
102
+ - !ruby/object:Gem::Version
103
+ segments:
104
+ - 0
105
+ - 7
106
+ version: "0.7"
107
+ type: :runtime
108
+ version_requirements: *id006
109
+ - !ruby/object:Gem::Dependency
110
+ name: rake
111
+ prerelease: false
112
+ requirement: &id007 !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ segments:
118
+ - 0
119
+ - 8
120
+ - 7
121
+ version: 0.8.7
122
+ type: :runtime
123
+ version_requirements: *id007
124
+ description: |-
125
+ Ruby on ETags is a set of rake tasks to help a developer keep TAGS file up to
126
+ date.
127
+ email:
128
+ - aleksei.gusev@gmail.com
129
+ executables: []
130
+
131
+ extensions: []
132
+
133
+ extra_rdoc_files: []
134
+
135
+ files:
136
+ - .gitignore
137
+ - Gemfile
138
+ - Gemfile.lock
139
+ - README.rdoc
140
+ - Rakefile
141
+ - features/ruby_project.feature
142
+ - features/step_definitions/custom_steps.rb
143
+ - features/support/env.rb
144
+ - lib/ruby_on_etags.rb
145
+ - lib/ruby_on_etags/version.rb
146
+ - ruby_on_etags.gemspec
147
+ - spec/lib/ruby_on_etags_spec.rb
148
+ - spec/spec_helper.rb
149
+ - tests.watchr
150
+ has_rdoc: true
151
+ homepage: https://github.com/hron/dotfiles
152
+ licenses: []
153
+
154
+ post_install_message:
155
+ rdoc_options: []
156
+
157
+ require_paths:
158
+ - lib
159
+ required_ruby_version: !ruby/object:Gem::Requirement
160
+ none: false
161
+ requirements:
162
+ - - ">="
163
+ - !ruby/object:Gem::Version
164
+ segments:
165
+ - 0
166
+ version: "0"
167
+ required_rubygems_version: !ruby/object:Gem::Requirement
168
+ none: false
169
+ requirements:
170
+ - - ">="
171
+ - !ruby/object:Gem::Version
172
+ segments:
173
+ - 0
174
+ version: "0"
175
+ requirements: []
176
+
177
+ rubyforge_project: ruby_on_etags
178
+ rubygems_version: 1.3.7
179
+ signing_key:
180
+ specification_version: 3
181
+ summary: Automatic generation of TAGS for all ruby modules a project use.
182
+ test_files: []
183
+