rails_finder 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,5 +1,6 @@
1
1
  *.gem
2
2
  *.rbc
3
+ *.swp
3
4
  .bundle
4
5
  .config
5
6
  .yardoc
data/CHANGELOG.md ADDED
@@ -0,0 +1,18 @@
1
+ # Rails Finder Changelog
2
+
3
+ ## 0.0.2
4
+
5
+ [8 commits by 2 authors](https://github.com/thorncp/rails_finder/compare/v0.0.1...v0.0.2)
6
+
7
+ * chmod +x bin/find_rails
8
+ * Default rake task to spec
9
+ * Add support for Isolate (alternative to bundler)
10
+ * Handle case where Gemfile has rails entry with no version requirement
11
+ * Fix constant modification warning
12
+ * Add changelog
13
+
14
+ ## 0.0.1
15
+
16
+ [9 commits by 1 author](https://github.com/thorncp/rails_finder/commits/v0.0.1)
17
+
18
+ * `find_rails` command with support for *config/environment.rb* and *Gemfile*.
data/Rakefile CHANGED
@@ -1 +1,6 @@
1
1
  require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/find_rails CHANGED
@@ -4,7 +4,7 @@ require "rails_finder"
4
4
 
5
5
  def print_help
6
6
  puts <<END
7
- Finds Rails applications in the given directory and reports their
7
+ Finds Rails applications in the given directory and report their
8
8
  version numbers. If no directory is given, uses the current.
9
9
  END
10
10
  puts "\n\tusage: find_rails [directory]"
@@ -1,5 +1,6 @@
1
1
  require "rails_finder/gemfile"
2
2
  require "rails_finder/environment_file"
3
+ require "rails_finder/isolate_file"
3
4
 
4
5
  module RailsFinder
5
6
  class App
@@ -16,6 +17,8 @@ module RailsFinder
16
17
  def rails_version
17
18
  if gemfile.exists?
18
19
  gemfile.rails_version
20
+ elsif isofile.exists?
21
+ isofile.rails_version
19
22
  elsif envfile.exists?
20
23
  envfile.rails_version
21
24
  else
@@ -32,5 +35,10 @@ module RailsFinder
32
35
  def envfile
33
36
  @envfile ||= EnvironmentFile.new(File.join(root, "config", "environment.rb"))
34
37
  end
38
+
39
+ def isofile
40
+ @isofile ||= IsolateFile.new(File.join(root, "Isolate"))
41
+ end
35
42
  end
36
43
  end
44
+
@@ -14,10 +14,11 @@ module RailsFinder
14
14
  return @rails_version if @rails_version
15
15
  line = File.readlines(path).find { |l| l =~ /^gem.+rails/i }
16
16
  if line
17
- @rails_version = line[/\d+\.\d+(\.\d+)?/]
17
+ @rails_version = line[/\d+\.\d+(\.\d+)?/] || "n/a"
18
18
  else
19
19
  @rails_version = "n/a"
20
20
  end
21
21
  end
22
22
  end
23
23
  end
24
+
@@ -0,0 +1,24 @@
1
+ module RailsFinder
2
+ class IsolateFile
3
+ attr_reader :path
4
+
5
+ def initialize(path)
6
+ @path = path
7
+ end
8
+
9
+ def exists?
10
+ File.exists?(path)
11
+ end
12
+
13
+ def rails_version
14
+ return @rails_version if @rails_version
15
+ line = File.readlines(path).find { |l| l =~ /^gem.+rails/i }
16
+ if line
17
+ @rails_version = line[/\d+\.\d+(\.\d+)?/] || "n/a"
18
+ else
19
+ @rails_version = "n/a"
20
+ end
21
+ end
22
+ end
23
+ end
24
+
@@ -1,3 +1,3 @@
1
1
  module RailsFinder
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/rails_finder.gemspec CHANGED
@@ -6,8 +6,8 @@ require 'rails_finder/version'
6
6
  Gem::Specification.new do |gem|
7
7
  gem.name = "rails_finder"
8
8
  gem.version = RailsFinder::VERSION
9
- gem.authors = ["Chris Thorn"]
10
- gem.email = ["thorncp@gmail.com"]
9
+ gem.authors = ["Chris Thorn", "Tobi Lehman"]
10
+ gem.email = ["thorncp@gmail.com", "tobi.lehman@gmail.com"]
11
11
  gem.description = %q{Overly simple utility to recursively find Rails apps and their versions}
12
12
  gem.summary = %q{Overly simple utility to recursively find Rails apps and their versions}
13
13
  gem.homepage = "https://github.com/thorncp/rails_finder"
@@ -36,9 +36,21 @@ module RailsFinder
36
36
  end
37
37
  end
38
38
 
39
+ it "reports none when no Rails entry" do
40
+ with_dir do |dir|
41
+ File.open(gemfile(dir), "w") do |file|
42
+ file.puts "source :rubygems"
43
+ file.puts "gem 'rspec', '2.12.0'"
44
+ end
45
+
46
+ Gemfile.new(gemfile(dir)).rails_version.should == "n/a"
47
+ end
48
+ end
49
+
39
50
  it "reports none when no Rails version" do
40
51
  with_dir do |dir|
41
52
  File.open(gemfile(dir), "w") do |file|
53
+ file.puts "gem 'rails'"
42
54
  file.puts "source :rubygems"
43
55
  file.puts "gem 'rspec', '2.12.0'"
44
56
  end
@@ -47,6 +59,7 @@ module RailsFinder
47
59
  end
48
60
  end
49
61
 
62
+
50
63
  it "memoizes rails version" do
51
64
  with_dir do |dir|
52
65
  File.open(gemfile(dir), "w") do |file|
@@ -3,7 +3,7 @@ require "rails_finder"
3
3
  require "tmpdir"
4
4
  require "fileutils"
5
5
 
6
- VALID_GEMFILE = <<END
6
+ LEGIT_GEMFILE = <<END
7
7
  source :rubygems
8
8
 
9
9
  gem 'rails', '3.2.11'
@@ -26,13 +26,21 @@ Rails::Initializer.run do |config|
26
26
  end
27
27
  END
28
28
 
29
+ VALID_ISOLATE_FILE = <<END
30
+ options :system => false
31
+
32
+ gem 'rails', '3.0.20', :require => 'rails'
33
+ gem 'oauth'
34
+ gem 'mysql2', '0.2.18'
35
+ END
36
+
29
37
  describe RailsFinder do
30
38
  it "finds and reports on valid Gemfile" do
31
39
  Dir.mktmpdir "rails_finder-valid_app" do |dir|
32
40
  FileUtils.mkdir_p(File.join(dir, "config"))
33
41
  FileUtils.touch(File.join(dir, "config", "environment.rb"))
34
42
  File.open(File.join(dir, "Gemfile"), "w") do |file|
35
- file.puts(VALID_GEMFILE)
43
+ file.puts(LEGIT_GEMFILE)
36
44
  end
37
45
 
38
46
  out = StringIO.new
@@ -55,4 +63,19 @@ describe RailsFinder do
55
63
  out.string.should include "valid_2.3_app"
56
64
  end
57
65
  end
66
+
67
+ it "finds and reports on valid Isolate file" do
68
+ Dir.mktmpdir "valid_app_with_isolate" do |dir|
69
+ FileUtils.mkdir_p(File.join(dir, "config"))
70
+ FileUtils.touch(File.join(dir, "config", "environment.rb"))
71
+ File.open(File.join(dir, "Isolate"), "w") do |file|
72
+ file.puts(VALID_ISOLATE_FILE)
73
+ end
74
+
75
+ out = StringIO.new
76
+ RailsFinder.run(dir, out)
77
+ out.string.should include "3.0.20"
78
+ out.string.should include "valid_app_with_isolate"
79
+ end
80
+ end
58
81
  end
metadata CHANGED
@@ -1,22 +1,23 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_finder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Chris Thorn
9
+ - Tobi Lehman
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2013-01-29 00:00:00.000000000 Z
13
+ date: 2013-02-14 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: rspec
16
17
  requirement: !ruby/object:Gem::Requirement
17
18
  none: false
18
19
  requirements:
19
- - - ~>
20
+ - - "~>"
20
21
  - !ruby/object:Gem::Version
21
22
  version: 2.12.0
22
23
  type: :development
@@ -24,18 +25,20 @@ dependencies:
24
25
  version_requirements: !ruby/object:Gem::Requirement
25
26
  none: false
26
27
  requirements:
27
- - - ~>
28
+ - - "~>"
28
29
  - !ruby/object:Gem::Version
29
30
  version: 2.12.0
30
31
  description: Overly simple utility to recursively find Rails apps and their versions
31
32
  email:
32
33
  - thorncp@gmail.com
34
+ - tobi.lehman@gmail.com
33
35
  executables:
34
36
  - find_rails
35
37
  extensions: []
36
38
  extra_rdoc_files: []
37
39
  files:
38
- - .gitignore
40
+ - ".gitignore"
41
+ - CHANGELOG.md
39
42
  - Gemfile
40
43
  - LICENSE.txt
41
44
  - README.md
@@ -45,6 +48,7 @@ files:
45
48
  - lib/rails_finder/app.rb
46
49
  - lib/rails_finder/environment_file.rb
47
50
  - lib/rails_finder/gemfile.rb
51
+ - lib/rails_finder/isolate_file.rb
48
52
  - lib/rails_finder/version.rb
49
53
  - rails_finder.gemspec
50
54
  - spec/rails_finder/app_spec.rb
@@ -61,13 +65,13 @@ require_paths:
61
65
  required_ruby_version: !ruby/object:Gem::Requirement
62
66
  none: false
63
67
  requirements:
64
- - - ! '>='
68
+ - - ">="
65
69
  - !ruby/object:Gem::Version
66
70
  version: '0'
67
71
  required_rubygems_version: !ruby/object:Gem::Requirement
68
72
  none: false
69
73
  requirements:
70
- - - ! '>='
74
+ - - ">="
71
75
  - !ruby/object:Gem::Version
72
76
  version: '0'
73
77
  requirements: []