roda-route_list 2.0.0 → 2.1.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: 745db7ba79ed2650b068c20e5665ab0c7b96e78b
4
- data.tar.gz: 963dbb5cf8bc7da828ebd287522f7e562e05a4e3
3
+ metadata.gz: a77d83e5113f962868d1ac46dae2a1f1476fc717
4
+ data.tar.gz: a224916022deddc115cb074fe2cb274b2db03e7c
5
5
  SHA512:
6
- metadata.gz: ec654b9fa1c3e65b62b238870e15b4d3824f4017d35f21d5a034e91cc23a74be5af3ea53a42d8c13e0ef1e4d69fb45b46b0681f37a5c40b4b5827f6b269393a5
7
- data.tar.gz: 9c689b0166f9a48b417d3906ae4b15e9da3ba292a94a50ece93289f996532c316d4fe16a524f53846699330169072c62635078b42250f16878bfa1f36b5f4f8e
6
+ metadata.gz: f30faf5497f0c6a52f28aaa1ca6cdb83e693bf228b79cb72c1bd092d5b2211646ee3d8e1385e4e644bdef6d9b0a115977be36416d977725a90e3d7434528120d
7
+ data.tar.gz: 56c09a4ba09b5ada0bce76f5e2f717182cf8a9bd3dd9ef45c5f2595b1ee0fdf827b081402f1ee93ff6f77a12884a93b724ae52a58519e5f2db71fd4457491e7c
data/CHANGELOG CHANGED
@@ -1,6 +1,10 @@
1
+ = 2.1.0 (2017-10-09)
2
+
3
+ * Add support for -p flag for bin/roda-parse_routes to pretty print the JSON file (oldgreen) (#3)
4
+
1
5
  = 2.0.0 (2016-02-24)
2
6
 
3
- * Use Roda.listed_route instead of Road.named_route to not conflict with multi_route plugin (jeremyevans) (#1)
7
+ * Use Roda.listed_route instead of Roda.named_route to not conflict with multi_route plugin (jeremyevans) (#1)
4
8
 
5
9
  = 1.0.0 (2015-03-08)
6
10
 
@@ -1,4 +1,4 @@
1
- Copyright (c) 2015-2016 Jeremy Evans
1
+ Copyright (c) 2015-2017 Jeremy Evans
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/Rakefile CHANGED
@@ -10,11 +10,9 @@ end
10
10
 
11
11
  ### Specs
12
12
 
13
- desc "Build roda-route_list gem"
13
+ desc "Run all specs"
14
14
  task :spec do |p|
15
15
  ENV['RUBY'] = FileUtils::RUBY
16
- ENV['RUBYLIB'] = "ENV['RUBYLIB']:lib"
17
- ENV['RUBYOPT'] = "-rubygems"
18
16
  sh %{#{FileUtils::RUBY} spec/roda-route_list_spec.rb }
19
17
  end
20
18
  task :default=>:spec
@@ -29,19 +27,12 @@ begin
29
27
  rescue Gem::LoadError
30
28
  end
31
29
 
32
- rdoc_task_class = begin
33
- require "rdoc/task"
34
- RDoc::Task
35
- rescue LoadError
36
- require "rake/rdoctask"
37
- Rake::RDocTask
38
- end
30
+ require "rdoc/task"
39
31
 
40
32
  RDOC_OPTS = RDOC_DEFAULT_OPTS + ['--main', 'README.rdoc']
41
33
 
42
- rdoc_task_class.new do |rdoc|
34
+ RDoc::Task.new do |rdoc|
43
35
  rdoc.rdoc_dir = "rdoc"
44
36
  rdoc.options += RDOC_OPTS
45
37
  rdoc.rdoc_files.add %w"README.rdoc CHANGELOG MIT-LICENSE lib/**/*.rb"
46
38
  end
47
-
@@ -5,6 +5,7 @@ require 'json'
5
5
  require File.join(File.dirname(File.dirname(File.expand_path(__FILE__))), 'lib', 'roda-route_parser')
6
6
 
7
7
  file = $stdout
8
+ json_gen_opts = {}
8
9
  options = OptionParser.new do |opts|
9
10
  opts.banner = "roda-parse_routes: Parse route comments from roda app files"
10
11
  opts.define_head "Usage: roda-parse_routes [options] [file] ..."
@@ -18,8 +19,12 @@ options = OptionParser.new do |opts|
18
19
  opts.on("-f", "--file ", "output to given file instead of stdout") do |v|
19
20
  file = File.open(v, 'wb')
20
21
  end
22
+
23
+ opts.on("-p", "--pretty", "output pretty json (with indentation and newlines)") do
24
+ json_gen_opts = {:indent => ' ', :space => ' ', :object_nl => "\n", :array_nl => "\n"}
25
+ end
21
26
  end
22
27
  opts = options
23
28
  opts.parse!
24
29
 
25
- file.puts(RodaRouteParser.parse(ARGF).to_json)
30
+ file.puts(RodaRouteParser.parse(ARGF).to_json(json_gen_opts))
@@ -1,7 +1,10 @@
1
1
  require 'roda'
2
2
  require 'json'
3
+ gem 'minitest'
3
4
  require 'minitest/autorun'
4
5
 
6
+ $: << File.join(File.dirname(__FILE__), '..', 'lib')
7
+
5
8
  describe 'roda-route_list plugin' do
6
9
  def req(path='/', env={})
7
10
  if path.is_a?(Hash)
@@ -98,7 +101,12 @@ end
98
101
 
99
102
  describe 'roda-route_parser executable' do
100
103
  after do
101
- File.delete "spec/routes-example.json"
104
+ %w[spec/routes-example.json spec/routes-example-pretty.json].each do |file|
105
+ begin
106
+ File.delete(file)
107
+ rescue Errno::ENOENT
108
+ end
109
+ end
102
110
  end
103
111
 
104
112
  it "should correctly parse the routes" do
@@ -106,4 +114,16 @@ describe 'roda-route_parser executable' do
106
114
  File.file?("spec/routes-example.json").must_equal true
107
115
  JSON.parse(File.read('spec/routes-example.json')).must_equal JSON.parse(File.read('spec/routes.json'))
108
116
  end
117
+
118
+ it "should correctly write the pretty routes" do
119
+ system(ENV['RUBY'] || 'ruby', "bin/roda-parse_routes", "-f", "spec/routes-example-pretty.json", "-p", "spec/routes.example")
120
+ File.file?("spec/routes-example-pretty.json").must_equal true
121
+ File.read("spec/routes-example-pretty.json").must_equal(File.read("spec/routes-pretty.json"))
122
+ end
123
+
124
+ it "should correctly parse the pretty routes" do
125
+ system(ENV['RUBY'] || 'ruby', "bin/roda-parse_routes", "-f", "spec/routes-example-pretty.json", "-p", "spec/routes.example")
126
+ File.file?("spec/routes-example-pretty.json").must_equal true
127
+ JSON.parse(File.read('spec/routes-example-pretty.json')).must_equal JSON.parse(File.read('spec/routes.json'))
128
+ end
109
129
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roda-route_list
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Evans
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-24 00:00:00.000000000 Z
11
+ date: 2017-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: roda
@@ -89,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
89
  version: '0'
90
90
  requirements: []
91
91
  rubyforge_project:
92
- rubygems_version: 2.5.1
92
+ rubygems_version: 2.6.13
93
93
  signing_key:
94
94
  specification_version: 4
95
95
  summary: List routes when using Roda