apiaryio 0.2.4 → 0.2.5

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.
data/README.md CHANGED
@@ -57,7 +57,7 @@ look in how to use this tool.
57
57
 
58
58
  ## Copyright
59
59
 
60
- Copyright 2012-14 (c) Apiary Ltd.
60
+ Copyright 2012-15 (c) Apiary Ltd.
61
61
 
62
62
  ## Contributors
63
63
 
data/Rakefile CHANGED
@@ -10,6 +10,7 @@ rescue LoadError
10
10
  puts "Cannot load bundler/gem_tasks"
11
11
  end
12
12
 
13
+ desc "Run all features"
13
14
  Cucumber::Rake::Task.new(:features) do |t|
14
15
  t.cucumber_opts = "features --format pretty"
15
16
  end
@@ -17,6 +18,7 @@ end
17
18
  desc "Run all specs"
18
19
  RSpec::Core::RakeTask.new(:spec) do |t|
19
20
  t.verbose = true
21
+ t.rspec_opts = "-fd"
20
22
  end
21
23
 
22
24
  desc 'Default: Run all specs.'
@@ -23,7 +23,7 @@ Gem::Specification.new do |gem|
23
23
 
24
24
  gem.add_runtime_dependency "json", "~> 1.8.1"
25
25
 
26
- gem.add_development_dependency "rspec", "~> 3.1.0"
26
+ gem.add_development_dependency "rspec", "~> 3.2.0"
27
27
  gem.add_development_dependency "webmock"
28
28
  gem.add_development_dependency "yard"
29
29
  gem.add_development_dependency "aruba"
@@ -0,0 +1,48 @@
1
+ FORMAT: 1A
2
+
3
+ # Apiary Client Test - DON'T CHANGE DOCUMENT!
4
+
5
+ This document is used for testing apiary-client
6
+
7
+ # Group Notes
8
+ Notes related resources of the **Notes API**
9
+
10
+ ## Notes Collection [/notes
11
+ ### List all Notes [GET]
12
+ + Response 200 (application/json)
13
+
14
+ [{
15
+ "id": 1, "title": "Jogging in park"
16
+ }, {
17
+ "id": 2, "title": "Pick-up posters from post-office"
18
+ }]
19
+
20
+ ### Create a Note [POST
21
+
22
+ + Request
23
+
24
+ sflmvs;mv;dsm{ "title": "Buy cheese and bread for breakfast." }
25
+
26
+ + Response 201 (application/json)
27
+
28
+ { "id": 3, "title": "Buy cheese and bread for breakfast." }
29
+
30
+ ## Note [/notes/{id}]
31
+ A single Note object with all its details
32
+
33
+ + Parameters
34
+ + id (required, number, `1`) ... Numeric `id` of the Note to perform action with. Has example value.
35
+
36
+ ### Retrieve a Note [GET]
37
+ + Response 200 (application/json)
38
+
39
+ + Header
40
+
41
+ X-My-Header: The Value
42
+
43
+ + Body
44
+
45
+ { "id": 2, "title": "Pick-up posters from post-office" }
46
+
47
+ ### Remove a Note [DELETE]
48
+ + Response 204
@@ -16,7 +16,6 @@ module Apiary
16
16
  @options = OpenStruct.new(opts)
17
17
  @options.path ||= "apiary.apib"
18
18
  @options.api_host ||= "api.apiary.io"
19
- @options.port ||= 8080
20
19
  @options.api_name ||= false
21
20
  @options.api_key ||= ENV['APIARY_API_KEY']
22
21
  @options.proxy ||= ENV['http_proxy']
@@ -16,7 +16,6 @@ module Apiary
16
16
  @options = OpenStruct.new(opts)
17
17
  @options.path ||= "apiary.apib"
18
18
  @options.api_host ||= "api.apiary.io"
19
- @options.port ||= 8080
20
19
  @options.api_name ||= false
21
20
  @options.api_key ||= ENV['APIARY_API_KEY']
22
21
  @options.proxy ||= ENV['http_proxy']
@@ -50,6 +49,11 @@ module Apiary
50
49
  common.validate_apib_file(apib_file)
51
50
  end
52
51
 
52
+ def get_apib_file(apib_file)
53
+ common = Apiary::Common.new
54
+ common.get_apib_file(apib_file)
55
+ end
56
+
53
57
  def path
54
58
  @options.path || "#{File.basename(Dir.pwd)}.apib"
55
59
  end
@@ -58,7 +62,7 @@ module Apiary
58
62
  url = "https://#{host}/blueprint/publish/#{@options.api_name}"
59
63
  if validate_apib_file path
60
64
  data = {
61
- :code => File.read(path),
65
+ :code => get_apib_file(path),
62
66
  :messageToSave => @options.commit_message
63
67
  }
64
68
  RestClient.proxy = @options.proxy
@@ -9,12 +9,21 @@ module Apiary
9
9
  def initialize()
10
10
  end
11
11
 
12
+ def get_apib_file(apib_file)
13
+ if validate_apib_file(apib_file)
14
+ text_without_bom = nil
15
+ File.open(apib_file, "r:bom|utf-8") { |file|
16
+ text_without_bom = file.read
17
+ }
18
+ text_without_bom
19
+ end
20
+ end
21
+
12
22
  def validate_apib_file(apib_file)
13
23
  unless File.exist?(apib_file)
14
24
  raise "Apiary definition file hasn't been found: #{apib_file.inspect}"
15
25
  end
16
- File.read(apib_file)
26
+ true
17
27
  end
18
-
19
28
  end
20
29
  end
@@ -1,3 +1,3 @@
1
1
  module Apiary
2
- VERSION = "0.2.4"
2
+ VERSION = "0.2.5"
3
3
  end
@@ -16,4 +16,14 @@ describe Apiary::Common do
16
16
 
17
17
  end
18
18
 
19
+ describe 'Test get file with and without BOM' do
20
+
21
+ it 'get file and compare' do
22
+ common = Apiary::Common.new
23
+ file1 = common.get_apib_file('features/fixtures/apiary.apib')
24
+ file2 = common.get_apib_file('features/fixtures/apiary_with_bom.apib')
25
+ expect(file1).to eq(file2)
26
+ end
27
+ end
28
+
19
29
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apiaryio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-02-24 00:00:00.000000000 Z
12
+ date: 2015-03-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client
@@ -104,7 +104,7 @@ dependencies:
104
104
  requirements:
105
105
  - - ~>
106
106
  - !ruby/object:Gem::Version
107
- version: 3.1.0
107
+ version: 3.2.0
108
108
  type: :development
109
109
  prerelease: false
110
110
  version_requirements: !ruby/object:Gem::Requirement
@@ -112,7 +112,7 @@ dependencies:
112
112
  requirements:
113
113
  - - ~>
114
114
  - !ruby/object:Gem::Version
115
- version: 3.1.0
115
+ version: 3.2.0
116
116
  - !ruby/object:Gem::Dependency
117
117
  name: webmock
118
118
  requirement: !ruby/object:Gem::Requirement
@@ -198,6 +198,7 @@ files:
198
198
  - features/fetch.feature
199
199
  - features/fixtures/apiary-invalid.apib
200
200
  - features/fixtures/apiary.apib
201
+ - features/fixtures/apiary_with_bom.apib
201
202
  - features/preview.feature
202
203
  - features/publish.feature
203
204
  - features/step_definitions/file_content_step.rb
@@ -231,7 +232,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
231
232
  version: '0'
232
233
  segments:
233
234
  - 0
234
- hash: -3863851522074434890
235
+ hash: -821896092872960155
235
236
  required_rubygems_version: !ruby/object:Gem::Requirement
236
237
  none: false
237
238
  requirements:
@@ -240,7 +241,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
240
241
  version: '0'
241
242
  segments:
242
243
  - 0
243
- hash: -3863851522074434890
244
+ hash: -821896092872960155
244
245
  requirements: []
245
246
  rubyforge_project:
246
247
  rubygems_version: 1.8.23
@@ -251,6 +252,7 @@ test_files:
251
252
  - features/fetch.feature
252
253
  - features/fixtures/apiary-invalid.apib
253
254
  - features/fixtures/apiary.apib
255
+ - features/fixtures/apiary_with_bom.apib
254
256
  - features/preview.feature
255
257
  - features/publish.feature
256
258
  - features/step_definitions/file_content_step.rb