cid 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZmU0ZTUwYjBlNGY2M2M1YTMwYzllNjhlMWJhZjE3OWZjMmM4ZTVlMw==
4
+ NWE5MjE3MDc5N2RmYmYxYzVkMWI0MWZmZmUwM2I5ODhkOTg2NGUxZQ==
5
5
  data.tar.gz: !binary |-
6
- ZGUxYzBmODUyMWQ1MjRkYjM1YzNhMzNjNzFiNjA1M2Y4YjFkMDkyZA==
6
+ NDc4NzgwNWMyMzRhYzVjYjBkMmQ0ZDYxZjgxNjkzMjI3ZTFmMjVhNA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YTg5MGExZDBjZDdiYzc2NTI5MDZkOWJiMTNjMDI3ZTFlZDAxNzI1MTc3MGVj
10
- YjIwOTQwNWIwYTU0ZjRiYzk5N2NhMDFhNDMwNmRmYWJhODRiMDNlNjNiODEy
11
- NGFlNmU2NzExMzM3MmEzNjJkNTU2NGZjMDYyNWJkYmRkYmFiMmY=
9
+ NDQzZjMwYzM4NWVjYjQ4YmQzYWY0Y2Y5OTQzNGVhMzAyYTJiYmE1NjljYjNl
10
+ YWM5ZGIzMjg3YmM2NzM5NGJlZTUyNGRhNzI2NTkwMmZmMDk0OGQzZjYzMGFh
11
+ MmI0Y2JlYzM4MTQ2NjM1ZjM0YTVmOTczMGY2MTY0YmEwY2QwMDU=
12
12
  data.tar.gz: !binary |-
13
- ZTJhZmEyYTFjN2M2MGQ5NWY3YzhhMDVlN2M0MDdhODQwOGVlOGY0NzFmZGU2
14
- N2RmZDdlOTU5M2NiOTYyZmE5MWFhZGQ1MjEzNzc4ZGMzYzY0NjdiZGVmNGI5
15
- YmUyZDk4ZDg5MDk2YWE3YjBhNmNhNzFkZjdiNzMzYTJhNmNlYWM=
13
+ NGIyMTdlMDkyZWI0MGIzODIyMmQ5OTNhM2RmNzRmOWUxYjU1YTBkYzA2Mzkx
14
+ M2MwMzc2ODRkNGFhZjZmODU1ODMyMGY4OTI3MTMwOTRhOGI1ZjhlMTdhMmUy
15
+ NGI2YmU2MDkzOTI5MTY2YTZhNmJhOTIyMWQxZTc5YjhkMmYzODM=
@@ -19,3 +19,4 @@ deploy:
19
19
  on:
20
20
  tags: true
21
21
  repo: theodi/cid
22
+ all_branches: true
data/README.md CHANGED
@@ -65,7 +65,26 @@ If you just want to skip the GitHub push altogether, just run
65
65
 
66
66
  ## Getting this in Travis
67
67
 
68
- Obviously, Cid is at its most powerful when used in a CI build. To get Cid working in Travis, simply add a `.travis.yml` file to your repo that looks a bit like this:
68
+ Obviously, Cid is at its most powerful when used in a CI build. To get Cid working in Travis, simply run:
69
+
70
+ cid bootstrap --github-token=YOUR_TOKEN_HERE
71
+
72
+ This will create a `.travis.yml` to your repo and add your encrypted Github key.
73
+
74
+ Then just add your repo to Travis, and push your changes.
75
+
76
+ Now whenever someone makes a pull request on your data, Cid will validate the
77
+ data against the schema, and you'll get a nice build status telling you if it's good to go!
78
+
79
+ If the branch is master, it will also generate a new `datapackage.json` and push that to Github.
80
+
81
+ If you would rather generate the `datapackage.json` on a different branch (for example, `gh-pages`),
82
+ simply add the option `branch` like so:
83
+
84
+ cid bootstrap --github-token=YOUR_TOKEN_HERE --branch=gh-pages
85
+
86
+ You can also do this manually if you prefer - simply add a `.travis.yml` file to your repo
87
+ that looks a bit like this:
69
88
 
70
89
  before_script:
71
90
  - gem install cid
@@ -74,17 +93,10 @@ Obviously, Cid is at its most powerful when used in a CI build. To get Cid worki
74
93
  after_success:
75
94
  - '[ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && cid publish'
76
95
 
77
- This installs cid, runs the validation, and then (if the branch is master) generates a new `datapackage.json` and pushes it to github.
78
-
79
96
  You'll also need to add your Github token to the `.travis.yml` file. To do this, just run:
80
97
 
81
- gem install travis
82
98
  travis encrypt GITHUB_OAUTH_TOKEN="YOUR_TOKEN_HERE" --add
83
99
 
84
- Then just add your repo to Travis, and push your changes.
85
-
86
- Now whenever someone makes a pull request on your data, Cid will validate the data against the schema, and you'll get a nice build status telling you if it's good to go!
87
-
88
100
  ## Examples
89
101
 
90
102
  There's only two repos that use Cid so far (it is a new thing after all), and you can see it here:
data/Rakefile CHANGED
@@ -11,7 +11,8 @@ require 'rspec/core/rake_task'
11
11
  RSpec::Core::RakeTask.new(:spec)
12
12
  Coveralls::RakeTask.new
13
13
  Cucumber::Rake::Task.new(:features) do |t|
14
- t.cucumber_opts = "features --format pretty"
14
+ tags = "--tags ~@skip-ci" if ENV['TRAVIS']
15
+ t.cucumber_opts = "features --format pretty #{tags}"
15
16
  end
16
17
 
17
18
  task :default => [:spec, :features, 'coveralls:push']
data/bin/cid CHANGED
@@ -7,6 +7,22 @@ require 'thor'
7
7
 
8
8
  class CidBin < Thor
9
9
 
10
+ desc "bootstrap", "sets up your .travis.yml"
11
+ long_desc <<-LONGDESC
12
+ `cid bootstrap` will populate your repo's `.travis.yml` file.
13
+ LONGDESC
14
+ option :branch, :type => :string, :desc => "The branch you want to deploy from (default is master)"
15
+ option :github_token, :type => :string, :desc => "Your Github Oauth Token"
16
+ def bootstrap
17
+ branch = options[:branch] || "master"
18
+ travis = Cid::Bootstrap.new(:branch => branch, :github_token => options[:github_token])
19
+ travis.perform
20
+ if travis.no_remote === true
21
+ puts "Warning: Can't figure out GitHub repo name. Please ensure your directory contains a Github remote".colorize(:red)
22
+ end
23
+ puts "Cid sucessfully bootstrapped!".colorize(:green)
24
+ end
25
+
10
26
  desc "validate PATH", "validate a package"
11
27
  long_desc <<-LONGDESC
12
28
  `cid validate` will validate a datapackage containing CSVs and schemas.
@@ -25,6 +25,7 @@ Gem::Specification.new do |spec|
25
25
  spec.add_dependency "dotenv"
26
26
  spec.add_dependency "memoist"
27
27
  spec.add_dependency "thor"
28
+ spec.add_dependency "travis"
28
29
 
29
30
  spec.add_development_dependency "bundler", "~> 1.3"
30
31
  spec.add_development_dependency "rake"
@@ -37,5 +38,6 @@ Gem::Specification.new do |spec|
37
38
  spec.add_development_dependency "spork"
38
39
  spec.add_development_dependency "vcr"
39
40
  spec.add_development_dependency "webmock"
41
+ spec.add_development_dependency "aruba-doubles"
40
42
 
41
43
  end
@@ -0,0 +1,42 @@
1
+ @bootstrap @inprocess
2
+ Feature: Bootstrap .travis.yml file
3
+
4
+ Scenario: Create a .travis.yml file
5
+ Given I run `cp -r ../../spec/fixtures/valid valid`
6
+ And I cd to "valid"
7
+ When I run `cid bootstrap`
8
+ And I run `cat .travis.yml`
9
+ Then the output should contain:
10
+ """
11
+ ---
12
+ before_script: gem install cid
13
+ script: cid validate
14
+ after_success: '[ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && cid publish'
15
+
16
+ """
17
+
18
+ Scenario: Specify different branch
19
+ Given I run `cp -r ../../spec/fixtures/valid valid`
20
+ And I cd to "valid"
21
+ When I run `cid bootstrap --branch=gh-pages`
22
+ And I run `cat .travis.yml`
23
+ Then the output should contain "gh-pages"
24
+
25
+ @skip-ci
26
+ Scenario: Create a .travis.yml file with a Github token
27
+ Given I run `git clone https://github.com/theodi/cid-test.git`
28
+ And I cd to "cid-test"
29
+ And I run `rm .travis.yml`
30
+ When I run `cid bootstrap --github-token=foobarbaz`
31
+ Then the output should not contain "Can't figure out GitHub repo name."
32
+ And I run `cat .travis.yml`
33
+ Then the output should contain "secure:"
34
+
35
+ @skip-ci
36
+ Scenario: Not in a repo with a Github remote
37
+ Given I run `mkdir no-remote && cd no-remote`
38
+ And I set up a new git repo
39
+ And I run `cid bootstrap --github-token=foobarbaz`
40
+ Then the output should contain "Can't figure out GitHub repo name."
41
+ And I run `cat .travis.yml`
42
+ Then the output should not contain "secure:"
@@ -19,7 +19,7 @@ Before('@validate') do
19
19
  @dirs = ["#{File.dirname(__FILE__)}/../.."]
20
20
  end
21
21
 
22
- After('@publish') do
22
+ After('@publish, @bootstrap') do
23
23
  `rm -rf tmp/aruba/`
24
24
  end
25
25
 
data/lib/cid.rb CHANGED
@@ -3,6 +3,9 @@ module Cid
3
3
  module Helpers
4
4
  end
5
5
 
6
+ class Bootstrap
7
+ end
8
+
6
9
  end
7
10
 
8
11
  require "cid/helpers/github"
@@ -11,3 +14,4 @@ require "cid/version"
11
14
  require "cid/validation"
12
15
  require "cid/datapackage"
13
16
  require "cid/publish"
17
+ require "cid/bootstrap"
@@ -0,0 +1,40 @@
1
+ module Cid
2
+ class Bootstrap
3
+
4
+ attr_accessor :no_remote
5
+
6
+ def initialize(options)
7
+ @branch = options[:branch]
8
+ @github_token = options[:github_token]
9
+ end
10
+
11
+ def perform
12
+ write
13
+ if @github_token
14
+ encrypt_token
15
+ end
16
+ end
17
+
18
+ def encrypt_token
19
+ output = `travis encrypt GITHUB_OAUTH_TOKEN=#{@github_token} --add`
20
+ no_remote = true if output.match /Can't figure out GitHub repo name/
21
+ end
22
+
23
+ def write
24
+ File.write(travis_yaml, yaml_string)
25
+ end
26
+
27
+ def travis_yaml(dir = Dir.pwd)
28
+ path = File.expand_path('.travis.yml', dir)
29
+ end
30
+
31
+ def yaml_string
32
+ {
33
+ 'before_script' => 'gem install cid',
34
+ 'script' => 'cid validate',
35
+ 'after_success' => "[ \"$TRAVIS_BRANCH\" == \"#{@branch}\" ] && [ \"$TRAVIS_PULL_REQUEST\" == \"false\" ] && cid publish"
36
+ }.to_yaml(options = {line_width: -1})
37
+ end
38
+
39
+ end
40
+ end
@@ -1,3 +1,3 @@
1
1
  module Cid
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - pezholio
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-24 00:00:00.000000000 Z
11
+ date: 2014-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: csvlint
@@ -122,6 +122,20 @@ dependencies:
122
122
  - - ! '>='
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: travis
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ! '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ! '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: bundler
127
141
  requirement: !ruby/object:Gem::Requirement
@@ -276,6 +290,20 @@ dependencies:
276
290
  - - ! '>='
277
291
  - !ruby/object:Gem::Version
278
292
  version: '0'
293
+ - !ruby/object:Gem::Dependency
294
+ name: aruba-doubles
295
+ requirement: !ruby/object:Gem::Requirement
296
+ requirements:
297
+ - - ! '>='
298
+ - !ruby/object:Gem::Version
299
+ version: '0'
300
+ type: :development
301
+ prerelease: false
302
+ version_requirements: !ruby/object:Gem::Requirement
303
+ requirements:
304
+ - - ! '>='
305
+ - !ruby/object:Gem::Version
306
+ version: '0'
279
307
  description:
280
308
  email:
281
309
  - pezholio@gmail.com
@@ -292,11 +320,13 @@ files:
292
320
  - Rakefile
293
321
  - bin/cid
294
322
  - cid.gemspec
323
+ - features/bootstrap.feature
295
324
  - features/publish.feature
296
325
  - features/step_definitions/cid.rb
297
326
  - features/support/env.rb
298
327
  - features/validate.feature
299
328
  - lib/cid.rb
329
+ - lib/cid/bootstrap.rb
300
330
  - lib/cid/datapackage.rb
301
331
  - lib/cid/helpers/github.rb
302
332
  - lib/cid/publish.rb
@@ -354,6 +384,7 @@ signing_key:
354
384
  specification_version: 4
355
385
  summary: Tools to allow continuous integration when collaborating on data in Github
356
386
  test_files:
387
+ - features/bootstrap.feature
357
388
  - features/publish.feature
358
389
  - features/step_definitions/cid.rb
359
390
  - features/support/env.rb