apipie-rails 0.0.21 → 0.0.22

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -3,3 +3,4 @@ rvm:
3
3
  - 1.8.7
4
4
  - 1.9.2
5
5
  - 1.9.3
6
+ - 2.0.0
data/CHANGELOG CHANGED
@@ -2,6 +2,12 @@
2
2
  Changelog
3
3
  ===========
4
4
 
5
+ v0.0.22
6
+ -------
7
+
8
+ * fix "named_resources" option
9
+ * fix generating static files when concerns used
10
+
5
11
  v0.0.21
6
12
  -------
7
13
 
data/README.rst CHANGED
@@ -2,7 +2,8 @@
2
2
  API Documentation Tool
3
3
  ========================
4
4
 
5
- .. image:: https://secure.travis-ci.org/Pajk/apipie-rails.png?branch=master
5
+ .. image:: https://travis-ci.org/Pajk/apipie-rails.png?branch=master
6
+ :target: https://travis-ci.org/Pajk/apipie-rails
6
7
 
7
8
  Apipie-rails is a DSL and Rails engine for documenting you RESTful
8
9
  API. Instead of traditional use of ``#comments``, Apipie let's you
@@ -131,7 +132,6 @@ Example:
131
132
 
132
133
  resource_description do
133
134
  short 'Site members'
134
- path '/users'
135
135
  formats ['json']
136
136
  param :id, Fixnum, :desc => "User ID", :required => false
137
137
  param :resource_param, Hash, :desc => 'Param description for all methods' do
@@ -147,20 +147,20 @@ Example:
147
147
  These can now be accessed in <tt>shared/header</tt> with:
148
148
  Headline: <%= headline %>
149
149
  First name: <%= person.first_name %>
150
-
150
+
151
151
  If you need to find out whether a certain local variable has been
152
152
  assigned a value in a particular render call, you need to use the
153
153
  following pattern:
154
-
154
+
155
155
  <% if local_assigns.has_key? :headline %>
156
156
  Headline: <%= headline %>
157
157
  <% end %>
158
-
158
+
159
159
  Testing using <tt>defined? headline</tt> will not work. This is an
160
160
  implementation restriction.
161
-
161
+
162
162
  === Template caching
163
-
163
+
164
164
  By default, Rails will compile each template to a method in order
165
165
  to render it. When you alter a template, Rails will check the
166
166
  file's modification time and recompile it in development mode.
@@ -218,7 +218,7 @@ Example:
218
218
  param :regexp_param, /^[0-9]* years/, :desc => "regexp param"
219
219
  param :array_param, [100, "one", "two", 1, 2], :desc => "array validator"
220
220
  param :boolean_param, [true, false], :desc => "array validator with boolean"
221
- param :proc_param, lambda { |val|
221
+ param :proc_param, lambda { |val|
222
222
  val == "param value" ? true : "The only good value is 'param value'."
223
223
  }, :desc => "proc validator"
224
224
  description "method description"
@@ -656,23 +656,23 @@ So we create apipie_validators.rb initializer with this content:
656
656
  .. code:: ruby
657
657
 
658
658
  class IntegerValidator < Apipie::Validator::BaseValidator
659
-
659
+
660
660
  def initialize(param_description, argument)
661
661
  super(param_description)
662
662
  @type = argument
663
663
  end
664
-
664
+
665
665
  def validate(value)
666
666
  return false if value.nil?
667
667
  !!(value.to_s =~ /^[-+]?[0-9]+$/)
668
668
  end
669
-
669
+
670
670
  def self.build(param_description, argument, options, block)
671
671
  if argument == Integer || argument == Fixnum
672
672
  self.new(param_description, argument)
673
673
  end
674
674
  end
675
-
675
+
676
676
  def description
677
677
  "Must be #{@type}."
678
678
  end
@@ -832,10 +832,62 @@ tests or a running server, setting ``APIPIE_RECORD=examples``
832
832
  APIPIE_RECORD=examples rake test:functionals
833
833
  APIPIE_RECORD=examples rails server
834
834
 
835
- The data are written into ``doc/apipie_examples.yml``. By default,
835
+ The data is written into ``doc/apipie_examples.yml``. By default,
836
836
  only the first example is shown for each action. You can customize
837
837
  this by setting ``show_in_doc`` attribute at each example.
838
838
 
839
+ .. code::
840
+
841
+ --- !omap
842
+ - announcements#index:
843
+ - !omap
844
+ - verb: :GET
845
+ - path: /api/blabla/1
846
+ - versions:
847
+ - '1.0'
848
+ - query:
849
+ - request_data:
850
+ - response_data:
851
+ ...
852
+ - code: 200
853
+ - show_in_doc: 1 # If 1, show. If 0, do not show.
854
+ - recorded: true
855
+
856
+ In RSpec you can add metadata to examples. We can use that feature
857
+ to mark selected examples – the ones that perform the requests that we want to
858
+ show as examples in the documentation.
859
+
860
+ For example, we can add ``show_in_doc`` to examples, like this:
861
+
862
+ .. code:: ruby
863
+
864
+ describe "This is the correct path" do
865
+ it "some test", :show_in_doc do
866
+ ....
867
+ end
868
+ end
869
+
870
+ context "These are edge cases" do
871
+ it "Can't authenticate" do
872
+ ....
873
+ end
874
+
875
+ it "record not found" do
876
+ ....
877
+ end
878
+ end
879
+
880
+ And then configure RSpec in this way:
881
+
882
+ .. code:: ruby
883
+
884
+ RSpec.configure do |config|
885
+ config.treat_symbols_as_metadata_keys_with_true_values = true
886
+ config.filter_run :show_in_doc => true if ENV['APIPIE_RECORD']
887
+ end
888
+
889
+ This way, when running in recording mode, only the tests that has been marked with the
890
+ ``:show_in_doc`` metadata will be ran, and hence only those will be used as examples.
839
891
 
840
892
  ====================
841
893
  Bindings Generator
data/apipie-rails.gemspec CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
9
9
  s.email = ["pajkycz@gmail.com", "inecas@redhat.com"]
10
10
  s.homepage = "http://github.com/Pajk/apipie-rails"
11
11
  s.summary = %q{Rails REST API documentation tool}
12
- s.description = %q{Maintain your API documentation up to date!}
12
+ s.description = %q{Rails REST API documentation tool}
13
13
 
14
14
 
15
15
  s.files = `git ls-files`.split("\n")
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.add_dependency "rails", ">= 3.0.10"
20
20
  s.add_development_dependency "rspec-rails"
21
21
  s.add_development_dependency "sqlite3"
22
- s.add_development_dependency "minitest"
22
+ s.add_development_dependency "minitest", '~> 4.0'
23
23
  s.add_development_dependency "maruku"
24
24
  s.add_development_dependency "RedCloth"
25
25
  s.add_development_dependency "rake"
@@ -292,8 +292,13 @@ module Apipie
292
292
 
293
293
  def version_prefix(klass)
294
294
  version = controller_versions(klass).first
295
- path = Apipie.configuration.api_base_url[version]
296
- path[1..-1] + "/"
295
+ base_url = get_base_url(version)
296
+ return "/" if base_url.nil?
297
+ base_url[1..-1] + "/"
298
+ end
299
+
300
+ def get_base_url(version)
301
+ Apipie.configuration.api_base_url[version]
297
302
  end
298
303
 
299
304
  def get_resource_version(resource_description)
@@ -1,3 +1,3 @@
1
1
  module Apipie
2
- VERSION = '0.0.21'
2
+ VERSION = '0.0.22'
3
3
  end
@@ -124,7 +124,7 @@ namespace :apipie do
124
124
 
125
125
  def with_loaded_documentation
126
126
  Apipie.configuration.use_cache = false # we don't want to skip DSL evaluation
127
- Dir[File.join(Rails.root, "app", "controllers", "**","*.rb")].each {|f| load f}
127
+ Apipie.reload_documentation
128
128
  yield
129
129
  end
130
130
 
@@ -4,19 +4,34 @@ describe Apipie::Application do
4
4
 
5
5
  describe "get_resource_name" do
6
6
  subject {Apipie.get_resource_name(Api::V2::Nested::ArchitecturesController)}
7
+
7
8
  context "with namespaced_resources enabled" do
8
9
  before { Apipie.configuration.namespaced_resources = true }
10
+ context "with a defined base url" do
11
+
12
+ it "should not overwrite the parent resource" do
13
+ should_not eq(Apipie.get_resource_name(Api::V2::ArchitecturesController))
14
+ end
15
+
16
+ end
9
17
 
10
- it "should not overwrite the parent resource" do
11
- subject.should_not eq(Apipie.get_resource_name(Api::V2::ArchitecturesController))
18
+ context "with an undefined base url" do
19
+ before {Apipie.app.stub(:get_base_url) { nil }}
20
+
21
+ it "should not raise an error" do
22
+ expect { Apipie.get_resource_name(Api::V2::ArchitecturesController) }.
23
+ not_to raise_error
24
+ end
12
25
  end
26
+
27
+ after { Apipie.configuration.namespaced_resources = false }
13
28
  end
14
29
 
15
30
  context "with namespaced_resources enabled" do
16
31
  before { Apipie.configuration.namespaced_resources = false }
17
32
 
18
33
  it "should overwrite the the parent" do
19
- subject.should eq(Apipie.get_resource_name(Api::V2::ArchitecturesController))
34
+ should eq(Apipie.get_resource_name(Api::V2::ArchitecturesController))
20
35
  end
21
36
  end
22
37
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apipie-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.21
4
+ version: 0.0.22
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-03-29 00:00:00.000000000 Z
13
+ date: 2013-06-12 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -65,17 +65,17 @@ dependencies:
65
65
  requirement: !ruby/object:Gem::Requirement
66
66
  none: false
67
67
  requirements:
68
- - - ! '>='
68
+ - - ~>
69
69
  - !ruby/object:Gem::Version
70
- version: '0'
70
+ version: '4.0'
71
71
  type: :development
72
72
  prerelease: false
73
73
  version_requirements: !ruby/object:Gem::Requirement
74
74
  none: false
75
75
  requirements:
76
- - - ! '>='
76
+ - - ~>
77
77
  - !ruby/object:Gem::Version
78
- version: '0'
78
+ version: '4.0'
79
79
  - !ruby/object:Gem::Dependency
80
80
  name: maruku
81
81
  requirement: !ruby/object:Gem::Requirement
@@ -124,7 +124,7 @@ dependencies:
124
124
  - - ! '>='
125
125
  - !ruby/object:Gem::Version
126
126
  version: '0'
127
- description: Maintain your API documentation up to date!
127
+ description: Rails REST API documentation tool
128
128
  email:
129
129
  - pajkycz@gmail.com
130
130
  - inecas@redhat.com