rails_parser 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/.rspec +1 -0
- data/FEATURES.md +4 -0
- data/Gemfile +2 -0
- data/LICENCE +22 -0
- data/README.md +25 -0
- data/Rakefile +2 -0
- data/lib/rails_parser.rb +9 -0
- data/lib/rails_parser/blueprints.rb +6 -0
- data/lib/rails_parser/blueprints/gem_blueprint.rb +20 -0
- data/lib/rails_parser/parsers.rb +4 -0
- data/lib/rails_parser/parsers/rails/application_config_parser.rb +52 -0
- data/lib/rails_parser/parsers/rails/config_parser.rb +42 -0
- data/lib/rails_parser/parsers/rails/gemfile_parser.rb +82 -0
- data/lib/rails_parser/version.rb +3 -0
- data/rails_parser.gemspec +26 -0
- data/spec/default_app/Gemfile +38 -0
- data/spec/default_app/README.rdoc +261 -0
- data/spec/default_app/Rakefile +7 -0
- data/spec/default_app/app/assets/images/rails.png +0 -0
- data/spec/default_app/app/assets/javascripts/application.js +15 -0
- data/spec/default_app/app/assets/stylesheets/application.css +13 -0
- data/spec/default_app/app/controllers/application_controller.rb +3 -0
- data/spec/default_app/app/helpers/application_helper.rb +2 -0
- data/spec/default_app/app/mailers/.gitkeep +0 -0
- data/spec/default_app/app/models/.gitkeep +0 -0
- data/spec/default_app/app/views/layouts/application.html.erb +14 -0
- data/spec/default_app/config.ru +4 -0
- data/spec/default_app/config/application.rb +59 -0
- data/spec/default_app/config/boot.rb +6 -0
- data/spec/default_app/config/database.yml +25 -0
- data/spec/default_app/config/environment.rb +5 -0
- data/spec/default_app/config/environments/development.rb +37 -0
- data/spec/default_app/config/environments/production.rb +67 -0
- data/spec/default_app/config/environments/test.rb +37 -0
- data/spec/default_app/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/default_app/config/initializers/inflections.rb +15 -0
- data/spec/default_app/config/initializers/mime_types.rb +5 -0
- data/spec/default_app/config/initializers/secret_token.rb +7 -0
- data/spec/default_app/config/initializers/session_store.rb +8 -0
- data/spec/default_app/config/initializers/wrap_parameters.rb +14 -0
- data/spec/default_app/config/locales/en.yml +5 -0
- data/spec/default_app/config/routes.rb +58 -0
- data/spec/default_app/db/seeds.rb +7 -0
- data/spec/default_app/lib/assets/.gitkeep +0 -0
- data/spec/default_app/lib/tasks/.gitkeep +0 -0
- data/spec/default_app/log/.gitkeep +0 -0
- data/spec/default_app/public/404.html +26 -0
- data/spec/default_app/public/422.html +26 -0
- data/spec/default_app/public/500.html +25 -0
- data/spec/default_app/public/favicon.ico +0 -0
- data/spec/default_app/public/index.html +241 -0
- data/spec/default_app/public/robots.txt +5 -0
- data/spec/default_app/script/rails +6 -0
- data/spec/default_app/test/fixtures/.gitkeep +0 -0
- data/spec/default_app/test/functional/.gitkeep +0 -0
- data/spec/default_app/test/integration/.gitkeep +0 -0
- data/spec/default_app/test/performance/browsing_test.rb +12 -0
- data/spec/default_app/test/test_helper.rb +13 -0
- data/spec/default_app/test/unit/.gitkeep +0 -0
- data/spec/default_app/vendor/assets/javascripts/.gitkeep +0 -0
- data/spec/default_app/vendor/assets/stylesheets/.gitkeep +0 -0
- data/spec/default_app/vendor/plugins/.gitkeep +0 -0
- data/spec/spec_helper.rb +14 -0
- data/spec/specs/blueprints/gem_blueprint_spec.rb +39 -0
- data/spec/specs/parsers/rails/application_config_parser_spec.rb +18 -0
- data/spec/specs/parsers/rails/config_parser_spec.rb +36 -0
- data/spec/specs/parsers/rails/gemfile_parser_spec.rb +91 -0
- metadata +156 -0
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module RailsParser::Parsers::Rails
|
4
|
+
|
5
|
+
=begin
|
6
|
+
describe ApplicationConfigParser do
|
7
|
+
it "should save the app's name" do
|
8
|
+
parser = ApplicationConfigParser.new
|
9
|
+
parser.parse("#{default_application_path}/config/application.rb")
|
10
|
+
parser.application_name.should == "DefaultApp"
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should get an array of config values" do
|
14
|
+
parser.config_options.keys.length.should == 20
|
15
|
+
end
|
16
|
+
end
|
17
|
+
=end
|
18
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module RailsParser::Parsers::Rails
|
4
|
+
|
5
|
+
describe ApplicationConfigParser do
|
6
|
+
|
7
|
+
it "should get get a top-level config value" do
|
8
|
+
content = <<-EOS
|
9
|
+
config.encoding = "utf-8"
|
10
|
+
EOS
|
11
|
+
parser = ConfigParser.new
|
12
|
+
parser.process(RubyParser.new.process(content))
|
13
|
+
parser.config_options[:encoding].should == "utf-8"
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should get a nested config values" do
|
17
|
+
content = <<-EOS
|
18
|
+
config.assets.enabled = true
|
19
|
+
EOS
|
20
|
+
parser = ConfigParser.new
|
21
|
+
parser.process(RubyParser.new.process(content))
|
22
|
+
parser.config_options[:assets][:enabled].should == true
|
23
|
+
end
|
24
|
+
|
25
|
+
=begin
|
26
|
+
it "should only parse config variables" do
|
27
|
+
content = <<-EOS
|
28
|
+
cat.dog = mouse
|
29
|
+
EOS
|
30
|
+
parser = ConfigParser.new
|
31
|
+
parser.process(RubyParser.new.process(content))
|
32
|
+
parser.config_options.keys.length.should == 0
|
33
|
+
end
|
34
|
+
=end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module RailsParser::Parsers::Rails
|
4
|
+
describe GemfileParser do
|
5
|
+
|
6
|
+
it "should parse a Gemfile" do
|
7
|
+
parser = GemfileParser.new
|
8
|
+
parser.parse("#{default_application_path}/Gemfile")
|
9
|
+
parser.gems[:rails].should == {blueprint:RailsParser::Blueprints::GemBlueprint.new("rails", version: "3.2.1"), groups: []}
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "Ungrouped gems" do
|
13
|
+
before :each do
|
14
|
+
content = <<-EOS
|
15
|
+
gem 'gem1'
|
16
|
+
gem 'gem2', '3.2.1'
|
17
|
+
gem 'gem3', :git => 'git://github.com/ihid/gem3'
|
18
|
+
gem 'gem4', :git => 'git://github.com/ihid/gem4', :branch => "foobar"
|
19
|
+
EOS
|
20
|
+
|
21
|
+
@gemfile = create_tempfile(content)
|
22
|
+
@parser = GemfileParser.new
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should return the name of a gem" do
|
26
|
+
@parser.parse(@gemfile)
|
27
|
+
@parser.gems.keys.should include :gem1
|
28
|
+
@parser.gems[:gem1][:blueprint].name.should == "gem1"
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should return the name and version of a gem" do
|
32
|
+
@parser.parse(@gemfile)
|
33
|
+
@parser.gems[:gem2][:blueprint].name.should == "gem2"
|
34
|
+
@parser.gems[:gem2][:blueprint].version.should == "3.2.1"
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should return the git repository of a gem" do
|
38
|
+
@parser.parse(@gemfile)
|
39
|
+
@parser.gems[:gem3][:blueprint].name.should == "gem3"
|
40
|
+
@parser.gems[:gem3][:blueprint].git_repository.should == "git://github.com/ihid/gem3"
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should return the git repository of a gem" do
|
44
|
+
@parser.parse(@gemfile)
|
45
|
+
@parser.gems[:gem4][:blueprint].name.should == "gem4"
|
46
|
+
@parser.gems[:gem4][:blueprint].git_repository.should == "git://github.com/ihid/gem4"
|
47
|
+
@parser.gems[:gem4][:blueprint].git_branch.should == "foobar"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe "Grouped gems" do
|
52
|
+
before :each do
|
53
|
+
content = <<-EOS
|
54
|
+
gem 'gem1'
|
55
|
+
group :test, :development do
|
56
|
+
gem 'gem2', '3.2.1'
|
57
|
+
gem 'gem3'
|
58
|
+
end
|
59
|
+
gem 'gem4', :group => :development
|
60
|
+
EOS
|
61
|
+
|
62
|
+
@gemfile = create_tempfile(content)
|
63
|
+
@parser = GemfileParser.new
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should correctly count the gems in a Gemfile" do
|
67
|
+
@parser.parse(@gemfile)
|
68
|
+
@parser.gems.size.should == 4
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should correctly put gems in groups" do
|
72
|
+
@parser.parse(@gemfile)
|
73
|
+
@parser.gems[:gem1][:groups].should == []
|
74
|
+
@parser.gems[:gem2][:groups].should == [:test, :development]
|
75
|
+
@parser.gems[:gem3][:groups].should == [:test, :development]
|
76
|
+
@parser.gems[:gem4][:groups].should == [:development]
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should save the source" do
|
81
|
+
content = <<-EOS
|
82
|
+
source 'https://rubygems.org'
|
83
|
+
gem 'gem1'
|
84
|
+
EOS
|
85
|
+
@gemfile = create_tempfile(content)
|
86
|
+
@parser = GemfileParser.new
|
87
|
+
@parser.parse(@gemfile)
|
88
|
+
@parser.source.should == "https://rubygems.org"
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
metadata
ADDED
@@ -0,0 +1,156 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rails_parser
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jeremy Walker
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-05-11 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
requirement: &70294498569120 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70294498569120
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: awesome_print
|
27
|
+
requirement: &70294498568660 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70294498568660
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: ruby_parser
|
38
|
+
requirement: &70294498568240 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70294498568240
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: sexp_processor
|
49
|
+
requirement: &70294498567820 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :runtime
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70294498567820
|
58
|
+
description: An parser for Rails apps
|
59
|
+
email: jez.walker@gmail.com
|
60
|
+
executables: []
|
61
|
+
extensions: []
|
62
|
+
extra_rdoc_files: []
|
63
|
+
files:
|
64
|
+
- .gitignore
|
65
|
+
- .rspec
|
66
|
+
- FEATURES.md
|
67
|
+
- Gemfile
|
68
|
+
- LICENCE
|
69
|
+
- README.md
|
70
|
+
- Rakefile
|
71
|
+
- lib/rails_parser.rb
|
72
|
+
- lib/rails_parser/blueprints.rb
|
73
|
+
- lib/rails_parser/blueprints/gem_blueprint.rb
|
74
|
+
- lib/rails_parser/parsers.rb
|
75
|
+
- lib/rails_parser/parsers/rails/application_config_parser.rb
|
76
|
+
- lib/rails_parser/parsers/rails/config_parser.rb
|
77
|
+
- lib/rails_parser/parsers/rails/gemfile_parser.rb
|
78
|
+
- lib/rails_parser/version.rb
|
79
|
+
- rails_parser.gemspec
|
80
|
+
- spec/default_app/Gemfile
|
81
|
+
- spec/default_app/README.rdoc
|
82
|
+
- spec/default_app/Rakefile
|
83
|
+
- spec/default_app/app/assets/images/rails.png
|
84
|
+
- spec/default_app/app/assets/javascripts/application.js
|
85
|
+
- spec/default_app/app/assets/stylesheets/application.css
|
86
|
+
- spec/default_app/app/controllers/application_controller.rb
|
87
|
+
- spec/default_app/app/helpers/application_helper.rb
|
88
|
+
- spec/default_app/app/mailers/.gitkeep
|
89
|
+
- spec/default_app/app/models/.gitkeep
|
90
|
+
- spec/default_app/app/views/layouts/application.html.erb
|
91
|
+
- spec/default_app/config.ru
|
92
|
+
- spec/default_app/config/application.rb
|
93
|
+
- spec/default_app/config/boot.rb
|
94
|
+
- spec/default_app/config/database.yml
|
95
|
+
- spec/default_app/config/environment.rb
|
96
|
+
- spec/default_app/config/environments/development.rb
|
97
|
+
- spec/default_app/config/environments/production.rb
|
98
|
+
- spec/default_app/config/environments/test.rb
|
99
|
+
- spec/default_app/config/initializers/backtrace_silencers.rb
|
100
|
+
- spec/default_app/config/initializers/inflections.rb
|
101
|
+
- spec/default_app/config/initializers/mime_types.rb
|
102
|
+
- spec/default_app/config/initializers/secret_token.rb
|
103
|
+
- spec/default_app/config/initializers/session_store.rb
|
104
|
+
- spec/default_app/config/initializers/wrap_parameters.rb
|
105
|
+
- spec/default_app/config/locales/en.yml
|
106
|
+
- spec/default_app/config/routes.rb
|
107
|
+
- spec/default_app/db/seeds.rb
|
108
|
+
- spec/default_app/lib/assets/.gitkeep
|
109
|
+
- spec/default_app/lib/tasks/.gitkeep
|
110
|
+
- spec/default_app/log/.gitkeep
|
111
|
+
- spec/default_app/public/404.html
|
112
|
+
- spec/default_app/public/422.html
|
113
|
+
- spec/default_app/public/500.html
|
114
|
+
- spec/default_app/public/favicon.ico
|
115
|
+
- spec/default_app/public/index.html
|
116
|
+
- spec/default_app/public/robots.txt
|
117
|
+
- spec/default_app/script/rails
|
118
|
+
- spec/default_app/test/fixtures/.gitkeep
|
119
|
+
- spec/default_app/test/functional/.gitkeep
|
120
|
+
- spec/default_app/test/integration/.gitkeep
|
121
|
+
- spec/default_app/test/performance/browsing_test.rb
|
122
|
+
- spec/default_app/test/test_helper.rb
|
123
|
+
- spec/default_app/test/unit/.gitkeep
|
124
|
+
- spec/default_app/vendor/assets/javascripts/.gitkeep
|
125
|
+
- spec/default_app/vendor/assets/stylesheets/.gitkeep
|
126
|
+
- spec/default_app/vendor/plugins/.gitkeep
|
127
|
+
- spec/spec_helper.rb
|
128
|
+
- spec/specs/blueprints/gem_blueprint_spec.rb
|
129
|
+
- spec/specs/parsers/rails/application_config_parser_spec.rb
|
130
|
+
- spec/specs/parsers/rails/config_parser_spec.rb
|
131
|
+
- spec/specs/parsers/rails/gemfile_parser_spec.rb
|
132
|
+
homepage: http://github.com/ihid/rails_parser
|
133
|
+
licenses: []
|
134
|
+
post_install_message:
|
135
|
+
rdoc_options: []
|
136
|
+
require_paths:
|
137
|
+
- lib
|
138
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
139
|
+
none: false
|
140
|
+
requirements:
|
141
|
+
- - ! '>='
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '0'
|
144
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - ! '>='
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
requirements: []
|
151
|
+
rubyforge_project:
|
152
|
+
rubygems_version: 1.8.10
|
153
|
+
signing_key:
|
154
|
+
specification_version: 3
|
155
|
+
summary: An parser for Rails apps
|
156
|
+
test_files: []
|